Skip to content

Commit

Permalink
fix: 修复store动态引入问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Jun 21, 2023
1 parent 9b716ac commit 223ff0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
21 changes: 12 additions & 9 deletions src/components/meWangEditor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<IDomEditor | undefined>();
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();
Expand Down
1 change: 0 additions & 1 deletion types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 223ff0d

Please sign in to comment.