mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-18 10:18:14 +08:00
♻️ 请求模块重构
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
<v-window v-model="tab">
|
||||
<v-window-item v-for="(value, index) in tabValues" :key="index" :value="value">
|
||||
<div class="anno-grid">
|
||||
<TAnnocard
|
||||
<TAnnoCard
|
||||
v-for="item in annoCards[value]"
|
||||
:key="item.id"
|
||||
:model-value="item"
|
||||
@@ -59,11 +59,10 @@ import { useRouter } from "vue-router";
|
||||
|
||||
import showLoading from "../../components/func/loading.js";
|
||||
import showSnackbar from "../../components/func/snackbar.js";
|
||||
import TAnnocard from "../../components/main/t-annocard.vue";
|
||||
import TAnnoCard from "../../components/main/t-annocard.vue";
|
||||
import { useAppStore } from "../../store/modules/app.js";
|
||||
import TGLogger from "../../utils/TGLogger.js";
|
||||
import { AnnoLang, AnnoServer } from "../../web/request/getAnno.js";
|
||||
import TGRequest from "../../web/request/TGRequest.js";
|
||||
import Hk4eApi, { AnnoLang, AnnoServer } from "../../web/request/hk4eReq.js";
|
||||
import { getAnnoCard } from "../../web/utils/getAnnoCard.js";
|
||||
import { decodeRegExp } from "../../web/utils/tools.js";
|
||||
|
||||
@@ -144,12 +143,12 @@ async function loadData(): Promise<void> {
|
||||
"正在获取公告数据",
|
||||
`服务器:${getRegionName(curRegion.value)},语言:${getLangName(curLang.value)}`,
|
||||
);
|
||||
const annoData = await TGRequest.Anno.getList(curRegion.value, curLang.value);
|
||||
const annoData = await Hk4eApi.anno.list(curRegion.value, curLang.value);
|
||||
const listCards = getAnnoCard(annoData);
|
||||
await Promise.all(
|
||||
listCards.map(async (item) => {
|
||||
if (item.typeLabel === AnnoType.game) return;
|
||||
const detail = await TGRequest.Anno.getContent(item.id, curRegion.value, "zh-cn");
|
||||
const detail = await Hk4eApi.anno.content(item.id, curRegion.value, "zh-cn");
|
||||
const timeStr = getAnnoTime(detail.content);
|
||||
if (timeStr !== false) item.timeStr = timeStr;
|
||||
}),
|
||||
|
||||
@@ -129,7 +129,7 @@ import { backUpUserData, restoreUserData } from "../../utils/dataBS.js";
|
||||
import { getBuildTime } from "../../utils/TGBuild.js";
|
||||
import TGLogger from "../../utils/TGLogger.js";
|
||||
import { bytesToSize, getCacheDir, getDeviceInfo, getRandomString } from "../../utils/toolFunc.js";
|
||||
import TGRequest from "../../web/request/TGRequest.js";
|
||||
import OtherApi from "../../web/request/otherReq.js";
|
||||
|
||||
// Store
|
||||
const appStore = useAppStore();
|
||||
@@ -244,7 +244,7 @@ async function confirmUpdateDevice(force?: boolean): Promise<void> {
|
||||
await TGLogger.Info("[Config][confirmUpdateDevice][force] 取消强制更新设备信息");
|
||||
return;
|
||||
}
|
||||
appStore.deviceInfo = await TGRequest.Device.getFp();
|
||||
appStore.deviceInfo = await OtherApi.fp();
|
||||
if (appStore.deviceInfo.device_fp === "0000000000000") {
|
||||
appStore.deviceInfo.device_fp = getRandomString(13, "hex");
|
||||
showSnackbar.warn(`设备信息获取失败!已使用随机值${appStore.deviceInfo.device_fp}代替`);
|
||||
@@ -267,7 +267,7 @@ async function confirmUpdateDevice(force?: boolean): Promise<void> {
|
||||
}
|
||||
}
|
||||
console.log(appStore.deviceInfo);
|
||||
appStore.deviceInfo = await TGRequest.Device.getFp(appStore.deviceInfo);
|
||||
appStore.deviceInfo = await OtherApi.fp(appStore.deviceInfo);
|
||||
console.log(appStore.deviceInfo);
|
||||
if (appStore.deviceInfo.device_fp === "0000000000000") {
|
||||
appStore.deviceInfo.device_fp = getRandomString(13, "hex");
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<div class="pc-posts">
|
||||
<div v-for="item in getPageItems()" :key="item.post.post_id">
|
||||
<TPostCard
|
||||
@update:selected="(v) => (selectedPost = v)"
|
||||
@onSelected="handleSelected"
|
||||
:model-value="item"
|
||||
:selected="selectedPost"
|
||||
:select-mode="selectedMode"
|
||||
@@ -102,7 +102,7 @@ import ToCollectPost from "../../components/overlay/to-collectPost.vue";
|
||||
import TSUserCollection from "../../plugins/Sqlite/modules/userCollect.js";
|
||||
import { useUserStore } from "../../store/modules/user.js";
|
||||
import TGLogger from "../../utils/TGLogger.js";
|
||||
import TGRequest from "../../web/request/TGRequest.js";
|
||||
import BBSApi from "../../web/request/bbsReq.js";
|
||||
|
||||
const userStore = storeToRefs(useUserStore());
|
||||
|
||||
@@ -134,6 +134,10 @@ onUnmounted(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function handleSelected(v: string[]) {
|
||||
selectedPost.value = v;
|
||||
}
|
||||
|
||||
function sortPost(value: boolean) {
|
||||
let ori = sortId.value;
|
||||
sortId.value = value;
|
||||
@@ -364,12 +368,9 @@ async function freshUser(uid?: string): Promise<void> {
|
||||
showSnackbar.warn("请先登录");
|
||||
return;
|
||||
}
|
||||
const cookie = {
|
||||
cookie_token: userStore.cookie.value.cookie_token,
|
||||
account_id: userStore.cookie.value.account_id,
|
||||
};
|
||||
showLoading.start("获取用户收藏...", `UID: ${uid || userStore.briefInfo.value.uid}`);
|
||||
let res = await TGRequest.User.getCollect(cookie, uid || userStore.briefInfo.value.uid);
|
||||
const uidReal = uid || userStore.briefInfo.value.uid;
|
||||
showLoading.start("获取用户收藏...", `UID: ${uidReal}`);
|
||||
let res = await BBSApi.lovePost(userStore.cookie.value, uidReal);
|
||||
while (true) {
|
||||
if ("retcode" in res) {
|
||||
showLoading.end();
|
||||
@@ -385,8 +386,8 @@ async function freshUser(uid?: string): Promise<void> {
|
||||
await mergePosts(posts, uid || userStore.briefInfo.value.uid);
|
||||
if (res.is_last) break;
|
||||
showLoading.update("获取用户收藏...", `[offset]${res.next_offset} [is_last]${res.is_last}`);
|
||||
res = await TGRequest.User.getCollect(
|
||||
cookie,
|
||||
res = await BBSApi.lovePost(
|
||||
userStore.cookie.value,
|
||||
uid || userStore.briefInfo.value.uid,
|
||||
res.next_offset,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user