mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🐛 应用初次加载也加载数据库,完善数据库 load #40
This commit is contained in:
10
src/App.vue
10
src/App.vue
@@ -22,6 +22,7 @@ import { useAppStore } from "./store/modules/app";
|
|||||||
// utils
|
// utils
|
||||||
import { getEmojis } from "./plugins/Mys/request/getEmojis";
|
import { getEmojis } from "./plugins/Mys/request/getEmojis";
|
||||||
import showSnackbar from "./components/func/snackbar";
|
import showSnackbar from "./components/func/snackbar";
|
||||||
|
import TGSqlite from "./plugins/Sqlite";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const isMain = ref<boolean>(false);
|
const isMain = ref<boolean>(false);
|
||||||
@@ -76,6 +77,7 @@ async function checkLoad(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await createDataDir();
|
await createDataDir();
|
||||||
|
await initData();
|
||||||
appStore.loading = true;
|
appStore.loading = true;
|
||||||
console.info("数据加载完成!");
|
console.info("数据加载完成!");
|
||||||
}
|
}
|
||||||
@@ -89,6 +91,14 @@ async function createDataDir(): Promise<void> {
|
|||||||
}
|
}
|
||||||
console.info("数据文件夹创建完成!");
|
console.info("数据文件夹创建完成!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化数据库
|
||||||
|
async function initData(): Promise<void> {
|
||||||
|
await TGSqlite.reset();
|
||||||
|
showSnackbar({
|
||||||
|
text: "已成功初始化数据库!",
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="css">
|
<style lang="css">
|
||||||
.app-container {
|
.app-container {
|
||||||
|
|||||||
@@ -221,7 +221,14 @@ onMounted(async () => {
|
|||||||
loadingSub.value = "正在获取系统版本";
|
loadingSub.value = "正在获取系统版本";
|
||||||
osVersion.value = await os.version();
|
osVersion.value = await os.version();
|
||||||
loadingSub.value = "正在获取数据库信息";
|
loadingSub.value = "正在获取数据库信息";
|
||||||
|
try {
|
||||||
dbInfo.value = await TGSqlite.getAppData();
|
dbInfo.value = await TGSqlite.getAppData();
|
||||||
|
} catch (e) {
|
||||||
|
showSnackbar({
|
||||||
|
text: "加载数据库错误,请重置数据库!",
|
||||||
|
color: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
loadingSub.value = "";
|
loadingSub.value = "";
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
@@ -385,6 +392,7 @@ async function confirmRestore(): Promise<void> {
|
|||||||
}
|
}
|
||||||
loadingSub.value = "正在恢复祈愿数据";
|
loadingSub.value = "正在恢复祈愿数据";
|
||||||
res = await restoreCookieData();
|
res = await restoreCookieData();
|
||||||
|
userStore.cookie = await TGSqlite.getCookie();
|
||||||
if (!res) {
|
if (!res) {
|
||||||
fail.push("Cookie");
|
fail.push("Cookie");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user