From 77ea6d37483f25d30f19c7035e447167c3457112 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 25 Nov 2022 23:01:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ts=E7=B1=BB=E5=9E=8B=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=AF=BC=E5=87=BA=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/types/app_setting.d.ts | 931 +++++++++--------- src/common/utils/vueTools.ts | 9 +- src/lang/i18n.ts | 24 +- src/lang/index.ts | 26 +- src/main/event/index.ts | 2 +- src/renderer-lyric/plugins/i18n.ts | 6 +- .../components/base/useVirtualizedList.ts | 1 + src/renderer/core/useApp/useDataInit.ts | 2 +- src/renderer/event/index.ts | 6 +- src/renderer/main.ts | 6 +- src/renderer/plugins/i18n.ts | 6 +- src/renderer/store/list/listManage/action.ts | 2 +- src/renderer/store/search/songlist/action.ts | 3 +- src/renderer/store/search/songlist/state.ts | 2 +- src/renderer/store/songList/action.ts | 4 +- src/renderer/utils/index.ts | 2 +- .../views/Search/SongListList/useList.ts | 3 +- .../songList/List/components/SongList.vue | 2 +- tsconfig.json | 3 +- 19 files changed, 527 insertions(+), 513 deletions(-) diff --git a/src/common/types/app_setting.d.ts b/src/common/types/app_setting.d.ts index c0a0b18f..1dae619a 100644 --- a/src/common/types/app_setting.d.ts +++ b/src/common/types/app_setting.d.ts @@ -1,466 +1,469 @@ - - -declare namespace LX { - type AddMusicLocationType = 'top' | 'bottom' - - interface AppSetting { - version: string - - /** - * 窗口大小id - */ - 'common.windowSizeId': number - - /** - * 窗口大小id - */ - 'common.fontSize': number - - /** - * 是否以全屏启动 - */ - 'common.startInFullscreen': boolean - - /** - * 语言id - */ - 'common.langId': string | null - - /** - * api id - */ - 'common.apiSource': string - - /** - * 音源名称类型,原名、别名 - */ - 'common.sourceNameType': 'alias' | 'real' - - /** - * 显示的字体 - */ - 'common.font': string - - /** - * 是否启用动画 - */ - 'common.isShowAnimation': boolean - - /** - * 是否启用随机弹窗动画 - */ - 'common.randomAnimate': boolean - - /** - * 是否同意软件协议 - */ - 'common.isAgreePact': boolean - - /** - * 控制按钮位置,左边、右边 - */ - 'common.controlBtnPosition': 'left' | 'right' - - /** - * 启动时自动播放歌曲 - */ - 'player.startupAutoPlay': boolean - - /** - * 切歌模式 - */ - 'player.togglePlayMethod': 'listLoop' | 'random' | 'list' | 'singleLoop' | 'none' - - /** - * 是否优先播放320k音质 - */ - 'player.highQuality': boolean - - /** - * 是否显示任务栏进度条 - */ - 'player.isShowTaskProgess': boolean - - /** - * 音量大小 - */ - 'player.volume': number - - /** - * 是否静音 - */ - 'player.isMute': boolean - - /** - * 音频输出设备id - */ - 'player.mediaDeviceId': string - - /** - * 是否在音频输出设备更改时暂停播放 - */ - 'player.isMediaDeviceRemovedStopPlay': boolean - - /** - * 是否显示歌词翻译 - */ - 'player.isShowLyricTranslation': boolean - - /** - * 是否显示歌词罗马音 - */ - 'player.isShowLyricRoma': boolean - - /** - * 是否将歌词从简体转换为繁体 - */ - 'player.isS2t': boolean - - /** - * 是否播放卡拉OK歌词 - */ - 'player.isPlayLxlrc': boolean - - /** - * 启动软件时是否恢复上次播放进度 - */ - 'player.isSavePlayTime': boolean - - /** - * 是否启用音频可视化 - */ - 'player.audioVisualization': boolean - - /** - * 定时暂停播放-是否等待歌曲播放完毕再暂停 - */ - 'player.waitPlayEndStop': boolean - - /** - * 定时暂停播放-倒计时时间 - */ - 'player.waitPlayEndStopTime': string - - /** - * 是否启用音频加载失败时自动切歌 - */ - 'player.autoSkipOnError': boolean - - /** - * 播放详情页-是否缩放当前播放的歌词行 - */ - 'playDetail.isZoomActiveLrc': boolean - - /** - * 播放详情页-是否允许通过歌词调整播放进度 - */ - 'playDetail.isShowLyricProgressSetting': boolean - - /** - * 播放详情页-歌词字体大小 - */ - 'playDetail.style.fontSize': number - - /** - * 播放详情页-歌词对齐方式 - */ - 'playDetail.style.align': 'center' | 'left' | 'right' - - - /** - * 是否启用桌面歌词 - */ - 'desktopLyric.enable': boolean - - /** - * 是否锁定桌面歌词 - */ - 'desktopLyric.isLock': boolean - - /** - * 是在置顶桌面 - */ - 'desktopLyric.isAlwaysOnTop': boolean - - /** - * 是否自动刷新歌词置顶 - */ - 'desktopLyric.isAlwaysOnTopLoop': boolean - - /** - * 是否启用音频可视化 - */ - 'desktopLyric.audioVisualization': boolean - - /** - * 桌面歌词窗口宽度 - */ - 'desktopLyric.width': number - - /** - * 桌面歌词窗口高度 - */ - 'desktopLyric.height': number - - /** - * 桌面歌词窗口x坐标 - */ - 'desktopLyric.x': number | null - - /** - * 桌面歌词窗口y坐标 - */ - 'desktopLyric.y': number | null - - /** - * 是否允许桌面歌词窗口拖出主屏幕之外 - */ - 'desktopLyric.isLockScreen': boolean - - /** - * 是否延迟桌面歌词滚动 - */ - 'desktopLyric.isDelayScroll': boolean - - /** - * 歌词滚动位置 - */ - 'desktopLyric.scrollAlign': 'top' | 'center' - - /** - * 是否在鼠标划过桌面歌词窗口时降低歌词透明度 - */ - 'desktopLyric.isHoverHide': boolean - - /** - * 歌词方向 - */ - 'desktopLyric.direction': 'horizontal' | 'vertical' - - /** - * 歌词对齐方式 - */ - 'desktopLyric.style.align': 'center' | 'left' | 'right' - - /** - * 桌面歌词字体 - */ - 'desktopLyric.style.font': string - - /** - * 桌面歌词字体大小 - */ - 'desktopLyric.style.fontSize': number - - /** - * 歌词间距大小 - */ - 'desktopLyric.style.lineGap': number - - /** - * 桌面歌词未播放字体颜色 - */ - 'desktopLyric.style.lyricUnplayColor': string - - /** - * 桌面歌词已播放字体颜色 - */ - 'desktopLyric.style.lyricPlayedColor': string - - /** - * 桌面歌词字体阴影颜色 - */ - 'desktopLyric.style.lyricShadowColor': string - - /** - * 桌面歌词加粗字体 - */ - // 'desktopLyric.style.fontWeight': boolean - - /** - * 桌面歌词字体透明度 - */ - 'desktopLyric.style.opacity': number - - /** - * 桌面歌词是否允许换行 - */ - 'desktopLyric.style.ellipsis': boolean - - /** - * 是否缩放当前正在播放的桌面歌词 - */ - 'desktopLyric.style.isZoomActiveLrc': boolean - - /** - * 是否启用双击列表里的歌曲时自动切换到当前列表播放(仅对歌单、排行榜有效) - */ - 'list.isClickPlayList': boolean - - /** - * 是否显示歌曲来源(仅对我的列表有效) - */ - 'list.isShowSource': boolean - - /** - * 是否自动恢复列表滚动位置(仅对我的列表有效) - */ - 'list.isSaveScrollLocation': boolean - - /** - * 添加歌曲到我的列表时的方式 - */ - 'list.addMusicLocationType': LX.AddMusicLocationType - - /** - * 是否显示列表操作按钮列 - */ - 'list.actionButtonsVisible': boolean - - /** - * 是否启用下载功能 - */ - 'download.enable': boolean - - /** - * 下载路径 - */ - 'download.savePath': string - - /** - * 文件命名方式 - */ - 'download.fileName': '歌名 - 歌手' | '歌手 - 歌名' | '歌名' - - /** - * 最大并发下载数 - */ - 'download.maxDownloadNum': number - - /** - * 是否下载lrc文件 - */ - 'download.isDownloadLrc': boolean - - /** - * 是否下载翻译歌词文件 - */ - 'download.isDownloadTLrc': boolean - - /** - * 是否下载罗马音歌词文件 - */ - 'download.isDownloadRLrc': boolean - - /** - * 保存lrc时的文本编码格式 - */ - 'download.lrcFormat': 'utf8' | 'gbk' - - /** - * 是否在音频文件中嵌入歌曲封面 - */ - 'download.isEmbedPic': boolean - - /** - * 是否在音频文件中嵌入歌词 - */ - 'download.isEmbedLyric': boolean - - /** - * 歌曲源不可用时,是否启用换源下载 - */ - 'download.isUseOtherSource': boolean - - /** - * 主题id - */ - 'theme.id': string - - /** - * 亮色主题id - */ - 'theme.lightId': string - - /** - * 暗色主题id - */ - 'theme.darkId': string - - /** - * 是否显示热门搜索 - */ - 'search.isShowHotSearch': boolean - - /** - * 是否显示搜索历史 - */ - 'search.isShowHistorySearch': boolean - - /** - * 软件启动时是否自动聚焦搜索框 - */ - 'search.isFocusSearchBox': boolean - - /** - * 是否启用代理 - */ - 'network.proxy.enable': boolean - - /** - * 代理服务器地址 - */ - 'network.proxy.host': string - - /** - * 代理服务器端口号 - */ - 'network.proxy.port': string - - /** - * 代理服务器用户名 - */ - 'network.proxy.username': string - - /** - * 代理服务器密码 - */ - 'network.proxy.password': string - - /** - * 是否启用托盘 - */ - 'tray.enable': boolean - - /** - * 是否关闭时是否最小化到托盘 - */ - // 'tray.isToTray': boolean - - /** - * 托盘主题id - */ - 'tray.themeId': number - - /** - * 是否启用同步服务 - */ - 'sync.enable': boolean - - /** - * 同步服务端口号 - */ - 'sync.port': '23332' | string - - /** - * 是否在离开搜索界面时自动清空搜索框 - */ - 'odc.isAutoClearSearchInput': boolean - - /** - * 是否在离开搜索界面时自动清空搜索结果列表 - */ - 'odc.isAutoClearSearchList': boolean +import type { I18n } from '@/lang/i18n' + +declare global { + + declare namespace LX { + type AddMusicLocationType = 'top' | 'bottom' + + interface AppSetting { + version: string + + /** + * 窗口大小id + */ + 'common.windowSizeId': number + + /** + * 窗口大小id + */ + 'common.fontSize': number + + /** + * 是否以全屏启动 + */ + 'common.startInFullscreen': boolean + + /** + * 语言id + */ + 'common.langId': I18n['locale'] | null + + /** + * api id + */ + 'common.apiSource': string + + /** + * 音源名称类型,原名、别名 + */ + 'common.sourceNameType': 'alias' | 'real' + + /** + * 显示的字体 + */ + 'common.font': string + + /** + * 是否启用动画 + */ + 'common.isShowAnimation': boolean + + /** + * 是否启用随机弹窗动画 + */ + 'common.randomAnimate': boolean + + /** + * 是否同意软件协议 + */ + 'common.isAgreePact': boolean + + /** + * 控制按钮位置,左边、右边 + */ + 'common.controlBtnPosition': 'left' | 'right' + + /** + * 启动时自动播放歌曲 + */ + 'player.startupAutoPlay': boolean + + /** + * 切歌模式 + */ + 'player.togglePlayMethod': 'listLoop' | 'random' | 'list' | 'singleLoop' | 'none' + + /** + * 是否优先播放320k音质 + */ + 'player.highQuality': boolean + + /** + * 是否显示任务栏进度条 + */ + 'player.isShowTaskProgess': boolean + + /** + * 音量大小 + */ + 'player.volume': number + + /** + * 是否静音 + */ + 'player.isMute': boolean + + /** + * 音频输出设备id + */ + 'player.mediaDeviceId': string + + /** + * 是否在音频输出设备更改时暂停播放 + */ + 'player.isMediaDeviceRemovedStopPlay': boolean + + /** + * 是否显示歌词翻译 + */ + 'player.isShowLyricTranslation': boolean + + /** + * 是否显示歌词罗马音 + */ + 'player.isShowLyricRoma': boolean + + /** + * 是否将歌词从简体转换为繁体 + */ + 'player.isS2t': boolean + + /** + * 是否播放卡拉OK歌词 + */ + 'player.isPlayLxlrc': boolean + + /** + * 启动软件时是否恢复上次播放进度 + */ + 'player.isSavePlayTime': boolean + + /** + * 是否启用音频可视化 + */ + 'player.audioVisualization': boolean + + /** + * 定时暂停播放-是否等待歌曲播放完毕再暂停 + */ + 'player.waitPlayEndStop': boolean + + /** + * 定时暂停播放-倒计时时间 + */ + 'player.waitPlayEndStopTime': string + + /** + * 是否启用音频加载失败时自动切歌 + */ + 'player.autoSkipOnError': boolean + + /** + * 播放详情页-是否缩放当前播放的歌词行 + */ + 'playDetail.isZoomActiveLrc': boolean + + /** + * 播放详情页-是否允许通过歌词调整播放进度 + */ + 'playDetail.isShowLyricProgressSetting': boolean + + /** + * 播放详情页-歌词字体大小 + */ + 'playDetail.style.fontSize': number + + /** + * 播放详情页-歌词对齐方式 + */ + 'playDetail.style.align': 'center' | 'left' | 'right' + + + /** + * 是否启用桌面歌词 + */ + 'desktopLyric.enable': boolean + + /** + * 是否锁定桌面歌词 + */ + 'desktopLyric.isLock': boolean + + /** + * 是在置顶桌面 + */ + 'desktopLyric.isAlwaysOnTop': boolean + + /** + * 是否自动刷新歌词置顶 + */ + 'desktopLyric.isAlwaysOnTopLoop': boolean + + /** + * 是否启用音频可视化 + */ + 'desktopLyric.audioVisualization': boolean + + /** + * 桌面歌词窗口宽度 + */ + 'desktopLyric.width': number + + /** + * 桌面歌词窗口高度 + */ + 'desktopLyric.height': number + + /** + * 桌面歌词窗口x坐标 + */ + 'desktopLyric.x': number | null + + /** + * 桌面歌词窗口y坐标 + */ + 'desktopLyric.y': number | null + + /** + * 是否允许桌面歌词窗口拖出主屏幕之外 + */ + 'desktopLyric.isLockScreen': boolean + + /** + * 是否延迟桌面歌词滚动 + */ + 'desktopLyric.isDelayScroll': boolean + + /** + * 歌词滚动位置 + */ + 'desktopLyric.scrollAlign': 'top' | 'center' + + /** + * 是否在鼠标划过桌面歌词窗口时降低歌词透明度 + */ + 'desktopLyric.isHoverHide': boolean + + /** + * 歌词方向 + */ + 'desktopLyric.direction': 'horizontal' | 'vertical' + + /** + * 歌词对齐方式 + */ + 'desktopLyric.style.align': 'center' | 'left' | 'right' + + /** + * 桌面歌词字体 + */ + 'desktopLyric.style.font': string + + /** + * 桌面歌词字体大小 + */ + 'desktopLyric.style.fontSize': number + + /** + * 歌词间距大小 + */ + 'desktopLyric.style.lineGap': number + + /** + * 桌面歌词未播放字体颜色 + */ + 'desktopLyric.style.lyricUnplayColor': string + + /** + * 桌面歌词已播放字体颜色 + */ + 'desktopLyric.style.lyricPlayedColor': string + + /** + * 桌面歌词字体阴影颜色 + */ + 'desktopLyric.style.lyricShadowColor': string + + /** + * 桌面歌词加粗字体 + */ + // 'desktopLyric.style.fontWeight': boolean + + /** + * 桌面歌词字体透明度 + */ + 'desktopLyric.style.opacity': number + + /** + * 桌面歌词是否允许换行 + */ + 'desktopLyric.style.ellipsis': boolean + + /** + * 是否缩放当前正在播放的桌面歌词 + */ + 'desktopLyric.style.isZoomActiveLrc': boolean + + /** + * 是否启用双击列表里的歌曲时自动切换到当前列表播放(仅对歌单、排行榜有效) + */ + 'list.isClickPlayList': boolean + + /** + * 是否显示歌曲来源(仅对我的列表有效) + */ + 'list.isShowSource': boolean + + /** + * 是否自动恢复列表滚动位置(仅对我的列表有效) + */ + 'list.isSaveScrollLocation': boolean + + /** + * 添加歌曲到我的列表时的方式 + */ + 'list.addMusicLocationType': LX.AddMusicLocationType + + /** + * 是否显示列表操作按钮列 + */ + 'list.actionButtonsVisible': boolean + + /** + * 是否启用下载功能 + */ + 'download.enable': boolean + + /** + * 下载路径 + */ + 'download.savePath': string + + /** + * 文件命名方式 + */ + 'download.fileName': '歌名 - 歌手' | '歌手 - 歌名' | '歌名' + + /** + * 最大并发下载数 + */ + 'download.maxDownloadNum': number + + /** + * 是否下载lrc文件 + */ + 'download.isDownloadLrc': boolean + + /** + * 是否下载翻译歌词文件 + */ + 'download.isDownloadTLrc': boolean + + /** + * 是否下载罗马音歌词文件 + */ + 'download.isDownloadRLrc': boolean + + /** + * 保存lrc时的文本编码格式 + */ + 'download.lrcFormat': 'utf8' | 'gbk' + + /** + * 是否在音频文件中嵌入歌曲封面 + */ + 'download.isEmbedPic': boolean + + /** + * 是否在音频文件中嵌入歌词 + */ + 'download.isEmbedLyric': boolean + + /** + * 歌曲源不可用时,是否启用换源下载 + */ + 'download.isUseOtherSource': boolean + + /** + * 主题id + */ + 'theme.id': string + + /** + * 亮色主题id + */ + 'theme.lightId': string + + /** + * 暗色主题id + */ + 'theme.darkId': string + + /** + * 是否显示热门搜索 + */ + 'search.isShowHotSearch': boolean + + /** + * 是否显示搜索历史 + */ + 'search.isShowHistorySearch': boolean + + /** + * 软件启动时是否自动聚焦搜索框 + */ + 'search.isFocusSearchBox': boolean + + /** + * 是否启用代理 + */ + 'network.proxy.enable': boolean + + /** + * 代理服务器地址 + */ + 'network.proxy.host': string + + /** + * 代理服务器端口号 + */ + 'network.proxy.port': string + + /** + * 代理服务器用户名 + */ + 'network.proxy.username': string + + /** + * 代理服务器密码 + */ + 'network.proxy.password': string + + /** + * 是否启用托盘 + */ + 'tray.enable': boolean + + /** + * 是否关闭时是否最小化到托盘 + */ + // 'tray.isToTray': boolean + + /** + * 托盘主题id + */ + 'tray.themeId': number + + /** + * 是否启用同步服务 + */ + 'sync.enable': boolean + + /** + * 同步服务端口号 + */ + 'sync.port': '23332' | string + + /** + * 是否在离开搜索界面时自动清空搜索框 + */ + 'odc.isAutoClearSearchInput': boolean + + /** + * 是否在离开搜索界面时自动清空搜索结果列表 + */ + 'odc.isAutoClearSearchList': boolean + } } -} +} diff --git a/src/common/utils/vueTools.ts b/src/common/utils/vueTools.ts index db1aa2b4..618a82fe 100644 --- a/src/common/utils/vueTools.ts +++ b/src/common/utils/vueTools.ts @@ -75,9 +75,6 @@ export { unref, onMounted, markRaw, - ComputedRef, - Ref, - ShallowRef, defineProps, defineEmits, defineComponent, @@ -85,3 +82,9 @@ export { defineExpose, withDefaults, } + +export type { + ComputedRef, + Ref, + ShallowRef, +} diff --git a/src/lang/i18n.ts b/src/lang/i18n.ts index e9eeb233..47f03a43 100644 --- a/src/lang/i18n.ts +++ b/src/lang/i18n.ts @@ -1,22 +1,24 @@ import { App, ref } from 'vue' -import { messages, Messages, Message } from './index' - +import { messages } from './index' +import type { Messages, Message } from './index' type TranslateValues = Record +type Langs = keyof Messages + export declare interface I18n { - locale: keyof Messages - fallbackLocale: keyof Messages - availableLocales: Array + locale: Langs + fallbackLocale: Langs + availableLocales: Langs[] messages: Messages message: Message - setLanguage: (locale: string) => void + setLanguage: (locale: Langs) => void fillMessage: (message: string, val: TranslateValues) => string getMessage: (key: keyof Message, val?: TranslateValues) => string t: (key: keyof Message, val?: TranslateValues) => string } -const locale = ref('zh-cn') +const locale = ref('zh-cn') let i18n: I18n @@ -47,7 +49,7 @@ const useI18n = () => { } } -const setLanguage = (lang: string) => { +const setLanguage = (lang: Langs) => { i18n.setLanguage(lang) } @@ -55,10 +57,10 @@ const createI18n = (): I18n => { return i18n = { locale: locale.value, fallbackLocale: 'zh-cn', - availableLocales: Object.keys(messages), + availableLocales: Object.keys(messages) as Langs[], messages, message: messages[locale.value], - setLanguage(_locale: string) { + setLanguage(_locale: Langs) { this.locale = _locale this.message = messages[_locale] locale.value = _locale @@ -74,7 +76,7 @@ const createI18n = (): I18n => { return val ? this.fillMessage(targetMessage, val) : targetMessage }, t(key: keyof Message, val?: TranslateValues): string { - trackReactivityValues() + // trackReactivityValues() return this.getMessage(key, val) }, } diff --git a/src/lang/index.ts b/src/lang/index.ts index af7fbd9a..7fe049ff 100644 --- a/src/lang/index.ts +++ b/src/lang/index.ts @@ -6,20 +6,13 @@ type Message = Record | Record | Record -interface Lang { - name: string - locale: string - alternate?: string - country: string - fallback?: boolean - message: Message -} +type Messages = Record<(typeof langs)[number]['locale'], Message> -const langs: Lang[] = [ +const langs = [ { name: '简体中文', locale: 'zh-cn', - alternate: 'zh-hans', + // alternate: 'zh-hans', country: 'cn', fallback: true, message: zh_cn, @@ -27,7 +20,7 @@ const langs: Lang[] = [ { name: '繁体中文', locale: 'zh-tw', - alternate: 'zh-hk', + // alternate: 'zh-hk', country: 'cn', message: zh_tw, }, @@ -37,20 +30,20 @@ const langs: Lang[] = [ country: 'us', message: en_us, }, -] +] as const const langList: Array<{ name: string - locale: string + locale: keyof Messages alternate?: string }> = [] -type Messages = Record +// @ts-expect-error const messages: Messages = {} langs.forEach(item => { langList.push({ name: item.name, locale: item.locale, - alternate: item.alternate, + // alternate: item.alternate, }) messages[item.locale] = item.message }) @@ -58,6 +51,9 @@ langs.forEach(item => { export { langList, messages, +} + +export type { Messages, Message, } diff --git a/src/main/event/index.ts b/src/main/event/index.ts index b628d48f..ed367ed7 100644 --- a/src/main/event/index.ts +++ b/src/main/event/index.ts @@ -1,7 +1,7 @@ import { Event as App, Type as AppType } from './AppEvent' import { Event as List, Type as ListType } from './ListEvent' -export { +export type { AppType, ListType, } diff --git a/src/renderer-lyric/plugins/i18n.ts b/src/renderer-lyric/plugins/i18n.ts index 19a9df25..62c5c5c7 100644 --- a/src/renderer-lyric/plugins/i18n.ts +++ b/src/renderer-lyric/plugins/i18n.ts @@ -1,9 +1,11 @@ -import { createI18n, i18nPlugin, useI18n, I18n } from '@/lang' +import type { I18n } from '@/lang' +import { createI18n, i18nPlugin, useI18n } from '@/lang' window.i18n = createI18n() export { i18nPlugin, useI18n, - I18n, } + +export type { I18n } diff --git a/src/renderer/components/base/useVirtualizedList.ts b/src/renderer/components/base/useVirtualizedList.ts index cfb2b1e1..86ce33ff 100644 --- a/src/renderer/components/base/useVirtualizedList.ts +++ b/src/renderer/components/base/useVirtualizedList.ts @@ -225,3 +225,4 @@ // getScrollTop, // } // } +export {} diff --git a/src/renderer/core/useApp/useDataInit.ts b/src/renderer/core/useApp/useDataInit.ts index 1028aba6..f11d2c8f 100644 --- a/src/renderer/core/useApp/useDataInit.ts +++ b/src/renderer/core/useApp/useDataInit.ts @@ -14,7 +14,7 @@ const initPrevPlayInfo = async() => { window.lx.restorePlayInfo = null if (!info?.listId || info.index < 0) return const list = await getListMusics(info.listId) - if (!list?.[info.index]) return + if (!list[info.index]) return window.lx.restorePlayInfo = info playList(info.listId, info.index) diff --git a/src/renderer/event/index.ts b/src/renderer/event/index.ts index a842dc09..472ccb82 100644 --- a/src/renderer/event/index.ts +++ b/src/renderer/event/index.ts @@ -39,7 +39,9 @@ export const registerEvents = () => { // // unregisterRendererEvents() // } -export { AppEventTypes } from './appEvent' -export { KeyEventTypes, clearDownKeys } from './keyEvent' +export { clearDownKeys } from './keyEvent' + +export type { AppEventTypes } from './appEvent' +export type { KeyEventTypes } from './keyEvent' registerEvents() diff --git a/src/renderer/main.ts b/src/renderer/main.ts index 33d14cb5..114a3862 100644 --- a/src/renderer/main.ts +++ b/src/renderer/main.ts @@ -19,6 +19,8 @@ import router from './router' import { getSetting, updateSetting } from './utils/ipc' import { langList } from '@/lang' +import type { I18n } from '@/lang/i18n' + import { initSetting } from './store/setting' // import { bubbleCursor } from './utils/cursor-effects/bubbleCursor' @@ -40,8 +42,8 @@ void getSetting().then(setting => { // window.lx.appSetting = setting // Set language automatically if (!setting['common.langId'] || !window.i18n.availableLocales.includes(setting['common.langId'])) { - let langId = null - let locale = window.navigator.language.toLocaleLowerCase() + let langId: I18n['locale'] | null = null + let locale = window.navigator.language.toLocaleLowerCase() as I18n['locale'] if (window.i18n.availableLocales.includes(locale)) { langId = locale } else { diff --git a/src/renderer/plugins/i18n.ts b/src/renderer/plugins/i18n.ts index 19a9df25..62c5c5c7 100644 --- a/src/renderer/plugins/i18n.ts +++ b/src/renderer/plugins/i18n.ts @@ -1,9 +1,11 @@ -import { createI18n, i18nPlugin, useI18n, I18n } from '@/lang' +import type { I18n } from '@/lang' +import { createI18n, i18nPlugin, useI18n } from '@/lang' window.i18n = createI18n() export { i18nPlugin, useI18n, - I18n, } + +export type { I18n } diff --git a/src/renderer/store/list/listManage/action.ts b/src/renderer/store/list/listManage/action.ts index c7213ce3..2bb31e29 100644 --- a/src/renderer/store/list/listManage/action.ts +++ b/src/renderer/store/list/listManage/action.ts @@ -17,7 +17,7 @@ export const setUserLists = (lists: LX.List.UserListInfo[]) => { export const setMusicList = (listId: string, musicList: LX.Music.MusicInfo[]) => { const list = shallowReactive(markRawList(musicList)) - allMusicList.set(listId, shallowReactive(musicList)) + allMusicList.set(listId, list) return list } diff --git a/src/renderer/store/search/songlist/action.ts b/src/renderer/store/search/songlist/action.ts index c3e2b45a..4a84b062 100644 --- a/src/renderer/store/search/songlist/action.ts +++ b/src/renderer/store/search/songlist/action.ts @@ -2,7 +2,8 @@ import { markRawList } from '@common/utils/vueTools' import music from '@renderer/utils/musicSdk' import { sortInsert, similar } from '@common/utils/common' -import { sources, maxPages, listInfos, ListInfoItem, SearchListInfo } from './state' +import type { ListInfoItem, SearchListInfo } from './state' +import { sources, maxPages, listInfos } from './state' interface SearchResult { list: ListInfoItem[] diff --git a/src/renderer/store/search/songlist/state.ts b/src/renderer/store/search/songlist/state.ts index 31062619..9263b42a 100644 --- a/src/renderer/store/search/songlist/state.ts +++ b/src/renderer/store/search/songlist/state.ts @@ -5,7 +5,7 @@ import music from '@renderer/utils/musicSdk' import { ListInfo } from '@renderer/store/songList/state' -export { ListInfoItem } from '@renderer/store/songList/state' +export type { ListInfoItem } from '@renderer/store/songList/state' export const sources: Array = markRaw([]) diff --git a/src/renderer/store/songList/action.ts b/src/renderer/store/songList/action.ts index 53184bc2..d81424f6 100644 --- a/src/renderer/store/songList/action.ts +++ b/src/renderer/store/songList/action.ts @@ -2,14 +2,12 @@ import { deduplicationList, toNewMusicInfo } from '@renderer/utils' import musicSdk from '@renderer/utils/musicSdk' import { markRaw, markRawList } from '@common/utils/vueTools' +import type { ListDetailInfo, ListInfoItem, ListInfo } from './state' import { tags, TagInfo, listInfo, listDetailInfo, - ListDetailInfo, - ListInfoItem, - ListInfo, selectListInfo, isVisibleListDetail, openSongListInputInfo, diff --git a/src/renderer/utils/index.ts b/src/renderer/utils/index.ts index 99ba26ad..91bdb641 100644 --- a/src/renderer/utils/index.ts +++ b/src/renderer/utils/index.ts @@ -53,7 +53,7 @@ export const getFontSizeWithScreen = (screenWidth: number = window.innerWidth): export const deduplicationList = (list: T[]): T[] => { - const ids: Set = new Set() + const ids: Set = new Set() return list.filter(s => { if (ids.has(s.id)) return false ids.add(s.id) diff --git a/src/renderer/views/Search/SongListList/useList.ts b/src/renderer/views/Search/SongListList/useList.ts index d3cfdbfc..2bf79bb7 100644 --- a/src/renderer/views/Search/SongListList/useList.ts +++ b/src/renderer/views/Search/SongListList/useList.ts @@ -3,7 +3,8 @@ import { ref, nextTick } from '@common/utils/vueTools' import { addHistoryWord } from '@renderer/store/search/action' // import { useI18n } from '@renderer/plugins/i18n' // import { } from '@renderer/store/search/state' -import { search as searchSongList, listInfos, SearchListInfo, ListInfoItem } from '@renderer/store/search/songlist' +import type { SearchListInfo, ListInfoItem } from '@renderer/store/search/songlist' +import { search as searchSongList, listInfos } from '@renderer/store/search/songlist' export declare type SearchSource = LX.OnlineSource | 'all' diff --git a/src/renderer/views/songList/List/components/SongList.vue b/src/renderer/views/songList/List/components/SongList.vue index 15863701..558ae1b0 100644 --- a/src/renderer/views/songList/List/components/SongList.vue +++ b/src/renderer/views/songList/List/components/SongList.vue @@ -34,7 +34,7 @@