♻️ types 重构后的问题搞完了,累死

This commit is contained in:
BTMuli
2023-05-23 00:56:43 +08:00
parent 573eb8bbe4
commit caadb5df79
38 changed files with 362 additions and 408 deletions

View File

@@ -61,7 +61,7 @@
}"
@click="openImg()"
>
<v-list-item :title="getCardInfo.name" :subtitle="getCardInfo.description">
<v-list-item :title="getCardInfo.name" :subtitle="getCardInfo.desc">
<template #prepend>
<v-img width="80px" style="margin-right: 10px" :src="getCardInfo.icon" />
</template>
@@ -129,11 +129,11 @@ const loadingTitle = ref("正在加载数据" as string);
// data
const title = ref(achievementsStore.title as string);
const getCardInfo = ref({} as BTMuli.SQLite.NameCard);
const getCardInfo = ref({} as TGApp.Sqlite.NameCard.Item);
// series
const seriesList = ref([] as BTMuli.SQLite.AchievementSeries[]);
const seriesList = ref([] as TGApp.Sqlite.Achievement.SeriesTable[]);
const selectedSeries = ref(-1 as number);
const selectedAchievement = ref([] as BTMuli.SQLite.Achievements[]);
const selectedAchievement = ref([] as TGApp.Sqlite.Achievement.SingleTable[]);
const renderAchievement = computed(() => {
return selectedAchievement.value.slice(start.value, start.value + itemCount.value + 1);
});
@@ -349,13 +349,6 @@ async function exportJson () {
width: 100%;
}
.list-container {
position: relative;
width: 100%;
height: 100%;
max-height: calc(100vh - 100px);
}
/* 版本信息 */
.version-icon-series {
font-family: Genshin, serif;

View File

@@ -115,10 +115,10 @@ const router = useRouter();
// 数据
const tab = ref("");
const annoCards = ref({
activity: [] as BTMuli.Genshin.Announcement.ListCard[],
game: [] as BTMuli.Genshin.Announcement.ListCard[],
activity: [] as TGApp.App.Announcement.ListCard[],
game: [] as TGApp.App.Announcement.ListCard[],
});
const annoData = ref({} as BTMuli.Genshin.Announcement.ListData);
const annoData = ref({} as TGApp.BBS.Announcement.ListData);
onMounted(async () => {
loadingTitle.value = "正在获取公告数据";
@@ -139,7 +139,7 @@ async function switchNews () {
await router.push("/news/2");
}
async function toPost (item: BTMuli.Genshin.Announcement.ListCard) {
async function toPost (item: TGApp.App.Announcement.ListCard) {
const path = router.resolve({
name: "游戏内公告",
params: {
@@ -150,7 +150,7 @@ async function toPost (item: BTMuli.Genshin.Announcement.ListCard) {
createTGWindow(path, "游戏内公告", item.title, 960, 720, false, false);
}
async function toJson (item: BTMuli.Genshin.Announcement.ListCard) {
async function toJson (item: TGApp.App.Announcement.ListCard) {
const path = router.resolve({
name: "游戏内公告JSON",
params: {

View File

@@ -246,7 +246,13 @@ onMounted(async () => {
versionTauri.value = await app.getTauriVersion();
osPlatform.value = `${await os.platform()}`;
osVersion.value = await os.version();
dbInfo.value = await TGSqlite.getAppData();
try {
dbInfo.value = await TGSqlite.getAppData();
} catch (e) {
snackbarText.value = "读取数据库失败!";
snackbarColor.value = "warn";
snackbar.value = true;
}
loading.value = false;
});
@@ -484,7 +490,7 @@ async function refreshUser () {
}
const infoRes = await TGRequest.User.byCookie.getUserInfo(ck.cookie_token, ck.account_id);
if (infoRes.hasOwnProperty("nickname")) {
const info = infoRes as BTMuli.User.Base.BriefInfo;
const info = infoRes as TGApp.App.Account.BriefInfo;
userStore.setBriefInfo(info);
loadingTitle.value = "获取成功!正在获取用户游戏账号信息";
} else {
@@ -493,8 +499,8 @@ async function refreshUser () {
}
const accountRes = await TGRequest.User.byCookie.getAccounts(ck.cookie_token, ck.account_id);
if (Array.isArray(accountRes)) {
loadingTitle.value = "获取成功!正在保存到数据库!";
await TGSqlite.insertAccount(accountRes);
loadingTitle.value = "获取成功!";
} else {
loadingTitle.value = "获取失败!";
failCount++;
@@ -538,9 +544,9 @@ async function inputCookie () {
loadingTitle.value = "正在获取用户信息...";
const cookie_token = userStore.getCookieItem("cookie_token");
const resUser = await TGRequest.User.byCookie.getUserInfo(cookie_token, uid);
// . 判断返回是否为 BTMuli.User.Base.BriefInfo
// . 判断返回是否为 BTMuli.User.Account.BriefInfo
if (resUser.hasOwnProperty("nickname")) {
const info = resUser as BTMuli.User.Base.BriefInfo;
const info = resUser as TGApp.App.Account.BriefInfo;
userStore.setBriefInfo(info);
appStore.isLogin = true;
}

View File

@@ -26,7 +26,7 @@ const abyssCookie = ref({
ltoken: "",
ltuid: "",
});
const user = ref({} as BTMuli.User.Game.Account);
const user = ref({} as TGApp.User.Account.Game);
onMounted(async () => {
const curUser = await TGSqlite.getCurAccount();
@@ -44,7 +44,7 @@ onMounted(async () => {
async function getAbyssData (schedule:string): Promise<void> {
const res = await TGRequest.User.byCookie.getAbyss(abyssCookie.value, schedule, user.value);
if (res.hasOwnProperty("retcode")) {
const warn = res as BTMuli.Genshin.Base.Response;
const warn = res as TGApp.BBS.Response.Base;
console.warn(warn);
} else {
console.log(res);

View File

@@ -11,28 +11,24 @@
<script lang="ts" setup>
// vue
import { ref, onMounted } from "vue";
import { ref, computed } from "vue";
import TMiniAvatar from "../../components/t-mini-avatar.vue";
// utils
import { createTGWindow } from "../../utils/TGWindow";
import { TGAppData } from "../../data";
import { AppCharacterData } from "../../data";
import { OBC_CONTENT_API } from "../../plugins/Mys/interface/utils";
// snackbar
const snackbar = ref(false);
// data
const cardsInfo = ref([] as BTMuli.Genshin.Wiki.Character.BriefInfo[]);
const cardsInfo = computed(() => AppCharacterData);
onMounted(async () => {
cardsInfo.value = TGAppData.character;
});
function toOuter (item: BTMuli.Genshin.Wiki.Character.BriefInfo) {
if (item.content_id === null || item.content_id === undefined) {
function toOuter (item: TGApp.App.Character.WikiBriefInfo) {
if (item.contentId === 0) {
snackbar.value = true;
return;
}
const url = OBC_CONTENT_API.replace("{content_id}", item.content_id.toString());
const url = OBC_CONTENT_API.replace("{content_id}", item.contentId.toString());
createTGWindow(url, "角色详情", item.name, 1200, 800, true);
}

View File

@@ -30,7 +30,7 @@
<v-window v-model="tab">
<v-window-item value="character">
<div class="cards-grid">
<v-card v-for="item in CardsInfoC" :key="item.content_id" class="card-cls" @click="toOuter(item.name, item.content_id)">
<v-card v-for="item in CardsInfoC" :key="item.contentId" class="card-cls" @click="toOuter(item.name, item.contentId)">
<div class="card-border">
<img src="/WIKI/GCG/bg/normal.webp" alt="border">
</div>
@@ -45,7 +45,7 @@
</v-window-item>
<v-window-item value="action">
<div class="cards-grid">
<v-card v-for="item in CardsInfoA" :key="item.content_id" class="card-cls" @click="toOuter(item.name, item.content_id)">
<v-card v-for="item in CardsInfoA" :key="item.contentId" class="card-cls" @click="toOuter(item.name, item.contentId)">
<div class="card-border">
<img src="/WIKI/GCG/bg/normal.webp" alt="border">
</div>
@@ -60,7 +60,7 @@
</v-window-item>
<v-window-item value="monster">
<div class="cards-grid">
<v-card v-for="item in CardsInfoM" :key="item.content_id" class="card-cls" @click="toOuter(item.name, item.content_id)">
<v-card v-for="item in CardsInfoM" :key="item.contentId" class="card-cls" @click="toOuter(item.name, item.contentId)">
<div class="card-border">
<img src="/WIKI/GCG/bg/normal.webp" alt="border">
</div>
@@ -77,7 +77,7 @@
</div>
<div v-else>
<div class="cards-grid">
<div v-for="item in CardsInfoS" :key="item.content_id" class="card-cls" @click="toOuter(item.name, item.content_id)">
<div v-for="item in CardsInfoS" :key="item.contentId" class="card-cls" @click="toOuter(item.name, item.contentId)">
<div class="card-border">
<img src="/WIKI/GCG/bg/normal.webp" alt="border">
</div>
@@ -97,16 +97,17 @@
</template>
<script lang="ts" setup>
// vue
import { ref, onMounted } from "vue";
import { ref, onMounted, computed } from "vue";
import TLoading from "../../components/t-loading.vue";
// utils
import { createTGWindow } from "../../utils/TGWindow";
import { TGAppData } from "../../data";
import { AppGCGData } from "../../data";
// interface
import { OBC_CONTENT_API } from "../../plugins/Mys/interface/utils";
// loading
const loading = ref(true);
const allCards = computed(() => AppGCGData);
// snackbar
const snackbar = ref(false);
// search
@@ -114,20 +115,19 @@ const doSearch = ref(false);
const search = ref("");
// data
const tab = ref("character");
const CardsInfoC = ref([] as BTMuli.Genshin.Wiki.GCG.BriefInfo[]);
const CardsInfoA = ref([] as BTMuli.Genshin.Wiki.GCG.BriefInfo[]);
const CardsInfoM = ref([] as BTMuli.Genshin.Wiki.GCG.BriefInfo[]);
const CardsInfoS = ref([] as BTMuli.Genshin.Wiki.GCG.BriefInfo[]);
const CardsInfoC = ref([] as TGApp.App.GCG.WikiBriefInfo[]);
const CardsInfoA = ref([] as TGApp.App.GCG.WikiBriefInfo[]);
const CardsInfoM = ref([] as TGApp.App.GCG.WikiBriefInfo[]);
const CardsInfoS = ref([] as TGApp.App.GCG.WikiBriefInfo[]);
onMounted(async () => {
await loadData();
});
async function loadData () {
const CardsInfo = TGAppData.GCG;
CardsInfoC.value = CardsInfo.filter((item) => item.type === "角色牌");
CardsInfoA.value = CardsInfo.filter((item) => item.type === "行动牌");
CardsInfoM.value = CardsInfo.filter((item) => item.type === "魔物牌");
CardsInfoC.value = allCards.value.filter((item) => item.type === "角色牌");
CardsInfoA.value = allCards.value.filter((item) => item.type === "行动牌");
CardsInfoM.value = allCards.value.filter((item) => item.type === "魔物牌");
loading.value = false;
}
function toOuter (cardName: string, cardId: number) {
@@ -137,9 +137,8 @@ function toOuter (cardName: string, cardId: number) {
async function searchCard () {
loading.value = true;
doSearch.value = true;
const res: BTMuli.Genshin.Wiki.GCG.BriefInfo[] = [];
const allCardsInfo = TGAppData.GCG;
allCardsInfo.map((item) => (item.name.includes(search.value) ? res.push(item) : null));
const res: TGApp.App.GCG.WikiBriefInfo[] = [];
allCards.value.map((item) => (item.name.includes(search.value) ? res.push(item) : null));
res.sort((a, b) => a.name.localeCompare(b.name));
loading.value = false;
if (res.length === 0) {

View File

@@ -11,28 +11,24 @@
<script lang="ts" setup>
// vue
import { ref, onMounted } from "vue";
import { ref, computed } from "vue";
import TMiniWeapon from "../../components/t-mini-weapon.vue";
// utils
import { createTGWindow } from "../../utils/TGWindow";
import { TGAppData } from "../../data";
import { AppWeaponData } from "../../data";
import { OBC_CONTENT_API } from "../../plugins/Mys/interface/utils";
// snackbar
const snackbar = ref(false);
// data
const cardsInfo = ref([] as BTMuli.Genshin.Wiki.Weapon.BriefInfo[]);
const cardsInfo = computed(() => AppWeaponData);
onMounted(async () => {
cardsInfo.value = TGAppData.weapon;
});
function toOuter (item: BTMuli.Genshin.Wiki.Weapon.BriefInfo) {
if (item.content_id === null || item.content_id === undefined) {
function toOuter (item: TGApp.App.Weapon.WikiBriefInfo) {
if (item.contentId === 0) {
snackbar.value = true;
return;
}
const url = OBC_CONTENT_API.replace("{content_id}", item.content_id.toString());
const url = OBC_CONTENT_API.replace("{content_id}", item.contentId.toString());
createTGWindow(url, "武器详情", item.name, 1200, 800, true);
}