From 1923ca1e8e03c6fd9cf8eb6a6aaff41b6b167132 Mon Sep 17 00:00:00 2001 From: Joe <1712833832@qq.com> Date: Mon, 15 Jan 2024 13:38:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=B8=A0=E9=81=93=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Buttons/Button.vue | 2 +- .../images/TrafficAccidents.svg | 5 + .../RoadAndEvents/utils/layerImages.js | 2 +- .../Cards/AuditDetails/DetailCard.vue | 67 ++++++++++-- .../Cards/AuditDetails/index.vue | 6 +- .../Cards/AuditLists/ListItem.vue | 18 ++-- .../Cards/AuditLists/index.vue | 19 +++- .../components/Card.vue | 101 ++++++++++++++++++ .../components/Switcher.vue | 94 ++++++++++++++++ .../PublishingChannelManagement/index.vue | 60 ++++++++++- .../views/JiHeExpressway/utils/axios/auth.js | 68 ++++++++---- ruoyi-ui/vue.config.js | 2 +- 12 files changed, 399 insertions(+), 45 deletions(-) create mode 100644 ruoyi-ui/src/views/JiHeExpressway/images/TrafficAccidents.svg create mode 100644 ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Card.vue create mode 100644 ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Switcher.vue diff --git a/ruoyi-ui/src/views/JiHeExpressway/components/Buttons/Button.vue b/ruoyi-ui/src/views/JiHeExpressway/components/Buttons/Button.vue index fd383c28..06b7bb5d 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/components/Buttons/Button.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/components/Buttons/Button.vue @@ -19,7 +19,7 @@ export default { diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Switcher.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Switcher.vue new file mode 100644 index 00000000..ba3232a1 --- /dev/null +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Switcher.vue @@ -0,0 +1,94 @@ + + + {{ getActiveOptions.active.text }} + {{ getActiveOptions.unActive.text }} + + {{ getActiveOptions[active ? 'active' : + 'unActive'].text }} + + + + + + diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/index.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/index.vue index af4468ac..07aba29e 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/index.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/index.vue @@ -1,15 +1,71 @@ - PublishingChannelManagement + + + + + + + + + + + + diff --git a/ruoyi-ui/src/views/JiHeExpressway/utils/axios/auth.js b/ruoyi-ui/src/views/JiHeExpressway/utils/axios/auth.js index bce63156..757ffb27 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/utils/axios/auth.js +++ b/ruoyi-ui/src/views/JiHeExpressway/utils/axios/auth.js @@ -1,22 +1,45 @@ import axios from "axios"; -const RequestURL = `http://10.168.65.211:3000`; +// 摄像头 +// const RequestURL = `http://10.168.65.211:3000`; -const UN = "jhgskj", - PD = "jhgskj@2023", +// 后台 +const RequestURL = `http://10.168.77.209:1024/dev-api`; + +// const UN = "jhgskj", +// PD = "jhgskj@2023", +const UN = "admin", + PD = "admin123", tokeKey = "LOCAL_TOKEN"; +let continueRefreshToken = true; + function getToken() { - return axios - .post(`${RequestURL}/apiLogin`, { - username: UN, - password: PD, - }) - .then((res) => { - localStorage.setItem(tokeKey, res.data.token); - - return res.data.token; - }); + const token = localStorage.getItem(tokeKey); + + if (token) return Promise.resolve(token); + + return new Promise((resolve, reject) => { + axios + .post(`${RequestURL}/login`, { + username: UN, + password: PD, + }) + .then((res) => { + if (res.data.code === 200) { + localStorage.setItem(tokeKey, `Bearer ${res.data.token}`); + console.log("get token success"); + resolve(res.data.token); + } else { + console.log("get token failed"); + reject(void 0); + } + }) + .catch((e) => { + console.log("get token failed", error); + reject(e); + }); + }); } const axiosIns = axios.create({ @@ -28,11 +51,9 @@ axiosIns.defaults.baseURL = RequestURL; // request拦截器 axiosIns.interceptors.request.use( async (config) => { - // let token = localStorage.getItem(tokeKey); - - // if (!token) token = await getToken(); + const token = await getToken(); - // config.headers["Authorization"] = token; + config.headers["Authorization"] = token; return config; }, @@ -44,7 +65,18 @@ axiosIns.interceptors.request.use( // response拦截器 axiosIns.interceptors.response.use( async (response) => { - // if (response.data.code === 401) {} + if (response.data.code === 401 && continueRefreshToken) { + localStorage.removeItem(tokeKey); + + return getToken() + .then(async () => { + return await axiosIns.request(response.config); + }) + .catch((e) => { + continueRefreshToken = false; + return null; + }); + } return response.data; }, diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index bdb6139f..c65bee06 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -41,7 +41,7 @@ module.exports = { // target: `http://192.168.0.194:8080`, // target: `http://10.0.81.201:8080`, // target: `http://10.168.73.36:8080`, // 周乐 - target: `http://10.168.77.209:8080`,// 刘朋 + target: `http://10.168.77.209:8080`, // 刘朋 // target: `http://10.168.66.196:8080`, changeOrigin: true, pathRewrite: {