import { type ModuleConfig } from '/@/cool';
import { router } from '/@/cool';
import './service';

export default (): ModuleConfig => {
	return {
		order: 11,
		views: [
			{
				path: '/dingtalk/config',
				meta: {
					label: '钉钉配置'
				},
				component: () => import('./views/config.vue')
			},
			{
				path: '/dingtalk/sync',
				meta: {
					label: '同步管理'
				},
				component: () => import('./views/sync.vue')
			},
			{
				path: '/dingtalk/sync-log',
				meta: {
					label: '同步日志'
				},
				component: () => import('./views/sync-log.vue')
			},
			{
				path: '/dingtalk/department',
				meta: {
					label: '部门管理'
				},
				component: () => import('./views/department.vue')
			}
		],
		onLoad() {
			// 确保路由被正确添加到 router 中
			const moduleRoutes = [
				{
					path: '/dingtalk/config',
					meta: {
						label: '钉钉配置'
					},
					component: () => import('./views/config.vue')
				},
				{
					path: '/dingtalk/sync',
					meta: {
						label: '同步管理'
					},
					component: () => import('./views/sync.vue')
				},
				{
					path: '/dingtalk/sync-log',
					meta: {
						label: '同步日志'
					},
					component: () => import('./views/sync-log.vue')
				},
				{
					path: '/dingtalk/department',
					meta: {
						label: '部门管理'
					},
					component: () => import('./views/department.vue')
				}
			];

			// 将路由添加到 router 中
			router.append(moduleRoutes);
		}
	};
};
