wujingjing
2025-04-14 77b15609b62c9bcd80fcdfd65f134a06252920b9
src/utils/request.ts
@@ -8,7 +8,7 @@
import { debounce, decodeFormData } from './util';
import { AUTH_URL, MAIN_URL, SECONDARY_URL } from '/@/constants';
import { Local, LoginInfo, Session } from '/@/utils/storage';
import { isSharePage } from '../stores/chatRoom';
import { isSharePage, logoutClick, openLoginDlg } from '../stores/chatRoom';
// import JSONbig from 'json-bigint';
//#region ====================== 后端 res.err_code ======================
@@ -23,19 +23,19 @@
//#endregion
const emitNoAuth = () => {
   emitter.emit('logout');
   emitter.emit('openLoginDlg');
   logoutClick();
   openLoginDlg();
};
export const handleNormalAuth = () => {
   const accessSession = Local.get(accessSessionKey);
   if (!accessSession) {
      emitter.emit('logout');
      emitter.emit('openLoginDlg');
      logoutClick();
      openLoginDlg();
   }
   return !!accessSession;
};
export const SESSION_KEY = 'hswatersession';
export const handleNoAuth = debounce(() => {
   emitNoAuth();
});
@@ -47,7 +47,7 @@
         const accessSession = Local.get(accessSessionKey);
         if (accessSession) {
            // 将 token 添加到请求报文头中
            config.headers['hswatersession'] = accessSession;
            config.headers[SESSION_KEY] = accessSession;
         }
         if (!NO_AUTH_API_LIST.includes(config.url) && !isSharePage.value) {
            if (!accessSession && config.url !== LOGIN_URL && config.url !== TEL_LOGIN_URL) {
@@ -228,10 +228,10 @@
export const userName = 'userName';
export const getSessionKey = (win: Window) => {
   return  sessionName;
   return sessionName;
};
export const getUserNameKey = (win: Window) => {
   return  userName;
   return userName;
};
export const accessSessionKey = getSessionKey(window);
@@ -240,7 +240,7 @@
export const refreshAccessTokenKey = `x-${accessSessionKey}`;
// userInfo键定义
export const userInfoKey ='userInfo';
export const userInfoKey = 'userInfo';
// 获取 token
export const getSession = () => {
   return Local.get(accessSessionKey);