✨(component): 新增 menu 组件 changeSelectedKey 与 changeOpenKeys 事件
This commit is contained in:
parent
9431b27389
commit
ca334396d2
@ -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 }
|
||||
|
@ -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") {
|
||||
|
Loading…
Reference in New Issue
Block a user