Browse Source

登录路由修改

dev
jiangyy 5 years ago
parent
commit
8094ae07e7
  1. 13
      epmet-oper-web/src/App.vue
  2. 34
      epmet-oper-web/src/js/store/modules/app.js
  3. 3
      epmet-oper-web/src/js/store/type.js
  4. 52
      epmet-oper-web/src/router/index.js
  5. 83
      epmet-oper-web/src/views/main-navbar.vue
  6. 3
      epmet-oper-web/src/views/pages/login.vue
  7. 13
      epmet-oper-web/src/views/pages/loginWork.vue

13
epmet-oper-web/src/App.vue

@ -9,6 +9,7 @@ import { mapActions } from 'vuex'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { messages } from '@/i18n' import { messages } from '@/i18n'
import Vue from 'vue' import Vue from 'vue'
import { mapGetters } from 'vuex'
export default { export default {
watch: { watch: {
'$i18n.locale': 'i18nHandle' '$i18n.locale': 'i18nHandle'
@ -39,10 +40,18 @@ export default {
}) })
}) })
}, },
...mapActions(['setClientHeight', 'setSize', 'setResolution', 'setEnv']) ...mapActions(['setClientHeight', 'setSize', 'setResolution', 'setEnv', 'setUserType'])
},
computed: {
...mapGetters(['userType'])
}, },
mounted () { mounted () {
const that = this const that = this
if (!that.userType || that.userType === '') {
that.setUserType('oper')
}
console.log(that.userType)
let envShow = process.env.VUE_APP_NODE_ENV let envShow = process.env.VUE_APP_NODE_ENV
let env = 'dev' let env = 'dev'
if (envShow === 'dev' || envShow === 'prod:sit') { // if (envShow === 'dev' || envShow === 'prod:sit') { //
@ -76,7 +85,7 @@ export default {
if (!that.timer) { if (!that.timer) {
that.timer = true that.timer = true
// window.onresizevuex // window.onresizevuex
setTimeout(function () { setTimeout(function() {
that.setClientHeight(document.documentElement.clientHeight) that.setClientHeight(document.documentElement.clientHeight)
// debugger // debugger
if (document.documentElement.clientHeight < 800) { if (document.documentElement.clientHeight < 800) {

34
epmet-oper-web/src/js/store/modules/app.js

@ -5,40 +5,48 @@ export default {
clientHeight: document.documentElement.clientHeight, clientHeight: document.documentElement.clientHeight,
size: 'medium', size: 'medium',
resolution: 'medium', resolution: 'medium',
env: 'dev' env: 'dev',
userType: 'oper'
}, },
getters: { getters: {
clientHeight: state => state.clientHeight, clientHeight: (state) => state.clientHeight,
size: state => state.size, size: (state) => state.size,
resolution: state => state.resolution, resolution: (state) => state.resolution,
env: state => state.env env: (state) => state.env,
userType: (state) => state.userType
}, },
mutations: { mutations: {
[type.client_height] (state, payload) { [type.client_height](state, payload) {
state.clientHeight = payload state.clientHeight = payload
}, },
[type.size] (state, payload) { [type.size](state, payload) {
state.size = payload state.size = payload
}, },
[type.resolution] (state, payload) { [type.resolution](state, payload) {
state.resolution = payload state.resolution = payload
}, },
[type.env] (state, payload) { [type.env](state, payload) {
state.env = payload state.env = payload
},
[type.user_type](state, payload) {
state.userType = payload
} }
}, },
actions: { actions: {
setClientHeight ({ commit }, payload) { setClientHeight({ commit }, payload) {
commit(type.client_height, payload) commit(type.client_height, payload)
}, },
setSize ({ commit }, payload) { setSize({ commit }, payload) {
commit(type.size, payload) commit(type.size, payload)
}, },
setResolution ({ commit }, payload) { setResolution({ commit }, payload) {
commit(type.resolution, payload) commit(type.resolution, payload)
}, },
setEnv ({ commit }, payload) { setEnv({ commit }, payload) {
commit(type.env, payload) commit(type.env, payload)
},
setUserType({ commit }, payload) {
commit(type.user_type, payload)
} }
} }
} }

3
epmet-oper-web/src/js/store/type.js

@ -2,5 +2,6 @@ export default {
client_height: 'CLIENT_HEIGHT', client_height: 'CLIENT_HEIGHT',
size: 'SIZE', size: 'SIZE',
resolution: 'RESOLUTION', resolution: 'RESOLUTION',
env: 'ENV' env: 'ENV',
user_type: 'USER_TYPE'
} }

52
epmet-oper-web/src/router/index.js

@ -2,6 +2,7 @@ import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import http from '@/utils/request' import http from '@/utils/request'
import { isURL } from '@/utils/validate' import { isURL } from '@/utils/validate'
import store from '@/js/store'
Vue.use(Router) Vue.use(Router)
@ -98,6 +99,7 @@ router.beforeEach((to, from, next) => {
) { ) {
return next() return next()
} }
// 获取字典列表, 添加并全局变量保存 // 获取字典列表, 添加并全局变量保存
http http
.get('/sys/dict/type/all') .get('/sys/dict/type/all')
@ -109,21 +111,41 @@ router.beforeEach((to, from, next) => {
}) })
.catch(() => {}) .catch(() => {})
// 获取菜单列表, 添加并全局变量保存 // 获取菜单列表, 添加并全局变量保存
http const userType = store.state.app.userType
.get('/oper/access/menu/nav') debugger
.then(({ data: res }) => { if (userType === 'work') {
if (res.code !== 0) { http
// Vue.prototype.$message.error(res.msg) .get('/oper/access/menu/nav')
return next({ name: 'login' }) .then(({ data: res }) => {
} if (res.code !== 0) {
window.SITE_CONFIG['menuList'] = res.data // Vue.prototype.$message.error(res.msg)
fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList']) return next({ name: 'loginWork' })
// next({ ...to, replace: true }) }
next({ ...to, replace: true }) window.SITE_CONFIG['menuList'] = res.data
}) fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])
.catch(() => { // next({ ...to, replace: true })
next({ name: 'login' }) next({ ...to, replace: true })
}) })
.catch(() => {
next({ name: 'loginWork' })
})
} else {
http
.get('/oper/access/menu/nav')
.then(({ data: res }) => {
if (res.code !== 0) {
// Vue.prototype.$message.error(res.msg)
return next({ name: 'login' })
}
window.SITE_CONFIG['menuList'] = res.data
fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])
// next({ ...to, replace: true })
next({ ...to, replace: true })
})
.catch(() => {
next({ name: 'login' })
})
}
}) })
/** /**

83
epmet-oper-web/src/views/main-navbar.vue

@ -1,39 +1,66 @@
<template> <template>
<nav class="aui-navbar" :class="`aui-navbar--${$store.state.navbarLayoutType}`"> <nav class="aui-navbar"
:class="`aui-navbar--${$store.state.navbarLayoutType}`">
<div class="aui-navbar__header"> <div class="aui-navbar__header">
<h1 class="aui-navbar__brand" @click="$router.push({ name: 'home' })"> <h1 class="aui-navbar__brand"
<a class="aui-navbar__brand-lg" href="javascript:;">{{ $t('brand.lg') }}</a> @click="$router.push({ name: 'home' })">
<a class="aui-navbar__brand-mini" href="javascript:;">{{ $t('brand.mini') }}</a> <a class="aui-navbar__brand-lg"
href="javascript:;">{{ $t('brand.lg') }}</a>
<a class="aui-navbar__brand-mini"
href="javascript:;">{{ $t('brand.mini') }}</a>
</h1> </h1>
</div> </div>
<div class="aui-navbar__body"> <div class="aui-navbar__body">
<el-menu class="aui-navbar__menu mr-auto" mode="horizontal"> <el-menu class="aui-navbar__menu mr-auto"
<el-menu-item index="1" @click="$store.state.sidebarFold = !$store.state.sidebarFold"> mode="horizontal">
<svg class="icon-svg aui-navbar__icon-menu aui-navbar__icon-menu--switch" aria-hidden="true"><use xlink:href="#icon-outdent"></use></svg> <el-menu-item index="1"
@click="$store.state.sidebarFold = !$store.state.sidebarFold">
<svg class="icon-svg aui-navbar__icon-menu aui-navbar__icon-menu--switch"
aria-hidden="true">
<use xlink:href="#icon-outdent"></use>
</svg>
</el-menu-item> </el-menu-item>
<el-menu-item index="2" @click="refresh()"> <el-menu-item index="2"
<svg class="icon-svg aui-navbar__icon-menu aui-navbar__icon-menu--refresh" aria-hidden="true"><use xlink:href="#icon-sync"></use></svg> @click="refresh()">
<svg class="icon-svg aui-navbar__icon-menu aui-navbar__icon-menu--refresh"
aria-hidden="true">
<use xlink:href="#icon-sync"></use>
</svg>
</el-menu-item> </el-menu-item>
</el-menu> </el-menu>
<el-menu class="aui-navbar__menu" mode="horizontal"> <el-menu class="aui-navbar__menu"
mode="horizontal">
<el-menu-item index="1"> <el-menu-item index="1">
<el-dropdown placement="bottom" :show-timeout="0"> <el-dropdown placement="bottom"
:show-timeout="0">
<el-button size="mini">{{ $t('_lang') }}</el-button> <el-button size="mini">{{ $t('_lang') }}</el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="(val, key) in i18nMessages" :key="key" @click.native="$i18n.locale = key">{{ val._lang }}</el-dropdown-item> <el-dropdown-item v-for="(val, key) in i18nMessages"
:key="key"
@click.native="$i18n.locale = key">{{ val._lang }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-menu-item> </el-menu-item>
<el-menu-item index="2"> <el-menu-item index="2">
<a href="//www.renren.io/" target="_blank"> <a href="//www.renren.io/"
<svg class="icon-svg aui-navbar__icon-menu" aria-hidden="true"><use xlink:href="#icon-earth"></use></svg> target="_blank">
<svg class="icon-svg aui-navbar__icon-menu"
aria-hidden="true">
<use xlink:href="#icon-earth"></use>
</svg>
</a> </a>
</el-menu-item> </el-menu-item>
<el-menu-item index="3" @click="fullscreenHandle()"> <el-menu-item index="3"
<svg class="icon-svg aui-navbar__icon-menu" aria-hidden="true"><use xlink:href="#icon-fullscreen"></use></svg> @click="fullscreenHandle()">
<svg class="icon-svg aui-navbar__icon-menu"
aria-hidden="true">
<use xlink:href="#icon-fullscreen"></use>
</svg>
</el-menu-item> </el-menu-item>
<el-menu-item index="4" class="aui-navbar__avatar"> <el-menu-item index="4"
<el-dropdown placement="bottom" :show-timeout="0"> class="aui-navbar__avatar">
<el-dropdown placement="bottom"
:show-timeout="0">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
<img src="~@/assets/img/avatar.png"> <img src="~@/assets/img/avatar.png">
<span>{{ $store.state.user.realName }}</span> <span>{{ $store.state.user.realName }}</span>
@ -48,12 +75,14 @@
</el-menu> </el-menu>
</div> </div>
<!-- 弹窗, 修改密码 --> <!-- 弹窗, 修改密码 -->
<update-password v-if="updatePassowrdVisible" ref="updatePassowrd"></update-password> <update-password v-if="updatePassowrdVisible"
ref="updatePassowrd"></update-password>
</nav> </nav>
</template> </template>
<script> <script>
import { messages } from '@/i18n' import { messages } from '@/i18n'
import { mapGetters } from 'vuex'
import screenfull from 'screenfull' import screenfull from 'screenfull'
import UpdatePassword from './main-navbar-update-password' import UpdatePassword from './main-navbar-update-password'
import { clearLoginInfo } from '@/utils' import { clearLoginInfo } from '@/utils'
@ -68,6 +97,9 @@ export default {
components: { components: {
UpdatePassword UpdatePassword
}, },
computed: {
...mapGetters(['userType'])
},
methods: { methods: {
// //
fullscreenHandle () { fullscreenHandle () {
@ -98,10 +130,17 @@ export default {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
clearLoginInfo() clearLoginInfo()
this.$router.push({ name: 'login' }) console.log('logout:::::' + this.userType)
}).catch(() => {}) if (this.userType === 'work') {
}).catch(() => {}) this.$router.push({ name: 'loginWork' })
} else {
this.$router.push({ name: 'login' })
}
}).catch(() => { })
}).catch(() => { })
} }
} }
} }

3
epmet-oper-web/src/views/pages/login.vue

@ -90,6 +90,7 @@
<script> <script>
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { mapActions } from 'vuex'
import debounce from 'lodash/debounce' import debounce from 'lodash/debounce'
import { messages } from '@/i18n' import { messages } from '@/i18n'
import { getUUID } from '@/utils' import { getUUID } from '@/utils'
@ -128,6 +129,7 @@ export default {
this.getCaptcha() this.getCaptcha()
}, },
methods: { methods: {
...mapActions(['setUserType']),
// //
getCaptcha () { getCaptcha () {
this.dataForm.uuid = getUUID() this.dataForm.uuid = getUUID()
@ -144,6 +146,7 @@ export default {
this.getCaptcha() this.getCaptcha()
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
this.setUserType('oper')
Cookies.set('token', res.data.token) Cookies.set('token', res.data.token)
this.$router.replace({ name: 'home' }) this.$router.replace({ name: 'home' })
}).catch(() => { }) }).catch(() => { })

13
epmet-oper-web/src/views/pages/loginWork.vue

@ -1,10 +1,10 @@
<template> <template>
<div class="aui-wrapper aui-page__login"> <div class="aui-wrapper aui-page__login">
<div class="aui-content__wrapper">WorkWorkWorkWorkWork</div>
<div class="aui-content__wrapper"> <div class="aui-content__wrapper">
<main class="aui-content"> <main class="aui-content">
<div class="login-header"> <div class="login-header">
<h2 class="login-brand">{{ $t('brand.lg') }}</h2> <h2 class="login-brand">{{ $t('brand.work') }}</h2>
</div> </div>
<div class="login-body"> <div class="login-body">
<h3 class="login-title">{{ $t('login.title') }}</h3> <h3 class="login-title">{{ $t('login.title') }}</h3>
@ -91,6 +91,8 @@
<script> <script>
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { mapActions } from 'vuex'
import { mapGetters } from 'vuex'
import debounce from 'lodash/debounce' import debounce from 'lodash/debounce'
import { messages } from '@/i18n' import { messages } from '@/i18n'
import { getUUID } from '@/utils' import { getUUID } from '@/utils'
@ -111,6 +113,7 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['userType']),
dataRule () { dataRule () {
return { return {
phone: [ phone: [
@ -128,7 +131,9 @@ export default {
created () { created () {
this.getCaptcha() this.getCaptcha()
}, },
methods: { methods: {
...mapActions(['setUserType']),
// //
getCaptcha () { getCaptcha () {
this.dataForm.uuid = getUUID() this.dataForm.uuid = getUUID()
@ -145,6 +150,10 @@ export default {
this.getCaptcha() this.getCaptcha()
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
this.setUserType('work')
Cookies.set('token', res.data.token) Cookies.set('token', res.data.token)
this.$router.replace({ name: 'home' }) this.$router.replace({ name: 'home' })
}).catch(() => { }) }).catch(() => { })

Loading…
Cancel
Save