diff --git a/src/components/meWangEditor/index.vue b/src/components/meWangEditor/index.vue index 3b6c6b23..af740e4d 100644 --- a/src/components/meWangEditor/index.vue +++ b/src/components/meWangEditor/index.vue @@ -64,20 +64,23 @@ const emit = defineEmits<{ (e: 'customAlert', s: string, t: string): void; (e: 'customPaste', editor: IDomEditor, event: ClipboardEvent): void; }>(); -const { i18n } = useGlobalStore(); +const { i18n } = storeToRefs(useGlobalStore()); // 编辑器实例,必须用 shallowRef const editorRef = shallowRef(); defineExpose({ editorRef }); //切换语言 const showEditor = ref(true); -i18nChangeLanguage(i18n.locale.value); -watch(i18n.locale, async (locale) => { - // 切换语言 - 'en' 或者 'zh-CN' - showEditor.value = false; - await nextTick(); - i18nChangeLanguage(locale); - showEditor.value = true; -}); +i18nChangeLanguage(i18n.value.locale.value); +watch( + () => i18n.value.locale.value, + async (locale) => { + // 切换语言 - 'en' 或者 'zh-CN' + showEditor.value = false; + await nextTick(); + i18nChangeLanguage(locale); + showEditor.value = true; + }, +); // 组件销毁时,也及时销毁编辑器 onBeforeUnmount(() => { editorRef.value && editorRef.value.destroy(); diff --git a/types/auto-imports.d.ts b/types/auto-imports.d.ts index 1d06c04e..1071a503 100644 --- a/types/auto-imports.d.ts +++ b/types/auto-imports.d.ts @@ -3,7 +3,6 @@ export {} declare global { const EffectScope: typeof import('vue')['EffectScope'] const ElLoading: typeof import('element-plus/es')['ElLoading'] - const ElMessageBox: typeof import('element-plus/es')['ElMessageBox'] const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef']