import { RouteRecordRaw } from 'vue-router';
import { Session } from '/@/utils/storage';
/**
 * 建议：路由 path 路径与文件夹名称相同，找文件可浏览器地址找，方便定位文件位置
 *
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      isLink：        是否超链接菜单，开启外链条件，`1、isLink: 链接地址不为空 2、isIframe:false`
 *      isHide：        是否隐藏此路由
 *      isKeepAlive：   是否缓存组件状态
 *      isAffix：       是否固定在 tagsView 栏上
 *      isIframe：      是否内嵌窗口，开启条件，`1、isIframe:true 2、isLink：链接地址不为空`
 *      roles：         当前路由权限标识，取角色管理。控制路由显示、隐藏。超级管理员：admin 普通角色：common
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

// 扩展 RouteMeta 接口
declare module 'vue-router' {
	interface RouteMeta {
		title?: string;
		isLink?: string;
		isHide?: boolean;
		isKeepAlive?: boolean;
		isAffix?: boolean;
		isIframe?: boolean;
		roles?: string[];
		icon?: string;
	}
}

/**
 * 定义动态路由
 * 前端添加路由，请在顶级节点的 `children 数组` 里添加
 * @description 未开启 isRequestRoutes 为 true 时使用（前端控制路由），开启时第一个顶级 children 的路由将被替换成接口请求回来的路由数据
 * @description 各字段请查看 `/@/views/system/menu/component/addMenu.vue 下的 ruleForm`
 * @returns 返回路由菜单数据
 */
