mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-09 08:48:21 +08:00
@@ -264,7 +264,8 @@ const themeTitle = computed(() => {
|
||||
});
|
||||
|
||||
watch(themeTitle, async (val) => {
|
||||
await TGLogger.Info(`[App][theme] 已切换到${val}`);
|
||||
const themeNow = val === "夜间模式" ? "浅色模式" : "深色模式";
|
||||
await TGLogger.Info(`[App][theme] 已切换到${themeNow}`);
|
||||
});
|
||||
|
||||
function collapse(): void {
|
||||
|
||||
@@ -79,6 +79,7 @@ import TuaOverview from "../../components/userAbyss/tua-overview.vue";
|
||||
import Hutao from "../../plugins/Hutao";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
import { useUserStore } from "../../store/modules/user";
|
||||
import TGLogger from "../../utils/TGLogger";
|
||||
import { generateShareImg } from "../../utils/TGShare";
|
||||
import TGRequest from "../../web/request/TGRequest";
|
||||
|
||||
@@ -99,6 +100,7 @@ const curAbyss = ref<TGApp.Sqlite.Abyss.SingleTable>(<TGApp.Sqlite.Abyss.SingleT
|
||||
const abyssRef = ref<HTMLElement>(<HTMLElement>{});
|
||||
|
||||
onMounted(async () => {
|
||||
await TGLogger.Info("[UserAbyss][onMounted] 打开角色深渊页面");
|
||||
loadingTitle.value = "正在加载深渊数据";
|
||||
await initAbyssData();
|
||||
loading.value = false;
|
||||
@@ -106,16 +108,21 @@ onMounted(async () => {
|
||||
|
||||
async function initAbyssData(): Promise<void> {
|
||||
const abyssGet = await TGSqlite.getAbyss(user.value.gameUid);
|
||||
if (abyssGet.length === 0) return;
|
||||
if (abyssGet.length === 0) {
|
||||
await TGLogger.Warn("[UserAbyss][initAbyssData] 未找到深渊数据");
|
||||
return;
|
||||
}
|
||||
localAbyss.value = abyssGet;
|
||||
localAbyss.value.forEach((item) => {
|
||||
localAbyssID.value.push(item.id);
|
||||
});
|
||||
curAbyss.value = localAbyss.value[0];
|
||||
userTab.value = localAbyssID.value[0];
|
||||
await TGLogger.Info(`[UserAbyss][initAbyssData] 成功获取 ${abyssGet.length} 条深渊数据`);
|
||||
}
|
||||
|
||||
async function getAbyssData(): Promise<void> {
|
||||
await TGLogger.Info("[UserAbyss][getAbyssData] 更新深渊数据");
|
||||
loadingTitle.value = "正在获取深渊数据";
|
||||
loading.value = true;
|
||||
if (!userStore.cookie.value) {
|
||||
@@ -124,6 +131,7 @@ async function getAbyssData(): Promise<void> {
|
||||
color: "error",
|
||||
});
|
||||
loading.value = false;
|
||||
await TGLogger.Warn("[UserAbyss][getAbyssData] 未登录");
|
||||
return;
|
||||
}
|
||||
const cookie = {
|
||||
@@ -135,6 +143,7 @@ async function getAbyssData(): Promise<void> {
|
||||
loadingTitle.value = "正在获取上期深渊数据";
|
||||
const resP = await TGRequest.User.byCookie.getAbyss(cookie, "2", user.value);
|
||||
if (!("retcode" in resP)) {
|
||||
await TGLogger.Info("[UserAbyss][getAbyssData] 成功获取上期深渊数据");
|
||||
loadingTitle.value = "正在保存上期深渊数据";
|
||||
await TGSqlite.saveAbyss(user.value.gameUid, resP);
|
||||
} else {
|
||||
@@ -143,6 +152,8 @@ async function getAbyssData(): Promise<void> {
|
||||
color: "error",
|
||||
});
|
||||
loading.value = false;
|
||||
await TGLogger.Error("[UserAbyss][getAbyssData] 获取上期深渊数据失败");
|
||||
await TGLogger.Error(`[UserAbyss][getAbyssData] ${resP.retcode} ${resP.message}`);
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = "正在获取本期深渊数据";
|
||||
@@ -150,12 +161,15 @@ async function getAbyssData(): Promise<void> {
|
||||
if (!("retcode" in res)) {
|
||||
loadingTitle.value = "正在保存本期深渊数据";
|
||||
await TGSqlite.saveAbyss(user.value.gameUid, res);
|
||||
await TGLogger.Info("[UserAbyss][getAbyssData] 成功获取本期深渊数据");
|
||||
} else {
|
||||
showSnackbar({
|
||||
text: `[${res.retcode}]${res.message}`,
|
||||
color: "error",
|
||||
});
|
||||
loading.value = false;
|
||||
await TGLogger.Error("[UserAbyss][getAbyssData] 获取本期深渊数据失败");
|
||||
await TGLogger.Error(`[UserAbyss][getAbyssData] ${res.retcode} ${res.message}`);
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = "正在加载深渊数据";
|
||||
@@ -183,6 +197,7 @@ async function shareAbyss(): Promise<void> {
|
||||
});
|
||||
return;
|
||||
}
|
||||
await TGLogger.Info(`[UserAbyss][shareAbyss][${curAbyss.value.id}] 生成深渊数据分享图片`);
|
||||
const fileName = `【深渊数据】${curAbyss.value.id}-${user.value.gameUid}`;
|
||||
loadingTitle.value = "正在生成图片";
|
||||
loadingSub.value = `${fileName}.png`;
|
||||
@@ -191,15 +206,18 @@ async function shareAbyss(): Promise<void> {
|
||||
await generateShareImg(fileName, abyssRef.value);
|
||||
loadingSub.value = "";
|
||||
loading.value = false;
|
||||
await TGLogger.Info(`[UserAbyss][shareAbyss][${curAbyss.value.id}] 生成深渊数据分享图片成功`);
|
||||
}
|
||||
|
||||
async function uploadAbyss(): Promise<void> {
|
||||
await TGLogger.Info("[UserAbyss][uploadAbyss] 上传深渊数据");
|
||||
const abyssData = localAbyss.value.find((item) => item.id === Math.max(...localAbyssID.value));
|
||||
if (!abyssData) {
|
||||
showSnackbar({
|
||||
text: "未找到深渊数据",
|
||||
color: "error",
|
||||
});
|
||||
await TGLogger.Warn("[UserAbyss][uploadAbyss] 未找到深渊数据");
|
||||
return;
|
||||
}
|
||||
const startTime = new Date(abyssData.startTime).getTime();
|
||||
@@ -210,6 +228,7 @@ async function uploadAbyss(): Promise<void> {
|
||||
text: "非最新深渊数据,请刷新深渊数据后重试!",
|
||||
color: "error",
|
||||
});
|
||||
await TGLogger.Warn("[UserAbyss][uploadAbyss] 非最新深渊数据");
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = "正在转换深渊数据";
|
||||
@@ -227,12 +246,15 @@ async function uploadAbyss(): Promise<void> {
|
||||
const res = await Hutao.Abyss.postData(transAbyss);
|
||||
loading.value = false;
|
||||
if (res.retcode === 0) {
|
||||
showSnackbar({ text: <string>res.message });
|
||||
showSnackbar({ text: res.message ?? "上传深渊数据成功" });
|
||||
await TGLogger.Info("[UserAbyss][uploadAbyss] 上传深渊数据成功");
|
||||
} else {
|
||||
showSnackbar({
|
||||
text: <string>res.message,
|
||||
text: `[${res.retcode}]${res.message}`,
|
||||
color: "error",
|
||||
});
|
||||
await TGLogger.Error("[UserAbyss][uploadAbyss] 上传深渊数据失败");
|
||||
await TGLogger.Error(`[UserAbyss][uploadAbyss] ${res.retcode} ${res.message}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -64,6 +64,7 @@ import TucDetailOverlay from "../../components/userCharacter/tuc-detail-overlay.
|
||||
import TucRoleBox from "../../components/userCharacter/tuc-role-box.vue";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
import { useUserStore } from "../../store/modules/user";
|
||||
import TGLogger from "../../utils/TGLogger";
|
||||
import { generateShareImg } from "../../utils/TGShare";
|
||||
import TGRequest from "../../web/request/TGRequest";
|
||||
|
||||
@@ -104,6 +105,7 @@ function clickOverlay(pos: "left" | "right") {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await TGLogger.Info("[Character][onMounted] 进入角色页面");
|
||||
loadingTitle.value = "正在获取角色数据";
|
||||
loading.value = true;
|
||||
await loadRole();
|
||||
@@ -128,10 +130,15 @@ async function loadRole(): Promise<void> {
|
||||
roleList.value = roleData;
|
||||
dataVal.value = roleData[selectIndex.value];
|
||||
isEmpty.value = false;
|
||||
await TGLogger.Info(`[Character][loadRole][${user.gameUid}] 成功加载角色数据`);
|
||||
await TGLogger.Info(`[Character][loadRole][${user.gameUid}] 共获取到${roleData.length}个角色`);
|
||||
} else {
|
||||
await TGLogger.Warn(`[Character][loadRole][${user.gameUid}] 未获取到角色数据`);
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshRoles(): Promise<void> {
|
||||
await TGLogger.Info(`[Character][refreshRoles][${user.gameUid}] 正在更新角色数据`);
|
||||
loadingTitle.value = "正在获取角色数据";
|
||||
loading.value = true;
|
||||
if (!userStore.cookie.value) {
|
||||
@@ -150,6 +157,8 @@ async function refreshRoles(): Promise<void> {
|
||||
};
|
||||
const res = await TGRequest.User.byLToken.getRoleList(cookie, user);
|
||||
if (Array.isArray(res)) {
|
||||
await TGLogger.Info(`[Character][refreshRoles][${user.gameUid}] 获取角色数据成功`);
|
||||
await TGLogger.Info(`[Character][refreshRoles][${user.gameUid}] 共获取到${res.length}个角色`);
|
||||
loadingTitle.value = "正在保存角色数据";
|
||||
await TGSqlite.saveUserCharacter(user.gameUid, res);
|
||||
loadingTitle.value = "正在更新角色数据";
|
||||
@@ -159,7 +168,10 @@ async function refreshRoles(): Promise<void> {
|
||||
text: `[${res.retcode}] ${res.message}`,
|
||||
color: "error",
|
||||
});
|
||||
console.error(res);
|
||||
await TGLogger.Error(`[Character][refreshRoles][${user.gameUid}] 更新角色数据失败`);
|
||||
await TGLogger.Error(
|
||||
`[Character][refreshRoles][${user.gameUid}] ${res.retcode} ${res.message}`,
|
||||
);
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -196,10 +208,20 @@ async function refreshTalent(): Promise<void> {
|
||||
icon: skill.icon,
|
||||
});
|
||||
});
|
||||
const skillStr = talent.map((i) => `${i.id}:${i.level}`).join(",");
|
||||
await TGLogger.Info(
|
||||
`[Character][refreshTalent][${user.gameUid}] 成功获取到${role.name}的天赋数据 ${skillStr}`,
|
||||
);
|
||||
await TGSqlite.saveUserCharacterTalent(user.gameUid, role.cid, talent);
|
||||
} else {
|
||||
loadingTitle.value = `获取${role.name}的天赋数据失败`;
|
||||
loadingSub.value = `[${res.retcode}] ${res.message}`;
|
||||
await TGLogger.Error(
|
||||
`[Character][refreshTalent][${user.gameUid}] 获取 ${role.name} 的天赋数据失败`,
|
||||
);
|
||||
await TGLogger.Error(
|
||||
`[Character][refreshTalent][${user.gameUid}] ${res.retcode} ${res.message}`,
|
||||
);
|
||||
setTimeout(() => {}, 1000);
|
||||
}
|
||||
}
|
||||
@@ -215,6 +237,7 @@ async function refreshTalent(): Promise<void> {
|
||||
}
|
||||
|
||||
async function shareRoles(): Promise<void> {
|
||||
await TGLogger.Info(`[Character][shareRoles][${user.gameUid}] 正在生成分享图片`);
|
||||
const rolesBox = <HTMLElement>document.querySelector(".uc-box");
|
||||
const fileName = `【角色列表】-${user.gameUid}`;
|
||||
loadingTitle.value = "正在生成图片";
|
||||
@@ -223,6 +246,7 @@ async function shareRoles(): Promise<void> {
|
||||
await generateShareImg(fileName, rolesBox);
|
||||
loadingSub.value = "";
|
||||
loading.value = false;
|
||||
await TGLogger.Info(`[Character][shareRoles][${user.gameUid}] 生成分享图片成功`);
|
||||
}
|
||||
|
||||
function getUpdateTime(): string {
|
||||
|
||||
@@ -54,6 +54,7 @@ import { AppCharacterData, AppWeaponData } from "../../data";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
import { useAppStore } from "../../store/modules/app";
|
||||
import { useUserStore } from "../../store/modules/user";
|
||||
import TGLogger from "../../utils/TGLogger";
|
||||
import { backupUigfData, exportUigfData, readUigfData, verifyUigfData } from "../../utils/UIGF";
|
||||
import TGRequest from "../../web/request/TGRequest";
|
||||
|
||||
@@ -75,6 +76,7 @@ const gachaListCur = ref<TGApp.Sqlite.GachaRecords.SingleTable[]>([]);
|
||||
const tab = ref<string>("");
|
||||
|
||||
onMounted(async () => {
|
||||
await TGLogger.Info("[UserGacha][onMounted] 进入角色祈愿页面");
|
||||
loadingTitle.value = "正在获取祈愿 UID 列表";
|
||||
selectItem.value = await TGSqlite.getUidList();
|
||||
if (selectItem.value.length === 0) {
|
||||
@@ -83,11 +85,15 @@ onMounted(async () => {
|
||||
text: "暂无祈愿数据,请先导入祈愿数据",
|
||||
});
|
||||
loading.value = false;
|
||||
await TGLogger.Warn("[UserGacha][onMounted] 暂无祈愿数据,请先导入祈愿数据");
|
||||
return;
|
||||
}
|
||||
uidCur.value = selectItem.value[0];
|
||||
loadingTitle.value = `正在获取祈愿数据,默认 UID:${uidCur.value}`;
|
||||
gachaListCur.value = await TGSqlite.getGachaRecords(uidCur.value);
|
||||
await TGLogger.Info(
|
||||
`[UserGacha][onMounted] 获取到 ${uidCur.value} 的 ${gachaListCur.value.length} 条祈愿数据`,
|
||||
);
|
||||
loadingTitle.value = "正在渲染数据";
|
||||
tab.value = "echarts";
|
||||
loading.value = false;
|
||||
@@ -98,6 +104,7 @@ onMounted(async () => {
|
||||
|
||||
// 刷新按钮点击事件
|
||||
async function confirmRefresh(): Promise<void> {
|
||||
await TGLogger.Info(`[UserGacha][${account.gameUid}][confirmRefresh] 刷新祈愿数据`);
|
||||
const confirmRes = await showConfirm({
|
||||
title: "是否刷新祈愿数据?",
|
||||
text: `将刷新 UID:${account.gameUid} 的祈愿数据`,
|
||||
@@ -107,6 +114,7 @@ async function confirmRefresh(): Promise<void> {
|
||||
color: "cancel",
|
||||
text: "已取消刷新祈愿数据",
|
||||
});
|
||||
await TGLogger.Warn("[UserGacha][${account.gameUid}][confirmRefresh] 已取消刷新祈愿数据");
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = "正在获取 authkey";
|
||||
@@ -117,6 +125,7 @@ async function confirmRefresh(): Promise<void> {
|
||||
text: "请先登录",
|
||||
});
|
||||
loading.value = false;
|
||||
await TGLogger.Warn("[UserGacha][${account.gameUid}][confirmRefresh] 未检测到 cookie");
|
||||
return;
|
||||
}
|
||||
const cookie = {
|
||||
@@ -127,11 +136,16 @@ async function confirmRefresh(): Promise<void> {
|
||||
const authkeyRes = await TGRequest.User.getAuthkey(cookie, gameUid);
|
||||
if (typeof authkeyRes === "string") {
|
||||
authkey.value = authkeyRes;
|
||||
await TGLogger.Info(`[UserGacha][${account.gameUid}][confirmRefresh] 成功获取 authkey`);
|
||||
} else {
|
||||
showSnackbar({
|
||||
color: "error",
|
||||
text: "获取 authkey 失败",
|
||||
});
|
||||
await TGLogger.Error(`[UserGacha][${account.gameUid}][confirmRefresh] 获取 authkey 失败`);
|
||||
await TGLogger.Error(
|
||||
`[UserGacha][${account.gameUid}][confirmRefresh] ${authkeyRes.retcode} ${authkeyRes.message}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = "正在刷新新手祈愿数据";
|
||||
@@ -152,14 +166,21 @@ async function confirmRefresh(): Promise<void> {
|
||||
resolve("");
|
||||
}, 1000);
|
||||
});
|
||||
await TGLogger.Info(`[UserGacha][${account.gameUid}][confirmRefresh] 刷新祈愿数据完成`);
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
// 获取祈愿数据并写入数据库
|
||||
async function getGachaLogs(pool: string, endId: string = "0"): Promise<void> {
|
||||
await TGLogger.Info(
|
||||
`[UserGacha][${account.gameUid}][getGachaLogs] 获取祈愿数据,pool:${pool},endId:${endId}`,
|
||||
);
|
||||
const gachaRes = await TGRequest.User.getGachaLog(authkey.value, pool, endId);
|
||||
console.log(pool, endId, gachaRes);
|
||||
if (Array.isArray(gachaRes)) {
|
||||
await TGLogger.Info(
|
||||
`[UserGacha][${account.gameUid}][getGachaLogs] 成功获取到 ${gachaRes.length} 条祈愿数据`,
|
||||
);
|
||||
const uigfList: TGApp.Plugins.UIGF.GachaItem[] = [];
|
||||
gachaRes.forEach((item) => {
|
||||
loadingSub.value = `[${item.item_type}][${item.time}] ${item.name}`;
|
||||
@@ -197,11 +218,16 @@ async function getGachaLogs(pool: string, endId: string = "0"): Promise<void> {
|
||||
color: "error",
|
||||
text: `[${pool}][${gachaRes.retcode}] ${gachaRes.message}`,
|
||||
});
|
||||
await TGLogger.Error(`[UserGacha][${account.gameUid}][getGachaLogs] 获取祈愿数据失败`);
|
||||
await TGLogger.Error(
|
||||
`[UserGacha][${account.gameUid}][getGachaLogs] ${gachaRes.retcode} ${gachaRes.message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 导入按钮点击事件
|
||||
async function handleImportBtn(savePath?: string): Promise<void> {
|
||||
await TGLogger.Info("[UserGacha][handleImportBtn] 导入祈愿数据");
|
||||
let selectedFile;
|
||||
if (savePath) {
|
||||
selectedFile = await dialog.open({
|
||||
@@ -230,51 +256,55 @@ async function handleImportBtn(savePath?: string): Promise<void> {
|
||||
directory: false,
|
||||
});
|
||||
}
|
||||
if (selectedFile) {
|
||||
const check = await verifyUigfData(<string>selectedFile);
|
||||
if (!check) {
|
||||
showSnackbar({
|
||||
color: "error",
|
||||
text: "读取 UIGF 文件失败,请检查文件是否符合规范",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const remoteData = await readUigfData(<string>selectedFile);
|
||||
const res = await showConfirm({
|
||||
title: "是否导入祈愿数据?",
|
||||
text: `UID:${remoteData.info.uid} 共 ${remoteData.list.length} 条数据`,
|
||||
});
|
||||
if (!res) {
|
||||
showSnackbar({
|
||||
color: "cancel",
|
||||
text: "已取消祈愿数据导入",
|
||||
});
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = "正在导入祈愿数据";
|
||||
loading.value = true;
|
||||
if (remoteData.list.length === 0) {
|
||||
loading.value = false;
|
||||
showSnackbar({
|
||||
color: "error",
|
||||
text: "导入的祈愿数据为空",
|
||||
});
|
||||
} else {
|
||||
await TGSqlite.mergeUIGF(remoteData.info.uid, remoteData.list);
|
||||
loading.value = false;
|
||||
showSnackbar({
|
||||
text: `成功导入 ${remoteData.list.length} 条祈愿数据`,
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
} else {
|
||||
if (!selectedFile) {
|
||||
showSnackbar({
|
||||
color: "cancel",
|
||||
text: "已取消文件选择",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const check = await verifyUigfData(<string>selectedFile);
|
||||
if (!check) {
|
||||
showSnackbar({
|
||||
color: "error",
|
||||
text: "读取 UIGF 文件失败,请检查文件是否符合规范",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const remoteData = await readUigfData(<string>selectedFile);
|
||||
const res = await showConfirm({
|
||||
title: "是否导入祈愿数据?",
|
||||
text: `UID:${remoteData.info.uid} 共 ${remoteData.list.length} 条数据`,
|
||||
});
|
||||
await TGLogger.Info(`[UserGacha][${account.gameUid}][handleImportBtn] 确认导入祈愿数据`);
|
||||
if (!res) {
|
||||
showSnackbar({
|
||||
color: "cancel",
|
||||
text: "已取消祈愿数据导入",
|
||||
});
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = "正在导入祈愿数据";
|
||||
loading.value = true;
|
||||
if (remoteData.list.length === 0) {
|
||||
loading.value = false;
|
||||
showSnackbar({
|
||||
color: "error",
|
||||
text: "导入的祈愿数据为空",
|
||||
});
|
||||
return;
|
||||
}
|
||||
await TGSqlite.mergeUIGF(remoteData.info.uid, remoteData.list);
|
||||
loading.value = false;
|
||||
showSnackbar({
|
||||
text: `成功导入 ${remoteData.list.length} 条祈愿数据`,
|
||||
});
|
||||
await TGLogger.Info(
|
||||
`[UserGacha][handleImportBtn] 成功导入 ${remoteData.info.uid} 的 ${remoteData.list.length} 条祈愿数据`,
|
||||
);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// 导出按钮点击事件
|
||||
@@ -291,6 +321,7 @@ async function handleExportBtn(): Promise<void> {
|
||||
title: "是否导出祈愿数据?",
|
||||
text: `UID:${uidCur.value},共 ${gachaList.length} 条数据`,
|
||||
});
|
||||
await TGLogger.Info(`[UserGacha][${account.gameUid}][handleExportBtn] 导出祈愿数据`);
|
||||
if (!res) {
|
||||
showSnackbar({
|
||||
color: "cancel",
|
||||
@@ -315,6 +346,9 @@ async function handleExportBtn(): Promise<void> {
|
||||
});
|
||||
return;
|
||||
}
|
||||
await TGLogger.Info(
|
||||
`[UserGacha][${account.gameUid}][handleExportBtn] 导出${gachaList.length} 条祈愿数据到 ${file}`,
|
||||
);
|
||||
loadingTitle.value = "正在导出祈愿数据";
|
||||
loading.value = true;
|
||||
await exportUigfData(uidCur.value, gachaList, file);
|
||||
@@ -322,6 +356,7 @@ async function handleExportBtn(): Promise<void> {
|
||||
showSnackbar({
|
||||
text: "祈愿数据已成功导出",
|
||||
});
|
||||
await TGLogger.Info(`[UserGacha][${account.gameUid}][handleExportBtn] 导出祈愿数据完成`);
|
||||
}
|
||||
|
||||
// 恢复UID祈愿数据,相当于导入祈愿数据,不过目录固定
|
||||
@@ -338,6 +373,7 @@ async function backupGacha(): Promise<void> {
|
||||
});
|
||||
return;
|
||||
}
|
||||
await TGLogger.Info(`[UserGacha][${uidCur.value}][backupGacha] 备份祈愿数据`);
|
||||
const res = await showConfirm({
|
||||
title: "是否备份祈愿数据?",
|
||||
text: `UID:${uidCur.value},共 ${gachaListCur.value.length} 条数据`,
|
||||
@@ -347,6 +383,7 @@ async function backupGacha(): Promise<void> {
|
||||
color: "cancel",
|
||||
text: "已取消祈愿数据备份",
|
||||
});
|
||||
await TGLogger.Warn(`[UserGacha][${uidCur.value}][backupGacha] 已取消祈愿数据备份`);
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = "正在备份祈愿数据";
|
||||
@@ -356,6 +393,9 @@ async function backupGacha(): Promise<void> {
|
||||
showSnackbar({
|
||||
text: `已成功备份 ${uidCur.value} 的祈愿数据`,
|
||||
});
|
||||
await TGLogger.Info(
|
||||
`[UserGacha][${uidCur.value}][backupGacha] 成功备份 ${gachaListCur.value.length} 条祈愿数据`,
|
||||
);
|
||||
}
|
||||
|
||||
// 删除当前 UID 的祈愿数据
|
||||
@@ -367,6 +407,7 @@ async function deleteGacha(): Promise<void> {
|
||||
});
|
||||
return;
|
||||
}
|
||||
await TGLogger.Info(`[UserGacha][${uidCur.value}][deleteGacha] 删除祈愿数据`);
|
||||
const firstConfirm = await showConfirm({
|
||||
title: "是否删除祈愿数据?",
|
||||
text: `UID:${uidCur.value},共 ${gachaListCur.value.length} 条数据`,
|
||||
@@ -376,6 +417,7 @@ async function deleteGacha(): Promise<void> {
|
||||
color: "cancel",
|
||||
text: "已取消祈愿数据删除",
|
||||
});
|
||||
await TGLogger.Info(`[UserGacha][${uidCur.value}][deleteGacha] 已取消祈愿数据删除`);
|
||||
return;
|
||||
}
|
||||
const uidList = await TGSqlite.getUidList();
|
||||
@@ -391,6 +433,7 @@ async function deleteGacha(): Promise<void> {
|
||||
color: "cancel",
|
||||
text: "已取消祈愿数据删除",
|
||||
});
|
||||
await TGLogger.Info(`[UserGacha][${uidCur.value}][deleteGacha] 已取消祈愿数据删除`);
|
||||
return;
|
||||
}
|
||||
loadingTitle.value = `正在删除${uidCur.value}的祈愿数据`;
|
||||
@@ -400,6 +443,9 @@ async function deleteGacha(): Promise<void> {
|
||||
showSnackbar({
|
||||
text: `已成功删除 ${uidCur.value} 的祈愿数据`,
|
||||
});
|
||||
await TGLogger.Info(
|
||||
`[UserGacha][${uidCur.value}][deleteGacha] 成功删除 ${gachaListCur.value.length} 条祈愿数据`,
|
||||
);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
@@ -411,6 +457,9 @@ watch(uidCur, async (newUid) => {
|
||||
showSnackbar({
|
||||
text: `成功获取 ${gachaListCur.value.length} 条祈愿数据`,
|
||||
});
|
||||
await TGLogger.Info(
|
||||
`[UserGacha][${newUid}][watch] 成功获取 ${gachaListCur.value.length} 条祈愿数据`,
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -44,6 +44,7 @@ import TurOverviewGrid from "../../components/userRecord/tur-overview-grid.vue";
|
||||
import TurWorldGrid from "../../components/userRecord/tur-world-grid.vue";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
import { useUserStore } from "../../store/modules/user";
|
||||
import TGLogger from "../../utils/TGLogger";
|
||||
import { generateShareImg } from "../../utils/TGShare";
|
||||
import TGRequest from "../../web/request/TGRequest";
|
||||
|
||||
@@ -61,6 +62,7 @@ const isEmpty = ref<boolean>(true);
|
||||
const recordData = ref<TGApp.Sqlite.Record.SingleTable>(<TGApp.Sqlite.Record.SingleTable>{});
|
||||
|
||||
onMounted(async () => {
|
||||
await TGLogger.Info("[UserRecord][onMounted] 打开角色战绩页面");
|
||||
loadingTitle.value = "正在加载战绩数据";
|
||||
loading.value = true;
|
||||
await initUserRecordData();
|
||||
@@ -73,14 +75,17 @@ onMounted(async () => {
|
||||
async function initUserRecordData(): Promise<void> {
|
||||
const recordGet = await TGSqlite.getUserRecord(user.gameUid);
|
||||
if (recordGet !== false) {
|
||||
await TGLogger.Info(`[UserRecord][initUserRecordData][${user.gameUid}] 成功加载战绩数据`);
|
||||
recordData.value = recordGet;
|
||||
isEmpty.value = false;
|
||||
} else {
|
||||
await TGLogger.Info(`[UserRecord][initUserRecordData][${user.gameUid}] 未找到战绩数据`);
|
||||
isEmpty.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function refresh(): Promise<void> {
|
||||
await TGLogger.Info(`[UserRecord][refresh][${user.gameUid}] 刷新战绩数据`);
|
||||
loadingTitle.value = "正在获取战绩数据";
|
||||
loading.value = true;
|
||||
if (!userStore.cookie.value) {
|
||||
@@ -89,6 +94,7 @@ async function refresh(): Promise<void> {
|
||||
color: "error",
|
||||
});
|
||||
loading.value = false;
|
||||
await TGLogger.Warn(`[UserRecord][refresh][${user.gameUid}] 未登录`);
|
||||
return;
|
||||
}
|
||||
const cookie = {
|
||||
@@ -97,7 +103,8 @@ async function refresh(): Promise<void> {
|
||||
};
|
||||
const res = await TGRequest.User.getRecord(cookie, user);
|
||||
if (!("retcode" in res)) {
|
||||
console.log(res);
|
||||
await TGLogger.Info(`[UserRecord][refresh][${user.gameUid}] 获取战绩数据成功`);
|
||||
await TGLogger.Info(`[UserRecord][refresh][${user.gameUid}] ${JSON.stringify(res)}`, false);
|
||||
loadingTitle.value = "正在保存战绩数据";
|
||||
await TGSqlite.saveUserRecord(res, user.gameUid);
|
||||
await initUserRecordData();
|
||||
@@ -106,7 +113,8 @@ async function refresh(): Promise<void> {
|
||||
text: `[${res.retcode}] ${res.message}`,
|
||||
color: "error",
|
||||
});
|
||||
console.error(res);
|
||||
await TGLogger.Error(`[UserRecord][refresh][${user.gameUid}] 获取战绩数据失败`);
|
||||
await TGLogger.Error(`[UserRecord][refresh][${user.gameUid}] ${res.retcode} ${res.message}`);
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -117,6 +125,7 @@ function getTitle(): string {
|
||||
}
|
||||
|
||||
async function shareRecord(): Promise<void> {
|
||||
await TGLogger.Info(`[UserRecord][shareRecord][${user.gameUid}] 生成分享图片`);
|
||||
const recordBox = <HTMLElement>document.querySelector(".ur-box");
|
||||
const fileName = `【原神战绩】-${user.gameUid}`;
|
||||
loadingTitle.value = "正在生成图片";
|
||||
@@ -125,6 +134,7 @@ async function shareRecord(): Promise<void> {
|
||||
await generateShareImg(fileName, recordBox);
|
||||
loadingSub.value = "";
|
||||
loading.value = false;
|
||||
await TGLogger.Info(`[UserRecord][shareRecord][${user.gameUid}] 生成分享图片成功`);
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { dialog, fs, path } from "@tauri-apps/api";
|
||||
import { computed, nextTick, onBeforeMount, onMounted, ref } from "vue";
|
||||
import { computed, nextTick, onMounted, ref } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import showConfirm from "../../components/func/confirm";
|
||||
|
||||
@@ -62,8 +62,6 @@ function readLoading(): void {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const items = showHome.value.join("、");
|
||||
await TGLogger.Info(`[Home][onMounted] 打开首页,当前显示:${items}`);
|
||||
loadingTitle.value = "正在加载首页";
|
||||
const isProdEnv = import.meta.env.MODE === "production";
|
||||
// 获取当前环境
|
||||
@@ -85,6 +83,8 @@ onMounted(async () => {
|
||||
}),
|
||||
);
|
||||
timer.value = setInterval(readLoading, 100);
|
||||
const items = showHome.value.join("、");
|
||||
await TGLogger.Info(`[Home][onMounted] 打开首页,当前显示:${items}`);
|
||||
});
|
||||
|
||||
async function submitHome(): Promise<void> {
|
||||
@@ -109,9 +109,8 @@ async function submitHome(): Promise<void> {
|
||||
}
|
||||
|
||||
// 监听定时器
|
||||
onUpdated(() => {
|
||||
onUpdated(async () => {
|
||||
if (!loading.value && timer.value !== null) {
|
||||
TGLogger.Info("[Home][onMounted] 首页加载完成");
|
||||
clearInterval(timer.value);
|
||||
timer.value = null;
|
||||
}
|
||||
@@ -119,6 +118,9 @@ onUpdated(() => {
|
||||
|
||||
onUnmounted(() => {
|
||||
itemRefs.value = [];
|
||||
components.value = [];
|
||||
clearInterval(timer.value);
|
||||
timer.value = null;
|
||||
});
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
Reference in New Issue
Block a user