mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-18 04:56:47 +08:00
♻️ erasableSyntaxOnly
This commit is contained in:
@@ -72,7 +72,7 @@ import { storeToRefs } from "pinia";
|
||||
import { type Component, computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
import { useAppStore } from "@/store/modules/app.js";
|
||||
import { ShowItemEnum, useHomeStore } from "@/store/modules/home.js";
|
||||
import { useHomeStore } from "@/store/modules/home.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
|
||||
@@ -87,20 +87,16 @@ type SelectItem = { icon: string; title: string; gid: number };
|
||||
const { devMode, isLogin } = storeToRefs(useAppStore());
|
||||
const homeStore = useHomeStore();
|
||||
|
||||
const showItemsAll: Array<ShowItemEnum> = [
|
||||
ShowItemEnum.calendar,
|
||||
ShowItemEnum.pool,
|
||||
ShowItemEnum.position,
|
||||
];
|
||||
const showItemsAll: Array<string> = ["素材日历", "限时祈愿", "近期活动"];
|
||||
|
||||
const curGid = ref<number>(2);
|
||||
const gameList = shallowRef<Array<SelectItem>>();
|
||||
|
||||
const loadItems = shallowRef<Array<ShowItemEnum>>([]);
|
||||
const loadItems = shallowRef<Array<string>>([]);
|
||||
const components = shallowRef<Array<SFComp>>([]);
|
||||
const showItems = computed<Array<ShowItemEnum>>({
|
||||
const showItems = computed<Array<string>>({
|
||||
get: () => homeStore.getShowItems(),
|
||||
set: (v: Array<ShowItemEnum>) => homeStore.setShowItems(v),
|
||||
set: (v: Array<string>) => homeStore.setShowItems(v),
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -154,14 +150,14 @@ async function submitHome(): Promise<void> {
|
||||
await loadComp();
|
||||
}
|
||||
|
||||
function getName(name: string): ShowItemEnum | undefined {
|
||||
function getName(name: string): string | undefined {
|
||||
switch (name) {
|
||||
case "ph-comp-pool":
|
||||
return ShowItemEnum.pool;
|
||||
return "限时祈愿";
|
||||
case "ph-comp-position":
|
||||
return ShowItemEnum.position;
|
||||
return "近期活动";
|
||||
case "ph-comp-calendar":
|
||||
return ShowItemEnum.calendar;
|
||||
return "素材日历";
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ import type { Ref } from "vue";
|
||||
import { computed, onMounted, reactive, ref, shallowRef } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { type NewsType, NewsTypeEnum, useAppStore } from "@/store/modules/app.js";
|
||||
import { type NewsType, useAppStore } from "@/store/modules/app.js";
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
@@ -87,6 +87,7 @@ const { recentNewsType } = storeToRefs(useAppStore());
|
||||
const { gid } = <{ gid: string }>useRoute().params;
|
||||
|
||||
const tabValues: Readonly<Array<NewsType>> = ["notice", "activity", "news"];
|
||||
const tabMap: Readonly<Record<NewsType, string>> = { notice: "1", activity: "2", news: "3" };
|
||||
const gameName = TGBbs.channels.find((v) => v.gid.toString() === gid)?.title || "未知分区";
|
||||
|
||||
const loading = ref<boolean>(false);
|
||||
@@ -123,7 +124,7 @@ async function firstLoad(key: NewsType, refresh: boolean = false): Promise<void>
|
||||
}
|
||||
await showLoading.start(`正在获取${gameName}${rawData[key].name}数据`);
|
||||
document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
|
||||
const getData = await painterReq.news(gid, NewsTypeEnum[key]);
|
||||
const getData = await painterReq.news(gid, tabMap[key]);
|
||||
await showLoading.update(`数量:${getData.list.length},是否最后一页:${getData.is_last}`);
|
||||
rawData[key] = { isLast: getData.is_last, name: rawData[key].name, lastId: getData.list.length };
|
||||
postData[key] = getData.list;
|
||||
@@ -150,7 +151,7 @@ async function loadMore(key: NewsType): Promise<void> {
|
||||
await showLoading.start(`正在获取${gameName}${rawData[key].name}数据`);
|
||||
const mod = rawData[key].lastId % 20;
|
||||
const pageSize = mod === 0 ? 20 : 20 - mod;
|
||||
const getData = await painterReq.news(gid, NewsTypeEnum[key], pageSize, rawData[key].lastId);
|
||||
const getData = await painterReq.news(gid, tabMap[key], pageSize, rawData[key].lastId);
|
||||
await showLoading.update(`数量:${getData.list.length},是否最后一页:${getData.is_last}`);
|
||||
rawData[key].lastId = rawData[key].lastId + getData.list.length;
|
||||
rawData[key].isLast = getData.is_last;
|
||||
|
||||
Reference in New Issue
Block a user