From 159fafce5c16df95e6782b60bd644b71701acd32 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期二, 14 六月 2022 16:11:49 +0800
Subject: [PATCH] 1.页面可调用接口登录

---
 src/permission.js               |   24 +++++--
 /dev/null                       |   24 --------
 src/api/user.js                 |    7 ++
 src/store/modules/permission.js |   23 +++----
 src/router/index.js             |   73 ++++++++++++++++++++++++
 5 files changed, 108 insertions(+), 43 deletions(-)

diff --git a/src/api/user.js b/src/api/user.js
index 43a99cf..2edbe7a 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -7,6 +7,13 @@
     params: data
   })
 }
+export function LoginMenu(data) {
+  return request({
+    url: 'Login/LoginMenu',
+    method: 'get',
+    params: data
+  })
+}
 
 export function getInfo(token) {
   return request({
diff --git a/src/permission.js b/src/permission.js
index 7881f68..89024f9 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -3,7 +3,7 @@
 import { Message } from 'element-ui'
 import NProgress from 'nprogress' // progress bar
 import 'nprogress/nprogress.css' // progress bar style
-import { getToken } from '@/utils/auth' // get token from cookie
+import { getCookie, getToken } from '@/utils/auth' // get token from cookie
 import getPageTitle from '@/utils/get-page-title'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
@@ -18,8 +18,8 @@
   document.title = getPageTitle(to.meta.title)
 
   // determine whether the user has logged in
-  const hasToken = getToken()
-
+  // const hasToken = getToken()
+  const hasToken = getCookie('admin')
   if (hasToken) {
     if (to.path === '/login') {
       // if is logged in, redirect to the home page
@@ -36,14 +36,24 @@
           // next()
 
           // 鎷夊彇info
-          const info = await store.dispatch('user/getInfo')
+          // const info = await store.dispatch('user/getInfo')
           // 鐢熸垚鍙闂殑璺敱琛�
-          await store.dispatch('permission/generateRoutes', info)
+          // await store.dispatch('permission/generateRoutes')
+
           // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛�
-          router.addRoutes(store.getters.addRouters)
+          // router.addRoutes(store.getters.addRouters)
 
           // hack鏂规硶 纭繚addRoutes宸插畬鎴�
-          next({ ...to, replace: true })
+          // next({ ...to, replace: true })
+
+          // console.log(store.getters.addRouters, 1)
+          // const s = store.getters.addRouters
+          // router.addRoutes(s)
+          // if (s) {
+          //   console.log(s)
+          // }
+          next()
+          // next({ ...to, replace: true })
         } catch (error) {
           // remove token and go to login page to re-login
           await store.dispatch('user/resetToken')
diff --git a/src/router/index.js b/src/router/index.js
index 591df6c..66962f9 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -41,6 +41,79 @@
     path: '/404',
     component: () => import('@/views/404'),
     hidden: true
+  },
+  {
+    path: '/redirect',
+    component: Layout,
+    hidden: true,
+    children: [
+      {
+        path: '/redirect/:path(.*)',
+        component: () => import('@/views/redirect/index')
+      }
+    ]
+  },
+  {
+    path: '/',
+    component: Layout,
+    redirect: '/index',
+    children: [{
+      path: 'index',
+      name: 'index',
+      component: () => import('@/views/xtsy/index'),
+      meta: { title: '绯荤粺棣栭〉', icon: 'dashboard' }
+    }]
+  },
+  {
+    path: '/jcsz',
+    component: Layout,
+    redirect: '/jcsz/zzjg',
+    name: 'jcsz',
+    meta: { title: '鍩虹璁剧疆', icon: 'el-icon-setting' },
+    children: [
+      {
+        path: 'zzjg',
+        name: 'Table',
+        component: () => import('@/views/jcsz/zzjg'),
+        meta: { title: '缁勭粐鏋舵瀯', icon: '' }
+      }, {
+        path: 'jsqd',
+        name: 'jsqd',
+        component: () => import('@/views/jcsz/jsqd'),
+        meta: { title: '瑙掕壊娓呭崟', icon: '' }
+      }, {
+        path: 'yhqd',
+        name: 'yhqd',
+        component: () => import('@/views/jcsz/yhqd'),
+        meta: { title: '鐢ㄦ埛娓呭崟', icon: '' }
+      }, {
+        path: 'wldw',
+        name: 'wldw',
+        component: () => import('@/views/jcsz/wldw'),
+        meta: { title: '寰�鏉ュ崟浣�', icon: '' }
+      }
+    ]
+  },
+  {
+    path: '/zzmx',
+    component: Layout,
+    redirect: '/zzmx/gylx',
+    name: 'zzmx',
+    meta: { title: '鍒堕�犳ā鍨�', icon: 'el-icon-s-help' },
+    children: [
+      {
+        path: 'gylx',
+        name: 'gylx',
+        component: () => import('@/views/zzmx/gylx'),
+        meta: { title: '鍏泭璺嚎', icon: 'table' }
+      },
+      {
+        path: 'jpgj',
+        name: 'jpgj',
+        component: () => import('@/views/zzmx/jpgj'),
+        meta: { title: '鑺傛媿宸ヤ环', icon: 'tree' }
+      }
+    ]
   }
 ]
 
diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js
index 8e7e811..b6cba09 100644
--- a/src/store/modules/permission.js
+++ b/src/store/modules/permission.js
@@ -102,17 +102,6 @@
       // '0'浠h〃false,'1'浠h〃true
       const routes = [
         {
-          path: '/redirect',
-          component: 'Layout',
-          hidden: '1',
-          children: [
-            {
-              path: '/redirect/:path(.*)',
-              component: '/redirect/index'
-            }
-          ]
-        },
-        {
           path: '/',
           component: 'Layout',
           redirect: '/index',
@@ -122,6 +111,17 @@
             component: '/xtsy/index',
             meta: { title: '绯荤粺棣栭〉', icon: 'el-icon-house', affix: '1' }
           }]
+        },
+        {
+          path: '/redirect',
+          component: 'Layout',
+          hidden: '1',
+          children: [
+            {
+              path: '/redirect/:path(.*)',
+              component: '/redirect/index'
+            }
+          ]
         },
         {
           path: '/jcsz',
@@ -188,7 +188,6 @@
       asyncRoutes.push({ path: '*', redirect: '/404', hidden: true })
       commit('SET_ROUTES', asyncRoutes)
       resolve(asyncRoutes)
-      console.log(asyncRoutes, 1)
     })
   }
 }
diff --git a/src/views/zzmx/test.vue b/src/views/zzmx/test.vue
deleted file mode 100644
index d8850db..0000000
--- a/src/views/zzmx/test.vue
+++ /dev/null
@@ -1,24 +0,0 @@
-<template>
-  <div>
-    <div class="text" contenteditable="true">鎴戞槸娴嬭瘯鍐呭</div>
-  </div>
-</template>
-
-<script>
-export default {
-  name: 'Test'
-}
-</script>
-
-<style scoped>
-.text{
-
-}
-
-[contenteditable]{
-  margin-left: 20px;
-  font-size: 20px;
-  color: blue;
-  caret-color: yellow;
-}
-</style>

--
Gitblit v1.9.3