mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-04 07:05:07 +08:00
♻️ 重构深渊、剧诗、危战页面使用 Hutao.raw.valid 验证器
This commit is contained in:
@@ -127,7 +127,7 @@ import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import TuaDetail from "@comp/userAbyss/tua-detail.vue";
|
||||
import TuaOverview from "@comp/userAbyss/tua-overview.vue";
|
||||
import hutao from "@Hutao/index.js";
|
||||
import Hutao from "@Hutao/index.js";
|
||||
import recordReq from "@req/recordReq.js";
|
||||
import TSUserAbyss from "@Sqlm/userAbyss.js";
|
||||
import TSUserAccount from "@Sqlm/userAccount.js";
|
||||
@@ -321,10 +321,15 @@ async function tryReadAbyss(): Promise<void> {
|
||||
showSnackbar.warn("文件数据格式错误");
|
||||
return;
|
||||
}
|
||||
// TODO:数据结构
|
||||
if (!Hutao.raw.valid.abyss(fileData)) {
|
||||
await showLoading.end();
|
||||
showSnackbar.warn("深渊数据验证失败,请检查数据格式");
|
||||
return;
|
||||
}
|
||||
// 类型收束后的安全访问
|
||||
for (const item of fileData) {
|
||||
await showLoading.update(`Uid: ${item["uid"]},ScheduleId: ${item["schedule_id"]}`);
|
||||
await TSUserAbyss.saveAbyss(item["uid"], item["data"]);
|
||||
await showLoading.update(`Uid: ${item.uid},ScheduleId: ${item.schedule_id}`);
|
||||
await TSUserAbyss.saveAbyss(item.uid, item.data);
|
||||
}
|
||||
await showLoading.end();
|
||||
showSnackbar.success(`成功导入 ${fileData.length} 条深渊数据,即将刷新页面`);
|
||||
@@ -378,7 +383,7 @@ async function uploadAbyss(): Promise<void> {
|
||||
}
|
||||
try {
|
||||
await showLoading.start(`正在上传 ${gcFind.gameUid} 的深渊数据`, `期数:${abyssData.id}`);
|
||||
const transAbyss = hutao.Abyss.utils.transData(abyssData);
|
||||
const transAbyss = Hutao.Abyss.utils.transData(abyssData);
|
||||
if (userName.value) transAbyss.ReservedUserName = userName.value;
|
||||
const check = await refreshAvatars(acFind.cookie!, gcFind);
|
||||
if (!check) return;
|
||||
@@ -389,10 +394,10 @@ async function uploadAbyss(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
await showLoading.update("正在转换角色数据");
|
||||
transAbyss.Avatars = hutao.Abyss.utils.transAvatars(roles);
|
||||
transAbyss.Avatars = Hutao.Abyss.utils.transAvatars(roles);
|
||||
await showLoading.update("正在上传深渊数据");
|
||||
console.log("uploadAbyss", transAbyss);
|
||||
const res = await hutao.Abyss.upload(transAbyss);
|
||||
const res = await Hutao.Abyss.upload(transAbyss);
|
||||
if (res.retcode !== 0) {
|
||||
showSnackbar.error(`[${res.retcode}]${res.message}`);
|
||||
await TGLogger.Error("[Abyss][uploadAbyss] 上传深渊数据失败");
|
||||
|
||||
@@ -155,6 +155,7 @@ import { getVersion } from "@tauri-apps/api/app";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
import { readTextFile } from "@tauri-apps/plugin-fs";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import Hutao from "@Hutao/index.js";
|
||||
import { getRfAc } from "@utils/acUtils.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { generateShareImg } from "@utils/TGShare.js";
|
||||
@@ -372,10 +373,15 @@ async function tryReadChallenge(): Promise<void> {
|
||||
showSnackbar.warn("文件数据格式错误");
|
||||
return;
|
||||
}
|
||||
// TODO:数据结构
|
||||
if (!Hutao.raw.valid.challenge(fileData)) {
|
||||
await showLoading.end();
|
||||
showSnackbar.warn("危战数据验证失败,请检查数据格式");
|
||||
return;
|
||||
}
|
||||
// 类型收束后的安全访问
|
||||
for (const item of fileData) {
|
||||
await showLoading.update(`Uid: ${item["uid"]},ScheduleId: ${item["schedule_id"]}`);
|
||||
await TSUserChallenge.saveChallenge(item["uid"], item["data"]);
|
||||
await showLoading.update(`Uid: ${item.uid},ScheduleId: ${item.schedule_id}`);
|
||||
await TSUserChallenge.saveChallenge(item.uid, item.data);
|
||||
}
|
||||
await showLoading.end();
|
||||
showSnackbar.success(`成功导入 ${fileData.length} 条危战数据,即将刷新页面`);
|
||||
|
||||
@@ -155,7 +155,7 @@ import TucOvStat from "@comp/userCombat/tuc-ov-stat.vue";
|
||||
import TucOvTarot from "@comp/userCombat/tuc-ov-tarot.vue";
|
||||
import TucOverview from "@comp/userCombat/tuc-overview.vue";
|
||||
import TucRound from "@comp/userCombat/tuc-round.vue";
|
||||
import hutao from "@Hutao/index.js";
|
||||
import Hutao from "@Hutao/index.js";
|
||||
import recordReq from "@req/recordReq.js";
|
||||
import TSUserAccount from "@Sqlm/userAccount.js";
|
||||
import TSUserCombat from "@Sqlm/userCombat.js";
|
||||
@@ -231,7 +231,7 @@ async function hideAllOverlay(): Promise<void> {
|
||||
|
||||
async function loadWiki(): Promise<void> {
|
||||
await showLoading.start("正在加载统计数据");
|
||||
const res = await hutao.Combat.data();
|
||||
const res = await Hutao.Combat.data();
|
||||
if (res === undefined) showSnackbar.error("未获取到剧诗数据");
|
||||
else if ("retcode" in res) {
|
||||
showSnackbar.warn(`[${res.retcode}] ${res.message}`);
|
||||
@@ -431,8 +431,8 @@ async function uploadCombat(): Promise<void> {
|
||||
}
|
||||
try {
|
||||
await showLoading.start("正在上传剧诗数据");
|
||||
const transCombat = hutao.Combat.trans(combatData);
|
||||
const res = await hutao.Combat.upload(transCombat);
|
||||
const transCombat = Hutao.Combat.trans(combatData);
|
||||
const res = await Hutao.Combat.upload(transCombat);
|
||||
if (res.retcode === 0) {
|
||||
showSnackbar.success(res.message ?? "上传剧诗数据成功");
|
||||
await TGLogger.Info("[UserCombat][uploadCombat] 上传剧诗数据成功");
|
||||
@@ -484,10 +484,15 @@ async function tryReadCombat(): Promise<void> {
|
||||
showSnackbar.warn("文件数据格式错误");
|
||||
return;
|
||||
}
|
||||
// TODO:数据结构
|
||||
if (!Hutao.raw.valid.combat(fileData)) {
|
||||
await showLoading.end();
|
||||
showSnackbar.warn("剧诗数据验证失败,请检查数据格式");
|
||||
return;
|
||||
}
|
||||
// 类型收束后的安全访问
|
||||
for (const item of fileData) {
|
||||
await showLoading.update(`Uid: ${item["uid"]},ScheduleId: ${item["schedule_id"]}`);
|
||||
await TSUserCombat.saveCombat(item["uid"], item["data"]);
|
||||
await showLoading.update(`Uid: ${item.uid},ScheduleId: ${item.schedule_id}`);
|
||||
await TSUserCombat.saveCombat(item.uid, item.data);
|
||||
}
|
||||
await showLoading.end();
|
||||
showSnackbar.success(`成功导入 ${fileData.length} 条剧诗数据,即将刷新页面`);
|
||||
|
||||
Reference in New Issue
Block a user