guoxiaohuan 4 年 前
コミット
2ecbcce68f
5 ファイル変更52 行追加60 行削除
  1. 5 2
      public/systemConf.js
  2. 1 0
      src/api/httputils.js
  3. 6 22
      src/main.ts
  4. 16 21
      src/router/index.js
  5. 24 15
      src/store/index.js

+ 5 - 2
public/systemConf.js

@@ -24,11 +24,14 @@ var __systemConf = {
     systemCode: 'wandaBmGuide',
     conf: {
         // 阿里云
-        editerUrl: 'http://60.205.177.43:80/wandaEditer/', // 编辑器地址
-        wandaBmGuideUrl: 'http://60.205.177.43:80/wandaBmGuide/', //管理书地址
+        // editerUrl: 'http://60.205.177.43:80/wandaEditer/', // 编辑器地址
+        // wandaBmGuideUrl: 'http://60.205.177.43:80/wandaBmGuide/', //管理书地址
         // http://glsms.wanda-dev.cn/ 测试服
         // editerUrl: 'http://glsms.wanda-dev.cn/wandaEditer/', // 编辑器地址
         // wandaBmGuideUrl: 'http://glsms.wanda-dev.cn/wandaBmGuide/', //管理书地址
+
+        editerUrl: 'http://localhost:8091/wandaEditer/', // 编辑器地址
+        wandaBmGuideUrl: 'http://localhost:8090/wandaBmGuide/', //管理书地址
     },
 }
 window.__systemConf = __systemConf

+ 1 - 0
src/api/httputils.js

@@ -32,6 +32,7 @@ axiosservice.interceptors.request.use(
         if (config.url.indexOf('/data') > -1) {
             config.headers = {
                 'sso-token': token,
+                isPreview: isPreview, //默认false,当预览开启的时候是true
             }
         }
         return config

+ 6 - 22
src/main.ts

@@ -29,10 +29,9 @@ import Pui from 'meri-design'
 import 'meri-design/dist/index.css'
 import 'leaflet/dist/leaflet.css'
 
-import {login} from './api/login.js';
+import { login } from './api/login.js'
 Vue.use(Pui)
 
- 
 //////////模拟传入参数
 const username = 'lengqiang'
 /////////////////
@@ -45,23 +44,8 @@ const username = 'lengqiang'
 //     }
 //     next()
 // })
-
-login({}).then( (res ) => {  // 获取用户当前权限
-    if (res.result === 'success') {
-        store.commit('STOREACCESSLEVEL', res)
-        new Vue({
-            router,
-            store,
-            render: (h) => h(App),
-            mounted() {
-                // let level = store.state.accessLevel
-                let level = 0
-                if (level === 0) {
-                    router.push({path:'./home/homepage'})
-                } else {
-                    router.push({path:'./group'})
-                }
-            },
-        }).$mount('#app')
-    }
-})
+new Vue({
+    router,
+    store,
+    render: (h) => h(App),
+}).$mount('#app')

+ 16 - 21
src/router/index.js

@@ -6,10 +6,10 @@ import { query } from '@/utils/query'
 Vue.use(VueRouter)
 const routes = [
     // 登陆页面
-    {
-        path: '/',
-        redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
-    },
+    // {
+    //     path: '/',
+    //     redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
+    // },
     {
         path: '/404',
         component: () => import('../components/404'),
@@ -73,28 +73,23 @@ const router = new VueRouter({
     routes,
 })
 //不需要token的路由
-const ignore = ['/404', '/legendLibrary', '/legendRules']
+const ignore = ['/404', '/home/legendLibrary', '/home/legendRules']
 router.beforeEach(async (to, from, next) => {
     if (!ignore.includes(to.path)) {
         console.log('vuex', store.state.accessLevel)
-        const token = query().token
-        const ssoToken = store.getters['ssoToken']
-        if (ssoToken) {
-            store.commit('SETSSOTOKEN', ssoToken)
-            await store.dispatch('getUserInfo', router)
+        const token = store.getters['ssoToken'] || query().token
+        if (token) {
+            store.commit('SETSSOTOKEN', token)
+            if (to.path == '/') {
+                next('/group')
+            }
+            if (to.path == '/group' || to.path == '/home/homepage') {
+                if (store.state.accessLevel == -1) {
+                    await store.dispatch('getUserInfo', router)
+                }
+            }
             await store.dispatch('getFloors')
             await store.dispatch('getBrand')
-            let level = store.state.accessLevel
-            console.log(level)
-            // if (level ===0) {
-            //     next('/group')
-            // } else {
-            //     next('/home/homepage')
-            // }
-            next()
-        } else if (token) {
-            store.commit('SETSSOTOKEN', token)
-            await store.dispatch('getUserInfo', router)
             next()
         } else {
             let lastRoute = {

+ 24 - 15
src/store/index.js

@@ -8,8 +8,8 @@ import router from '../router'
 Vue.use(Vuex)
 export default new Vuex.Store({
     state: {
-        ssoToken: 'admin:lengqiang',
-        // ssoToken: null,
+        // ssoToken: 'admin:lengqiang',
+        ssoToken: null,
         isPreview: false,
         lastRoute: '',
         isrequestAuth: true, // 是否请求登录校验接口
@@ -32,7 +32,7 @@ export default new Vuex.Store({
         remarksText: '', //备注
         bunkObj: {}, // 铺位名称
         currentFloor: {}, //当前选中的楼层信息
-        accessLevel: 0, //
+        accessLevel: -1, // 权限级别
         showView: 1,
     },
     getters: {
@@ -123,20 +123,29 @@ export default new Vuex.Store({
         // 获取项目列表、userId
         async getUserInfo({ commit }, palyload) {
             await login({}).then((res) => {
-                if (res.result == 'success') {
-                    commit('STOREACCESSLEVEL', res)
+                // 获取用户当前权限
+                console.log(res)
+                if (res.result === 'success') {
+                    commit('STOREACCESSLEVEL', res.level)
+                    let level = res.level
+                    if (level === 0) {
+                        router.push({ path: './home/homepage' })
+                    } else {
+                        router.push({ path: './group' })
+                    }
+                    // commit('SETISREQUESTtAUTH', false)
                 }
-                // token校验成功 拿到权限
-                //commit("SETISREQUESTtAUTH", true)
-                //     if (res.permissions.length == 0) {
-                //         router.push('/404')
-                //     }
-                //     commit('SETAUTHMSG', res)
-                // } else {
-                //     commit('SETISREQUESTtAUTH', false)
-                //     router.push('/404')
-                // }
             })
+            // token校验成功 拿到权限
+            //commit("SETISREQUESTtAUTH", true)
+            //     if (res.permissions.length == 0) {
+            //         router.push('/404')
+            //     }
+            //     commit('SETAUTHMSG', res)
+            // } else {
+            //     commit('SETISREQUESTtAUTH', false)
+            //     router.push('/404')
+            // }
         },
         getFloors(context) {
             queryFloor({