| | |
| | | // 增加loading 如果pending请求数量等于1,弹出loading, 防止重复弹出 |
| | | requestNum++; |
| | | if (requestNum == 1) { |
| | | loadingInstance = ElLoadingService({ |
| | | loadingInstance = ElLoadingService({ |
| | | text: '加载中...', |
| | | target: '.layout-parent', |
| | | }); |
| | |
| | | // 添加请求拦截器 |
| | | request.interceptors.request.use( |
| | | (config) => { |
| | | console.log('🚀 ~ config:', config); |
| | | // 获取本地的 token |
| | | const accessSession = Local.get(accessSessionKey); |
| | | const { loading = true, noAuth = false, handleFail = true } = config as ExtraConfig; |
| | |
| | | config.headers['hswatersession'] = accessSession; |
| | | } |
| | | if (!noAuth) { |
| | | if (!accessSession ) { |
| | | if (!accessSession) { |
| | | handleNoAuth(); |
| | | } |
| | | } |
| | |
| | | switch (serveData?.err_code) { |
| | | case ErrorCode.Auth: |
| | | handleNoAuth(); |
| | | throw '权限验证失败'; |
| | | throw '权限验证失败'; |
| | | break; |
| | | case ErrorCode.Exception: |
| | | ElMessage.error('内部错误!'); |