mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
♻️ 部分分区动态获取,重构部分调用
This commit is contained in:
@@ -7,10 +7,10 @@
|
||||
v-for="(item, index) in channelList"
|
||||
:key="index"
|
||||
class="toc-list-item"
|
||||
:class="{ active: props.gid === item.gid }"
|
||||
:class="props.gid === item.gid.toString() ? 'active' : ''"
|
||||
@click="toChannel(item)"
|
||||
>
|
||||
<img :src="item.icon" alt="icon" />
|
||||
<TMiImg :src="item.icon" alt="icon" :ori="true" />
|
||||
<span>{{ item.title }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -18,25 +18,30 @@
|
||||
</TOverlay>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import TMiImg from "@comp/app/t-mi-img.vue";
|
||||
import TOverlay from "@comp/app/t-overlay.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useRouter } from "vue-router";
|
||||
import { onMounted, shallowRef } from "vue";
|
||||
|
||||
import { type NewsType, useAppStore } from "@/store/modules/app.js";
|
||||
import type { ToChannelItem } from "@/web/constant/bbs.js";
|
||||
import TGConstant from "@/web/constant/TGConstant.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
|
||||
type ChannelItem = { icon: string; title: string; gid: number };
|
||||
type ToChannelProps = { gid?: string; curType?: string };
|
||||
|
||||
const router = useRouter();
|
||||
const { recentNewsType } = storeToRefs(useAppStore());
|
||||
const channelList = TGConstant.BBS.CHANNELS;
|
||||
const channelList = shallowRef<Array<ChannelItem>>();
|
||||
const props = defineProps<ToChannelProps>();
|
||||
const visible = defineModel<boolean>({ default: false });
|
||||
|
||||
async function toChannel(item: ToChannelItem): Promise<void> {
|
||||
if (props.gid === item.gid) {
|
||||
onMounted(async () => {
|
||||
const allGames = await apiHubReq.game();
|
||||
channelList.value = allGames.map((i) => ({ icon: i.app_icon, title: i.name, gid: i.id }));
|
||||
});
|
||||
|
||||
async function toChannel(item: ChannelItem): Promise<void> {
|
||||
if (props.gid === item.gid.toString()) {
|
||||
showSnackbar.warn("当前已经在该频道");
|
||||
return;
|
||||
}
|
||||
@@ -48,7 +53,7 @@ async function toChannel(item: ToChannelItem): Promise<void> {
|
||||
link = link.replace("{type}", "notice");
|
||||
recentNewsType.value = "notice";
|
||||
}
|
||||
await router.push(link);
|
||||
window.location.href = link;
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="tops-box">
|
||||
<div class="tops-top">查找:{{ search }}</div>
|
||||
<div class="tops-act">
|
||||
<span>分区:{{ getGameName(Number(game)) }}</span>
|
||||
<span>分区:{{ gameName }}</span>
|
||||
<v-btn :loading="load" size="small" class="tops-btn" @click="searchPosts()" rounded>
|
||||
加载更多({{ results.length }})
|
||||
</v-btn>
|
||||
@@ -21,9 +21,9 @@ import TOverlay from "@comp/app/t-overlay.vue";
|
||||
import TPostCard from "@comp/app/t-postcard.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
import { getGameName } from "@/utils/toolFunc.js";
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
|
||||
type ToPostSearchProps = { gid: string; keyword?: string };
|
||||
|
||||
@@ -35,6 +35,9 @@ const game = ref<string>("2");
|
||||
const isLast = ref<boolean>(false);
|
||||
const load = ref<boolean>(false);
|
||||
const results = shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]);
|
||||
const gameName = computed<string>(
|
||||
() => TGBbs.channels.find((v) => v.gid.toString() === game.value)?.title || "未知分区",
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
game.value = props.gid;
|
||||
|
||||
Reference in New Issue
Block a user