From a78921a9b1870fad7ccdb2609a559e4464071e15 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Thu, 29 Jan 2026 14:39:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=9D=E5=AD=98=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E9=87=87=E7=94=A8=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=EF=BC=8C=E9=81=BF=E5=85=8D=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=BC=E8=87=B4=E7=9A=84sql=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app/t-sidebar.vue | 1 + src/plugins/Sqlite/modules/userAccount.ts | 34 ++++++++--------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/components/app/t-sidebar.vue b/src/components/app/t-sidebar.vue index de7f2fb1..e93abe2c 100644 --- a/src/components/app/t-sidebar.vue +++ b/src/components/app/t-sidebar.vue @@ -428,6 +428,7 @@ async function tryGetTokens(ck: TGApp.App.Account.Cookie): Promise { ck.cookie_token = cookieTokenRes; await showLoading.update("正在获取用户信息"); const briefRes = await bbsReq.userInfo(ck); + console.debug(briefRes); if ("retcode" in briefRes) { await showLoading.end(); showSnackbar.error(`[${briefRes.retcode}]${briefRes.message}`); diff --git a/src/plugins/Sqlite/modules/userAccount.ts b/src/plugins/Sqlite/modules/userAccount.ts index c9255ffd..cf772fc4 100644 --- a/src/plugins/Sqlite/modules/userAccount.ts +++ b/src/plugins/Sqlite/modules/userAccount.ts @@ -1,6 +1,6 @@ /** * 用户账户模块 - * @since Beta v0.9.2 + * @since Beta v0.9.5 */ import showLoading from "@comp/func/loading.js"; @@ -41,24 +41,6 @@ function getInsertGameAccountSql(uid: string, data: TGApp.BBS.Game.Account): str `; } -/** - * 获取插入账号数据的 sql - * @since Beta v0.6.1 - * @param user - 账号 - * @returns 插入Sql - */ -function getInsertAccountSql(user: TGApp.App.Account.User): string { - const table = transUser(user); - return ` - INSERT INTO UserAccount(uid, cookie, brief, updated) - VALUES ('${table.uid}', '${table.cookie}', '${table.brief}', '${table.updated}') - ON CONFLICT(uid) DO UPDATE - SET cookie = '${table.cookie}', - brief = '${table.brief}', - updated = '${table.updated}'; - `; -} - /** * 数据库转成可用数据 * @since Beta v0.6.0 @@ -130,14 +112,22 @@ async function getUserAccount(uid: string): Promise { const db = await TGSqlite.getDB(); - const sql = getInsertAccountSql(data); - await db.execute(sql); + const user = transUser(data); + await db.execute( + `INSERT INTO UserAccount(uid, cookie, brief, updated) + VALUES ($1, $2, $3, $4) + ON CONFLICT(uid) DO UPDATE + SET cookie = $2, + brief = $3, + updated = $4`, + [user.uid, user.cookie, user.brief, user.updated], + ); } /**