角色详情
|Render by TeyvatGuide v{{ version }}|
更新于 {{ getUpdateTime() }}
@@ -111,10 +122,11 @@ import { AppCharacterData } from "@/data/index.js";
import { useUserStore } from "@/store/modules/user.js";
import TGLogger from "@/utils/TGLogger.js";
import { generateShareImg } from "@/utils/TGShare.js";
-import { timestampToDate } from "@/utils/toolFunc.js";
+import { getZhElement, timestampToDate } from "@/utils/toolFunc.js";
import TakumiRecordGenshinApi from "@/web/request/recordReq.js";
type TabItem = { label: string; value: string };
+type OverviewItem = { element: string; cnt: number; label: string };
const modeList: Readonly
> = [
{ label: "经典视图", value: "classic" },
@@ -134,6 +146,7 @@ const showMode = ref<"classic" | "card" | "dev">("dev");
const resetSelect = ref(false);
const uidCur = ref();
const uidList = shallowRef>([]);
+const roleOverview = shallowRef>([]);
const roleList = shallowRef>([]);
const selectedList = shallowRef>([]);
const dataVal = shallowRef();
@@ -194,6 +207,20 @@ function getOrderedList(
});
}
+function getOverview(data: Array): Array {
+ const overview: Array = [];
+ for (const role of data) {
+ const element = role.avatar.element;
+ const index = overview.findIndex((item) => item.element === element);
+ if (index === -1) {
+ overview.push({ element, cnt: 1, label: `${getZhElement(element)}元素` });
+ } else {
+ overview[index].cnt += 1;
+ }
+ }
+ return overview.sort((a, b) => b.cnt - a.cnt);
+}
+
async function loadUid(): Promise {
uidList.value = await TSUserAvatar.getAllUid();
if (uidList.value.length === 0) uidList.value = [account.value.gameUid];
@@ -209,6 +236,7 @@ async function loadRole(): Promise {
roleList.value = [];
const roleData = await TSUserAvatar.getAvatars(Number(uidCur.value));
roleList.value = getOrderedList(roleData);
+ roleOverview.value = getOverview(roleData);
selectedList.value = roleList.value;
dataVal.value = roleData[selectIndex.value];
isEmpty.value = roleList.value.length === 0;
@@ -391,7 +419,29 @@ function handleSwitch(next: boolean): void {
dataVal.value = selectedList.value[selectIndex.value];
}
-