fix: some
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 2m59s

This commit is contained in:
luo
2026-10-13 14:53:19 +08:00
parent 77b0e25011
commit da95a914e3
31 changed files with 1702 additions and 116 deletions

View File

@@ -1,4 +1,5 @@
import { BASE_URL } from './env.js';
import { useUserStore } from '@/store/user.js';
const showErrorToast = (message) => {
uni.showToast({
@@ -26,12 +27,14 @@ const request = (options) => {
const { code, msg, data } = responseData;
if (res.statusCode === 401) {
uni.removeStorageSync('token');
uni.removeStorageSync('identifier');
showErrorToast(msg || '登录已过期,请重新登录');
setTimeout(() => {
uni.reLaunch({ url: '/pages/login/login' });
}, 2000);
// A late response from an old login must not clear a new session.
if (token === (uni.getStorageSync('token') || '')) {
useUserStore().clearUser();
showErrorToast(msg || responseData.message || '登录已过期,请重新登录');
setTimeout(() => {
if (!uni.getStorageSync('token')) uni.reLaunch({ url: '/pages/login/login' });
}, 2000);
}
reject(responseData);
return;
}
@@ -42,7 +45,7 @@ const request = (options) => {
}
if (options.showError !== false) {
showErrorToast(msg);
showErrorToast(msg || responseData.message);
}
reject(responseData);
},