<template>
    <div class="admin-layout">
        <a-menu v-model:openKeys="state.openKeys" v-model:selectedKeys="state.selectedKeys" style="width: 256px"
            :mode="state.mode" :items="items" :theme="state.theme"></a-menu>
        <div class="admin-contain">
           <router-view />
        </div>
    </div>
</template>
<script lang="ts" setup>
import { h, reactive } from 'vue';
import {
    MailOutlined,
    CalendarOutlined,
    AppstoreOutlined,
    SettingOutlined,
} from '@ant-design/icons-vue';
import type { MenuMode, MenuTheme } from 'ant-design-vue';
import { ItemType } from 'ant-design-vue';

const state = reactive({
    mode: 'inline' as MenuMode,
    theme: 'light' as MenuTheme,
    selectedKeys: ['1'],
    openKeys: ['sub1'],
});

function getItem(
    label: string,
    key: string,
    icon?: any,
    children?: ItemType[],
    type?: 'group',
): ItemType {
    return {
        key,
        icon,
        children,
        label,
        type,
    } as ItemType;
}

const items: ItemType[] = reactive([
    getItem('Navigation One', '1', h(MailOutlined)),
    getItem('Navigation Two', '2', h(CalendarOutlined)),
    getItem('Navigation Two', 'sub1', h(AppstoreOutlined), [
        getItem('Option 3', '3'),
        getItem('Option 4', '4'),
        getItem('Submenu', 'sub1-2', null, [getItem('Option 5', '5'), getItem('Option 6', '6')]),
    ]),
    getItem('Navigation Three', 'sub2', h(SettingOutlined), [
        getItem('Option 7', '7'),
        getItem('Option 8', '8'),
        getItem('Option 9', '9'),
        getItem('Option 10', '10'),
    ]),
]);

const changeMode = (checked: boolean) => {
    state.mode = checked ? 'vertical' : 'inline';
};

const changeTheme = (checked: boolean) => {
    state.theme = checked ? 'dark' : 'light';
};
</script>