♻️ refactor(types): 给笨蛋牡蛎一点小小的类型震撼

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
舰队的偶像-岛风酱!
2023-04-10 02:09:05 +00:00
committed by BTMuli
parent d7494739f6
commit e804553951
23 changed files with 438 additions and 483 deletions

View File

@@ -108,7 +108,6 @@ import { dialog, fs } from "@tauri-apps/api";
// Store
import { useAchievementsStore } from "../store/modules/achievements";
// Interface
import type TGTypes from "../core/types/TGTypes";
import { Achievements, UiafHeader, UiafAchievement } from "../plugins/UIAF/interface/UIAF";
// Plugins
import UiafOper from "../plugins/UIAF";
@@ -125,13 +124,13 @@ const loadingTitle = ref("正在加载数据" as string);
// data
const title = ref(achievementsStore.title as string);
const CardsInfo = ref([] as TGTypes.NameCard[]);
const getCardInfo = ref({} as TGTypes.NameCard);
const CardsInfo = ref([] as BTMuli.Genshin.NameCard.NameCard[]);
const getCardInfo = ref({} as BTMuli.Genshin.NameCard.NameCard);
// series
const seriesList = ref([] as TGTypes.AchievementSeries[]);
const seriesList = ref([] as BTMuli.Genshin.AchievementSeries[]);
const selectedIndex = ref(-1 as number);
const selectedSeries = ref(-1 as number);
const selectedAchievement = ref([] as TGTypes.Achievement[]);
const selectedAchievement = ref([] as BTMuli.Genshin.Achievement[]);
// render
const search = ref("" as string);
@@ -145,7 +144,7 @@ onMounted(async () => {
// 加载数据,数据源:合并后的本地数据
async function loadData () {
loadingTitle.value = "正在获取成就系列数据";
const seriesDB: TGTypes.AchievementSeries[] = await ReadAllTGData("AchievementSeries");
const seriesDB: BTMuli.Genshin.AchievementSeries[] = await ReadAllTGData("AchievementSeries");
loadingTitle.value = "正在获取成就系列名片数据";
CardsInfo.value = await ReadTGDataByIndex("NameCard", "type", 1);
loadingTitle.value = "对成就系列数据进行排序";
@@ -179,11 +178,11 @@ async function selectSeries (index: number) {
selectedIndex.value = index;
selectedSeries.value = seriesList.value[index].id;
loadingTitle.value = "正在查找对应的成就名片";
let getCard: TGTypes.NameCard;
let getCard: BTMuli.Genshin.NameCard.NameCard;
if (selectedSeries.value !== 0 && selectedSeries.value !== 17) {
getCard = CardsInfo.value.find((card) => card.name === seriesList.value[index].card)!;
} else {
getCard = {} as TGTypes.NameCard;
getCard = {} as BTMuli.Genshin.NameCard.NameCard;
}
loadingTitle.value = "正在对成就数据进行排序";
getAchievements.sort((a, b) => {
@@ -213,7 +212,7 @@ async function searchCard () {
}
loadingTitle.value = "正在搜索";
loading.value = true;
const res: TGTypes.Achievement[] = [];
const res: BTMuli.Genshin.Achievement[] = [];
const allAchievements = await ReadAllTGData("Achievements");
allAchievements.map((achievement) => {
if (achievement.name.includes(search.value) || achievement.description.includes(search.value)) {
@@ -265,7 +264,7 @@ async function importJson () {
await Promise.allSettled(
remoteData.list.map(async (data) => {
const id = data.id;
const localData: TGTypes.Achievement = (await ReadTGDataByKey("Achievements", [id]))[0];
const localData: BTMuli.Genshin.Achievement = (await ReadTGDataByKey("Achievements", [id]))[0];
// 获取 timeStamp 2023-03-15 00:00:00
const localTime = localData.completed_time;
// 如果本地数据不存在,或者本地数据的 timeStamp 小于远程数据的 timeStamp更新数据

View File

@@ -99,9 +99,6 @@ import TGRequest from "../core/request/TGRequest";
import TGUtils from "../core/utils/TGUtils";
import { createTGWindow } from "../utils/TGWindow";
// interface
import type TGTypes from "../core/types/TGTypes";
// store
const appStore = useAppStore();
@@ -114,10 +111,10 @@ const router = useRouter();
// 数据
const tab = ref("");
const annoCards = ref({
activity: [] as TGTypes.AnnoListCard[],
game: [] as TGTypes.AnnoListCard[],
activity: [] as BTMuli.Genshin.Announcement.ListCard[],
game: [] as BTMuli.Genshin.Announcement.ListCard[],
});
const annoData = ref({} as TGTypes.AnnoListData);
const annoData = ref({} as BTMuli.Genshin.Announcement.ListData);
onMounted(async () => {
loadingTitle.value = "正在获取公告数据";
@@ -138,7 +135,7 @@ async function switchNews () {
await router.push("/news");
}
async function toPost (item: TGTypes.AnnoListCard) {
async function toPost (item: BTMuli.Genshin.Announcement.ListCard) {
const path = router.resolve({
name: "游戏内公告",
params: {
@@ -149,7 +146,7 @@ async function toPost (item: TGTypes.AnnoListCard) {
createTGWindow(path, "游戏内公告", item.title, 960, 720, false, false);
}
async function toJson (item: TGTypes.AnnoListCard) {
async function toJson (item: BTMuli.Genshin.Announcement.ListCard) {
const path = router.resolve({
name: "游戏内公告JSON",
params: {