🌱 修复数据库读取异常,页面草创

This commit is contained in:
BTMuli
2025-12-09 01:41:22 +08:00
parent b1fe5b6987
commit eafd2fdff8
6 changed files with 141 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
/**
* Sqlite 数据库操作类
* @since Beta v0.8.4
* @since Beta v0.9.0
*/
import { app } from "@tauri-apps/api";
@@ -27,6 +27,8 @@ class Sqlite {
"UserAccount",
"UserCharacters",
"UserRecord",
// TODO: v0.9.0 进行注释移除
// "UserBagMaterial"
];
private db: Database | null = null;
private static instance: Sqlite | null = null;

View File

@@ -95,14 +95,15 @@ async function getMaterial(
): Promise<Array<TGApp.Sqlite.UserBag.TableMaterial>> {
const db = await TGSqlite.getDB();
let res: Array<TGApp.Sqlite.UserBag.TableMaterialRaw>;
if (id) {
// TODO: 排序
if (id !== undefined) {
res = await db.select<Array<TGApp.Sqlite.UserBag.TableMaterialRaw>>(
"SELECT * FROM UserBagMaterial WHERE uid = ? AND id = ?",
"SELECT * FROM UserBagMaterial WHERE uid = ? AND id = ?;",
[uid, id],
);
} else {
res = await db.select<Array<TGApp.Sqlite.UserBag.TableMaterialRaw>>(
"SELECT * FROM UserBagMaterial WHERE uid =",
"SELECT * FROM UserBagMaterial WHERE uid =?;",
[uid],
);
}