hookehuyr

fix 优化401授权跳转

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