1
This commit is contained in:
@@ -13,7 +13,7 @@ export const useDnfHelperStore = defineStore("dnfHelperStore", () => {
|
||||
const loading = ref(false);
|
||||
const errorMessage = ref("");
|
||||
|
||||
const refleshHelperInfo = async (uid?: string) => {
|
||||
const refreshHelperInfoInner = async (uid?: string) => {
|
||||
if (!uid) return;
|
||||
loading.value = true;
|
||||
errorMessage.value = "";
|
||||
@@ -22,7 +22,6 @@ export const useDnfHelperStore = defineStore("dnfHelperStore", () => {
|
||||
if (data) {
|
||||
helperInfo.value = data;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
errorMessage.value = error instanceof Error ? error.message : "同步助手数据失败";
|
||||
throw error;
|
||||
@@ -32,7 +31,12 @@ export const useDnfHelperStore = defineStore("dnfHelperStore", () => {
|
||||
};
|
||||
|
||||
const refreshHelperInfo = async (uid?: string) => {
|
||||
await refleshHelperInfo(uid);
|
||||
await refreshHelperInfoInner(uid);
|
||||
};
|
||||
|
||||
// Keep compatibility with existing callers.
|
||||
const refleshHelperInfo = async (uid?: string) => {
|
||||
await refreshHelperInfoInner(uid);
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
|
||||
+102
-102
@@ -1,81 +1,81 @@
|
||||
import api from '@/api'
|
||||
import type { ICharacterInfo, IEquipment, ISuit } from '@/api/info/type'
|
||||
import { defineStore } from 'pinia'
|
||||
import { useConfigStore } from './config'
|
||||
import type { IResult, IResultSkill, IResultSkillCount } from '@/api/calc/type'
|
||||
import api from "@/api";
|
||||
import type { ICharacterInfo, IEquipment, ISuit } from "@/api/info/type";
|
||||
import { defineStore } from "pinia";
|
||||
import { useConfigStore } from "./config";
|
||||
import type { IResult, IResultSkill, IResultSkillCount } from "@/api/calc/type";
|
||||
|
||||
export const useInfoStore = defineStore('infoStore', () => {
|
||||
const alter_token = ref<string>('')
|
||||
const infos = ref<ICharacterInfo | null>(null)
|
||||
export const useInfoStore = defineStore("infoStore", () => {
|
||||
const alter_token = ref<string>("");
|
||||
const infos = ref<ICharacterInfo | null>(null);
|
||||
|
||||
const oathCache = ref<
|
||||
{
|
||||
suitId: string
|
||||
skillId: string
|
||||
rarity: string
|
||||
lv: number
|
||||
data: ISuit
|
||||
suitId: string;
|
||||
skillId: string;
|
||||
rarity: string;
|
||||
lv: number;
|
||||
data: ISuit;
|
||||
}[]
|
||||
>([])
|
||||
>([]);
|
||||
|
||||
const skills = computed(() => infos.value?.skills ?? [])
|
||||
const skills = computed(() => infos.value?.skills ?? []);
|
||||
|
||||
const equips = computed(() => infos.value?.equips ?? [])
|
||||
const equips = computed(() => infos.value?.equips ?? []);
|
||||
|
||||
const suits = computed(() => infos.value?.suits ?? [])
|
||||
const suits = computed(() => infos.value?.suits ?? []);
|
||||
|
||||
const enchants = computed(() => infos.value?.enchants ?? [])
|
||||
const enchants = computed(() => infos.value?.enchants ?? []);
|
||||
|
||||
const emblems = computed(() => infos.value?.emblems ?? [])
|
||||
const emblems = computed(() => infos.value?.emblems ?? []);
|
||||
|
||||
// const stones = computed(() => infos.value?.stones ?? [])
|
||||
|
||||
const avatars = computed(() => infos.value?.avatar ?? {})
|
||||
const avatars = computed(() => infos.value?.avatar ?? {});
|
||||
|
||||
const jades = computed(() => infos.value?.jades ?? [])
|
||||
const jades = computed(() => infos.value?.jades ?? []);
|
||||
|
||||
const sundries = computed(() => infos.value?.sundry ?? {})
|
||||
const sundries = computed(() => infos.value?.sundry ?? {});
|
||||
|
||||
const options = computed(() => infos.value?.options ?? [])
|
||||
const options = computed(() => infos.value?.options ?? []);
|
||||
|
||||
const oaths = computed(() => {
|
||||
const origin = infos.value?.oaths ?? []
|
||||
const result: IEquipment[] = []
|
||||
const origin = infos.value?.oaths ?? [];
|
||||
const result: IEquipment[] = [];
|
||||
origin.forEach((o) => {
|
||||
o.position.forEach((p, i) => {
|
||||
o.position.forEach((p) => {
|
||||
result.push({
|
||||
...o,
|
||||
oathPos: p,
|
||||
displayUrl: o.wearUrl?.[parseInt(p)]
|
||||
? `/equipment/icon/oathprimer/primer_equip/${o.wearUrl?.[parseInt(p)]}`
|
||||
: o.imageUrl,
|
||||
})
|
||||
})
|
||||
})
|
||||
return result
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
const getOathInfo = async (suitId: string, skillId: string, rarity: string, lv: number) => {
|
||||
const res = oathCache.value.find(
|
||||
(o) => o.suitId === suitId && o.skillId === skillId && o.rarity === rarity && o.lv === lv,
|
||||
)
|
||||
);
|
||||
if (res) {
|
||||
return {
|
||||
...res.data,
|
||||
}
|
||||
};
|
||||
}
|
||||
const data: ISuit = await api.getOathInfo(suitId, skillId, rarity, lv)
|
||||
oathCache.value.push({ suitId, skillId, rarity, lv, data })
|
||||
const data: ISuit = await api.getOathInfo(suitId, skillId, rarity, lv);
|
||||
oathCache.value.push({ suitId, skillId, rarity, lv, data });
|
||||
return {
|
||||
...data,
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const oathSkills = computed(() => {
|
||||
const origin = infos.value?.oaths_skills
|
||||
if (!origin) return origin
|
||||
const origin = infos.value?.oaths_skills;
|
||||
if (!origin) return origin;
|
||||
|
||||
const skillOrder = ['2', '1', '3']
|
||||
const skillOrder = ["2", "1", "3"];
|
||||
|
||||
return Object.fromEntries(
|
||||
Object.entries(origin).map(([key, value]) => [
|
||||
@@ -83,90 +83,90 @@ export const useInfoStore = defineStore('infoStore', () => {
|
||||
{
|
||||
...value,
|
||||
skills: [...value.skills].sort((left, right) => {
|
||||
const leftIndex = skillOrder.indexOf(left.skillId)
|
||||
const rightIndex = skillOrder.indexOf(right.skillId)
|
||||
const normalizedLeftIndex = leftIndex === -1 ? skillOrder.length : leftIndex
|
||||
const normalizedRightIndex = rightIndex === -1 ? skillOrder.length : rightIndex
|
||||
const leftIndex = skillOrder.indexOf(left.skillId);
|
||||
const rightIndex = skillOrder.indexOf(right.skillId);
|
||||
const normalizedLeftIndex = leftIndex === -1 ? skillOrder.length : leftIndex;
|
||||
const normalizedRightIndex = rightIndex === -1 ? skillOrder.length : rightIndex;
|
||||
|
||||
return normalizedLeftIndex - normalizedRightIndex
|
||||
return normalizedLeftIndex - normalizedRightIndex;
|
||||
}),
|
||||
},
|
||||
]),
|
||||
)
|
||||
})
|
||||
const standardUUID = ref<string>()
|
||||
);
|
||||
});
|
||||
const standardUUID = ref<string>();
|
||||
|
||||
const setStandard = (
|
||||
result?: IResult,
|
||||
skillCount?: {
|
||||
count: number
|
||||
mode: string
|
||||
name: string
|
||||
count: number;
|
||||
mode: string;
|
||||
name: string;
|
||||
}[],
|
||||
) => {
|
||||
if (!result) {
|
||||
if (!!standardUUID.value) {
|
||||
sessionStorage.removeItem(standardUUID.value)
|
||||
if (standardUUID.value) {
|
||||
sessionStorage.removeItem(standardUUID.value);
|
||||
}
|
||||
standardUUID.value = undefined
|
||||
standardUUID.value = undefined;
|
||||
} else {
|
||||
standardUUID.value = result.uuid
|
||||
sessionStorage.setItem(result.uuid, JSON.stringify({ skills: result.skills, skillCount }))
|
||||
standardUUID.value = result.uuid;
|
||||
sessionStorage.setItem(result.uuid, JSON.stringify({ skills: result.skills, skillCount }));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const standard = computed(() => {
|
||||
const value = sessionStorage.getItem(standardUUID.value ?? '')
|
||||
if (!value) return undefined
|
||||
else return JSON.parse(value) as { skills: IResultSkill[]; skillCount: IResultSkillCount[] }
|
||||
})
|
||||
const value = sessionStorage.getItem(standardUUID.value ?? "");
|
||||
if (!value) return undefined;
|
||||
else return JSON.parse(value) as { skills: IResultSkill[]; skillCount: IResultSkillCount[] };
|
||||
});
|
||||
|
||||
const parts = [
|
||||
'头肩',
|
||||
'上衣',
|
||||
'下装',
|
||||
'腰带',
|
||||
'鞋',
|
||||
'武器',
|
||||
'称号',
|
||||
'手镯',
|
||||
'项链',
|
||||
'辅助装备',
|
||||
'戒指',
|
||||
'耳环',
|
||||
'魔法石',
|
||||
'宠物',
|
||||
]
|
||||
"头肩",
|
||||
"上衣",
|
||||
"下装",
|
||||
"腰带",
|
||||
"鞋",
|
||||
"武器",
|
||||
"称号",
|
||||
"手镯",
|
||||
"项链",
|
||||
"辅助装备",
|
||||
"戒指",
|
||||
"耳环",
|
||||
"魔法石",
|
||||
"宠物",
|
||||
];
|
||||
|
||||
const avatarParts = [
|
||||
'武器装扮',
|
||||
'头部',
|
||||
'帽子',
|
||||
'脸部',
|
||||
'光环',
|
||||
'胸部',
|
||||
'上衣',
|
||||
'皮肤',
|
||||
'快捷栏装备',
|
||||
'腰带',
|
||||
'下装',
|
||||
'鞋',
|
||||
'宠物',
|
||||
'宠物装备-红',
|
||||
'宠物装备-绿',
|
||||
'宠物装备-蓝',
|
||||
]
|
||||
"武器装扮",
|
||||
"头部",
|
||||
"帽子",
|
||||
"脸部",
|
||||
"光环",
|
||||
"胸部",
|
||||
"上衣",
|
||||
"皮肤",
|
||||
"快捷栏装备",
|
||||
"腰带",
|
||||
"下装",
|
||||
"鞋",
|
||||
"宠物",
|
||||
"宠物装备-红",
|
||||
"宠物装备-绿",
|
||||
"宠物装备-蓝",
|
||||
];
|
||||
|
||||
const oathParts = Array.from({ length: 12 }, (_, i) => i.toString())
|
||||
const oathParts = Array.from({ length: 12 }, (_, i) => i.toString());
|
||||
|
||||
const emblemParts = ['彩色', '红色', '蓝色', '绿色', '黄色', '白金']
|
||||
const emblemParts = ["彩色", "红色", "蓝色", "绿色", "黄色", "白金"];
|
||||
|
||||
const createCharacter = async (alter: string, equVersion?: string) => {
|
||||
const time = new Date().getTime()
|
||||
alter_token.value = btoa(JSON.stringify({ alter, equVersion, time }))
|
||||
infos.value = await api.characterInfo()
|
||||
useConfigStore().loadConfig()
|
||||
}
|
||||
const time = new Date().getTime();
|
||||
alter_token.value = btoa(JSON.stringify({ alter, equVersion, time }));
|
||||
infos.value = await api.characterInfo();
|
||||
useConfigStore().loadConfig();
|
||||
};
|
||||
|
||||
return {
|
||||
alter_token,
|
||||
@@ -190,5 +190,5 @@ export const useInfoStore = defineStore('infoStore', () => {
|
||||
options,
|
||||
oathSkills,
|
||||
getOathInfo,
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user