diff --git a/src/pages/User/Abyss.vue b/src/pages/User/Abyss.vue index 9eae3409..f8a45d53 100644 --- a/src/pages/User/Abyss.vue +++ b/src/pages/User/Abyss.vue @@ -112,6 +112,7 @@ import TuaDetail from "@comp/userAbyss/tua-detail.vue"; import TuaOverview from "@comp/userAbyss/tua-overview.vue"; import recordReq from "@req/recordReq.js"; import TSUserAbyss from "@Sqlm/userAbyss.js"; +import useAppStore from "@store/app.js"; import useUserStore from "@store/user.js"; import { getVersion } from "@tauri-apps/api/app"; import { open } from "@tauri-apps/plugin-dialog"; @@ -123,6 +124,7 @@ import { onMounted, ref, shallowRef, watch } from "vue"; import { useRouter } from "vue-router"; const router = useRouter(); +const { isLogin } = storeToRefs(useAppStore()); const { account, cookie } = storeToRefs(useUserStore()); const userTab = ref(0); const version = ref(); @@ -135,10 +137,7 @@ onMounted(async () => { version.value = await getVersion(); await TGLogger.Info("[UserAbyss][onMounted] 打开角色深渊页面"); await showLoading.update("正在获取UID列表"); - uidList.value = await TSUserAbyss.getAllUid(); - if (uidList.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; - else if (uidList.value.length > 0) uidCur.value = uidList.value[0]; - else uidCur.value = ""; + await reloadUid(); await showLoading.update(`正在加载${uidCur.value}的深渊数据`); await showLoading.end(); showSnackbar.success(`已加载${uidCur.value}的${localAbyss.value.length}条深渊数据`); @@ -146,6 +145,16 @@ onMounted(async () => { watch(() => uidCur.value, loadAbyss); +async function reloadUid(): Promise { + uidList.value = await TSUserAbyss.getAllUid(); + if (uidList.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; + else if (uidList.value.length > 0) uidCur.value = uidList.value[0]; + else if (isLogin.value) { + uidList.value = [account.value.gameUid]; + uidCur.value = account.value.gameUid; + } else uidCur.value = undefined; +} + async function toCombat(): Promise { await router.push({ name: "真境剧诗" }); } @@ -218,8 +227,7 @@ async function refreshAbyss(): Promise { await TSUserAbyss.saveAbyss(account.value.gameUid, res); await TGLogger.Info(`[UserAbyss][getAbyssData] 成功获取${account.value.gameUid}的本期深渊数据`); await showLoading.update("正在加载深渊数据"); - uidList.value = await TSUserAbyss.getAllUid(); - uidCur.value = account.value.gameUid; + await reloadUid(); await loadAbyss(); await showLoading.end(); showSnackbar.success(`已加载${account.value.gameUid}的${localAbyss.value.length}条深渊数据`); @@ -254,9 +262,7 @@ async function deleteAbyss(): Promise { await TSUserAbyss.delAbyss(uidCur.value); await showLoading.end(); showSnackbar.success(`已清除 ${uidCur.value} 的深渊数据`); - uidList.value = await TSUserAbyss.getAllUid(); - if (uidList.value.length > 0) uidCur.value = uidList.value[0]; - else uidCur.value = undefined; + await reloadUid(); await loadAbyss(); } diff --git a/src/pages/User/Challenge.vue b/src/pages/User/Challenge.vue index 5805f2c6..8b79d4d7 100644 --- a/src/pages/User/Challenge.vue +++ b/src/pages/User/Challenge.vue @@ -142,6 +142,7 @@ import TucPopItem from "@comp/userChallenge/tuc-pop-item.vue"; import { GameServerEnum, getGameServerDesc } from "@enum/game.js"; import recordReq from "@req/recordReq.js"; import TSUserChallenge from "@Sqlm/userChallenge.js"; +import useAppStore from "@store/app.js"; import useUserStore from "@store/user.js"; import { getVersion } from "@tauri-apps/api/app"; import { open } from "@tauri-apps/plugin-dialog"; @@ -164,6 +165,7 @@ const serverList: ReadonlyArray> = [ ].map((i) => ({ text: getGameServerDesc(i), value: i })); const router = useRouter(); +const { isLogin } = storeToRefs(useAppStore()); const { account, cookie } = storeToRefs(useUserStore()); const version = ref(); @@ -238,13 +240,13 @@ async function shareChallenge(): Promise { async function reloadChallenge(): Promise { await showLoading.start("正在加载UID列表"); uidList.value = await TSUserChallenge.getAllUid(); - if (uidList.value.length === 0) { - uidCur.value = ""; - } else { - if (uidCur.value === undefined || uidCur.value === "") { - if (uidList.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; - else uidCur.value = uidList.value[0]; - } + if (uidList.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; + else if (uidList.value.length > 0) uidCur.value = uidList.value[0]; + else if (isLogin.value) { + uidList.value = [account.value.gameUid]; + uidCur.value = account.value.gameUid; + } else uidCur.value = undefined; + if (uidCur.value) { await showLoading.update(`正在加载UID${uidCur.value}的幽境危战数据`); await loadChallenge(); } @@ -316,7 +318,6 @@ async function refreshChallenge(): Promise { await TSUserChallenge.saveChallenge(account.value.gameUid, challenge); } isReq.value = false; - // await showLoading.end(); uidCur.value = account.value.gameUid; await reloadChallenge(); } diff --git a/src/pages/User/Characters.vue b/src/pages/User/Characters.vue index aac1ae34..6455fa8f 100644 --- a/src/pages/User/Characters.vue +++ b/src/pages/User/Characters.vue @@ -119,6 +119,7 @@ import TuaAvatarBox from "@comp/userAvatar/tua-avatar-box.vue"; import TuaDetailOverlay from "@comp/userAvatar/tua-detail-overlay.vue"; import recordReq from "@req/recordReq.js"; import TSUserAvatar from "@Sqlm/userAvatar.js"; +import useAppStore from "@store/app.js"; import useUserStore from "@store/user.js"; import { getVersion } from "@tauri-apps/api/app"; import TGLogger from "@utils/TGLogger.js"; @@ -137,7 +138,10 @@ const modeList: Readonly> = [ { label: "卡片视图(简略)", value: "card" }, { label: "卡片视图(详细)", value: "dev" }, ]; + +const { isLogin } = storeToRefs(useAppStore()); const { cookie, account, propMap } = storeToRefs(useUserStore()); + const loadData = ref(false); const loadShare = ref(false); const loadDel = ref(false); @@ -227,9 +231,12 @@ function getOverview(data: Array): Array { uidList.value = await TSUserAvatar.getAllUid(); - if (uidList.value.length === 0) uidList.value = [account.value.gameUid]; if (uidList.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; - else uidCur.value = uidList.value[0]; + else if (uidList.value.length > 0) uidCur.value = uidList.value[0]; + else if (isLogin.value) { + uidList.value = [account.value.gameUid]; + uidCur.value = account.value.gameUid; + } else uidCur.value = undefined; } async function loadRole(): Promise { diff --git a/src/pages/User/Combat.vue b/src/pages/User/Combat.vue index c92335f3..9ca6c94b 100644 --- a/src/pages/User/Combat.vue +++ b/src/pages/User/Combat.vue @@ -108,6 +108,7 @@ import TucOverview from "@comp/userCombat/tuc-overview.vue"; import TucRound from "@comp/userCombat/tuc-round.vue"; import recordReq from "@req/recordReq.js"; import TSUserCombat from "@Sqlm/userCombat.js"; +import useAppStore from "@store/app.js"; import useUserStore from "@store/user.js"; import { getVersion } from "@tauri-apps/api/app"; import { open } from "@tauri-apps/plugin-dialog"; @@ -119,6 +120,7 @@ import { onMounted, ref, shallowRef, watch } from "vue"; import { useRouter } from "vue-router"; const router = useRouter(); +const { isLogin } = storeToRefs(useAppStore()); const { account, cookie } = storeToRefs(useUserStore()); const userTab = ref(0); const version = ref(); @@ -131,15 +133,11 @@ onMounted(async () => { version.value = await getVersion(); await TGLogger.Info("[UserCombat][onMounted] 打开真境剧诗页面"); await showLoading.update("正在加载UID列表"); - uidList.value = await TSUserCombat.getAllUid(); - if (uidList.value.length === 0) { - uidCur.value = ""; - } else { - if (uidList.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; - else uidCur.value = uidList.value[0]; + await reloadUid(); + if (uidCur.value) { await showLoading.update(`正在加载UID${uidCur.value}的剧诗数据`); + await loadCombat(); } - await loadCombat(); await showLoading.end(); }); @@ -153,6 +151,16 @@ async function toChallenge(): Promise { await router.push({ name: "幽境危战" }); } +async function reloadUid(): Promise { + uidList.value = await TSUserCombat.getAllUid(); + if (uidList.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; + else if (uidList.value.length > 0) uidCur.value = uidList.value[0]; + else if (isLogin.value) { + uidList.value = [account.value.gameUid]; + uidCur.value = account.value.gameUid; + } else uidCur.value = undefined; +} + async function loadCombat(): Promise { localCombat.value = []; if (uidCur.value === undefined || uidCur.value === "") return; @@ -207,8 +215,7 @@ async function refreshCombat(): Promise { await TSUserCombat.saveCombat(account.value.gameUid, combat); } await showLoading.update("正在加载剧诗数据"); - uidList.value = await TSUserCombat.getAllUid(); - uidCur.value = account.value.gameUid; + await reloadUid(); await loadCombat(); await showLoading.end(); } @@ -242,9 +249,7 @@ async function deleteCombat(): Promise { await TSUserCombat.delCombat(uidCur.value); showSnackbar.success(`已清除 ${uidCur.value} 的剧诗数据`); await showLoading.update("正在加载剧诗数据"); - uidList.value = await TSUserCombat.getAllUid(); - if (uidList.value.length > 0) uidCur.value = uidList.value[0]; - else uidCur.value = undefined; + await reloadUid(); await loadCombat(); await showLoading.end(); } diff --git a/src/pages/User/Gacha.vue b/src/pages/User/Gacha.vue index afbd67d0..48ce1a18 100644 --- a/src/pages/User/Gacha.vue +++ b/src/pages/User/Gacha.vue @@ -45,8 +45,9 @@ prepend-icon="mdi-import" variant="elevated" @click="importUigf()" - >导入 + 导入 + 导出 + 导出 + 删除 + 删除 + (""); @@ -170,19 +173,14 @@ onMounted(async () => { } await showLoading.update("正在获取祈愿 UID 列表"); await TGLogger.Info("[UserGacha][onMounted] 进入角色祈愿页面"); - selectItem.value = await TSUserGacha.getUidList(); - if (selectItem.value.length === 0) { - await showLoading.end(); - showSnackbar.error("暂无祈愿数据,请先导入祈愿数据"); - await TGLogger.Warn("[UserGacha][onMounted] 暂无祈愿数据,请先导入祈愿数据"); - return; + await reloadUid(); + if (uidCur.value) { + await showLoading.update(`UID:${uidCur.value}`); + gachaListCur.value = await TSUserGacha.getGachaRecords(uidCur.value); + await TGLogger.Info( + `[UserGacha][onMounted] 获取到 ${uidCur.value} 的 ${gachaListCur.value.length} 条祈愿数据`, + ); } - uidCur.value = selectItem.value[0]; - await showLoading.update(`UID:${uidCur.value}`); - gachaListCur.value = await TSUserGacha.getGachaRecords(uidCur.value); - await TGLogger.Info( - `[UserGacha][onMounted] 获取到 ${uidCur.value} 的 ${gachaListCur.value.length} 条祈愿数据`, - ); await showLoading.end(); showSnackbar.success(`成功获取 ${gachaListCur.value.length} 条祈愿数据`); }); @@ -204,6 +202,16 @@ async function toBeyond(): Promise { await router.push({ name: "千星奇域祈愿记录" }); } +async function reloadUid(): Promise { + selectItem.value = await TSUserGacha.getUidList(); + if (selectItem.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; + if (selectItem.value.length > 0) uidCur.value = selectItem.value[0]; + else if (isLogin.value) { + selectItem.value = [account.value.gameUid]; + uidCur.value = account.value.gameUid; + } else uidCur.value = undefined; +} + // 刷新按钮点击事件 async function confirmRefresh(force: boolean): Promise { await TGLogger.Info(`[UserGacha][${account.value.gameUid}][confirmRefresh] 刷新祈愿数据`); diff --git a/src/pages/User/GachaB.vue b/src/pages/User/GachaB.vue index 3629695f..729f6617 100644 --- a/src/pages/User/GachaB.vue +++ b/src/pages/User/GachaB.vue @@ -95,18 +95,12 @@ const gachaListCur = shallowRef>([] onMounted(async () => { await TGLogger.Info("[UserGachaB][onMounted] 进入千星奇域页面"); await showLoading.start("正在加载千星奇域祈愿数据", "正在获取UID列表..."); - selectItem.value = await TSUserGachaB.getUidList(); - await TGLogger.Info(`[UserGachaB][onMounted] 总UID数:${selectItem.value.length}`); - if (selectItem.value.length === 0) { - await showLoading.end(); - await TGLogger.Info("[UserGachaB][onMounted] UID列表为空"); - return; + await reloadUid(); + if (uidCur.value) { + await showLoading.update(`UID: ${uidCur.value}`); + gachaListCur.value = await TSUserGachaB.getGachaRecords(uidCur.value); + await TGLogger.Info(`[UserGachaB][onMounted] 祈愿记录数: ${gachaListCur.value.length}`); } - uidCur.value = selectItem.value[0]; - await TGLogger.Info(`[UserGachaB][onMounted] 当前UID:${uidCur.value}`); - await showLoading.update(`UID: ${uidCur.value}`); - gachaListCur.value = await TSUserGachaB.getGachaRecords(uidCur.value); - await TGLogger.Info(`[UserGachaB][onMounted] 祈愿记录数: ${gachaListCur.value.length}`); await showLoading.end(); showSnackbar.success(`加载完成,共 ${gachaListCur.value.length} 条祈愿记录`); }); @@ -130,6 +124,16 @@ async function toGacha(): Promise { await router.push({ name: "祈愿记录" }); } +async function reloadUid(): Promise { + selectItem.value = await TSUserGachaB.getUidList(); + if (selectItem.value.includes(account.value.gameUid)) uidCur.value = account.value.gameUid; + else if (selectItem.value.length > 0) uidCur.value = selectItem.value[0]; + else if (isLogin.value) { + selectItem.value = [account.value.gameUid]; + uidCur.value = account.value.gameUid; + } else uidCur.value = undefined; +} + /** * 刷新祈愿数据 * @param {boolean} force 是否强制刷新 diff --git a/src/pages/User/Record.vue b/src/pages/User/Record.vue index a70404a8..04d4d135 100644 --- a/src/pages/User/Record.vue +++ b/src/pages/User/Record.vue @@ -1,3 +1,4 @@ +