mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 06:38:13 -05:00
✨ Feature: add 'migrate from PicGo' option in setting page
This commit is contained in:
parent
ccac4968e6
commit
6bfecba01d
@ -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
|
||||
|
@ -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: 点击设置
|
||||
|
@ -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: 點擊設定
|
||||
|
@ -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'),
|
||||
|
@ -42,6 +42,18 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_MIGRATE_FROM_PICGO')"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
round
|
||||
size="small"
|
||||
@click="handelMigrateFromPicGo"
|
||||
>
|
||||
{{ $T('SETTINGS_CLICK_TO_SET') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_OPEN_CONFIG_FILE')"
|
||||
>
|
||||
@ -787,7 +799,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ElForm, ElMessage as $message, FormRules } from 'element-plus'
|
||||
import { ElForm, ElMessage as $message, ElMessage, ElMessageBox, FormRules } from 'element-plus'
|
||||
import { Reading, QuestionFilled } from '@element-plus/icons-vue'
|
||||
import pkg from 'root/package.json'
|
||||
import { PICGO_OPEN_FILE, OPEN_URL, GET_PICBEDS } from '#/events/constants'
|
||||
@ -1085,6 +1097,23 @@ function confirmProxy () {
|
||||
}
|
||||
}
|
||||
|
||||
function handelMigrateFromPicGo () {
|
||||
ElMessageBox.confirm($T('SETTINGS_MIGRATE_FROM_PICGO_CONTENT'), $T('SETTINGS_MIGRATE_FROM_PICGO_TITLE'), {
|
||||
confirmButtonText: $T('CONFIRM'),
|
||||
cancelButtonText: $T('CANCEL'),
|
||||
type: 'warning',
|
||||
center: true
|
||||
}).then(() => {
|
||||
ipcRenderer.invoke('migrateFromPicGo').then(() => {
|
||||
ElMessage.success($T('SETTINGS_MIGRATE_FROM_PICGO_SUCCESS'))
|
||||
}).catch(() => {
|
||||
ElMessage.error($T('SETTINGS_MIGRATE_FROM_PICGO_FAILED'))
|
||||
})
|
||||
}).catch(() => {
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
function updateHelperChange (val: ICheckBoxValueType) {
|
||||
saveConfig('settings.showUpdateTip', val)
|
||||
}
|
||||
|
5
src/universal/types/i18n.d.ts
vendored
5
src/universal/types/i18n.d.ts
vendored
@ -99,6 +99,11 @@ interface ILocales {
|
||||
UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER: string
|
||||
SETTINGS: string
|
||||
SETTINGS_OPEN_CONFIG_FILE: string
|
||||
SETTINGS_MIGRATE_FROM_PICGO: string
|
||||
SETTINGS_MIGRATE_FROM_PICGO_TITLE: string
|
||||
SETTINGS_MIGRATE_FROM_PICGO_CONTENT: string
|
||||
SETTINGS_MIGRATE_FROM_PICGO_SUCCESS: string
|
||||
SETTINGS_MIGRATE_FROM_PICGO_FAILED: string
|
||||
SETTINGS_CLICK_TO_OPEN: string
|
||||
SETTINGS_SET_LOG_FILE: string
|
||||
SETTINGS_CLICK_TO_SET: string
|
||||
|
Loading…
Reference in New Issue
Block a user