(component): 新增 menu 组件 changeSelectedKey 与 changeOpenKeys 事件

This commit is contained in:
就眠儀式 2022-05-03 22:46:02 +08:00
parent 9431b27389
commit ca334396d2
2 changed files with 7 additions and 9 deletions

View File

@ -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<LayMenuProps>(), {
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 }

View File

@ -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") {