import type { RouteRecordRaw } from 'vue-router';

import { preferences } from '@vben/preferences';

const BasicLayout = () => import('#/layouts/basic.vue');

/** 全局404页面 */
const fallbackNotFoundRoute: RouteRecordRaw = {
  component: BasicLayout,
  meta: {
    hideInBreadcrumb: true,
    hideInMenu: true,
    hideInTab: true,
    title: '404',
  },
  name: 'NotFound',
  path: '/FallbackNotFound',
  children: [
    {
      component: () => import('#/views/_core/fallback/not-found.vue'),
      meta: {
        hideInBreadcrumb: true,
        hideInMenu: true,
        hideInTab: true,
        title: '404',
      },
      name: 'FallbackNotFound',
      path: '/:path(.*)*',
    },
  ],
};

/** 基本路由 */
const coreRoutes: RouteRecordRaw[] = [
  /**
   * 根路由
   * 使用基础布局，作为所有页面的父级容器，子级就不必配置BasicLayout。
   * 此路由必须存在，且不应修改
   */
  {
    component: BasicLayout,
    meta: {
      hideInBreadcrumb: true,
      title: 'Root',
    },
    name: 'Root',
    path: '/',
    redirect: preferences.app.defaultHomePath,
    children: [],
  },
  {
    name: 'login',
    path: '/login',
    component: () => import('#/views/_core/login/Login.vue'),
    meta: {
      hideMenu: true,
      title: '登录',
      i18nCode: 'page.auth.login',
    },
  },
  {
    name: 'sso',
    path: '/sso',
    component: () => import('#/views/_core/login/ssoRedirect.vue'),
    meta: {
      hideMenu: true,
      title: '',
    },
  },
  {
    name: 'formShortLink',
    path: '/formShortLink',
    component: () => import('#/views/common/formShortLink/index.vue'),
    meta: {
      hideMenu: true,
      ignoreAccess: true,
      title: '',
    },
  },
  {
    path: '/flowChat',
    name: 'flowChat',
    component: () => import('#/views/workFlow/flowChart/index.vue'),
    meta: {
      hideMenu: true,
      ignoreAccess: true,
      title: '',
    },
  },
  {
    path: '/reportPreview',
    name: 'flowChat',
    component: () => import('#/views/common/dynamicReport/index.vue'),
    meta: {
      hideMenu: true,
      ignoreAccess: true,
      title: '',
    },
  },
  {
    path: '/forbidden',
    name: 'Forbidden',
    component: () => import('#/views/_core/fallback/forbidden.vue'),
    meta: {
      hideInBreadcrumb: true,
      hideInMenu: true,
      hideInTab: true,
      title: '403',
    },
  },
];

export { coreRoutes, fallbackNotFoundRoute };
