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], + ); } /**