diff --git a/public/i18n/en.yml b/public/i18n/en.yml index e69c028..862b455 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -105,6 +105,11 @@ UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER: center SETTINGS: Settings SETTINGS_OPEN_CONFIG_FILE: Open Config File +SETTINGS_MIGRATE_FROM_PICGO: Migrate from PicGo +SETTINGS_MIGRATE_FROM_PICGO_TITLE: Notice +SETTINGS_MIGRATE_FROM_PICGO_CONTENT: Migrate from PicGo will overwrite your current settings and gallery, do you want to continue? +SETTINGS_MIGRATE_FROM_PICGO_SUCCESS: Import succeed, please restart PicList +SETTINGS_MIGRATE_FROM_PICGO_FAILED: Import failed SETTINGS_CLICK_TO_OPEN: Click to Open SETTINGS_SET_LOG_FILE: Set Log File SETTINGS_CLICK_TO_SET: Click to Set diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index 3bfa9b9..0526917 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -105,6 +105,11 @@ UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER: 中 SETTINGS: 设置 SETTINGS_OPEN_CONFIG_FILE: 打开配置文件 +SETTINGS_MIGRATE_FROM_PICGO: 从PicGo迁移 +SETTINGS_MIGRATE_FROM_PICGO_TITLE: 通知 +SETTINGS_MIGRATE_FROM_PICGO_CONTENT: 即将导入PicGo的配置文件和相册, 这将覆盖当前的配置文件和相册, 是否继续? +SETTINGS_MIGRATE_FROM_PICGO_SUCCESS: 导入成功, 请重启PicList生效 +SETTINGS_MIGRATE_FROM_PICGO_FAILED: 导入失败 SETTINGS_CLICK_TO_OPEN: 点击打开 SETTINGS_SET_LOG_FILE: 设置日志文件 SETTINGS_CLICK_TO_SET: 点击设置 diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index b24a0e7..929cd6b 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -105,6 +105,11 @@ UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER: 中 SETTINGS: 設定 SETTINGS_OPEN_CONFIG_FILE: 打開設定檔案 +SETTINGS_MIGRATE_FROM_PICGO: 從PicGo導入設定 +SETTINGS_MIGRATE_FROM_PICGO_TITLE: 通知 +SETTINGS_MIGRATE_FROM_PICGO_CONTENT: 即將導入PicGo的設定文件和相冊, 這將會覆蓋當前的設定, 是否繼續? +SETTINGS_MIGRATE_FROM_PICGO_SUCCESS: 導入成功, 請重啟應用 +SETTINGS_MIGRATE_FROM_PICGO_FAILED: 導入失敗 SETTINGS_CLICK_TO_OPEN: 點擊打開 SETTINGS_SET_LOG_FILE: 設定記錄檔案 SETTINGS_CLICK_TO_SET: 點擊設定 diff --git a/src/main/events/ipcList.ts b/src/main/events/ipcList.ts index 3b99350..81db845 100644 --- a/src/main/events/ipcList.ts +++ b/src/main/events/ipcList.ts @@ -15,6 +15,7 @@ import server from '~/main/server' import getPicBeds from '~/main/utils/getPicBeds' import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler' import bus from '@core/bus' +import fs from 'fs-extra' import { TOGGLE_SHORTKEY_MODIFIED_MODE, OPEN_DEVTOOLS, @@ -113,6 +114,34 @@ export default { } }) + ipcMain.handle('migrateFromPicGo', async () => { + const picGoConfigPath = STORE_PATH.replace('piclist', 'picgo') + console.log(picGoConfigPath) + const fileToMigration = [ + 'data.json', + 'data.bak.json', + 'picgo.db', + 'picgo.bak.db' + ] + const targetFileNames = [ + 'data.json', + 'data.bak.json', + 'piclist.db', + 'piclist.bak.db' + ] + try { + for (let i = 0; i < fileToMigration.length; i++) { + if (fs.existsSync(path.join(picGoConfigPath, fileToMigration[i]))) { + fs.removeSync(path.join(STORE_PATH, targetFileNames[i])) + fs.copyFileSync(path.join(picGoConfigPath, fileToMigration[i]), path.join(STORE_PATH, targetFileNames[i])) + } + } + return true + } catch (e) { + return false + } + }) + ipcMain.on('updateCustomLink', () => { const notification = new Notification({ title: T('OPERATION_SUCCEED'), diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index 854d1a2..a7f1434 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -42,6 +42,18 @@ /> + + + {{ $T('SETTINGS_CLICK_TO_SET') }} + + @@ -787,7 +799,7 @@