From 1c04ba1d44f2408126eae1964b816ba770f7561c Mon Sep 17 00:00:00 2001 From: BTMuli Date: Thu, 6 Jul 2023 17:28:06 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/User/Characters.vue | 66 +++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/pages/User/Characters.vue b/src/pages/User/Characters.vue index eeab4d4d..c0f8fa97 100644 --- a/src/pages/User/Characters.vue +++ b/src/pages/User/Characters.vue @@ -59,7 +59,7 @@ const loadingSub = ref(); // data const isEmpty = ref(true); -const roleList = ref>([]); +const roleList = ref([]); const roleCookie = computed(() => userStore.getCookieGroup4()); const user = computed(() => userStore.getCurAccount()); @@ -82,13 +82,13 @@ onMounted(async () => { loading.value = false; }); -function getGridGap() { +function getGridGap(): void { const width = document.querySelector(".uc-grid")?.clientWidth - 20; const count = Math.floor(width / 180); gridGap.value = `${(width - count * 180) / (count - 1)}px`; } -async function loadRole() { +async function loadRole(): Promise { const roleData = await TGSqlite.getUserCharacter(user.value.gameUid); if (roleData !== false) { roleList.value = roleData; @@ -96,7 +96,7 @@ async function loadRole() { } } -async function refreshRoles() { +async function refreshRoles(): Promise { loadingTitle.value = "正在获取角色数据"; loading.value = true; const res = await TGRequest.User.byLToken.getRoleList(roleCookie.value, user.value); @@ -109,40 +109,44 @@ async function refreshRoles() { loading.value = false; } -async function refreshTalent() { +async function refreshTalent(): Promise { loadingTitle.value = "正在获取天赋数据"; loading.value = true; const talentCookie = userStore.getCookieGroup2(); - await Promise.allSettled( - roleList.value.map(async (role) => { - const res = await TGRequest.User.calculate.getSyncAvatarDetail( - talentCookie, - user.value.gameUid, - role.cid, - ); - if ("skill_list" in res) { - const talent: TGApp.Sqlite.Character.RoleTalent[] = []; - const avatar = res; - avatar.skill_list.map((skill, index) => { - return talent.push({ - id: skill.id, - pos: index, - level: skill.level_current, - max: skill.max_level, - name: skill.name, - icon: skill.icon, - }); + for (const role of roleList.value) { + loadingTitle.value = `正在获取${role.name}的天赋数据`; + loadingSub.value = `CID:${role.cid}`; + const res = await TGRequest.User.calculate.getSyncAvatarDetail( + talentCookie, + user.value.gameUid, + role.cid, + ); + if ("skill_list" in res) { + const talent: TGApp.Sqlite.Character.RoleTalent[] = []; + res.skill_list.map((skill, index) => { + return talent.push({ + id: skill.id, + pos: index, + level: skill.level_current, + max: skill.max_level, + name: skill.name, + icon: skill.icon, }); - return await TGSqlite.saveUserCharacterTalent(user.value.gameUid, role.cid, talent); - } - }), - ); + }); + await TGSqlite.saveUserCharacterTalent(user.value.gameUid, role.cid, talent); + } else { + loadingTitle.value = `获取${role.name}的天赋数据失败`; + loadingSub.value = `[${res.retcode}] ${res.message}`; + setTimeout(() => {}, 1000); + } + } loadingTitle.value = "正在更新天赋数据"; + loadingSub.value = ""; await loadRole(); loading.value = false; } -async function shareRoles() { +async function shareRoles(): Promise { const rolesBox = document.querySelector(".uc-box"); const fileName = `【角色列表】-${user.value.gameUid}`; loadingTitle.value = "正在生成图片"; @@ -153,7 +157,7 @@ async function shareRoles() { loading.value = false; } -function getUpdateTime() { +function getUpdateTime(): string { let lastUpdateTime = 0; roleList.value.forEach((role) => { const updateTime = new Date(role.updated).getTime(); @@ -164,7 +168,7 @@ function getUpdateTime() { return new Date(lastUpdateTime).toLocaleString().replace(/\//g, "-"); } -function selectRole(role: TGApp.Sqlite.Character.UserRole) { +function selectRole(role: TGApp.Sqlite.Character.UserRole): void { dataVal.value = role; visible.value = true; }