/*
 * @Author: wfl
 * @LastEditors: wfl
 * @description:
 * @updateInfo:
 * @Date: 2022-07-29 11:45:14
 * @LastEditTime: 2022-10-24 15:45:49
 */
import { t } from '@/global/hooks/web/useI18n';
import {
  EXCEPTION_COMPONENT,
  LAYOUT,
  PAGE_NOT_FOUND_NAME,
  REDIRECT_NAME,
} from '@/mainApp/router/constant';
import type { AppRouteRecordRaw } from '@/mainApp/router/types';

// 404 on a page
export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = {
  path: '/:path(.*)*',
  name: PAGE_NOT_FOUND_NAME,
  component: LAYOUT,
  meta: {
    title: 'ErrorPage',
    hideBreadcrumb: true,
    hideMenu: true,
  },
  children: [
    {
      path: '/micro-app',
      name: '',
      component: () => import('@/mainApp/views/sys-default/micro/micro.vue'),
      meta: {
        title: 'micro-app',
      },
    },
    {
      path: '/:path(.*)*',
      name: PAGE_NOT_FOUND_NAME,
      component: EXCEPTION_COMPONENT,
      meta: {
        title: 'ErrorPage',
        hideBreadcrumb: true,
        hideMenu: true,
      },
    },
  ],
};

export const REDIRECT_ROUTE: AppRouteRecordRaw = {
  path: '/redirect',
  component: LAYOUT,
  name: 'RedirectTo',
  meta: {
    title: REDIRECT_NAME,
    hideBreadcrumb: true,
    hideMenu: true,
  },
  children: [
    {
      path: '/redirect/:path(.*)',
      name: REDIRECT_NAME,
      component: () => import('@/mainApp/views/sys-default/redirect/index.vue'),
      meta: {
        title: REDIRECT_NAME,
        hideBreadcrumb: true,
      },
    },
  ],
};

export const ERROR_LOG_ROUTE: AppRouteRecordRaw = {
  path: '/error-log',
  name: 'ErrorLog',
  component: LAYOUT,
  redirect: '/error-log/list',
  meta: {
    title: 'ErrorLog',
    hideBreadcrumb: true,
    hideChildrenInMenu: true,
  },
  children: [
    {
      path: 'list',
      name: 'ErrorLogList',
      component: () => import('@/mainApp/views/sys-default/error-log/index.vue'),
      meta: {
        title: t('routes.basic.errorLogList'),
        hideBreadcrumb: true,
        currentActiveMenu: '/error-log',
      },
    },
  ],
};

export const FRAME_ROUTE: AppRouteRecordRaw = {
  path: '/frame',
  name: 'Frame',
  component: LAYOUT,
  redirect: '/frame/frame',
  meta: {
    title: 'FramePage',
  },
  children: [
    {
      path: 'frame',
      name: 'FramePage',
      component: () => import('@/mainApp/views/sys-default/iframe/index.vue'),
      meta: {
        title: '',
        hideBreadcrumb: true,
      },
    },
  ],
};
