✨(component): 新增 menu 组件 changeSelectedKey 与 changeOpenKeys 事件
This commit is contained in:
parent
9431b27389
commit
ca334396d2
@ -19,7 +19,7 @@ export interface LayMenuProps {
|
|||||||
collapseTransition?: boolean | string;
|
collapseTransition?: boolean | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits(["update:selectedKey", "update:openKeys"]);
|
const emit = defineEmits(["update:selectedKey", "update:openKeys","changeSelectedKey","changeOpenKeys"]);
|
||||||
|
|
||||||
const props = withDefaults(defineProps<LayMenuProps>(), {
|
const props = withDefaults(defineProps<LayMenuProps>(), {
|
||||||
selectedKey: "",
|
selectedKey: "",
|
||||||
@ -43,6 +43,7 @@ const openKeys = computed({
|
|||||||
},
|
},
|
||||||
set(val) {
|
set(val) {
|
||||||
emit("update:openKeys", val);
|
emit("update:openKeys", val);
|
||||||
|
emit("changeOpenKeys", val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ const selectedKey = computed({
|
|||||||
},
|
},
|
||||||
set(val) {
|
set(val) {
|
||||||
emit("update:selectedKey", val);
|
emit("update:selectedKey", val);
|
||||||
|
emit("changeSelectedKey", val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,12 +61,10 @@ watch(
|
|||||||
() => props.collapse,
|
() => props.collapse,
|
||||||
() => {
|
() => {
|
||||||
if (props.collapse) {
|
if (props.collapse) {
|
||||||
// 删除所有打开
|
|
||||||
oldOpenKeys.value = props.openKeys;
|
oldOpenKeys.value = props.openKeys;
|
||||||
emit("update:openKeys", []);
|
openKeys.value = [];
|
||||||
} else {
|
} else {
|
||||||
// 赋值所有打开
|
openKeys.value = oldOpenKeys.value;
|
||||||
emit("update:openKeys", oldOpenKeys.value);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
@ -8,10 +8,10 @@ export default {
|
|||||||
import { watch } from "vue";
|
import { watch } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import {
|
import {
|
||||||
enable as enableDarkMode,
|
|
||||||
disable as disableDarkMode,
|
|
||||||
Theme,
|
Theme,
|
||||||
DynamicThemeFix,
|
DynamicThemeFix,
|
||||||
|
enable as enableDarkMode,
|
||||||
|
disable as disableDarkMode,
|
||||||
} from "darkreader";
|
} from "darkreader";
|
||||||
|
|
||||||
const { locale, setLocaleMessage, mergeLocaleMessage } = useI18n();
|
const { locale, setLocaleMessage, mergeLocaleMessage } = useI18n();
|
||||||
@ -60,9 +60,7 @@ const changeTheme = (theme: string) => {
|
|||||||
"div.layui-color-picker *",
|
"div.layui-color-picker *",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(defaultPartial, props.darkPartial);
|
Object.assign(defaultPartial, props.darkPartial);
|
||||||
|
|
||||||
if (theme === "dark") {
|
if (theme === "dark") {
|
||||||
enableDarkMode(defaultPartial, defaultFixes);
|
enableDarkMode(defaultPartial, defaultFixes);
|
||||||
} else if (theme === "light") {
|
} else if (theme === "light") {
|
||||||
|
Loading…
Reference in New Issue
Block a user