mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
✨ deviceInfo 保存到数据库
This commit is contained in:
23
src/App.vue
23
src/App.vue
@@ -23,6 +23,7 @@ import TGSqlite from "./plugins/Sqlite";
|
||||
import { useAppStore } from "./store/modules/app";
|
||||
import { useUserStore } from "./store/modules/user";
|
||||
import { getBuildTime } from "./utils/TGBuild";
|
||||
import TGRequest from "./web/request/TGRequest";
|
||||
|
||||
const appStore = useAppStore();
|
||||
const isMain = ref<boolean>(false);
|
||||
@@ -64,6 +65,7 @@ async function listenOnInit(): Promise<void> {
|
||||
await tauri.invoke("register_deep_link");
|
||||
await getDeepLink();
|
||||
await checkAppLoad();
|
||||
await checkDeviceFp();
|
||||
try {
|
||||
await checkUserLoad();
|
||||
} catch (error) {
|
||||
@@ -94,6 +96,27 @@ async function checkAppLoad(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// 检测 deviceFp
|
||||
async function checkDeviceFp(): Promise<void> {
|
||||
const appData = await TGSqlite.getAppData();
|
||||
const deviceInfo = appData.find((item) => item.key === "deviceInfo")?.value;
|
||||
const deviceLocal = appStore.deviceInfo;
|
||||
if (deviceInfo === undefined) {
|
||||
if (deviceLocal.device_fp === "0000000000000") {
|
||||
// 获取 deviceFp
|
||||
appStore.deviceInfo = await TGRequest.Device.getFp(appStore.deviceInfo);
|
||||
console.info("deviceInfo 已重新获取!");
|
||||
}
|
||||
await TGSqlite.saveAppData("deviceInfo", JSON.stringify(deviceLocal));
|
||||
console.info("deviceInfo 数据已插入!");
|
||||
} else if (JSON.parse(deviceInfo) !== deviceLocal) {
|
||||
appStore.deviceInfo = JSON.parse(deviceInfo);
|
||||
console.info("deviceInfo 数据已加载!");
|
||||
} else {
|
||||
console.info("deviceInfo 数据已同步!");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测 ck,info 数据
|
||||
async function checkUserLoad(): Promise<void> {
|
||||
const ckDB = await TGSqlite.getCookie();
|
||||
|
||||
Reference in New Issue
Block a user