loulijun2021
2022-06-14 159fafce5c16df95e6782b60bd644b71701acd32
1.页面可调用接口登录
已修改4个文件
已删除1个文件
151 ■■■■ 文件已修改
src/api/user.js 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/permission.js 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/permission.js 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/zzmx/test.vue 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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({
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')
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' }
      }
    ]
  }
]
src/store/modules/permission.js
@@ -102,17 +102,6 @@
      // '0'代表false,'1'代表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)
    })
  }
}
src/views/zzmx/test.vue
ÎļþÒÑɾ³ý