feat: 未登录时,跳转到单独的登录页

This commit is contained in:
杨鹏
2025-09-08 16:15:45 +08:00
parent 48811b88dc
commit bfa57367dc
12 changed files with 54 additions and 73 deletions
+4 -2
View File
@@ -10,6 +10,7 @@ import $platform from '@/sheep/platform';
import { showAuthModal } from '@/sheep/hooks/useModal';
import AuthUtil from '@/sheep/api/member/auth';
import { getTerminal } from '@/sheep/helper/const';
import sheep from '@/sheep';
const options = {
// 显示操作成功消息 默认不显示
@@ -73,7 +74,8 @@ http.interceptors.request.use(
(config) => {
// 自定义处理【auth 授权】:必须登录的接口,则跳出 AuthModal 登录弹窗
if (config.custom.auth && !$store('user').isLogin) {
showAuthModal();
// showAuthModal();
sheep.$router.go('/pages/login/index', {}, { redirect: true });
return Promise.reject();
}
@@ -280,7 +282,7 @@ const refreshToken = async (config) => {
const handleAuthorized = () => {
const userStore = $store('user');
userStore.logout(true);
showAuthModal();
sheep.$router.go('/pages/login/index', {}, { redirect: true });
// 登录超时
return Promise.reject({
code: 401,