mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-11 09:08:14 +08:00
⚡️ 增加目录存在判断
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { dialog, path } from "@tauri-apps/api";
|
||||
import { dialog, fs, path } from "@tauri-apps/api";
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
|
||||
import showConfirm from "../../components/func/confirm";
|
||||
@@ -352,6 +352,9 @@ async function backupGacha(): Promise<void> {
|
||||
}
|
||||
loadingTitle.value = "正在备份祈愿数据";
|
||||
loading.value = true;
|
||||
if (!(await fs.exists("userData", { dir: fs.BaseDirectory.AppLocalData }))) {
|
||||
await fs.createDir("userData", { dir: fs.BaseDirectory.AppLocalData, recursive: true });
|
||||
}
|
||||
await backupUigfData(uidCur.value, gachaListCur.value);
|
||||
loading.value = false;
|
||||
showSnackbar({
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { app, fs, invoke, os } from "@tauri-apps/api";
|
||||
import { exit } from "@tauri-apps/api/process";
|
||||
import { relaunch } from "@tauri-apps/api/types/process";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
import showConfirm from "../../components/func/confirm";
|
||||
@@ -378,6 +378,10 @@ async function confirmBackup(): Promise<void> {
|
||||
}
|
||||
loadingTitle.value = "正在备份数据...";
|
||||
loading.value = true;
|
||||
if (!(await fs.exists("userData", { dir: fs.BaseDirectory.AppLocalData }))) {
|
||||
await fs.createDir("userData", { dir: fs.BaseDirectory.AppLocalData, recursive: true });
|
||||
}
|
||||
console.info("数据文件夹创建完成!");
|
||||
loadingSub.value = "正在获取成就数据";
|
||||
const achievements = await TGSqlite.getUIAF();
|
||||
loadingSub.value = "正在备份成就数据";
|
||||
@@ -410,6 +414,13 @@ async function confirmRestore(): Promise<void> {
|
||||
}
|
||||
loadingTitle.value = "正在恢复数据...";
|
||||
loading.value = true;
|
||||
if (!(await fs.exists("userData", { dir: fs.BaseDirectory.AppLocalData }))) {
|
||||
showSnackbar({
|
||||
color: "error",
|
||||
text: "数据文件夹不存在!",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const fail: string[] = [];
|
||||
let res: boolean;
|
||||
loadingSub.value = "正在恢复成就数据";
|
||||
@@ -523,7 +534,7 @@ async function confirmDelCache(): Promise<void> {
|
||||
});
|
||||
await new Promise(() => {
|
||||
setTimeout(async () => {
|
||||
await exit();
|
||||
await relaunch();
|
||||
}, 1500);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user