mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-15 03:53:16 +08:00
🚸 替换帖子卡片版块图标数据源
This commit is contained in:
@@ -116,11 +116,13 @@ import TMiImg from "@comp/app/t-mi-img.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import TpAvatar from "@comp/viewPost/tp-avatar.vue";
|
||||
import TpcTag from "@comp/viewPost/tpc-tag.vue";
|
||||
import useBBSStore from "@store/bbs.js";
|
||||
import { emit } from "@tauri-apps/api/event";
|
||||
import { str2Color } from "@utils/colorFunc.js";
|
||||
import { generateShareImg } from "@utils/TGShare.js";
|
||||
import { createPost } from "@utils/TGWindow.js";
|
||||
import { timestampToDate } from "@utils/toolFunc.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
@@ -158,11 +160,15 @@ const stats: Readonly<Array<RenderStatus>> = [
|
||||
{ stat: 2, label: "评选中", color: "var(--tgc-od-orange)" },
|
||||
{ stat: 3, label: "已结束", color: "var(--tgc-od-white)" },
|
||||
];
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { forumList } = storeToRefs(useBBSStore());
|
||||
|
||||
const props = withDefaults(defineProps<TPostCardProps>(), { selectMode: false });
|
||||
const isSelected = ref<boolean>(false);
|
||||
const emits = defineEmits<TPostCardEmits>();
|
||||
|
||||
const isSelected = ref<boolean>(false);
|
||||
const card = shallowRef<RenderCard>();
|
||||
|
||||
const cardBg = computed<string>(() => {
|
||||
@@ -220,11 +226,12 @@ function getCommonCard(item: TGApp.BBS.Post.FullData): RenderCard {
|
||||
let forumData: RenderForum | null = null;
|
||||
let statData: RenderData | null = null;
|
||||
if (item.forum !== null) {
|
||||
// 对部分缺失图标进行补充
|
||||
let forumIcon = item.forum.icon;
|
||||
if (item.forum.name === "攻略" && item.forum.id === 43) {
|
||||
forumIcon =
|
||||
"https://upload-bbs.mihoyo.com/upload/2020/09/14/ce666cea7c971b04e4b4a6fe0a9ebfd0.png";
|
||||
const findG = forumList.value.find((i) => i.game_id === item.post.game_id);
|
||||
if (findG) {
|
||||
console.log(findG, item);
|
||||
const findF = findG.forums.find((i) => i.id === item.forum.id);
|
||||
if (findF) forumIcon = findF.icon_pure;
|
||||
}
|
||||
forumData = { name: item.forum.name, icon: forumIcon, id: item.forum.id };
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<!-- 帖子页面 -->
|
||||
<template>
|
||||
<v-app-bar>
|
||||
<template #prepend>
|
||||
@@ -121,7 +122,7 @@
|
||||
<TPostCard :model-value="post" :user-click="true" @onUserClick="handleUserClick" />
|
||||
</div>
|
||||
</div>
|
||||
<VpOverlaySearch v-model="showSearch" :gid="curGid.toString()" :keyword="search" />
|
||||
<VpOverlaySearch v-model="showSearch" :gid="curGid" :keyword="search" />
|
||||
<VpOverlayUser v-model="showUser" :gid="curGid" :uid="curUid" />
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
@@ -133,7 +134,6 @@ import showSnackbar from "@comp/func/snackbar.js";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import VpOverlayUser from "@comp/viewPost/vp-overlay-user.vue";
|
||||
import { usePageReachBottom } from "@hooks/reachBottom.js";
|
||||
import ApiHubReq from "@req/apiHubReq.js";
|
||||
import painterReq from "@req/painterReq.js";
|
||||
import useBBSStore from "@store/bbs.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
@@ -166,7 +166,8 @@ const showSearch = ref<boolean>(false);
|
||||
const curUid = ref<string>("");
|
||||
const showUser = ref<boolean>(false);
|
||||
|
||||
const { gameList } = storeToRefs(useBBSStore());
|
||||
const bbsStore = useBBSStore();
|
||||
const { gameList, forumList } = storeToRefs(bbsStore);
|
||||
const selectedForum = shallowRef<SortSelect>();
|
||||
const sortGameList = shallowRef<Array<SortSelectGame>>([]);
|
||||
const postRaw = shallowRef<PostRaw>({ isLast: false, lastId: "", total: 0 });
|
||||
@@ -232,9 +233,9 @@ watch(
|
||||
|
||||
// 初始化
|
||||
async function loadForums(): Promise<void> {
|
||||
const allForums = await ApiHubReq.forum();
|
||||
await bbsStore.refreshForumList();
|
||||
const list: Array<SortSelectGame> = [];
|
||||
for (const gameForum of allForums) {
|
||||
for (const gameForum of forumList.value) {
|
||||
const gameFind = gameList.value.find((i) => i.id === gameForum.game_id);
|
||||
if (!gameFind) continue;
|
||||
const gameItem: SortSelectGame = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 米社数据状态管理
|
||||
* @since Beta v0.8.2
|
||||
* @since Beta v0.9.6
|
||||
*/
|
||||
import apiHubReq from "@req/apiHubReq.js";
|
||||
import { defineStore } from "pinia";
|
||||
@@ -13,12 +13,19 @@ const useBBSStore = defineStore(
|
||||
const gameList = shallowRef<Array<TGApp.BBS.Game.Item>>([]);
|
||||
// 游戏卡片配置项
|
||||
const gameUidCards = shallowRef<Record<string, TGApp.BBS.AppConfig.GameUidCardConf>>({});
|
||||
// 版块数据
|
||||
const forumList = shallowRef<Array<TGApp.BBS.Forum.GameForum>>([]);
|
||||
|
||||
// 刷新游戏列表
|
||||
async function refreshGameList(): Promise<void> {
|
||||
gameList.value = await apiHubReq.game();
|
||||
}
|
||||
|
||||
// 刷新版块列表
|
||||
async function refreshForumList(): Promise<void> {
|
||||
forumList.value = await apiHubReq.forum();
|
||||
}
|
||||
|
||||
// 刷新游戏卡片配置项
|
||||
async function refreshGameUidCards(): Promise<void> {
|
||||
const resp = await apiHubReq.appConfig();
|
||||
@@ -29,7 +36,14 @@ const useBBSStore = defineStore(
|
||||
gameUidCards.value = conf.game_uid_card_conf;
|
||||
}
|
||||
|
||||
return { gameList, refreshGameList, gameUidCards, refreshGameUidCards };
|
||||
return {
|
||||
gameList,
|
||||
refreshGameList,
|
||||
forumList,
|
||||
refreshForumList,
|
||||
gameUidCards,
|
||||
refreshGameUidCards,
|
||||
};
|
||||
},
|
||||
{ persist: true },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user