fix: vanillaCharCode not saved correctly

This commit is contained in:
--global 2024-08-04 00:21:16 +08:00
parent ef3f28c6de
commit 1649682b68
2 changed files with 8 additions and 3 deletions

View File

@ -61,8 +61,8 @@ onMounted(() => {
const element = toolbars[i];
const key = element.key;
if (element.hasOwnProperty("isActive")) {
element.isActive = appStore.setting.format[key as never] as boolean;
if (key === ToolBarModule.VANILLA_CHAR_CODE) {
element.isActive = appStore.setting.format.vanillaCharCode === '§';
}
}
});
@ -71,7 +71,7 @@ const onToolbarItemClickHandler = (item: ToolBarItem) => {
switch (item.key) {
case "vanillaCharCode":
item.isActive = !item.isActive;
appStore.setting.format.vanillaCharCode = item.isActive ? "§" : "&";
appStore.setVanillaCharCode(item.isActive ? "§" : "&");
emit("on-format-change");
break;
case "copy":

View File

@ -31,6 +31,11 @@ export const useAppStore = defineStore("app", {
return adapterMap.get(state.setting.usingAdapterKey);
},
},
actions: {
setVanillaCharCode(code: AppStoreState["setting"]["format"]["vanillaCharCode"]) {
this.setting.format.vanillaCharCode = code;
},
},
persist: {
paths: ["setting"],
},