hookehuyr

fix 优化401授权跳转

...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-05-28 10:17:40 3 * @Date: 2022-05-28 10:17:40
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-09 01:02:38 5 + * @LastEditTime: 2022-06-22 09:22:56
6 * @FilePath: /tswj/src/utils/axios.js 6 * @FilePath: /tswj/src/utils/axios.js
7 * @Description: 7 * @Description:
8 */ 8 */
...@@ -53,6 +53,7 @@ axios.interceptors.response.use( ...@@ -53,6 +53,7 @@ axios.interceptors.response.use(
53 response => { 53 response => {
54 // 默认显示错误提示 54 // 默认显示错误提示
55 response.data.show = true; 55 response.data.show = true;
56 + // 判断微信授权状态,进入页面时未授权需要授权跳转
56 // C/B 授权拼接头特殊标识,openid_x 57 // C/B 授权拼接头特殊标识,openid_x
57 let prefixAPI = router && router.currentRoute.value.href?.indexOf('business') > 0 ? 'b' : 'c'; 58 let prefixAPI = router && router.currentRoute.value.href?.indexOf('business') > 0 ? 'b' : 'c';
58 if (response.data.code === 401) { 59 if (response.data.code === 401) {
...@@ -63,7 +64,6 @@ axios.interceptors.response.use( ...@@ -63,7 +64,6 @@ axios.interceptors.response.use(
63 router.replace({ 64 router.replace({
64 path: '/auth', 65 path: '/auth',
65 query: { 66 query: {
66 - // href: router.currentRoute.value.href,
67 href: location.hash, 67 href: location.hash,
68 prefixAPI 68 prefixAPI
69 } 69 }
......
...@@ -23,22 +23,17 @@ import Cookies from 'js-cookie' ...@@ -23,22 +23,17 @@ import Cookies from 'js-cookie'
23 import 'animate.css'; 23 import 'animate.css';
24 import MyButton from '@/components/MyButton/index.vue' 24 import MyButton from '@/components/MyButton/index.vue'
25 import { onMounted } from 'vue' 25 import { onMounted } from 'vue'
26 -import { useGo, useReplace } from '@/hooks/useGo' 26 +import { useGo } from '@/hooks/useGo'
27 // 自定义按钮颜色样式 27 // 自定义按钮颜色样式
28 import { styleObject1, styleObject2 } from '@/settings/designSetting.js' 28 import { styleObject1, styleObject2 } from '@/settings/designSetting.js'
29 import { addPages } from '@/hooks/useKeepAlive' 29 import { addPages } from '@/hooks/useKeepAlive'
30 30
31 const go = useGo(); 31 const go = useGo();
32 -const replace = useReplace();
33 32
34 // TAG: keepAlive 缓存页面 33 // TAG: keepAlive 缓存页面
35 addPages(); 34 addPages();
36 35
37 onMounted(() => { 36 onMounted(() => {
38 - // 判断微信授权状态,进入页面时未授权需要授权跳转
39 - if (!Cookies.get('PHPSESSID')) {
40 - replace('/auth', { href: location.hash, prefixAPI: 'c' })
41 - }
42 // 进入项目自动打开导航栏 微信浏览器 避免样式错位 37 // 进入项目自动打开导航栏 微信浏览器 避免样式错位
43 window.history.pushState({}, "title", "#") 38 window.history.pushState({}, "title", "#")
44 }) 39 })
......