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