From 4f950148d531e6139dbdc933096e74f96ab3865c Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Tue, 21 May 2024 21:52:25 +0800 Subject: [PATCH] :bug: Fix(custom): fix el-select option display problem --- public/i18n/en.yml | 2 +- public/i18n/zh-CN.yml | 2 +- public/i18n/zh-TW.yml | 2 +- src/renderer/pages/PicGoSetting.vue | 72 +++++++++++++++++++---------- src/universal/types/view.d.ts | 5 +- 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/public/i18n/en.yml b/public/i18n/en.yml index cc21af5b..02f1ee1f 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -54,7 +54,7 @@ TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS: "Please create the folder yourself MANUAL_PAGE_OPEN_TIP: Please select the way to open the manual MANUAL_PAGE_OPEN_TIP_TITLE: Tips MANUAL_PAGE_OPEN_BY_BROWSER: Browser -MANUAL_PAGE_OPEN_BY_BUILD_IN: Built-in +MANUAL_PAGE_OPEN_BY_BUILD_IN: Built-in Window MANUAL_PAGE_OPEN_SETTING_TIP: Select the way to open the manual # ---renderer i18n begin--- diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index 740eb8f7..1a2a1c26 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -54,7 +54,7 @@ TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS: 请自行创建文件夹:${path} MANUAL_PAGE_OPEN_TIP: 请选择打开方式 MANUAL_PAGE_OPEN_TIP_TITLE: Tips MANUAL_PAGE_OPEN_BY_BROWSER: 浏览器 -MANUAL_PAGE_OPEN_BY_BUILD_IN: 内置 +MANUAL_PAGE_OPEN_BY_BUILD_IN: 内置窗口 MANUAL_PAGE_OPEN_SETTING_TIP: 选择手册打开方式 # ---renderer i18n begin--- diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index 02b0d376..971e9449 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -54,7 +54,7 @@ TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS: 請自行創建文件夾:${path} MANUAL_PAGE_OPEN_TIP: 請選擇打開方式 MANUAL_PAGE_OPEN_TIP_TITLE: Tips MANUAL_PAGE_OPEN_BY_BROWSER: 瀏覽器 -MANUAL_PAGE_OPEN_BY_BUILD_IN: 內置 +MANUAL_PAGE_OPEN_BY_BUILD_IN: 內置窗口s MANUAL_PAGE_OPEN_SETTING_TIP: 選擇打開手冊方式 # ---renderer i18n begin--- diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index e011f6a9..cc4348c1 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -96,7 +96,7 @@ :label="$T('MANUAL_PAGE_OPEN_SETTING_TIP')" > ({ + label: item.label, + value: item.value +})) + +const startModeList = [ + { + label: $T('SETTINGS_START_MODE_QUIET'), + value: ISartMode.QUIET + }, + { + label: $T('SETTINGS_START_MODE_MINI'), + value: ISartMode.MINI + }, + { + label: $T('SETTINGS_START_MODE_NO_TRAY'), + value: ISartMode.NO_TRAY + }, + { + label: $T('SETTINGS_START_MODE_MAIN'), + value: ISartMode.MAIN + } +] + const manualPageOpenList = [{ label: $T('MANUAL_PAGE_OPEN_BY_BUILD_IN'), value: 'window' @@ -1799,6 +1823,8 @@ const manualPageOpenList = [{ } ] +const picBed = ref([]) + const waterMarkPositionMap = new Map([ ['north', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP')], ['northeast', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP_RIGHT')], @@ -1934,9 +1960,7 @@ const form = reactive({ autoCloseMainWindow: false, logLevel: ['all'], autoCopyUrl: true, - checkBetaUpdate: true, useBuiltinClipboard: true, - language: 'zh-CN', logFileSizeLimit: 10, deleteCloudFile: false, isCustomMiniIcon: false, @@ -1955,22 +1979,20 @@ const form = reactive({ deleteLocalFile: false, serverKey: '', aesPassword: '', - manualPageOpen: 'browser', enableWebServer: false, webServerHost: '0.0.0.0', webServerPort: 37777, webServerPath: '' }) -const languageList = i18nManager.languageList.map(item => ({ - label: item.label, - value: item.value -})) - -const currentLanguage = ref('zh-CN') -const currentStartMode = ref('quiet') +const valueToOptionItem = (value: any, list: { label: string, value: any }[]) => { + return list.find(item => item.value === value) || list[0] +} -const picBed = ref([]) +const currentLanguage = ref() +const currentStartMode = ref() +const currentManualPageOpen = ref() +const currentShortUrlServer = ref() const logFileVisible = ref(false) const customLinkVisible = ref(false) @@ -2092,22 +2114,20 @@ async function initData () { if (config !== undefined) { const settings = config.settings || {} const picBed = config.picBed - form.updateHelper = settings.showUpdateTip === undefined ? true : settings.showUpdateTip + form.updateHelper = settings.showUpdateTip ?? true form.autoStart = settings.autoStart || false form.rename = settings.rename || false form.autoRename = settings.autoRename || false form.uploadNotification = settings.uploadNotification || false - form.uploadResultNotification = settings.uploadResultNotification === undefined ? true : settings.uploadResultNotification + form.uploadResultNotification = settings.uploadResultNotification ?? true form.miniWindowOntop = settings.miniWindowOntop || false form.autoCloseMiniWindow = settings.autoCloseMiniWindow || false form.autoCloseMainWindow = settings.autoCloseMainWindow || false form.logLevel = initArray(settings.logLevel || [], ['all']) - form.autoCopyUrl = settings.autoCopy === undefined ? true : settings.autoCopy - form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate - form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? true : settings.useBuiltinClipboard + form.autoCopyUrl = settings.autoCopy ?? true + form.useBuiltinClipboard = settings.useBuiltinClipboard ?? true form.isAutoListenClipboard = settings.isAutoListenClipboard || false - form.language = settings.language ?? 'zh-CN' - form.encodeOutputURL = settings.encodeOutputURL === undefined ? false : settings.encodeOutputURL + form.encodeOutputURL = settings.encodeOutputURL || false form.deleteCloudFile = settings.deleteCloudFile || false form.autoImport = settings.autoImport || false form.autoImportPicBed = initArray(settings.autoImportPicBed || [], []) @@ -2123,13 +2143,14 @@ async function initData () { form.deleteLocalFile = settings.deleteLocalFile || false form.serverKey = settings.serverKey || '' form.aesPassword = settings.aesPassword || 'PicList-aesPassword' - form.manualPageOpen = settings.manualPageOpen || 'window' form.enableWebServer = settings.enableWebServer || false form.webServerHost = settings.webServerHost || '0.0.0.0' form.webServerPort = settings.webServerPort || 37777 form.webServerPath = settings.webServerPath || '' - currentLanguage.value = settings.language ?? 'zh-CN' - currentStartMode.value = settings.startMode || 'quiet' + currentLanguage.value = valueToOptionItem(settings.language || 'zh-CN', languageList) + currentStartMode.value = valueToOptionItem(settings.startMode || ISartMode.QUIET, startModeList) + currentManualPageOpen.value = valueToOptionItem(settings.manualPageOpen || 'window', manualPageOpenList) + currentShortUrlServer.value = valueToOptionItem(settings.shortUrlServer || 'c1n', shortUrlServerList) customLink.value = settings.customLink || '![$fileName]($url)' proxy.value = picBed.proxy || '' npmRegistry.value = settings.registry || '' @@ -2298,7 +2319,7 @@ function handleAutoImportPicBedChange (val: string[]) { } function handleHideDockChange (val: ICheckBoxValueType) { - if (val && currentStartMode.value === 'no-tray') { + if (val && currentStartMode.value.value === ISartMode.NO_TRAY) { ElMessage.warning($T('SETTINGS_ISHIDEDOCK_TIPS')) form.isHideDock = false return @@ -2495,6 +2516,7 @@ function handleUseShortUrl (val: ICheckBoxValueType) { } function handleShortUrlServerChange (val: string) { + form.shortUrlServer = val saveConfig(configPaths.settings.shortUrlServer, val) } @@ -2667,7 +2689,7 @@ function handleStartModeChange (val: ISartModeValues) { if (val === ISartMode.NO_TRAY) { if (form.isHideDock) { ElMessage.warning($T('SETTINGS_ISHIDEDOCK_TIPS')) - currentStartMode.value = ISartMode.QUIET + currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList) return } $message.info($T('TIPS_NEED_RELOAD')) diff --git a/src/universal/types/view.d.ts b/src/universal/types/view.d.ts index 050b7877..423c02c5 100644 --- a/src/universal/types/view.d.ts +++ b/src/universal/types/view.d.ts @@ -11,9 +11,7 @@ interface ISettingForm { autoCloseMainWindow: boolean logLevel: string[] autoCopyUrl: boolean - checkBetaUpdate: boolean useBuiltinClipboard: boolean - language: 'zh-CN' | 'zh-TW' | 'en' logFileSizeLimit: number deleteCloudFile: boolean isCustomMiniIcon: boolean @@ -24,15 +22,14 @@ interface ISettingForm { encodeOutputURL: boolean isAutoListenClipboard: boolean useShortUrl: boolean - c1nToken: string shortUrlServer: string + c1nToken: string yourlsDomain: string yourlsSignature: string cfWorkerHost: string deleteLocalFile: boolean serverKey: string aesPassword: string - manualPageOpen: 'window' | 'browser' enableWebServer: boolean webServerHost: string webServerPort: number