Skip to content

Commit

Permalink
🐛 修复版本搜索失效,未完成成就优先
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Jun 4, 2024
1 parent 9c736a0 commit e79fdf6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/plugins/Sqlite/modules/userAchi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file plugins/Sqlite/modules/userAchi.ts
* @description 用户成就模块
* @since Beta v0.4.7
* @since Beta v0.4.8
*/

import { getUiafStatus } from "../../../utils/UIAF.js";
Expand Down Expand Up @@ -59,7 +59,7 @@ async function getSeries(id?: number): Promise<TGApp.Sqlite.Achievement.SeriesTa

/**
* @description 获取成就数据
* @since Beta v0.4.7
* @since Beta v0.4.8
* @param {number|undefined} id 成就系列ID
* @returns {Promise<TGApp.Sqlite.Achievement.SingleTable[]>} 成就数据
*/
Expand All @@ -72,7 +72,7 @@ async function getAchievements(id?: string): Promise<TGApp.Sqlite.Achievement.Si
);
} else {
res = await db.select<TGApp.Sqlite.Achievement.SingleTable>(
"SELECT * FROM Achievements WHERE series = ? ORDER BY `order`;",
"SELECT * FROM Achievements WHERE series = ? ORDER BY isCompleted,`order`;",
[id],
);
}
Expand All @@ -96,7 +96,7 @@ async function getSeriesNameCard(id: string): Promise<string> {

/**
* @description 查找成就数据
* @since Beta v0.4.7
* @since Beta v0.4.8
* @param {string} keyword 关键词
* @returns {Promise<TGApp.Sqlite.Achievement.SingleTable[]>} 成就数据
*/
Expand All @@ -106,10 +106,12 @@ async function searchAchievements(
if (keyword === "") return await getAchievements();
const db = await TGSqlite.getDB();
const versionReg = /^v\d+(\.\d+)?$/;
console.log(versionReg.test(keyword));
if (versionReg.test(keyword)) {
const version = keyword.replace("v", "");
return await db.select<TGApp.Sqlite.Achievement.SingleTable>(
"SELECT * FROM Achievements WHERE version LIKE ? ORDER BY isCompleted,`order`;",
[keyword],
[`%${version}%`],
);
}
return await db.select<TGApp.Sqlite.Achievement.SingleTable>(
Expand Down

0 comments on commit e79fdf6

Please sign in to comment.