mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-06 20:42:57 +08:00
✨ Feature(custom): add mirgration support from installation
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -736,7 +736,10 @@
|
||||
},
|
||||
"manageConfig": "管理配置",
|
||||
"migrateDesc": "从 PicGo 导入配置和相册数据",
|
||||
"migrateDescPicList": "从安装版PicList导入配置和相册数据",
|
||||
"migrateFromPicGo": "从PicGo迁移",
|
||||
"migrateFromPicListInstallation": "从安装版PicList迁移",
|
||||
"migrateFromPicListInstallationContent": "将安装版PicList的配置文件和相册数据导入到当前版本, 这将覆盖当前的配置文件和相册, 是否继续?",
|
||||
"mirgrateContent": "即将导入PicGo的配置文件和相册, 这将覆盖当前的配置文件和相册, 是否继续?",
|
||||
"mirgrateFailed": "导入失败",
|
||||
"mirgrateSuccess": "导入成功, 请重启PicList生效",
|
||||
|
||||
@@ -736,7 +736,10 @@
|
||||
},
|
||||
"manageConfig": "管理配置",
|
||||
"migrateDesc": "從 PicGo 導入配置和相冊數據",
|
||||
"migrateDescPicList": "從安裝版 PicList 導入配置和相冊數據",
|
||||
"migrateFromPicGo": "從PicGo遷移",
|
||||
"migrateFromPicListInstallation": "從安裝版 PicList 遷移",
|
||||
"migrateFromPicListInstallationContent": "將安裝版 PicList 的配置文件和相冊數據導入到當前版本, 這將覆蓋當前的配置文件和相冊, 是否繼續?",
|
||||
"mirgrateContent": "即將導入PicGo的配置文件和相冊, 這將覆蓋當前的配置文件和相冊, 是否繼續?",
|
||||
"mirgrateFailed": "導入失敗",
|
||||
"mirgrateSuccess": "導入成功, 請重啟PicList生效",
|
||||
|
||||
@@ -344,6 +344,20 @@
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="isPortable" class="sync-action-card" @click="handleMigrateFromPicListInstallation">
|
||||
<div class="sync-action-icon migrate">
|
||||
<Import :size="24" />
|
||||
</div>
|
||||
<div class="sync-action-content">
|
||||
<h4>{{ t('pages.settings.sync.migrateFromPicListInstallation') }}</h4>
|
||||
<p>{{ t('pages.settings.sync.migrateDescPicList') }}</p>
|
||||
</div>
|
||||
<div class="sync-action-arrow">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M9 18l6-6-6-6" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1876,6 +1890,7 @@ const themeList = ref<{ key: string; label: string }[]>([{ key: 'default.css', l
|
||||
const currentTheme = ref('default.css')
|
||||
const downloadingThemes = ref(false)
|
||||
const isDisableGPU = ref(false)
|
||||
const isPortable = ref(false)
|
||||
const currentTab = useStorage<'system' | 'sync' | 'upload' | 'advanced' | 'update'>('settings-current-tab', 'system')
|
||||
|
||||
// Tab configuration
|
||||
@@ -2242,6 +2257,7 @@ async function initData() {
|
||||
const settings = config.settings || {}
|
||||
const picBed = config.picBed
|
||||
isDisableGPU.value = settings.isDisableGPU || false
|
||||
isPortable.value = (await window.electron.triggerRPC<boolean>(IRPCActionType.GET_IS_PORTABLE)) || false
|
||||
showPicBedList.value = picBedG.value.filter(item => item.visible).map(item => item.name)
|
||||
galleryPicBedFilterList.value = settings.galleryPicBedFilter || []
|
||||
currentTheme.value = settings.theme || 'default.css'
|
||||
@@ -2378,6 +2394,28 @@ function handleMigrateFromPicGo() {
|
||||
})
|
||||
}
|
||||
|
||||
function handleMigrateFromPicListInstallation() {
|
||||
confirm({
|
||||
title: t('pages.settings.sync.mirgrateTitle'),
|
||||
message: t('pages.settings.sync.migrateFromPicListInstallationContent'),
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.confirm'),
|
||||
cancelButtonText: t('common.cancel'),
|
||||
center: true,
|
||||
}).then(result => {
|
||||
if (result) {
|
||||
window.electron
|
||||
.triggerRPC<boolean>(IRPCActionType.CONFIGURE_MIGRATE_FROM_PICLIST_INSTALLATION)
|
||||
.then(() => {
|
||||
message.success(t('pages.settings.sync.mirgrateSuccess'))
|
||||
})
|
||||
.catch(() => {
|
||||
message.error(t('pages.settings.sync.mirgrateFailed'))
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleHideDockChange(val: ICheckBoxValueType) {
|
||||
if (val && currentStartMode.value === ISartMode.NO_TRAY) {
|
||||
message.warning(t('pages.settings.system.hideDockHint'))
|
||||
|
||||
@@ -16,6 +16,8 @@ export const IWindowList = {
|
||||
|
||||
export const IRPCActionType = {
|
||||
// system rpc
|
||||
GET_IS_PORTABLE: 'GET_IS_PORTABLE',
|
||||
CONFIGURE_MIGRATE_FROM_PICLIST_INSTALLATION: 'CONFIGURE_MIGRATE_FROM_PICLIST_INSTALLATION',
|
||||
RELOAD_APP: 'RELOAD_APP',
|
||||
OPEN_URL: 'OPEN_URL',
|
||||
OPEN_FILE: 'OPEN_FILE',
|
||||
|
||||
Reference in New Issue
Block a user