From 57a5ad55e3c3ca68cb6f98a2cb9382e2cfb67dd8 Mon Sep 17 00:00:00 2001 From: laozt <2721205210@qq.com> Date: Fri, 27 Oct 2023 10:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=92=8C=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 8 ++-- src/layout/components/Navbar.vue | 15 +++++-- src/layout/newyjLayout.vue | 17 ++++++-- src/permission.js | 3 +- src/utils/dictzh.js | 33 ++++++-------- src/utils/request.js | 74 ++++++++++++++++---------------- 6 files changed, 83 insertions(+), 67 deletions(-) diff --git a/.env.production b/.env.production index 685bd77..b4d3c2e 100644 --- a/.env.production +++ b/.env.production @@ -10,16 +10,16 @@ ENV = 'production' VUE_APP_BASE_API = 'http://180.108.205.123:13002' n # 统一登录-内网 -VUE_APP_SSO_LOGIN = 'http://2.46.4.197:8090/sso-server/oauth2/sso?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code' +# VUE_APP_SSO_LOGIN = 'http://2.46.4.197:8090/sso-server/oauth2/sso?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code' # 退出登录-内网 -VUE_APP_SSO_LOGOUT ='http://2.46.4.197:8090/sso-server/oauth2/logout?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' +# VUE_APP_SSO_LOGOUT ='http://2.46.4.197:8090/sso-server/oauth2/logout?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' # 统一登录-外网 -# VUE_APP_SSO_LOGIN = 'http://180.108.205.123:8090/sso-server/oauth2/sso?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code' +VUE_APP_SSO_LOGIN = 'http://180.108.205.123:8090/sso-server/oauth2/sso?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code' # 退出登录-外网 -# VUE_APP_SSO_LOGOUT ='http://180.108.205.123:8090/sso-server/oauth2/logout?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' +VUE_APP_SSO_LOGOUT ='http://180.108.205.123:8090/sso-server/oauth2/logout?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F' # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true \ No newline at end of file diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 9cdb8a1..be221f5 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -36,9 +36,7 @@
- {{ dept.deptName }}    {{ username }} - + {{ userName }}
@@ -107,6 +105,17 @@ export default { }; }, methods: { + mounted() { + const isGovernmentAffairsNetwork = localStorage.getItem( + "isGovernmentAffairsNetwork" + ); + const G_USER_INFO = JSON.parse(localStorage.getItem("G_USER_INFO")); + if (isGovernmentAffairsNetwork == "1") { + this.userName = G_USER_INFO.data.username; + } else { + this.userName = this.dept.deptName + " " + this.username; + } + }, getDrop(e) { this.avatarFlag = e; }, diff --git a/src/layout/newyjLayout.vue b/src/layout/newyjLayout.vue index b86420e..eb97ddb 100644 --- a/src/layout/newyjLayout.vue +++ b/src/layout/newyjLayout.vue @@ -40,8 +40,8 @@
- {{ dept.deptName }}    {{ username }} + + {{ userName }} @@ -74,6 +74,7 @@ export default { return { routerIndex: 0, avatarFlag: false, + userName: null, }; }, computed: { @@ -85,7 +86,17 @@ export default { new1: (state) => state.user.new1, }), }, - created() {}, + mounted() { + let isGovernmentAffairsNetwork = localStorage.getItem( + "isGovernmentAffairsNetwork" + ); + const G_USER_INFO = JSON.parse(localStorage.getItem("G_USER_INFO")); + if (isGovernmentAffairsNetwork == "1") { + this.userName = G_USER_INFO.data.username; + } else { + this.userName = this.dept.deptName + " " + this.username; + } + }, watch: { $route: { handler(n, o) { diff --git a/src/permission.js b/src/permission.js index c653200..b9c9685 100644 --- a/src/permission.js +++ b/src/permission.js @@ -9,7 +9,7 @@ import { getUseInfo } from "@/api/login.js"; NProgress.configure({ showSpinner: false }); -const whiteList = ["/login", "/register"]; +const whiteList = ["/login"]; router.beforeEach((to, from, next) => { NProgress.start(); @@ -71,6 +71,7 @@ router.beforeEach((to, from, next) => { .then((user) => { // console.log(user, "用户信息"); localStorage.setItem("isGovernmentAffairsNetwork", "1"); + localStorage.setItem("G_USER_INFO", JSON.stringify(user)); store .dispatch("LoginNoCaptcha", { username: "admin", diff --git a/src/utils/dictzh.js b/src/utils/dictzh.js index 12847e9..173ccf6 100644 --- a/src/utils/dictzh.js +++ b/src/utils/dictzh.js @@ -1,23 +1,18 @@ let dictzh = { - A: "农、林、牧、渔业", - B: "采矿业", - C: "制造业", - D: "电力、热力、燃气及水生产和供应业", - E: "建筑业", - F: "批发和零售业", - G: "交通运输、仓储和邮政业", - H: "住宿和餐饮业", - I: "信息传输、软件和信息技术服务业", - J: "金融业", - K: "房地产业", - L: "租赁和商务服务业", - N: "水利、环境和公共设施管理业", - O: "居民服务、修理和其他服务业", - P: "教育", - Q: "卫生和社会工作", - R: "文化、体育和娱乐业", - S: "公共管理、社会保障和社会组织", - T: "国际组织", + A: "化工医药企业", + B: "矿山企业", + E: "冶金等工业企业", + Z: "民爆", + F: "谷物磨制", + G: "船舶及相关装置制造企业", + H: "航空、航天器及设备制造企业", + I: "畜禽屠宰", + J: "电力生产企业", + K: "燃气生产和供应企业", + L: "水生产和供应企业", + M: "石油天然气长输管道", + N: "废弃资源综合利用", + O: "危险品仓储", }; export default dictzh; diff --git a/src/utils/request.js b/src/utils/request.js index 2a547cb..0e6ae0e 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -37,43 +37,43 @@ service.interceptors.request.use( config.params = {}; config.url = url; } - if ( - !isRepeatSubmit && - (config.method === "post" || config.method === "put") - ) { - const requestObj = { - url: config.url, - data: - typeof config.data === "object" - ? JSON.stringify(config.data) - : config.data, - time: new Date().getTime(), - }; - const sessionObj = cache.session.getJSON("sessionObj"); - if ( - sessionObj === undefined || - sessionObj === null || - sessionObj === "" - ) { - cache.session.setJSON("sessionObj", requestObj); - } else { - const s_url = sessionObj.url; // 请求地址 - const s_data = sessionObj.data; // 请求数据 - const s_time = sessionObj.time; // 请求时间 - const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 - if ( - s_data === requestObj.data && - requestObj.time - s_time < interval && - s_url === requestObj.url - ) { - const message = "数据正在处理,请勿重复提交"; - console.warn(`[${s_url}]: ` + message); - return Promise.reject(new Error(message)); - } else { - cache.session.setJSON("sessionObj", requestObj); - } - } - } + // if ( + // !isRepeatSubmit && + // (config.method === "post" || config.method === "put") + // ) { + // const requestObj = { + // url: config.url, + // data: + // typeof config.data === "object" + // ? JSON.stringify(config.data) + // : config.data, + // time: new Date().getTime(), + // }; + // const sessionObj = cache.session.getJSON("sessionObj"); + // if ( + // sessionObj === undefined || + // sessionObj === null || + // sessionObj === "" + // ) { + // cache.session.setJSON("sessionObj", requestObj); + // } else { + // const s_url = sessionObj.url; // 请求地址 + // const s_data = sessionObj.data; // 请求数据 + // const s_time = sessionObj.time; // 请求时间 + // const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 + // if ( + // s_data === requestObj.data && + // requestObj.time - s_time < interval && + // s_url === requestObj.url + // ) { + // const message = "数据正在处理,请勿重复提交"; + // console.warn(`[${s_url}]: ` + message); + // return Promise.reject(new Error(message)); + // } else { + // cache.session.setJSON("sessionObj", requestObj); + // } + // } + // } return config; }, (error) => {