diff --git a/src/components/viewPost/tp-uid.vue b/src/components/viewPost/tp-uid.vue
index d434a62e..54bf90db 100644
--- a/src/components/viewPost/tp-uid.vue
+++ b/src/components/viewPost/tp-uid.vue
@@ -2,10 +2,10 @@
- mdi-content-copy
+ mdi-content-copy
复制
- {{ getGameName() }}
+ {{ gameInfo?.name ?? "未知游戏" }}
UID {{ props.data.insert.game_user_info.game_uid }}
@@ -19,7 +19,9 @@
-
diff --git a/src/pages/common/PageHome.vue b/src/pages/common/PageHome.vue
index c008de06..6baccfb2 100644
--- a/src/pages/common/PageHome.vue
+++ b/src/pages/common/PageHome.vue
@@ -97,6 +97,7 @@ const showItems = computed
>({
onMounted(async () => {
await bbsStore.refreshGameList();
+ await bbsStore.refreshGameUidCards();
// @ts-expect-error-next-line The import.meta meta-property is not allowed in files which will build into CommonJS output.
const isProdEnv = import.meta.env.MODE === "production";
if (isProdEnv && devMode.value) devMode.value = false;
diff --git a/src/request/apiHubReq.ts b/src/request/apiHubReq.ts
index f3f0cde6..83659d9a 100644
--- a/src/request/apiHubReq.ts
+++ b/src/request/apiHubReq.ts
@@ -1,7 +1,7 @@
/**
* @file request/apiHubReq.ts
* @description apiHub下的请求
- * @since Beta v0.7.2
+ * @since Beta v0.8.2
*/
import { getRequestHeader } from "@utils/getRequestHeader.js";
@@ -25,6 +25,25 @@ async function getAllGamesForums(): Promise> {
).data.list;
}
+/**
+ * @description 获取应用配置
+ * @since Beta v0.8.2
+ * @param {string} gid 分区ID
+ * @return {Promise}
+ */
+async function getAppConfig(
+ gid?: string,
+): Promise {
+ let url = `${Mahbu}api/getAppConfig`;
+ if (gid) url += `?gid=${gid}`;
+ const resp = await TGHttp(url, {
+ method: "GET",
+ headers: { "Content-Type": "application/json", referer: Referer },
+ });
+ if (resp.retcode === 0) return resp.data.config;
+ return resp;
+}
+
/**
* @description 获取所有分区
* @since Beta v0.6.8
@@ -202,6 +221,7 @@ async function upVotePost(
const apiHubReq = {
vote: { info: getVotes, result: getVoteResult },
+ appConfig: getAppConfig,
home: homeNew,
forum: getAllGamesForums,
game: getGameList,
diff --git a/src/store/modules/bbs.ts b/src/store/modules/bbs.ts
index d1035b91..5cefd07e 100644
--- a/src/store/modules/bbs.ts
+++ b/src/store/modules/bbs.ts
@@ -1,7 +1,7 @@
/**
* @file store/modules/bbs.ts
* @description BBS 模块状态管理
- * @since Beta v0.7.3
+ * @since Beta v0.8.2
*/
import apiHubReq from "@req/apiHubReq.js";
import { defineStore } from "pinia";
@@ -12,13 +12,23 @@ const useBBSStore = defineStore(
() => {
// 游戏列表
const gameList = shallowRef>([]);
+ // 游戏卡片配置项
+ const gameUidCards = shallowRef>({});
// 刷新游戏列表
async function refreshGameList(): Promise {
gameList.value = await apiHubReq.game();
}
- return { gameList, refreshGameList };
+ // 刷新游戏卡片配置项
+ async function refreshGameUidCards(): Promise {
+ const resp = await apiHubReq.appConfig();
+ if ("retcode" in resp) return;
+ const conf = JSON.parse(resp.game_uid_card_config);
+ gameUidCards.value = conf.game_uid_card_conf;
+ }
+
+ return { gameList, refreshGameList, gameUidCards, refreshGameUidCards };
},
{ persist: true },
);
diff --git a/src/types/BBS/AppConfig.d.ts b/src/types/BBS/AppConfig.d.ts
new file mode 100644
index 00000000..8a15f141
--- /dev/null
+++ b/src/types/BBS/AppConfig.d.ts
@@ -0,0 +1,57 @@
+/**
+ * @file types/BBS/AppConfig.d.ts
+ * @description 米游社应用配置类型
+ * @since Beta v0.8.2
+ */
+
+declare namespace TGApp.BBS.AppConfig {
+ /**
+ * @description 应用配置返回响应
+ * @since Beta v0.8.2
+ * @interface Resp
+ * @extends TGApp.BBS.Response.BaseWithData
+ * @property {FullRes} data 应用配置数据
+ */
+ type Resp = TGApp.BBS.Response.BaseWithData;
+
+ /**
+ * @description 应用配置数据
+ * @since Beta v0.8.2
+ * @interface FullRes
+ * @property {FullData} config 应用配置
+ */
+ type FullRes = { config: FullData };
+
+ /**
+ * @description 应用配置
+ * @since Beta v0.8.2
+ * @interface FullData
+ * @todo 只写了用到的部分
+ * @property {string} game_uid_card_config 游戏 UID 卡片配置(序列化的 JSON 字符串)
+ */
+ type FullData = { game_uid_card_config: string };
+
+ /**
+ * @description 游戏 UID 卡片配置-整体
+ * @since Beta v0.8.2
+ * @interface GameUidCardFullConf
+ * @property {Record} game_uid_card_conf 游戏 UID 卡片配置项,键为游戏 ID
+ */
+ type GameUidCardFullConf = { game_uid_card_conf: Record };
+
+ /**
+ * @description 游戏 UID 卡片配置-单个配置项
+ * @since Beta v0.8.2
+ * @interface GameUidCardConf
+ * @property {string} main_text_color 主文本颜色
+ * @property {boolean} is_open 是否开启
+ * @property {string} background_color 背景颜色
+ * @property {string} image_url 图片 URL
+ */
+ type GameUidCardConf = {
+ main_text_color: string;
+ is_open: boolean;
+ background_color: string;
+ image_url: string;
+ };
+}