diff --git a/.env.development b/.env.development index b90ae18..459bd29 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ # @Author: 张涛 # @Date: 2023-07-18 13:04:50 # @LastEditors: JC9527 - # @LastEditTime: 2023-10-11 10:38:17 + # @LastEditTime: 2023-10-11 13:29:25 # @FilePath: \Mudu2PC\.env.development ### # 页面标题 @@ -12,10 +12,11 @@ VUE_APP_TITLE = 苏州应急执法计划管理系统 ENV = 'development' # 苏州应急执法计划管理系统/开发环境 -VUE_APP_BASE_API = 'http://39.101.188.84:9033' +# VUE_APP_BASE_API = 'http://39.101.188.84:9033' # VUE_APP_BASE_API = 'http://192.168.0.105:9033' -# VUE_APP_BASE_API = 'http://180.108.205.123:13002' +VUE_APP_BASE_API = 'http://180.108.205.123:13002' # VUE_APP_BASE_API = '/api' +VUE_APP_LOCATION = 'http://2.46.4.197:8090' # 路由懒加载 diff --git a/.env.production b/.env.production index a010f1a..35c93e9 100644 --- a/.env.production +++ b/.env.production @@ -6,8 +6,10 @@ ENV = 'production' # 苏州应急执法计划管理系统/生产环境 # VUE_APP_BASE_API = 'http://192.168.0.105:9033' -VUE_APP_BASE_API = 'http://39.101.188.84:9033' -# VUE_APP_BASE_API = 'http://180.108.205.123:13002' +# VUE_APP_BASE_API = 'http://39.101.188.84:9033' +VUE_APP_BASE_API = 'http://180.108.205.123:13002' + +VUE_APP_LOCATION = 'http://2.46.4.197:8090' # 路由懒加载 diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 0eb36d7..c2a2265 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -138,20 +138,20 @@ export default { }) .then(() => { this.$store.dispatch("LogOut").then(() => { - location.href = process.env.NODE_ENV === "production" - ? "/demo/suzhouyingjiPC/" - : "/"; + // location.href = process.env.NODE_ENV === "production" + // ? "/demo/suzhouyingjiPC/" + // : "/"; - // let isGovernmentAffairsNetwork = localStorage.getItem('isGovernmentAffairsNetwork') - // if(process.env.NODE_ENV === "production") { - // if(isGovernmentAffairsNetwork == '1') { - // location.href = 'http://180.108.205.123:8090/sso-server/oauth2/login?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' - // } else { - // location.href = "/" - // } - // } else { - // location.href = "/" - // } + let isGovernmentAffairsNetwork = localStorage.getItem('isGovernmentAffairsNetwork') + if(process.env.NODE_ENV === "production") { + if(isGovernmentAffairsNetwork == '1') { + location.href = process.env.VUE_APP_LOCATION + '/sso-server/oauth2/login?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' + } else { + location.href = "/" + } + } else { + location.href = "/" + } }); }) .catch(() => {}); diff --git a/src/layout/newyjLayout.vue b/src/layout/newyjLayout.vue index 3a07d78..6514167 100644 --- a/src/layout/newyjLayout.vue +++ b/src/layout/newyjLayout.vue @@ -112,21 +112,21 @@ export default { }) .then(() => { this.$store.dispatch("LogOut").then(() => { - location.href = process.env.NODE_ENV === "production" - ? "/demo/suzhouyingjiPC/" - : "/"; - // let isGovernmentAffairsNetwork = localStorage.getItem('isGovernmentAffairsNetwork') - // if(process.env.NODE_ENV === "production") { - // console.log('production') - // if(isGovernmentAffairsNetwork == '1') { - // console.log('进入跳转政务网的登录页') - // location.href = 'http://180.108.205.123:8090/sso-server/oauth2/login?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' - // } else { - // location.href = "/" - // } - // } else { - // location.href = "/" - // } + // location.href = process.env.NODE_ENV === "production" + // ? "/demo/suzhouyingjiPC/" + // : "/"; + let isGovernmentAffairsNetwork = localStorage.getItem('isGovernmentAffairsNetwork') + if(process.env.NODE_ENV === "production") { + console.log('production') + if(isGovernmentAffairsNetwork == '1') { + console.log('进入跳转政务网的登录页') + location.href = process.env.VUE_APP_LOCATION + '/sso-server/oauth2/login?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' + } else { + location.href = "/" + } + } else { + location.href = "/" + } }); }) .catch(() => {}); diff --git a/src/permission.js b/src/permission.js index e8733d5..595d056 100644 --- a/src/permission.js +++ b/src/permission.js @@ -76,14 +76,21 @@ router.beforeEach((to, from, next) => { } else { // 没有token if(window.location.href.includes('?code')){ + // console.log(window.location.href) + var reg = new RegExp(/[?&]code=([^&#]+)/) + var r = window.location.href.match(reg) // console.log('有code') - const code = window.location.href.split("?")[1].split('=')[1]; + // const code = window.location.href.split("?")[1].split('=')[1]; + const code = r && r[1] + // console.log(code) getUseInfo({code:code}).then(user=>{ console.log(user,'用户信息') localStorage.setItem('isGovernmentAffairsNetwork','1') store.dispatch('LoginNoCaptcha',{username:'admin',password:'admin@123Jichuang'}).then((res) => { next('/home') }) + }).catch(err=>{ + location.href = process.env.VUE_APP_LOCATION + '/sso-server/oauth2/login?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' }) } else { // console.log('没code') @@ -97,7 +104,7 @@ router.beforeEach((to, from, next) => { } else { console.log('路由拦截跳转登录页') // next() - location.href = 'http://180.108.205.123:8090/sso-server/oauth2/login?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' + location.href = process.env.VUE_APP_LOCATION + '/sso-server/oauth2/login?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' } NProgress.done() } diff --git a/src/router/index.js b/src/router/index.js index fbf6984..afc559e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -210,8 +210,8 @@ Router.prototype.replace = function push(location) { }; export default new Router({ - // mode: "history", // 去掉url中的# - // base: "/", + mode: "history", // 去掉url中的# + base: "/", scrollBehavior: () => ({ y: 0 }), routes: constantRoutes, }); diff --git a/vue.config.js b/vue.config.js index a1c7c75..2c39ebe 100644 --- a/vue.config.js +++ b/vue.config.js @@ -25,8 +25,8 @@ module.exports = { // 部署生产环境和开发环境下的URL。 // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 - publicPath: process.env.NODE_ENV === "production" ? "/demo/suzhouyingjiPC/" : "/", - // publicPath: process.env.NODE_ENV === "production" ? "/" : "/", + // publicPath: process.env.NODE_ENV === "production" ? "/demo/suzhouyingjiPC/" : "/", + publicPath: process.env.NODE_ENV === "production" ? "/" : "/", // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) outputDir: "dist", // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)