From 4aae2c3fbeec190552f3e1a4f33d6a716d546c44 Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Mon, 13 Nov 2023 21:07:57 -0800 Subject: [PATCH] :hammer: Refactor(custom): change default temp dir to system temp dir path ISSUES CLOSED: #112 --- public/i18n/en.yml | 1 - public/i18n/zh-CN.yml | 1 - public/i18n/zh-TW.yml | 1 - src/main/manage/events/ipcList.ts | 7 ------- src/main/manage/utils/common.ts | 9 +-------- src/renderer/pages/PicGoSetting.vue | 25 +------------------------ src/universal/types/i18n.d.ts | 1 - src/universal/types/view.d.ts | 1 - 8 files changed, 2 insertions(+), 44 deletions(-) diff --git a/public/i18n/en.yml b/public/i18n/en.yml index 07dfaf1..a27fa9d 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -296,7 +296,6 @@ SETTINGS_TAB_SYNC_CONFIG: Sync and Configuration SETTINGS_TAB_UPLOAD: Upload SETTINGS_TAB_ADVANCED: Advanced SETTINGS_TAB_UPDATE: Update -SETTINGS_GENERAL_TEMP_DIR_PATH: Temporary directory path # shortcut-page BUILTIN_CLIPBOARD_TIPS: Use builtin clipboard function to upload instead of using scripts diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index 06c11a6..4acf3fc 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -299,7 +299,6 @@ SETTINGS_TAB_SYNC_CONFIG: 同步与配置 SETTINGS_TAB_UPLOAD: 上传设置 SETTINGS_TAB_ADVANCED: 高级设置 SETTINGS_TAB_UPDATE: 更新 -SETTINGS_GENERAL_TEMP_DIR_PATH: 临时文件夹路径 # shortcut-page SHORTCUT_NAME: 快捷键名称 diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index 4608322..31c627f 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -297,7 +297,6 @@ SETTINGS_TAB_SYNC_CONFIG: 同步與配置 SETTINGS_TAB_UPLOAD: 上傳設置 SETTINGS_TAB_ADVANCED: 高級設置 SETTINGS_TAB_UPDATE: 更新 -SETTINGS_GENERAL_TEMP_DIR_PATH: 本地暫存路徑 # shortcut-page SHORTCUT_NAME: 快捷鍵名稱 diff --git a/src/main/manage/events/ipcList.ts b/src/main/manage/events/ipcList.ts index 5368e49..6d3f03d 100644 --- a/src/main/manage/events/ipcList.ts +++ b/src/main/manage/events/ipcList.ts @@ -67,13 +67,6 @@ export const manageIpcList = { return res }) - ipcMain.handle('openDirectorySelectDialog', async () => { - const res = await dialog.showOpenDialog({ - properties: ['openDirectory'] - }) - return res.filePaths[0] - }) - ipcMain.handle('openFileSelectDialog', async () => { const res = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] diff --git a/src/main/manage/utils/common.ts b/src/main/manage/utils/common.ts index a22300e..c11031e 100644 --- a/src/main/manage/utils/common.ts +++ b/src/main/manage/utils/common.ts @@ -49,14 +49,7 @@ export function isInputConfigValid (config: any): boolean { export const getFileMimeType = (filePath: string): string => mime.lookup(filePath) || 'application/octet-stream' const getTempDirPath = () => { - const defaultPath = path.join(app.getPath('downloads'), 'piclistTemp') - try { - const configFilePath = path.join(app.getPath('userData'), 'data.json') - const { settings: { tempDirPath = '' } = {} } = fs.readJSONSync(configFilePath) || {} - return tempDirPath ? path.join(tempDirPath, 'piclistTemp') : defaultPath - } catch (e) { - return defaultPath - } + return path.join(app.getPath('temp'), 'piclistTemp') } const checkTempFolderExist = async (tempPath: string) => { diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index 00f75e9..50237ca 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -194,18 +194,6 @@ {{ $T('SETTINGS_CLICK_TO_SET') }} - - - {{ $T('SETTINGS_CLICK_TO_SET') }} - - @@ -1737,8 +1725,7 @@ const form = reactive({ yourlsSignature: '', deleteLocalFile: false, serverKey: '', - aesPassword: '', - tempDirPath: '' + aesPassword: '' }) const languageList = i18nManager.languageList.map(item => ({ @@ -1903,7 +1890,6 @@ async function initData () { form.deleteLocalFile = settings.deleteLocalFile || false form.serverKey = settings.serverKey || '' form.aesPassword = settings.aesPassword || 'PicList-aesPassword' - form.tempDirPath = settings.tempDirPath || '' currentLanguage.value = settings.language ?? 'zh-CN' currentStartMode.value = settings.startMode || 'quiet' customLink.value = settings.customLink || '![$fileName]($url)' @@ -2209,15 +2195,6 @@ function handleMiniWindowOntop (val: ICheckBoxValueType) { $message.info($T('TIPS_NEED_RELOAD')) } -async function handleTempDirPath (evt: Event) { - const result = await invokeToMain('openDirectorySelectDialog') - if (result) { - form.tempDirPath = result - saveConfig('settings.tempDirPath', form.tempDirPath) - $message.info($T('TIPS_NEED_RELOAD')) - } -} - async function handleMiniIconPath (evt: Event) { const result = await invokeToMain('openFileSelectDialog') if (result && result[0]) { diff --git a/src/universal/types/i18n.d.ts b/src/universal/types/i18n.d.ts index 0f8ec3e..354d618 100644 --- a/src/universal/types/i18n.d.ts +++ b/src/universal/types/i18n.d.ts @@ -292,7 +292,6 @@ interface ILocales { SETTINGS_TAB_UPLOAD: string SETTINGS_TAB_ADVANCED: string SETTINGS_TAB_UPDATE: string - SETTINGS_GENERAL_TEMP_DIR_PATH: string SHORTCUT_NAME: string SHORTCUT_BIND: string SHORTCUT_STATUS: string diff --git a/src/universal/types/view.d.ts b/src/universal/types/view.d.ts index 8376069..1f09864 100644 --- a/src/universal/types/view.d.ts +++ b/src/universal/types/view.d.ts @@ -30,7 +30,6 @@ interface ISettingForm { deleteLocalFile: boolean, serverKey: string, aesPassword: string, - tempDirPath: string, } interface IShortKeyMap {