This commit is contained in:
2025-12-12 14:58:06 +08:00
parent 292e30fd68
commit 8e6ad6ba2d
3 changed files with 89 additions and 52 deletions

View File

@ -521,35 +521,28 @@ const importProject = () => {
if (paths.length > 0) {
// let loadingInstance = this.$openLoading('拼命导入中...')
importWin = false
let arr = getElectronPath().replaceAll('\\', '/').split('/')
console.log(arr, 'arrarr')
arr.pop()
// let path: any = 'C:/Users/Administrator/AppData/Roaming/yjearth'
console.log(paths[0], arr.join('/'), 'pathpath')
unzip_file(paths[0], arr.join('/'))
.then((res) => {
// loadingInstance.close()
// ElMessage({
// message: '导入成功',
// type: 'success'
// })
setTimeout(() => {
const { ipcRenderer } = require('electron')
ipcRenderer.invoke('get-user-data-path').then((userDataPath) => {
ipcRenderer.send('import-project-override', { srcZip: paths[0], dst: userDataPath })
ipcRenderer.once('import-project-override-res', (ev, res) => {
if (res && res.ok) {
setTimeout(() => {
ElMessage({
message: '载入成功将在2s后自动重启',
type: 'success'
})
}, 1000)
setTimeout(() => {
$sendElectronChanel('restart')
}, 3000)
} else {
ElMessage({
message: '载入成功将在2s后自动重启',
type: 'success'
message: res?.error || '导入失败',
type: 'warning'
})
}, 1000)
setTimeout(() => {
$sendElectronChanel('restart')
}, 3000)
})
.catch((err) => {
console.log(err)
ElMessage({
message: err,
type: 'warning'
})
}
})
})
} else {
importWin = false
}
@ -657,31 +650,41 @@ function derive() {
$sendElectronChanel('saveFile', option)
$recvElectronChanel('selectedFileItem', (e, path) => {
if (path) {
// if (result.canceled) {
// this.exportWin = !this.exportWin
// return
// }
// let loadingInstance = this.$openLoading('拼命导出中...')
// exportWin = !exportWin
let arr = getElectronPath().replaceAll('\\', '/').split('/')
arr.pop()
arr[arr.length - 1] = 'yjearth/app.db'
let db_path: any = arr.join('/')
// let db_path: any = 'C:/Users/Administrator/AppData/Roaming/yjearth/app.db'
try {
zip_file([db_path], path, () => {
// loadingInstance.close()
const { ipcRenderer } = require('electron')
ipcRenderer.send('export-project', { dst: path })
ipcRenderer.once('export-project-res', (ev, res) => {
if (res && res.ok) {
ElMessage({
message: '导出完成',
type: 'success'
})
})
} catch (error) {
ElMessage({
message: error,
type: 'error'
})
}
} else {
ElMessage({
message: res?.error || '导出失败',
type: 'error'
})
}
})
// let arr = getElectronPath().replaceAll('\\', '/').split('/')
// arr.pop()
// arr[arr.length - 1] = 'yjearth/app.db'
// let db_path: any = arr.join('/')
// console.log(db_path, 'db_pathdb_path')
// try {
// zip_file([db_path], path, () => {
// // loadingInstance.close()
// ElMessage({
// message: '导出完成',
// type: 'success'
// })
// })
// } catch (error) {
// ElMessage({
// message: error,
// type: 'error'
// })
// }
}
})