diff --git a/src/main/events/rpc/routes/setting/configure.ts b/src/main/events/rpc/routes/setting/configure.ts index b7851fc9..84c0aa31 100644 --- a/src/main/events/rpc/routes/setting/configure.ts +++ b/src/main/events/rpc/routes/setting/configure.ts @@ -35,6 +35,54 @@ export default [ }, type: IRPCType.INVOKE, }, + { + action: IRPCActionType.CONFIGURE_MIGRATE_FROM_PICLIST_INSTALLATION, + handler: async () => { + const configDir = app.getPath('userData') + console.log('Migrating from PicList installation at:', configDir) + const files = [ + 'data.json', + 'data.bak.json', + 'manage.json', + 'manage.bak.json', + 'piclist.db', + 'piclist.bak.db', + 'taskQueue.json', + 'UpDownTaskQueue.json', + 'packages.json', + ] + const folders = [ + 'themes', + 'piclistTemp', + 'serverTemp', + 'i18n', + 'i18n-cli', + 'piclist-clipboard-images', + 'imgTemp', + 'node_modules', + ] + try { + await Promise.all( + files.map(async file => { + const sourcePath = path.join(configDir, file) + const targetPath = path.join(STORE_PATH, file) + await fs.copy(sourcePath, targetPath, { overwrite: true }) + }), + ) + await Promise.all( + folders.map(async folder => { + const sourcePath = path.join(configDir, folder) + const targetPath = path.join(STORE_PATH, folder) + await fs.copy(sourcePath, targetPath, { overwrite: true }) + }), + ) + } catch (err: any) { + logger.error(err) + throw new Error('Migrate failed') + } + }, + type: IRPCType.INVOKE, + }, { action: IRPCActionType.CONFIGURE_UPLOAD_COMMON_CONFIG, handler: async () => { diff --git a/src/main/events/rpc/routes/system/app.ts b/src/main/events/rpc/routes/system/app.ts index f373096a..10080c6a 100644 --- a/src/main/events/rpc/routes/system/app.ts +++ b/src/main/events/rpc/routes/system/app.ts @@ -1,3 +1,4 @@ +import { isPortable } from '@core/datastore/dirs' import picgo from '@core/picgo' import { app, nativeTheme, shell } from 'electron' @@ -80,4 +81,11 @@ export default [ }, type: IRPCType.INVOKE, }, + { + action: IRPCActionType.GET_IS_PORTABLE, + handler: async () => { + return isPortable() + }, + type: IRPCType.INVOKE, + }, ] diff --git a/src/main/utils/enum.ts b/src/main/utils/enum.ts index c1e78bac..cecac2a2 100644 --- a/src/main/utils/enum.ts +++ b/src/main/utils/enum.ts @@ -70,6 +70,8 @@ export const IRPCType = { export const IRPCActionType = { // system rpc + GET_IS_PORTABLE: 'GET_IS_PORTABLE', + CONFIGURE_MIGRATE_FROM_PICLIST_INSTALLATION: 'CONFIGURE_MIGRATE_FROM_PICLIST_INSTALLATION', GET_SYSTEM_THEME: 'GET_SYSTEM_THEME', SET_SYSTEM_THEME: 'SET_SYSTEM_THEME', APPLY_THEME: 'APPLY_THEME', diff --git a/src/renderer/i18n/locales/en.json b/src/renderer/i18n/locales/en.json index 6a7d8e17..fe26df94 100644 --- a/src/renderer/i18n/locales/en.json +++ b/src/renderer/i18n/locales/en.json @@ -741,7 +741,10 @@ }, "manageConfig": "Manage Configuration", "migrateDesc": "Import configuration and gallery data from PicGo", + "migrateDescPicList": "Import configuration and gallery data from PicList Installation", "migrateFromPicGo": "Migrate from PicGo", + "migrateFromPicListInstallation": "Migrate from PicList Installation", + "migrateFromPicListInstallationContent": "Import configuration files and albums from PicList Installation, which will overwrite the current configuration files and albums. Do you want to continue?", "mirgrateContent": "You are about to import configuration files and albums from PicGo, which will overwrite the current configuration files and albums. Do you want to continue?", "mirgrateFailed": "Import Failed", "mirgrateSuccess": "Import Successful, Please Restart PicList to Take Effect", diff --git a/src/renderer/i18n/locales/zh-CN.json b/src/renderer/i18n/locales/zh-CN.json index bb2de96d..731365cb 100644 --- a/src/renderer/i18n/locales/zh-CN.json +++ b/src/renderer/i18n/locales/zh-CN.json @@ -736,7 +736,10 @@ }, "manageConfig": "管理配置", "migrateDesc": "从 PicGo 导入配置和相册数据", + "migrateDescPicList": "从安装版PicList导入配置和相册数据", "migrateFromPicGo": "从PicGo迁移", + "migrateFromPicListInstallation": "从安装版PicList迁移", + "migrateFromPicListInstallationContent": "将安装版PicList的配置文件和相册数据导入到当前版本, 这将覆盖当前的配置文件和相册, 是否继续?", "mirgrateContent": "即将导入PicGo的配置文件和相册, 这将覆盖当前的配置文件和相册, 是否继续?", "mirgrateFailed": "导入失败", "mirgrateSuccess": "导入成功, 请重启PicList生效", diff --git a/src/renderer/i18n/locales/zh-TW.json b/src/renderer/i18n/locales/zh-TW.json index 00996328..3e79f42a 100644 --- a/src/renderer/i18n/locales/zh-TW.json +++ b/src/renderer/i18n/locales/zh-TW.json @@ -736,7 +736,10 @@ }, "manageConfig": "管理配置", "migrateDesc": "從 PicGo 導入配置和相冊數據", + "migrateDescPicList": "從安裝版 PicList 導入配置和相冊數據", "migrateFromPicGo": "從PicGo遷移", + "migrateFromPicListInstallation": "從安裝版 PicList 遷移", + "migrateFromPicListInstallationContent": "將安裝版 PicList 的配置文件和相冊數據導入到當前版本, 這將覆蓋當前的配置文件和相冊, 是否繼續?", "mirgrateContent": "即將導入PicGo的配置文件和相冊, 這將覆蓋當前的配置文件和相冊, 是否繼續?", "mirgrateFailed": "導入失敗", "mirgrateSuccess": "導入成功, 請重啟PicList生效", diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index 2c294306..7908c0b4 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -344,6 +344,20 @@ +
{{ t('pages.settings.sync.migrateDescPicList') }}
+