Merge branch 'master' into dev
Showing
5 changed files
with
63 additions
and
57 deletions
| ... | @@ -19,11 +19,11 @@ | ... | @@ -19,11 +19,11 @@ |
| 19 | </div> | 19 | </div> |
| 20 | </template> | 20 | </template> |
| 21 | <script> | 21 | <script> |
| 22 | import sidebarLeft from "./Sidebar/sidebarLeft"; | 22 | import sidebarLeft from "./Sidebar/sidebarLeft"; |
| 23 | import sidebarRight from "./Sidebar/sidebarRight"; | 23 | import sidebarRight from "./Sidebar/sidebarRight"; |
| 24 | import { logout } from "@/api/login.js"; | 24 | import { logout } from "@/api/login.js"; |
| 25 | import { mapGetters } from "vuex"; | 25 | import { mapGetters } from "vuex"; |
| 26 | export default { | 26 | export default { |
| 27 | components: { | 27 | components: { |
| 28 | sidebarLeft, | 28 | sidebarLeft, |
| 29 | sidebarRight, | 29 | sidebarRight, |
| ... | @@ -57,89 +57,89 @@ | ... | @@ -57,89 +57,89 @@ |
| 57 | }); | 57 | }); |
| 58 | }, | 58 | }, |
| 59 | }, | 59 | }, |
| 60 | }; | 60 | }; |
| 61 | </script> | 61 | </script> |
| 62 | <style lang="scss" scoped> | 62 | <style lang="scss" scoped> |
| 63 | /deep/.el-menu--horizontal { | 63 | /deep/.el-menu--horizontal { |
| 64 | display: flex; | 64 | display: flex; |
| 65 | align-items: center; | 65 | align-items: center; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | .menubg { | 68 | .menubg { |
| 69 | height: 34px; | 69 | height: 34px; |
| 70 | width: 130px; | 70 | width: 130px !important; |
| 71 | text-align: center; | 71 | text-align: center; |
| 72 | color: #ffffff; | 72 | color: #ffffff; |
| 73 | margin-right: 20px; | ||
| 74 | background: url("~@/image/navbar.png") no-repeat; | 73 | background: url("~@/image/navbar.png") no-repeat; |
| 75 | background-size: 100% 100%; | 74 | background-size: 100% 100%; |
| 76 | } | 75 | } |
| 77 | 76 | ||
| 78 | /deep/.el-menu-item { | 77 | /deep/.el-menu-item { |
| 79 | @extend .menubg; | 78 | @extend .menubg; |
| 80 | } | 79 | } |
| 81 | 80 | ||
| 82 | /deep/.el-submenu { | 81 | /deep/.el-submenu { |
| 83 | @extend .menubg; | 82 | @extend .menubg; |
| 84 | } | 83 | } |
| 85 | 84 | ||
| 86 | /deep/.el-submenu__title { | 85 | /deep/.el-submenu__title { |
| 87 | height: 34px; | 86 | height: 34px; |
| 88 | color: #ffffff; | 87 | color: #ffffff; |
| 89 | } | 88 | } |
| 90 | 89 | ||
| 91 | /deep/.el-submenu__title span { | 90 | /deep/.el-submenu__title span { |
| 92 | font-size: 14px; | 91 | font-size: 14px; |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | .sidebarLeft { | 94 | .sidebarLeft { |
| 96 | position: relative; | 95 | position: relative; |
| 97 | top: 13px; | 96 | top: 13px; |
| 98 | width: 30%; | 97 | width: 30%; |
| 99 | } | 98 | } |
| 100 | 99 | ||
| 101 | /deep/.el-menu { | 100 | /deep/.el-menu { |
| 102 | display: flex; | 101 | display: flex; |
| 103 | justify-content: space-between; | 102 | justify-content: space-between; |
| 104 | } | 103 | width: 100%; |
| 104 | } | ||
| 105 | 105 | ||
| 106 | /deep/.el-menu-item { | 106 | /deep/.el-menu-item { |
| 107 | flex: 1; | 107 | flex: 1; |
| 108 | width: 100%; | 108 | width: 100%; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | .sidebarRight { | 111 | .sidebarRight { |
| 112 | position: relative; | 112 | position: relative; |
| 113 | top: 13px; | 113 | top: 13px; |
| 114 | width: 30%; | 114 | width: 30%; |
| 115 | padding-left: 20px; | 115 | } |
| 116 | } | ||
| 117 | 116 | ||
| 118 | // 导航选中背景色 | 117 | // 导航选中背景色 |
| 119 | .xuanzhong { | 118 | .xuanzhong { |
| 120 | background: url("~@/image/selNavbar.png") no-repeat; | 119 | background: url("~@/image/selNavbar.png") no-repeat; |
| 121 | background-size: 100% 100%; | 120 | background-size: 100% 100%; |
| 122 | color: #ffffff !important; | 121 | color: #ffffff !important; |
| 123 | font-weight: 700; | 122 | font-weight: 700; |
| 124 | } | 123 | } |
| 125 | 124 | ||
| 126 | /deep/.el-menu-item:hover { | 125 | /deep/.el-menu-item:hover { |
| 127 | @extend .xuanzhong; | 126 | @extend .xuanzhong; |
| 128 | } | 127 | } |
| 129 | 128 | ||
| 130 | /deep/.el-submenu__title:hover { | 129 | /deep/.el-submenu__title:hover { |
| 131 | @extend .xuanzhong; | 130 | @extend .xuanzhong; |
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | /deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus { | 133 | /deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus { |
| 135 | @extend .xuanzhong; | 134 | @extend .xuanzhong; |
| 136 | } | 135 | } |
| 137 | 136 | ||
| 138 | /deep/.el-menu-item.is-active { | 137 | /deep/.el-menu-item.is-active { |
| 139 | @extend .xuanzhong; | 138 | @extend .xuanzhong; |
| 140 | } | ||
| 141 | 139 | ||
| 142 | .navbar { | 140 | } |
| 141 | |||
| 142 | .navbar { | ||
| 143 | height: $headerHeight; | 143 | height: $headerHeight; |
| 144 | overflow: hidden; | 144 | overflow: hidden; |
| 145 | position: relative; | 145 | position: relative; |
| ... | @@ -258,5 +258,5 @@ | ... | @@ -258,5 +258,5 @@ |
| 258 | } | 258 | } |
| 259 | } | 259 | } |
| 260 | } | 260 | } |
| 261 | } | 261 | } |
| 262 | </style> | 262 | </style> | ... | ... |
| ... | @@ -18,13 +18,13 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -18,13 +18,13 @@ router.beforeEach(async (to, from, next) => { |
| 18 | let hasUser = store.state.user.hasUser; | 18 | let hasUser = store.state.user.hasUser; |
| 19 | let hasAddRoute = store.state.permission.addRoutes; | 19 | let hasAddRoute = store.state.permission.addRoutes; |
| 20 | if (to.path == "/sb" || to.path == "/jg") { | 20 | if (to.path == "/sb" || to.path == "/jg") { |
| 21 | sessionStorage.removeItem("token"); | 21 | localStorage.removeItem("token"); |
| 22 | sessionStorage.setItem("psth", to.path) | 22 | sessionStorage.setItem("psth", to.path) |
| 23 | next(); | 23 | next(); |
| 24 | } else { | 24 | } else { |
| 25 | let code = sessionStorage.getItem("psth") == "/sb" ? "BDCSBPT" : "BDCJGPT" | 25 | let code = sessionStorage.getItem("psth") == "/sb" ? "BDCSBPT" : "BDCJGPT" |
| 26 | //判断token是否存在 | 26 | //判断token是否存在 |
| 27 | const hasToken = sessionStorage.getItem("token"); | 27 | const hasToken = localStorage.getItem("token"); |
| 28 | if (hasToken) { | 28 | if (hasToken) { |
| 29 | //请求用户信息 | 29 | //请求用户信息 |
| 30 | if (!hasUser) { | 30 | if (!hasUser) { | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Description: | 2 | * @Description: |
| 3 | * @Autor: renchao | 3 | * @Autor: renchao |
| 4 | * @LastEditTime: 2023-03-13 14:11:50 | 4 | * @LastEditTime: 2023-03-14 14:39:24 |
| 5 | */ | 5 | */ |
| 6 | /** | 6 | /** |
| 7 | * 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器 | 7 | * 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器 |
| ... | @@ -25,7 +25,7 @@ const service = axios.create({ | ... | @@ -25,7 +25,7 @@ const service = axios.create({ |
| 25 | service.interceptors.request.use( | 25 | service.interceptors.request.use( |
| 26 | (config) => { | 26 | (config) => { |
| 27 | //调用登录接口时无token,也不需要传token,其他接口都传入token | 27 | //调用登录接口时无token,也不需要传token,其他接口都传入token |
| 28 | config.headers.Authorization = sessionStorage.getItem("token") || ""; | 28 | config.headers.Authorization = localStorage.getItem("token") || ""; |
| 29 | config.headers.Accept = "application/json"; | 29 | config.headers.Accept = "application/json"; |
| 30 | return config; | 30 | return config; |
| 31 | }, | 31 | }, |
| ... | @@ -35,6 +35,7 @@ service.interceptors.request.use( | ... | @@ -35,6 +35,7 @@ service.interceptors.request.use( |
| 35 | } | 35 | } |
| 36 | ); | 36 | ); |
| 37 | 37 | ||
| 38 | window.tokenValid = true | ||
| 38 | // response interceptor | 39 | // response interceptor |
| 39 | service.interceptors.response.use( | 40 | service.interceptors.response.use( |
| 40 | (response) => { | 41 | (response) => { |
| ... | @@ -64,15 +65,20 @@ service.interceptors.response.use( | ... | @@ -64,15 +65,20 @@ service.interceptors.response.use( |
| 64 | //对错误信息的处理函数 | 65 | //对错误信息的处理函数 |
| 65 | function handleErrorData (status) { | 66 | function handleErrorData (status) { |
| 66 | switch (status) { | 67 | switch (status) { |
| 67 | // case 401: | 68 | case 401: |
| 68 | // Message.error("由于长时间未操作,请重新登录!"); | 69 | // 多个请求不重复提示错误信息 |
| 69 | // router.replace({ | 70 | if (window.tokenValid) { |
| 70 | // path: "/login/jg", | 71 | window.tokenValid = false; |
| 71 | // query: { | 72 | Message.error("由于长时间未操作,请重新登录!"); |
| 72 | // redirect: router.history.current.fullPath, | 73 | localStorage.removeItem("token"); |
| 73 | // }, | 74 | router.replace({ |
| 74 | // }); | 75 | path: "/jg", |
| 75 | // break; | 76 | query: { |
| 77 | redirect: router.history.current.fullPath, | ||
| 78 | }, | ||
| 79 | }); | ||
| 80 | } | ||
| 81 | break; | ||
| 76 | case 403: | 82 | case 403: |
| 77 | Message.error("拒绝访问"); | 83 | Message.error("拒绝访问"); |
| 78 | break; | 84 | break; | ... | ... |
| ... | @@ -96,7 +96,7 @@ | ... | @@ -96,7 +96,7 @@ |
| 96 | .then((res) => { | 96 | .then((res) => { |
| 97 | if (res.status === 1) { | 97 | if (res.status === 1) { |
| 98 | //存储token | 98 | //存储token |
| 99 | sessionStorage.setItem("token", `Bearer ${res.content}`); | 99 | localStorage.setItem("token", `Bearer ${res.content}`); |
| 100 | //登录成功后需判断有无重定向,没有重定向则跳转首页 | 100 | //登录成功后需判断有无重定向,没有重定向则跳转首页 |
| 101 | this.$router.replace(this.$route.query.redirect || "/"); | 101 | this.$router.replace(this.$route.query.redirect || "/"); |
| 102 | } else { | 102 | } else { | ... | ... |
| ... | @@ -103,7 +103,7 @@ | ... | @@ -103,7 +103,7 @@ |
| 103 | if (res.status === 1) { | 103 | if (res.status === 1) { |
| 104 | this.$store.dispatch('business/setInitRules', "layout1") | 104 | this.$store.dispatch('business/setInitRules', "layout1") |
| 105 | //存储token | 105 | //存储token |
| 106 | sessionStorage.setItem("token", `Bearer ${res.content}`); | 106 | localStorage.setItem("token", `Bearer ${res.content}`); |
| 107 | //登录成功后需判断有无重定向,没有重定向则跳转首页 | 107 | //登录成功后需判断有无重定向,没有重定向则跳转首页 |
| 108 | this.$router.replace(this.$route.query.redirect || "/"); | 108 | this.$router.replace(this.$route.query.redirect || "/"); |
| 109 | } else { | 109 | } else { | ... | ... |
-
Please register or sign in to post a comment