完成 深渊数据 的备份与恢复

This commit is contained in:
BTMuli
2023-06-19 08:49:52 +08:00
parent 2991a15e48
commit 44f715f4e1
5 changed files with 91 additions and 5 deletions

View File

@@ -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;
}