lint code

This commit is contained in:
lyswhut
2023-08-27 15:09:07 +08:00
parent 0d76c9ccb4
commit 71b84fb10d
69 changed files with 346 additions and 413 deletions
@@ -148,11 +148,11 @@ export default {
await importNewListData(allData.playList)
importNewSettingData(allData.setting)
break
default: return showImportTip(allData.type)
default: { showImportTip(allData.type) }
}
}
const handleImportAllData = () => {
showSelectDialog({
void showSelectDialog({
title: t('setting__backup_all_import_desc'),
properties: ['openFile'],
filters: [
@@ -161,13 +161,13 @@ export default {
],
}).then(result => {
if (result.canceled) return
dialog.confirm({
void dialog.confirm({
message: t('setting__backup_part_import_list_confirm'),
cancelButtonText: t('cancel_button_text'),
confirmButtonText: t('confirm_button_text'),
}).then(confirm => {
if (!confirm) return
importAllData(result.filePaths[0])
void importAllData(result.filePaths[0])
})
})
}
@@ -178,15 +178,15 @@ export default {
setting: { ...appSetting },
playList: await getAllLists(),
}
window.lx.worker.main.saveLxConfigFile(path, allData)
void window.lx.worker.main.saveLxConfigFile(path, allData)
}
const handleExportAllData = () => {
openSaveDir({
void openSaveDir({
title: t('setting__backup_all_export_desc'),
defaultPath: 'lx_datas_v2.lxmc',
}).then(result => {
if (result.canceled) return
exportAllData(result.filePath)
void exportAllData(result.filePath)
})
}
@@ -195,10 +195,10 @@ export default {
type: 'setting_v2',
data: { ...appSetting },
}
window.lx.worker.main.saveLxConfigFile(path, data)
void window.lx.worker.main.saveLxConfigFile(path, data)
}
const handleExportSetting = () => {
openSaveDir({
void openSaveDir({
title: t('setting__backup_part_export_setting_desc'),
defaultPath: 'lx_setting_v2.lxmc',
}).then(result => {
@@ -222,11 +222,11 @@ export default {
case 'setting_v2':
importNewSettingData(settingData.data)
break
default: return showImportTip(settingData.type)
default: { showImportTip(settingData.type) }
}
}
const handleImportSetting = () => {
showSelectDialog({
void showSelectDialog({
title: t('setting__backup_part_import_setting_desc'),
properties: ['openFile'],
filters: [
@@ -235,7 +235,7 @@ export default {
],
}).then(result => {
if (result.canceled) return
importSetting(result.filePaths[0])
void importSetting(result.filePaths[0])
})
}
@@ -244,15 +244,15 @@ export default {
type: 'playList_v2',
data: await getAllLists(),
}
window.lx.worker.main.saveLxConfigFile(path, data)
void window.lx.worker.main.saveLxConfigFile(path, data)
}
const handleExportPlayList = () => {
openSaveDir({
void openSaveDir({
title: t('setting__backup_part_export_list_desc'),
defaultPath: 'lx_list.lxmc',
}).then(result => {
if (result.canceled) return
exportPlayList(result.filePath)
void exportPlayList(result.filePath)
})
}
@@ -275,11 +275,11 @@ export default {
case 'playList_v2':
await importNewListData(listData.data)
break
default: return showImportTip(listData.type)
default: { showImportTip(listData.type) }
}
}
const handleImportPlayList = () => {
showSelectDialog({
void showSelectDialog({
title: t('setting__backup_part_import_list_desc'),
properties: ['openFile'],
filters: [
@@ -288,13 +288,13 @@ export default {
],
}).then(result => {
if (result.canceled) return
dialog.confirm({
void dialog.confirm({
message: t('setting__backup_part_import_list_confirm'),
cancelButtonText: t('cancel_button_text'),
confirmButtonText: t('confirm_button_text'),
}).then(confirm => {
if (!confirm) return
importPlayList(result.filePaths[0])
void importPlayList(result.filePaths[0])
})
})
}
@@ -310,23 +310,23 @@ export default {
confirmButtonText: t('confirm_button_text'),
})
if (confirm) {
openSaveDir({
void openSaveDir({
title: t('setting__backup_other_export_dir'),
defaultPath: 'lx_list_all.txt',
}).then(result => {
if (result.canceled) return
let path = result.filePath
if (!path.endsWith('.txt')) path += '.txt'
exportPlayListToText(path, true)
void exportPlayListToText(path, true)
})
} else {
showSelectDialog({
void showSelectDialog({
title: t('setting__backup_other_export_dir'),
// defaultPath: currentStting.value.download.savePath,
properties: ['openDirectory'],
}).then(result => {
if (result.canceled) return
exportPlayListToText(result.filePaths[0], false)
void exportPlayListToText(result.filePaths[0], false)
})
}
}
@@ -342,23 +342,23 @@ export default {
confirmButtonText: t('confirm_button_text'),
})
if (confirm) {
openSaveDir({
void openSaveDir({
title: t('setting__backup_other_export_dir'),
defaultPath: 'lx_list_all.csv',
}).then(result => {
if (result.canceled) return
let path = result.filePath
if (!path.endsWith('.csv')) path += '.csv'
exportPlayListToCsv(path, true)
void exportPlayListToCsv(path, true)
})
} else {
showSelectDialog({
void showSelectDialog({
title: t('setting__backup_other_export_dir'),
// defaultPath: currentStting.value.download.savePath,
properties: ['openDirectory'],
}).then(result => {
if (result.canceled) return
exportPlayListToCsv(result.filePaths[0], false)
void exportPlayListToCsv(result.filePaths[0], false)
})
}
}
@@ -186,7 +186,7 @@ export default {
const handleEditTheme = (theme) => {
// console.log(theme)
if (!theme && userThemes.length >= 10) {
dialog({
void dialog({
message: t('theme_max_tip'),
confirmButtonText: t('alert_button_text'),
})
@@ -214,7 +214,7 @@ export default {
if (themeId.value == 'auto') return
if (window.localStorage.getItem('theme-auto-tip') != 'true') {
window.localStorage.setItem('theme-auto-tip', 'true')
dialog({
void dialog({
message: t('setting__basic_theme_auto_tip'),
confirmButtonText: t('ok'),
})
@@ -271,7 +271,7 @@ export default {
const fontList = computed(() => {
return [{ id: '', label: t('setting__desktop_lyric_font_default') }, ...systemFontList.value]
})
getSystemFonts().then(fonts => {
void getSystemFonts().then(fonts => {
systemFontList.value = fonts.map(f => ({ id: f, label: f.replace(/(^"|"$)/g, '') }))
})
@@ -269,7 +269,7 @@ export default {
const fontList = computed(() => {
return [{ id: '', label: t('setting__desktop_lyric_font_default') }, ...systemFontList.value]
})
getSystemFonts().then(fonts => {
void getSystemFonts().then(fonts => {
systemFontList.value = fonts.map(f => ({ id: f, label: f.replace(/(^"|"$)/g, '') }))
})
@@ -67,7 +67,7 @@ export default {
const t = useI18n()
const handleChangeSavePath = () => {
showSelectDialog({
void showSelectDialog({
title: t('setting__download_select_save_path'),
defaultPath: appSetting['download.savePath'],
properties: ['openDirectory'],
@@ -134,6 +134,7 @@ export default {
if (config) {
if (config.key == newHotKey) return
originKey = config.key
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete current_hot_key.value[type].keys[config.key]
} else if (!newHotKey) return
@@ -143,6 +144,7 @@ export default {
config = tempInfo.keys[newHotKey]
if (config) {
console.log(newHotKey, info, config, info.name, config.name)
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete current_hot_key.value[tempType].keys[newHotKey]
break
}
@@ -203,7 +205,7 @@ export default {
await handleHotKeySaveConfig()
await getHotKeyStatus()
}
const getHotKeyStatus = () => {
const getHotKeyStatus = async() => {
return hotKeyGetStatus().then(status => {
// console.log(status)
hotKeyStatus.value = status
@@ -213,7 +215,7 @@ export default {
current_hot_key.value = window.lx.appHotKeyConfig
initHotKeyConfig()
getHotKeyStatus()
void getHotKeyStatus()
window.app_event.on('keyDown', handleKeyDown)
@@ -83,7 +83,7 @@ export default {
const isDisabledResourceCacheClear = ref(false)
// const isDisabledListCacheClear = ref(false)
const refreshCacheSize = () => {
getCacheSize().then(size => {
void getCacheSize().then(size => {
cacheSize.value = sizeFormate(size)
})
}
@@ -94,7 +94,7 @@ export default {
confirmButtonText: t('setting__other_resource_cache_confirm'),
})) return
isDisabledResourceCacheClear.value = true
clearCache().then(() => {
void clearCache().then(() => {
refreshCacheSize()
isDisabledResourceCacheClear.value = false
})
@@ -105,13 +105,13 @@ export default {
const otherSourceCount = ref(0)
const isDisabledOtherSourceCacheClear = ref(false)
const refreshOtherSourceCount = () => {
getOtherSourceCount().then(count => {
void getOtherSourceCount().then(count => {
otherSourceCount.value = count
})
}
const handleClearOtherSourceCache = async() => {
isDisabledOtherSourceCacheClear.value = true
clearOtherSource().then(() => {
void clearOtherSource().then(() => {
refreshOtherSourceCount()
isDisabledOtherSourceCacheClear.value = false
})
@@ -122,13 +122,13 @@ export default {
const musicUrlCount = ref(0)
const isDisabledMusicUrlCacheClear = ref(false)
const refreshMusicUrlCount = () => {
getMusicUrlCount().then(count => {
void getMusicUrlCount().then(count => {
musicUrlCount.value = count
})
}
const handleClearMusicUrlCache = async() => {
isDisabledMusicUrlCacheClear.value = true
clearMusicUrl().then(() => {
void clearMusicUrl().then(() => {
refreshMusicUrlCount()
isDisabledMusicUrlCacheClear.value = false
})
@@ -139,13 +139,13 @@ export default {
const lyricRawCount = ref(0)
const isDisabledLyricRawCacheClear = ref(false)
const refreshLyricRawCount = () => {
getLyricRawCount().then(count => {
void getLyricRawCount().then(count => {
lyricRawCount.value = count
})
}
const handleClearLyricRawCache = async() => {
isDisabledLyricRawCacheClear.value = true
clearLyricRaw().then(() => {
void clearLyricRaw().then(() => {
refreshLyricRawCount()
isDisabledLyricRawCacheClear.value = false
})
@@ -156,7 +156,7 @@ export default {
const lyricEditedCount = ref(0)
const isDisabledLyricEditedCacheClear = ref(false)
const refreshLyricEditedCount = () => {
getLyricEditedCount().then(count => {
void getLyricEditedCount().then(count => {
lyricEditedCount.value = count
})
}
@@ -167,7 +167,7 @@ export default {
confirmButtonText: t('setting__other_resource_cache_confirm'),
})) return
isDisabledLyricEditedCacheClear.value = true
clearLyricEdited().then(() => {
void clearLyricEdited().then(() => {
refreshLyricEditedCount()
isDisabledLyricEditedCacheClear.value = false
})
@@ -180,7 +180,7 @@ export default {
cancelButtonText: t('cancel_button_text'),
confirmButtonText: t('setting__other_resource_cache_confirm'),
})) return
overwriteListFull({
void overwriteListFull({
defaultList: [],
loveList: [],
userList: [],
@@ -47,7 +47,7 @@ export default {
mediaDevices.value = audioDevices
// console.log(this.mediaDevices)
}
getMediaDevice()
void getMediaDevice()
navigator.mediaDevices.addEventListener('devicechange', getMediaDevice)
onBeforeUnmount(() => {
@@ -91,7 +91,7 @@ export default {
})
const refreshSyncCode = () => {
sendSyncAction({ action: 'generate_code' })
void sendSyncAction({ action: 'generate_code' })
}
const setSyncServerPort = debounce(port => {
@@ -288,39 +288,39 @@ export default {
// console.log('appBgColor', color)
theme.config.extInfo['--color-app-background'] = color == appBgColor ? appBgColorOrigin : color
createPreview()
}, () => setAppBgColor(getColor(appBgColorOrigin, theme)))
}, () => { setAppBgColor(getColor(appBgColorOrigin, theme)) })
initAsideFontColor(asideFontColor, (color) => {
theme.config.extInfo['--color-nav-font'] = color == asideFontColor ? asideFontColorOrigin : color
createPreview()
}, () => setAsideFontColor(getColor(asideFontColorOrigin, theme)))
}, () => { setAsideFontColor(getColor(asideFontColorOrigin, theme)) })
initMainBgColor(mainBgColor, (color) => {
theme.config.extInfo['--color-main-background'] = color == mainBgColor ? mainBgColorOrigin : color
createPreview()
}, () => setMainBgColor(getColor(mainBgColorOrigin, theme)))
}, () => { setMainBgColor(getColor(mainBgColorOrigin, theme)) })
initBadgePrimaryColor(badgePrimaryColor, (color) => {
theme.config.extInfo['--color-badge-primary'] = color == badgePrimaryColor ? badgePrimaryColorOrigin : color
createPreview()
}, () => setBadgePrimaryColor(getColor(badgePrimaryColorOrigin, theme)))
}, () => { setBadgePrimaryColor(getColor(badgePrimaryColorOrigin, theme)) })
initBadgeSecondaryColor(badgeSecondaryColor, (color) => {
theme.config.extInfo['--color-badge-secondary'] = color == badgeSecondaryColor ? badgeSecondaryColorOrigin : color
createPreview()
}, () => setBadgeSecondaryColor(getColor(badgeSecondaryColorOrigin, theme)))
}, () => { setBadgeSecondaryColor(getColor(badgeSecondaryColorOrigin, theme)) })
initBadgeTertiaryColor(badgeTertiaryColor, (color) => {
theme.config.extInfo['--color-badge-tertiary'] = color == badgeTertiaryColor ? badgeTertiaryColorOrigin : color
createPreview()
}, () => setBadgeTertiaryColor(getColor(badgeTertiaryColorOrigin, theme)))
}, () => { setBadgeTertiaryColor(getColor(badgeTertiaryColorOrigin, theme)) })
initCloseBtnColor(closeBtnColor, (color) => {
theme.config.extInfo['--color-btn-close'] = color == closeBtnColor ? closeBtnColorOrigin : color
createPreview()
}, () => setCloseBtnColor(getColor(closeBtnColorOrigin, theme)))
}, () => { setCloseBtnColor(getColor(closeBtnColorOrigin, theme)) })
initMinBtnColor(minBtnColor, (color) => {
theme.config.extInfo['--color-btn-min'] = color == minBtnColor ? minBtnColorOrigin : color
createPreview()
}, () => setMinBtnColor(getColor(minBtnColorOrigin, theme)))
}, () => { setMinBtnColor(getColor(minBtnColorOrigin, theme)) })
initHideBtnColor(hideBtnColor, (color) => {
theme.config.extInfo['--color-btn-hide'] = color == hideBtnColor ? hideBtnColorOrigin : color
createPreview()
}, () => setHideBtnColor(getColor(hideBtnColorOrigin, theme)))
}, () => { setHideBtnColor(getColor(hideBtnColorOrigin, theme)) })
createPreview()
}
@@ -339,7 +339,7 @@ export default {
}
watch(() => props.modelValue, (visible) => {
nextTick(() => {
void nextTick(() => {
getThemes(({ themes, userThemes }) => {
if (visible) {
if (props.themeId) {
@@ -392,7 +392,7 @@ export default {
}
const removeBgImg = async() => {
if (currentBgPath) {
removeFile(currentBgPath)
void removeFile(currentBgPath)
currentBgPath = ''
}
bgImg.value = ''
@@ -432,7 +432,7 @@ export default {
// 移除旧背景
if (originBgName &&
theme.config.extInfo['--background-image'] != originBgName &&
!isUrl(theme.config.extInfo['--background-image'])) removeFile(joinPath(themeInfo.dataPath, originBgName))
!isUrl(theme.config.extInfo['--background-image'])) void removeFile(joinPath(themeInfo.dataPath, originBgName))
if (props.themeId) {
const index = themeInfo.userThemes.findIndex(t => t.id == theme.id)
if (index > -1) themeInfo.userThemes.splice(index, 1, theme)
@@ -468,7 +468,7 @@ export default {
}
}
if (isRequireUpdateSetting) updateSetting(newSetting)
if (originBgName) removeFile(joinPath(themeInfo.dataPath, originBgName))
if (originBgName) void removeFile(joinPath(themeInfo.dataPath, originBgName))
await removeTheme(props.themeId)
const index = themeInfo.userThemes.findIndex(t => t.id == theme.id)
console.log(index)
@@ -60,16 +60,16 @@ export default {
})
return
}
showSelectDialog({
void showSelectDialog({
title: this.$t('user_api__import_file'),
properties: ['openFile'],
filters: [
{ name: 'LX API File', extensions: ['js'] },
{ name: 'All Files', extensions: ['*'] },
],
}).then(result => {
}).then(async result => {
if (result.canceled) return
return readFile(result.filePaths[0]).then(data => {
return readFile(result.filePaths[0]).then(async data => {
return importUserApi(data.toString()).then(({ apiList }) => {
userApi.list = apiList
})
@@ -92,10 +92,10 @@ export default {
this.$emit('update:modelValue', false)
},
handleOpenUrl(url) {
openUrl(url)
void openUrl(url)
},
handleChangeAllowUpdateAlert(api, enable) {
setAllowShowUserApiUpdateAlert(api.id, enable)
void setAllowShowUserApiUpdateAlert(api.id, enable)
},
},
}
+1 -1
View File
@@ -119,7 +119,7 @@ export default {
const toggleTab = id => {
avtiveComponentName.value = id
nextTick(() => {
void nextTick(() => {
dom_content_ref.value?.scrollTo({
top: 0,
behavior: 'smooth',