<!--
 * @Author: vera_min vera_min@163.com
 * @Date: 2025-08-02 12:21:54
 * @LastEditors: vera_min vera_min@163.com
 * @LastEditTime: 2025-08-05 11:17:25
 * @FilePath: /sagoo-admin-ui/src/layout/navMenu/subItem.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
	<template v-for="val in chils">
		<el-sub-menu :index="val.path" :key="val.path" v-if="val.children && val.children.length > 0">
			<template #title>
				<SvgIcon :name="val.meta?.icon" />
				<span>{{ val.name.startsWith('message.') > 0 ? $t(val.name) : $t(val.meta?.title) }}</span>
			</template>
			<sub-item :chil="val.children" />
		</el-sub-menu>
		<template v-else>
			<el-menu-item :index="val.path" :key="val.path">
				<template v-if="!val.meta?.isLink || (val.meta?.isLink && val.meta.isIframe)">
					<SvgIcon :name="val.meta?.icon" />
					<span>{{ val.name.startsWith('message.') > 0 ? $t(val.name) : $t(val.meta?.title) }}</span>
				</template>
				<template v-else>
					<a :href="val.meta?.linkUrl" target="_blank" rel="opener" class="w100">
						<SvgIcon :name="val.meta?.icon" />
						{{ val.name.startsWith('message.') > 0 ? $t(val.name) : $t(val.meta?.title) }}
					</a>
				</template>
			</el-menu-item>
		</template>
	</template>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue';
export default defineComponent({
	name: 'navMenuSubItem',
	props: {
		chil: {
			type: Array,
			default: () => [],
		},
	},
	setup(props) {
		// 获取父级菜单数据
		const chils = computed(() => {
			return <any>props.chil;
		});
		return {
			chils,
		};
	},
});
</script>
