This commit is contained in:
2026-07-11 11:14:12 +08:00
parent ee631cdc54
commit 74c6634186
18 changed files with 594 additions and 300 deletions
+34 -37
View File
@@ -34,6 +34,7 @@ export interface IConfigEquip {
export interface IConfigOath {
id: string;
adaptation: number;
upgrade: number[];
}
export interface IConfigEmblem {
@@ -107,6 +108,7 @@ const defaultAvatarConfig = {
const createDefaultOathConfig = (): IConfigOath => ({
id: "",
adaptation: 0,
upgrade: [0, 0, 0, 0],
});
const defaultOathConfig = createDefaultOathConfig();
@@ -118,22 +120,24 @@ const createDefaultEmblemConfig = (): IConfigEmblem => ({
const defaultEmblemConfig = createDefaultEmblemConfig();
const createDefaultConfig = (): IConfig => ({
skills: {},
equips: {},
oaths: {},
oathSkill: "1",
jades: {},
avatar: {},
sundry: {},
bindAwake: 50,
DSB: false,
BUFF: false,
options: {},
avatarLink: "",
emblems: {},
});
export const useConfigStore = defineStore("configStore", () => {
const config = ref<IConfig>({
skills: {},
equips: {},
oaths: {},
oathSkill: "1",
jades: {},
avatar: {},
sundry: {},
bindAwake: 50,
DSB: false,
BUFF: false,
options: {},
avatarLink: "",
emblems: {},
});
const config = ref<IConfig>(createDefaultConfig());
const skillCountConfig = ref<IResultSkillCount[]>([]);
const changeSourceLogs = ref<IChangeSourceLog[]>([]);
@@ -142,32 +146,22 @@ export const useConfigStore = defineStore("configStore", () => {
const infoStore = useInfoStore();
const alter = infoStore.infos?.alter;
// A character with no persisted data must start clean instead of inheriting the last role's
// in-memory configuration or skill-count overrides.
config.value = createDefaultConfig();
skillCountConfig.value = [];
if (alter) {
const localConfig = localStorage.getItem(`dcalc/${alter}/config`);
const localSkillConfig = localStorage.getItem(`dcalc/${alter}/config/skillCount`);
if (localConfig) {
config.value = JSON.parse(localConfig);
try {
if (localConfig) config.value = JSON.parse(localConfig) as IConfig;
if (localSkillConfig) skillCountConfig.value = JSON.parse(localSkillConfig) as IResultSkillCount[];
} catch {
// Ignore malformed legacy browser data and continue with the current schema defaults.
config.value = createDefaultConfig();
skillCountConfig.value = [];
}
if (localSkillConfig) {
skillCountConfig.value = JSON.parse(localSkillConfig);
}
}
if (!config.value) {
config.value = {
skills: {},
equips: {},
oaths: {},
oathSkill: "1",
jades: {},
avatar: {},
sundry: {},
bindAwake: 50,
DSB: false,
BUFF: false,
options: {},
avatarLink: "",
emblems: {},
};
}
if (!config.value?.equips) config.value.equips = {};
if (!config.value?.skills) config.value.skills = {};
@@ -205,6 +199,8 @@ export const useConfigStore = defineStore("configStore", () => {
config.value &&
!config.value?.oaths.hasOwnProperty(p) &&
(config.value.oaths[p.toString()] = createDefaultOathConfig());
const oath = config.value.oaths[p.toString()];
if (oath && !Array.isArray(oath.upgrade)) oath.upgrade = [0, 0, 0, 0];
});
infoStore.options.forEach((option) => {
@@ -310,6 +306,7 @@ export const useConfigStore = defineStore("configStore", () => {
chooseEqu,
skillCountConfig,
defaultEqusConfig,
createDefaultConfig,
defaultAvatarConfig,
defaultOathConfig,
createDefaultOathConfig,