Browse Source

移除多余代码,修复测试或正式环境下一直重新加载信息请求问题

master
李磊 3 years ago
parent
commit
6b361adb31
  1. 2
      .env.production
  2. 2
      .env.test
  3. 9
      src/layout/components/AppMain.vue
  4. 12
      src/permission.js
  5. 2
      src/store/modules/user.js
  6. 9
      vue.config.js

2
.env.production

@ -22,4 +22,4 @@ VUE_APP_SJ_API = 'http://${VUE_APP_SJ_BASE_IP_ADDRESS}:9092/SJSE/'
VUE_APP_PREVIEW_API = '${VUE_APP_SERVER_API}/sdma-preview/' VUE_APP_PREVIEW_API = '${VUE_APP_SERVER_API}/sdma-preview/'
# websocket连接地址 # websocket连接地址
VUE_APP_WEBSOCKET = 'ws://${VUE_APP_SERVER_ADDRESS}:9100/sdma-websocket/websocket/' VUE_APP_WEBSOCKET = 'ws://${VUE_APP_SERVER_ADDRESS}/sdma-websocket/websocket/'

2
.env.test

@ -22,4 +22,4 @@ VUE_APP_SJ_API = 'http://${VUE_APP_SJ_BASE_IP_ADDRESS}:9092/SJSE/'
VUE_APP_PREVIEW_API = '${VUE_APP_SERVER_API}/sdma-preview/' VUE_APP_PREVIEW_API = '${VUE_APP_SERVER_API}/sdma-preview/'
# websocket连接地址 # websocket连接地址
VUE_APP_WEBSOCKET = 'ws://${VUE_APP_SERVER_ADDRESS}:9100/sdma-websocket/websocket/' VUE_APP_WEBSOCKET = 'ws://${VUE_APP_SERVER_ADDRESS}/sdma-websocket/websocket/'

9
src/layout/components/AppMain.vue

@ -1,23 +1,21 @@
<template> <template>
<section class="app-main"> <section class="app-main">
<transition name="fade-transform" mode="out-in"> <transition name="fade-transform" mode="out-in">
<keep-alive v-if="!$route.meta.iframe" :include="cachedViews"> <keep-alive :include="cachedViews">
<router-view :key="key" /> <router-view :key="key" />
</keep-alive> </keep-alive>
</transition> </transition>
<elFrame v-show="!!$route.meta.iframe" :src="oldURL" />
<message :result="dialogFormVisible" :message-info="message" @dialogData="closeDialog" /> <message :result="dialogFormVisible" :message-info="message" @dialogData="closeDialog" />
</section> </section>
</template> </template>
<script> <script>
import Message from '../../components/Notice/message' import Message from '../../components/Notice/message'
import elFrame from '../../components/Iframe/index'
import Utils from '../../utils/contact.js' import Utils from '../../utils/contact.js'
import { transactionTable } from '@/api/dashboard' import { transactionTable } from '@/api/dashboard'
export default { export default {
name: 'AppMain', name: 'AppMain',
components: { Message, elFrame }, components: { Message },
data() { data() {
return { return {
userId: this.$store.getters.userId, userId: this.$store.getters.userId,
@ -35,8 +33,7 @@ export default {
shebeizhonglei: '', shebeizhonglei: '',
shebeizhongleidaima: '', shebeizhongleidaima: '',
jianyanleibie: '' jianyanleibie: ''
}, }
oldURL: process.env.VUE_APP_OLD_API + 'user/index'
} }
}, },
computed: { computed: {

12
src/permission.js

@ -2,20 +2,20 @@ import router from './router'
import store from './store' import store from './store'
import NProgress from 'nprogress' // Progress 进度条 import NProgress from 'nprogress' // Progress 进度条
import 'nprogress/nprogress.css'// Progress 进度条样式 import 'nprogress/nprogress.css'// Progress 进度条样式
import { getToken, getRememberMeToken } from '@/utils/auth' // 验权 import { getToken } from '@/utils/auth' // 验权
const whiteList = ['/login', '/remote', '/404', '/viewhzd', '/upload', '/xingshi', '/wenjian', '/fangwei', '/qiye'] // 不重定向白名单 const whiteList = ['/login', '/remote', '/404', '/viewhzd', '/upload', '/xingshi', '/wenjian', '/fangwei', '/qiye'] // 不重定向白名单
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()
if (getToken() || getRememberMeToken()) { if (getToken()) {
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' }) next({ path: '/' })
NProgress.done() // 结束Progress NProgress.done() // 结束Progress
} else if (!store.getters.roles.length) { } else if (store.getters.roles.length) {
next()
} else {
store.dispatch('GetInfo').then(() => { store.dispatch('GetInfo').then(() => {
next({ ...to }) next({ ...to, replace: true })
}) })
} else {
next()
} }
} else { } else {
const ppath = to.path const ppath = to.path

2
src/store/modules/user.js

@ -22,7 +22,7 @@ const user = {
allUser: [], allUser: [],
allCategory: [], allCategory: [],
messageCount: [], messageCount: [],
prodName: process.env.NODE_ENV === 'test' ? '/sdmaFront' : '' // 开发环境下为空,生产环境下请设置为tomcat项目名称。(例如:/dist) prodName: process.env.NODE_ENV === 'development' ? '' : '/sdmaFront' // 开发环境下为空,生产环境下请设置为tomcat项目名称或者nginx代理项目名称。(例如:/dist)
}, },
mutations: { mutations: {
SET_USER: (state, userInfo) => { SET_USER: (state, userInfo) => {

9
vue.config.js

@ -7,13 +7,14 @@ function resolve(dir) {
} }
const name = pkg.name || 'sdma-front' // page title const name = pkg.name || 'sdma-front' // page title
const port = process.env.NODE_ENV === 'development' ? 9527 : 8090 const isDev = process.env.NODE_ENV === 'development'
console.log(process.env.NODE_ENV === 'development') const port = isDev ? 9527 : 8090
console.log(isDev)
module.exports = { module.exports = {
publicPath: process.env.NODE_ENV === 'test' ? '/sdmaFront' : './', publicPath: isDev ? './' : '/sdmaFront',
outputDir: 'sdmaFront', outputDir: 'sdmaFront',
assetsDir: 'static', assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development' ? 'error' : false, lintOnSave: isDev ? 'error' : false,
productionSourceMap: false, productionSourceMap: false,
runtimeCompiler: true, runtimeCompiler: true,
devServer: { devServer: {

Loading…
Cancel
Save