export const dynamicRoutes: Array<RouteRecordRaw> = [
	{
		path: '/',
		name: '/',
		component: () => import('/@/layout/index.vue'),
		redirect: '/index',
		meta: {
			isKeepAlive: true,
		},
		children: [
			{
				path: '/home',
				name: 'home',
				component: () => import('/@/views/pages/home/index.vue'),
				meta: {
					title: 'message.router.home',
					isLink: '',
					isHide: true,
					isKeepAlive: true,
					isAffix: true,
					isIframe: false,
					roles: ['admin', 'common', 'secondCommon'],
					icon: 'iconfont ele-Edit',
				},
			},
			{
				path: '/jindex',
				name: 'jindex',
				component: () => import('/@/views/pages/jnh/index.vue'),
				meta: {
					title: '账号管理',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: true,
					isIframe: false,
					roles: ['jnh'],
					icon: 'ele-Edit',
				},
			},
			{
				path: '/index',
				name: 'index',
				component: () => import('/@/views/pages/index/index.vue'),
				meta: {
					title: 'message.router.home',
					isLink: '',
					isHide: true,
					isKeepAlive: true,
					isAffix: true,
					isIframe: false,
					roles: ['admin', 'common', 'secondCommon'],
					icon: 'ele-Edit',
				},
			},
			{
				path: '/news',
				name: 'news',
				// component: () => import('/@/views/pages/news/index.vue'),
				meta: {
					title: '资讯管理',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: true,
					isIframe: false,
					roles: ['admin', 'common', 'secondCommon'],
					// icon: 'iconfont icon-diannao1',
					icon: 'ele-Edit',
				},
				children: [
					{
						path: '/richedit',
						name: 'richedit',
						component: () => import('/@/views/pages/richedit/index.vue'),
						meta: {
							title: '资讯精选',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['common'],
						},
					},
					{
						path: '/richedit',
						name: 'richedit',
						component: () => import('/@/views/pages/richedit/index.vue'),
						meta: {
							title: '资讯二审',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['secondCommon'],
						},
					},

					{
						path: '/richedit',
						name: 'richedit',
						component: () => import('/@/views/pages/richedit/index.vue'),
						meta: {
							title: Session.get('userInfoLocal')?.userType == '02' ? '资讯二审' : '资讯审核',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['admin'],
						},
					},
					{
						path: '/richeditall',
						name: 'richeditall',
						component: () => import('/@/views/pages/richedit/all.vue'),
						meta: {
							title: '资讯精选',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['admin', 'secondCommon'],
						},
					},
					{
						path: '/richeditMobile',
						name: 'richeditMobile',
						component: () => import('/@/views/pages/richedit/indexMobile.vue'),
						meta: {
							title: '资讯审核',
							isLink: '',
							isHide: true,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['admin'],
						},
					},
					{
						path: '/comprehensive',
						name: 'comprehensive',
						component: () => import('/@/views/pages/comprehensive/index.vue'),
						meta: {
							title: '全量资讯库',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['common'],
						},
					},
					{
						path: '/addrich',
						name: 'addrich',
						component: () => import('/@/views/pages/richedit/detail.vue'),
						meta: {
							title: '添加文章',
							isLink: '',
							isHide: true,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['admin', 'common', 'secondCommon'],
						},
					},
					// {
					// 	path: '/newsflash',
					// 	name: 'newsflash',
					// 	component: () => import('/@/views/pages/newsflash/index.vue'),
					// 	meta: {
					// 		title: '快讯管理',
					// 		isLink: '',
					// 		isHide: false,
					// 		isKeepAlive: true,
					// 		isAffix: true,
					// 		isIframe: false,
					// 		roles: ['admin', 'common'],
					// 	},
					// },
					// {
					// 	path: '/addnews',
					// 	name: 'addnews',
					// 	component: () => import('/@/views/pages/newsflash/detail.vue'),
					// 	meta: {
					// 		title: '添加快讯',
					// 		isLink: '',
					// 		isHide: true,
					// 		isKeepAlive: true,
					// 		isAffix: true,
					// 		isIframe: false,
					// 		roles: ['admin', 'common'],
					// 	},
					// },
				],
			},
			// {
			// 	path: '/column',
			// 	name: 'column',
			// 	// component: () => import('/@/views/pages/column/index.vue'),
			// 	meta: {
			// 		title: '栏目管理',
			// 		isLink: '',
			// 		isHide: false,
			// 		isKeepAlive: true,
			// 		isAffix: true,
			// 		isIframe: false,
			// 		roles: ['admin', 'common'],
			// 		icon: 'iconfont icon-zidingyibuju',
			// 	},
			// 	children: [
			// 		{
			// 			path: '/homeCol',
			// 			name: 'homeCol',
			// 			component: () => import('/@/views/pages/homeCol/index.vue'),
			// 			meta: {
			// 				title: '首页栏目',
			// 				isLink: '',
			// 				isHide: false,
			// 				isKeepAlive: true,
			// 				isAffix: true,
			// 				isIframe: false,
			// 				roles: ['admin', 'common'],
			// 			},
			// 		},
			// 		{
			// 			path: '/vipCol',
			// 			name: 'vipCol',
			// 			component: () => import('/@/views/pages/vipCol/index.vue'),
			// 			meta: {
			// 				title: 'vip栏目',
			// 				isLink: '',
			// 				isHide: false,
			// 				isKeepAlive: true,
			// 				isAffix: true,
			// 				isIframe: false,
			// 				roles: ['admin', 'common'],
			// 			},
			// 		},
			// 	],
			// },
			{
				path: '/tags',
				name: 'tags',
				// component: () => import('/@/views/pages/tags/index.vue'),
				meta: {
					title: '基础信息',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: true,
					isIframe: false,
					roles: ['common'],
					icon: 'ele-Document',
				},
				children: [
					{
						path: '/sourceTag',
						name: 'sourceTag',
						component: () => import('/@/views/pages/sourceTag/index.vue'),
						meta: {
							title: '媒体来源',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['admin', 'common'],
						},
					},
					{
						path: '/customTag',
						name: 'customTag',
						component: () => import('/@/views/pages/customTag/index.vue'),
						meta: {
							title: '概念标签',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['admin', 'common', 'secondCommon'],
						},
					},
					{
						path: '/industry',
						name: 'industry',
						component: () => import('/@/views/pages/industry/index.vue'),
						meta: {
							title: '行业分类',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: true,
							isIframe: false,
							roles: ['admin', 'common', 'secondCommon'],
						},
					},
				],
			},
			// {
			// 	path: '/userManagement',
			// 	name: 'userManagement',
			// 	component: () => import('/@/views/pages/userManagement/index.vue'),
			// 	meta: {
			// 		title: '用户管理',
			// 		isLink: '',
			// 		isHide: false,
			// 		isKeepAlive: true,
			// 		isAffix: true,
			// 		isIframe: false,
			// 		roles: ['admin', 'common'],
			// 		// icon: 'iconfont icon-diannao1',
			// 		icon: 'ele-UserFilled',
			// 	},
			// 	children: [],
			// },
		],
	},
];

/**
 * 定义404、401界面
 * @link 参考：https://next.router.vuejs.org/zh/guide/essentials/history-mode.html#netlify
 */
export const notFoundAndNoPower = [
	{
		path: '/:path(.*)*',
		name: 'notFound',
		component: () => import('/@/views/error/404.vue'),
		meta: {
			title: 'message.staticRoutes.notFound',
			isHide: true,
		},
	},
	{
		path: '/401',
		name: 'noPower',
		component: () => import('/@/views/error/401.vue'),
		meta: {
			title: 'message.staticRoutes.noPower',
			isHide: true,
		},
	},
];

/**
 * 定义静态路由（默认路由）
 * 此路由不要动，前端添加路由的话，请在 `dynamicRoutes 数组` 中添加
 * @description 前端控制直接改 dynamicRoutes 中的路由，后端控制不需要修改，请求接口路由数据时，会覆盖 dynamicRoutes 第一个顶级 children 的内容（全屏，不包含 layout 中的路由出口）
 * @returns 返回路由菜单数据
 */
export const staticRoutes: Array<RouteRecordRaw> = [
	{
		path: '/login',
		name: 'login',
		component: () => import('/@/views/login/index.vue'),
		meta: {
			title: '登录',
		},
	},
];
