feat:修改存在的问题
This commit is contained in:
2
src/utils/bus.js
Normal file
2
src/utils/bus.js
Normal file
@@ -0,0 +1,2 @@
|
||||
import mitt from 'mitt'
|
||||
export const emitter = mitt()
|
||||
@@ -16,7 +16,7 @@ const service = axios.create({
|
||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||
// 超时
|
||||
timeout: 10000,
|
||||
// timeout: 10000,
|
||||
});
|
||||
|
||||
// request拦截器
|
||||
@@ -134,11 +134,15 @@ service.interceptors.response.use(
|
||||
case 201:
|
||||
return Promise.resolve(responseData);
|
||||
case 401:
|
||||
return Promise.resolve(responseData);
|
||||
// return handleUnauthorized().then(() => {
|
||||
// return Promise.reject({ code: 401, message: '未授权' });
|
||||
// });
|
||||
|
||||
// return Promise.resolve(responseData);
|
||||
const currentPath = router.currentRoute.value.name;
|
||||
if(currentPath == 'ConferencingRoom'){
|
||||
return Promise.resolve(responseData);
|
||||
}else{
|
||||
return handleUnauthorized().then(() => {
|
||||
return Promise.reject({ code: 401, message: '未授权' });
|
||||
});
|
||||
}
|
||||
case 500:
|
||||
const serverErrorMsg = responseData.meta?.message || '服务器内部错误';
|
||||
ElMessage({ message: serverErrorMsg, type: 'error' });
|
||||
@@ -173,31 +177,54 @@ service.interceptors.response.use(
|
||||
);
|
||||
|
||||
// 单独处理401未授权
|
||||
// function handleUnauthorized() {
|
||||
// return ElMessageBox.confirm(
|
||||
// '认证信息已失效,您可以继续留在该页面,或者重新登录',
|
||||
// '系统提示',
|
||||
// {
|
||||
// confirmButtonText: '重新登录',
|
||||
// cancelButtonText: '取消',
|
||||
// type: 'warning',
|
||||
// }
|
||||
// )
|
||||
// .then(() => {
|
||||
// removeToken()
|
||||
// if (router.currentRoute.path !== '/login') {
|
||||
// router.push({
|
||||
// path: '/login',
|
||||
// query: { redirect: router.currentRoute.fullPath }
|
||||
// });
|
||||
// } else {
|
||||
// // 如果在登录页,强制刷新以清除残留状态
|
||||
// window.location.reload();
|
||||
// }
|
||||
// })
|
||||
// .catch(() => {
|
||||
// return Promise.reject('用户取消操作');
|
||||
// });
|
||||
// }
|
||||
|
||||
function handleUnauthorized() {
|
||||
return ElMessageBox.confirm(
|
||||
'认证信息已失效,您可以继续留在该页面,或者重新登录',
|
||||
'系统提示',
|
||||
{
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
removeToken()
|
||||
if (router.currentRoute.path !== '/login') {
|
||||
removeToken();
|
||||
|
||||
// 使用 nextTick 确保路由状态已更新
|
||||
import('vue').then(({ nextTick }) => {
|
||||
nextTick(() => {
|
||||
const currentPath = router.currentRoute.value.fullPath;
|
||||
console.log('当前路由:', currentPath);
|
||||
|
||||
if (router.currentRoute.value.path !== '/login') {
|
||||
router.push({
|
||||
path: '/login',
|
||||
query: { redirect: router.currentRoute.fullPath }
|
||||
query: {
|
||||
redirect: currentPath !== '/login' ? currentPath : undefined
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 如果在登录页,强制刷新以清除残留状态
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
return Promise.reject('用户取消操作');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default service;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getWhiteboardShapes, getWhiteboardHistory } from "@/views/custom/api";
|
||||
import { useMeterStore } from '@/stores/modules/meter';
|
||||
import { encode, decode } from '@msgpack/msgpack'
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { emitter } from "@/utils/bus.js";
|
||||
const meterStore = useMeterStore();
|
||||
meterStore.initUdid();
|
||||
|
||||
@@ -39,6 +39,8 @@ export const WhiteboardSync = {
|
||||
const res = await getWhiteboardHistory({ after_timestamp: 0 }, roomUid);
|
||||
if (res.meta.code === 200 && res.data.shapes.length > 0) {
|
||||
canvasInstance.addShape(res.data.shapes);
|
||||
}else if(res.meta.code === 401){
|
||||
emitter.emit('whiteboardFailed',true);
|
||||
}
|
||||
|
||||
// 订阅当前房间
|
||||
|
||||
Reference in New Issue
Block a user