|
@@ -18,14 +18,18 @@
|
|
|
import ActionMenus from "@/components/group-button/index.vue";
|
|
|
import {generateMixMenus, MenuRaw, menus, findMenuByKey} from './menus'
|
|
|
import {joinActions} from './actions'
|
|
|
-import {computed, onUnmounted, watchEffect} from "vue";
|
|
|
+import {computed, onMounted, onUnmounted, watchEffect} from "vue";
|
|
|
import {disabledMap} from "@/hook";
|
|
|
|
|
|
const props = withDefaults(
|
|
|
defineProps<{ menus?: MenuRaw[], level?: number }>(),
|
|
|
{level: 1}
|
|
|
)
|
|
|
-const emit = defineEmits<{ (e: 'back'): void }>();
|
|
|
+const emit = defineEmits<{
|
|
|
+ (e: 'back'): void,
|
|
|
+ (e: 'enterChild'): void,
|
|
|
+ (e: 'leaveChild'): void,
|
|
|
+}>();
|
|
|
const backMenu = {
|
|
|
icon: "return",
|
|
|
text: "",
|
|
@@ -56,8 +60,30 @@ if (props.level === 1) {
|
|
|
watchEffect(() => {
|
|
|
disabledMap.photo = !store.child.value?.length
|
|
|
})
|
|
|
+ watchEffect(() => {
|
|
|
+ if (store.child.value) {
|
|
|
+ emit('enterChild')
|
|
|
+ } else {
|
|
|
+ emit('leaveChild')
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
onUnmounted(joinActions(store.itemActiveKey));
|
|
|
+onMounted(() => {
|
|
|
+ if (props.level > 1) {
|
|
|
+ const defaultMenu = props.menus.find(menu => {
|
|
|
+ if (typeof menu.defaultSelect === 'function') {
|
|
|
+ return menu.defaultSelect()
|
|
|
+ } else {
|
|
|
+ return menu.defaultSelect
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(defaultMenu)
|
|
|
+ store.itemActiveKey.value = defaultMenu?.key
|
|
|
+ // store.activeMenuKey.value =
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|
|
|
<script lang="ts"> export default {name: 'scene-menus'}</script>
|
|
|
|
|
@@ -69,4 +95,4 @@ onUnmounted(joinActions(store.itemActiveKey));
|
|
|
transform: translateY(-50%);
|
|
|
z-index: 2;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|