Browse Source

refactor: 111

lanjianrong 4 years ago
parent
commit
ff052eb587

+ 1 - 0
.vscode/settings.json

@@ -147,6 +147,7 @@
   },
   },
   "prettier.requireConfig": true,
   "prettier.requireConfig": true,
   "typescript.updateImportsOnFileMove.enabled": "always",
   "typescript.updateImportsOnFileMove.enabled": "always",
+  "typescript.validate.enable": false,
   "workbench.sideBar.location": "left",
   "workbench.sideBar.location": "left",
   "[javascriptreact]": {
   "[javascriptreact]": {
     "editor.defaultFormatter": "esbenp.prettier-vscode"
     "editor.defaultFormatter": "esbenp.prettier-vscode"

+ 2 - 2
src/enums/pageEnum.ts

@@ -1,10 +1,10 @@
 export enum PageEnum {
 export enum PageEnum {
   // basic login path
   // basic login path
-  BASE_LOGIN = '/login',
+  BASE_LOGIN = '/preview',
   // basic home path
   // basic home path
   BASE_HOME = '/home',
   BASE_HOME = '/home',
   // error page path
   // error page path
   ERROR_PAGE = '/exception',
   ERROR_PAGE = '/exception',
   // error log page path
   // error log page path
-  ERROR_LOG_PAGE = '/error-log/list',
+  ERROR_LOG_PAGE = '/error-log/list'
 }
 }

+ 14 - 14
src/router/index.ts

@@ -1,33 +1,33 @@
-import type { RouteRecordRaw } from 'vue-router';
-import type { App } from 'vue';
+import type { RouteRecordRaw } from 'vue-router'
+import type { App } from 'vue'
 
 
-import { createRouter, createWebHashHistory } from 'vue-router';
-import { basicRoutes, LoginRoute } from './routes';
-import { REDIRECT_NAME } from './constant';
+import { createRouter, createWebHashHistory } from 'vue-router'
+import { basicRoutes, LoginRoute } from './routes'
+import { REDIRECT_NAME } from './constant'
 
 
-const WHITE_NAME_LIST = [LoginRoute.name, REDIRECT_NAME];
+const WHITE_NAME_LIST = [LoginRoute.name, REDIRECT_NAME]
 
 
 // app router
 // app router
 const router = createRouter({
 const router = createRouter({
   history: createWebHashHistory(),
   history: createWebHashHistory(),
   routes: (basicRoutes as unknown) as RouteRecordRaw[],
   routes: (basicRoutes as unknown) as RouteRecordRaw[],
   strict: true,
   strict: true,
-  scrollBehavior: () => ({ left: 0, top: 0 }),
-});
+  scrollBehavior: () => ({ left: 0, top: 0 })
+})
 
 
 // reset router
 // reset router
 export function resetRouter() {
 export function resetRouter() {
-  router.getRoutes().forEach((route) => {
-    const { name } = route;
+  router.getRoutes().forEach(route => {
+    const { name } = route
     if (name && !WHITE_NAME_LIST.includes(name as string)) {
     if (name && !WHITE_NAME_LIST.includes(name as string)) {
-      router.hasRoute(name) && router.removeRoute(name);
+      router.hasRoute(name) && router.removeRoute(name)
     }
     }
-  });
+  })
 }
 }
 
 
 // config router
 // config router
 export function setupRouter(app: App<Element>) {
 export function setupRouter(app: App<Element>) {
-  app.use(router);
+  app.use(router)
 }
 }
 
 
-export default router;
+export default router

+ 0 - 5
src/router/routes/index.ts

@@ -40,10 +40,5 @@ export const LoginRoute: AppRouteRecordRaw = {
   }
   }
 }
 }
 
 
-export const PreviewRoute: AppRouteRecordRaw = {
-  path: '/preview',
-  name: 'Preview',
-  component: () => import('/@/views/sys/preview')
-}
 // Basic routing without permission
 // Basic routing without permission
 export const basicRoutes = [LoginRoute, RootRoute, ...mainOutRoutes, REDIRECT_ROUTE]
 export const basicRoutes = [LoginRoute, RootRoute, ...mainOutRoutes, REDIRECT_ROUTE]

+ 12 - 12
src/router/routes/mainOut.ts

@@ -3,20 +3,20 @@ The routing of this file will not show the layout.
 It is an independent new page.
 It is an independent new page.
 the contents of the file still need to log in to access
 the contents of the file still need to log in to access
  */
  */
-import type { AppRouteModule } from '/@/router/types';
+import type { AppRouteModule } from '/@/router/types'
 
 
 // test
 // test
 // http:ip:port/main-out
 // http:ip:port/main-out
 export const mainOutRoutes: AppRouteModule[] = [
 export const mainOutRoutes: AppRouteModule[] = [
-  // {
-  //   path: '/main-out',
-  //   name: 'MainOut',
-  //   component: () => import('/@/views/demo/main-out/index.vue'),
-  //   meta: {
-  //     title: 'MainOut',
-  //     ignoreAuth: true,
-  //   },
-  // },
-];
+  {
+    path: '/preview',
+    name: 'Preview',
+    component: () => import('/@/views/sys/preview/index.vue'),
+    meta: {
+      title: '预览页',
+      ignoreAuth: true
+    }
+  }
+]
 
 
-export const mainOutRouteNames = mainOutRoutes.map((item) => item.name);
+export const mainOutRouteNames = mainOutRoutes.map(item => item.name)

+ 1 - 1
src/views/sys/preview/index.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-  <div class="w-full h-full"> </div>
+  <div class="w-full h-full">预览页</div>
 </template>
 </template>
 
 
 <script lang="ts">
 <script lang="ts">

+ 2 - 1
tsconfig.json

@@ -24,7 +24,8 @@
     "skipLibCheck": true,
     "skipLibCheck": true,
     "paths": {
     "paths": {
       "/@/*": ["src/*"],
       "/@/*": ["src/*"],
-      "/#/*": ["types/*"]
+      "/#/*": ["types/*"],
+      "@/*": ["src/*"]
     }
     }
   },
   },
   "include": [
   "include": [