From ca334396d2e05706a60f00a3e63681abc0a0962a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Tue, 3 May 2022 22:46:02 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(component):=20=E6=96=B0=E5=A2=9E=20me?= =?UTF-8?q?nu=20=E7=BB=84=E4=BB=B6=20changeSelectedKey=20=E4=B8=8E=20chang?= =?UTF-8?q?eOpenKeys=20=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/component/src/component/menu/index.vue | 10 +++++----- package/component/src/provider/index.vue | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/package/component/src/component/menu/index.vue b/package/component/src/component/menu/index.vue index 210b5ed7..7abef206 100644 --- a/package/component/src/component/menu/index.vue +++ b/package/component/src/component/menu/index.vue @@ -19,7 +19,7 @@ export interface LayMenuProps { collapseTransition?: boolean | string; } -const emit = defineEmits(["update:selectedKey", "update:openKeys"]); +const emit = defineEmits(["update:selectedKey", "update:openKeys","changeSelectedKey","changeOpenKeys"]); const props = withDefaults(defineProps(), { selectedKey: "", @@ -43,6 +43,7 @@ const openKeys = computed({ }, set(val) { emit("update:openKeys", val); + emit("changeOpenKeys", val); }, }); @@ -52,6 +53,7 @@ const selectedKey = computed({ }, set(val) { emit("update:selectedKey", val); + emit("changeSelectedKey", val); }, }); @@ -59,12 +61,10 @@ watch( () => props.collapse, () => { if (props.collapse) { - // 删除所有打开 oldOpenKeys.value = props.openKeys; - emit("update:openKeys", []); + openKeys.value = []; } else { - // 赋值所有打开 - emit("update:openKeys", oldOpenKeys.value); + openKeys.value = oldOpenKeys.value; } }, { immediate: true } diff --git a/package/component/src/provider/index.vue b/package/component/src/provider/index.vue index 843c30db..2a68965e 100644 --- a/package/component/src/provider/index.vue +++ b/package/component/src/provider/index.vue @@ -8,10 +8,10 @@ export default { import { watch } from "vue"; import { useI18n } from "vue-i18n"; import { - enable as enableDarkMode, - disable as disableDarkMode, Theme, DynamicThemeFix, + enable as enableDarkMode, + disable as disableDarkMode, } from "darkreader"; const { locale, setLocaleMessage, mergeLocaleMessage } = useI18n(); @@ -60,9 +60,7 @@ const changeTheme = (theme: string) => { "div.layui-color-picker *", ], }; - Object.assign(defaultPartial, props.darkPartial); - if (theme === "dark") { enableDarkMode(defaultPartial, defaultFixes); } else if (theme === "light") {