🐛 fix TGApp is not defined

This commit is contained in:
目棃
2024-12-06 18:54:25 +08:00
parent 6a3d2d6b36
commit d15cece933
3 changed files with 19 additions and 36 deletions

View File

@@ -67,14 +67,14 @@ import showSnackbar from "../../components/func/snackbar.js";
import ToChannel from "../../components/pageNews/to-channel.vue";
import VpOverlaySearch from "../../components/viewPost/vp-overlay-search.vue";
import Mys from "../../plugins/Mys/index.js";
import { useAppStore } from "../../store/modules/app.js";
import { NewsType, NewsTypeEnum, useAppStore } from "../../store/modules/app.js";
import TGLogger from "../../utils/TGLogger.js";
import { createPost } from "../../utils/TGWindow.js";
import { getGameName } from "../../web/utils/tools.js";
type PostData = { [key in TGApp.App.Store.NewsType]: TGApp.Plugins.Mys.Post.FullData[] };
type PostData = { [key in NewsType]: TGApp.Plugins.Mys.Post.FullData[] };
type RawData = {
[key in TGApp.App.Store.NewsType]: { isLast: boolean; name: string; lastId: number };
[key in NewsType]: { isLast: boolean; name: string; lastId: number };
};
const router = useRouter();
@@ -82,12 +82,12 @@ const appStore = useAppStore();
const gid = <string>useRoute().params.gid;
const gameName = getGameName(Number(gid));
const loading = ref<boolean>(false);
const tabValues: Readonly<Array<TGApp.App.Store.NewsType>> = ["notice", "activity", "news"];
const tabValues: Readonly<Array<NewsType>> = ["notice", "activity", "news"];
const showList = ref<boolean>(false);
const showSearch = ref<boolean>(false);
const tab = computed<TGApp.App.Store.NewsType>({
const tab = computed<NewsType>({
get: () => {
if (!(appStore.recentNewsType satisfies TGApp.App.Store.NewsType)) return "notice";
if (!(appStore.recentNewsType satisfies NewsType)) return "notice";
return appStore.recentNewsType;
},
set: (v) => (appStore.recentNewsType = v),
@@ -104,7 +104,7 @@ const rawData = ref<RawData>({
onMounted(async () => await firstLoad(tab.value));
async function firstLoad(key: TGApp.App.Store.NewsType, refresh: boolean = false): Promise<void> {
async function firstLoad(key: NewsType, refresh: boolean = false): Promise<void> {
if (rawData.value[key].lastId !== 0) {
if (!refresh) return;
postData.value[key] = [];
@@ -112,7 +112,7 @@ async function firstLoad(key: TGApp.App.Store.NewsType, refresh: boolean = false
}
showLoading.start(`正在获取${gameName}${rawData.value[key].name}数据...`);
document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
const getData = await Mys.Painter.getNewsList(gid, TGApp.App.Store.NewsTypeEnum[key]);
const getData = await Mys.Painter.getNewsList(gid, NewsTypeEnum[key]);
rawData.value[key].isLast = getData.is_last;
rawData.value[key].lastId = getData.list.length;
postData.value[key] = getData.list;
@@ -127,7 +127,7 @@ async function switchAnno(): Promise<void> {
}
// 加载更多
async function loadMore(key: TGApp.App.Store.NewsType): Promise<void> {
async function loadMore(key: NewsType): Promise<void> {
loading.value = true;
if (rawData.value[key].isLast) {
showSnackbar.warn("已经是最后一页了");
@@ -137,7 +137,7 @@ async function loadMore(key: TGApp.App.Store.NewsType): Promise<void> {
showLoading.start(`正在获取${gameName}${rawData.value[key].name}数据...`);
const getData = await Mys.Painter.getNewsList(
gid,
TGApp.App.Store.NewsTypeEnum[key],
NewsTypeEnum[key],
20,
rawData.value[key].lastId,
);

View File

@@ -18,6 +18,14 @@ const dbDataPath = `${await path.appConfigDir()}${path.sep()}TeyvatGuide.db`;
// 用于存放日志的路径
const logDataDir = await path.appLogDir();
export enum NewsTypeEnum {
notice = "1",
activity = "2",
news = "3",
}
export type NewsType = keyof typeof NewsTypeEnum;
export const useAppStore = defineStore(
"app",
() => {
@@ -46,7 +54,7 @@ export const useAppStore = defineStore(
// 语言
const lang = ref<AnnoLang>("zh-cn");
// 最近的咨讯类型
const recentNewsType = ref<TGApp.App.Store.NewsType>("notice");
const recentNewsType = ref<NewsType>("notice");
// 是否开启分辨率回正
const needResize = ref<string>("true");
// 分享图生成默认设置为0表示默认保存到文件为数字表示当大小超过xMB时保存到文件否则保存到剪贴板

View File

@@ -1,25 +0,0 @@
/**
* @file types/App/Store.d.ts
* @description 涉及store但是没有特定的store模块的类型定义文件
* @since Beta v0.6.5
*/
declare namespace TGApp.App.Store {
/**
* @description 咨讯类型枚举
* @since Beta v0.6.5
* @enum {string}
*/
enum NewsTypeEnum {
notice = "1",
activity = "2",
news = "3",
}
/**
* @description 咨讯类型枚举
* @since Beta v0.6.5
* @type {keyof typeof NewsTypeEnum}
*/
type NewsType = keyof typeof NewsTypeEnum;
}