mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
✨ 完成 深渊数据 的备份与恢复
This commit is contained in:
@@ -18,3 +18,14 @@ export async function backupCookieData (cookie: Record<string, string>): Promise
|
||||
const savePath = `${await path.appLocalDataDir()}\\userData\\cookie.json`;
|
||||
await fs.writeTextFile(savePath, JSON.stringify(cookie, null, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 备份深渊数据
|
||||
* @since Alpha v0.2.0
|
||||
* @param {TGApp.Sqlite.Abyss.SingleTable[]} abyssData 深渊数据
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function backupAbyssData (abyssData: TGApp.Sqlite.Abyss.SingleTable[]): Promise<void> {
|
||||
const savePath = `${await path.appLocalDataDir()}\\userData\\abyss.json`;
|
||||
await fs.writeTextFile(savePath, JSON.stringify(abyssData, null, 2));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// tauri
|
||||
import { fs, path } from "@tauri-apps/api";
|
||||
// utils
|
||||
import TGSqlite from "../../utils/TGSqlite";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
|
||||
/**
|
||||
* @description 恢复 Cookie 数据
|
||||
@@ -22,3 +22,16 @@ export async function restoreCookieData (): Promise<boolean> {
|
||||
await TGSqlite.saveAppData("cookie", JSON.stringify(JSON.parse(cookieData)));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 恢复深渊数据
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export async function restoreAbyssData (): Promise<boolean> {
|
||||
const abyssPath = `${await path.appLocalDataDir()}\\userData\\abyss.json`;
|
||||
if (!await fs.exists(abyssPath)) return false;
|
||||
const abyssData = await fs.readTextFile(abyssPath);
|
||||
await TGSqlite.restoreAbyss(JSON.parse(abyssData));
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user