注册页面店铺选择问题修复
This commit is contained in:
@@ -50,7 +50,14 @@ api.interceptors.response.use(
|
|||||||
async (error: AxiosError) => {
|
async (error: AxiosError) => {
|
||||||
const originalRequest = error.config as any
|
const originalRequest = error.config as any
|
||||||
|
|
||||||
if (error.response?.status === 401 && !originalRequest._retry) {
|
const isWhitelistedPath = (url: string) => {
|
||||||
|
return url?.includes('/user/login') ||
|
||||||
|
url?.includes('/user/register') ||
|
||||||
|
url?.includes('/user/refresh-token') ||
|
||||||
|
url?.includes('/shop/list/simple')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error.response?.status === 401 && !originalRequest._retry && !isWhitelistedPath(originalRequest.url)) {
|
||||||
if (isRefreshing) {
|
if (isRefreshing) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
failedQueue.push({ resolve, reject })
|
failedQueue.push({ resolve, reject })
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ const fetchShops = async () => {
|
|||||||
loadingShops.value = true
|
loadingShops.value = true
|
||||||
try {
|
try {
|
||||||
const response = await shopApi.getShopsSimple()
|
const response = await shopApi.getShopsSimple()
|
||||||
shops.value = response.data || []
|
shops.value = (response as unknown as any[]) || []
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取店铺列表失败:', error)
|
console.error('获取店铺列表失败:', error)
|
||||||
message.error('未登录,请先登录')
|
message.error('未登录,请先登录')
|
||||||
|
|||||||
@@ -57,9 +57,10 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWhitelistedPath(String path) {
|
private boolean isWhitelistedPath(String path) {
|
||||||
return path.contains("/user/login") ||
|
return path.contains("/api/user/login") ||
|
||||||
path.contains("/user/register") ||
|
path.contains("/api/user/register") ||
|
||||||
path.contains("/user/refresh-token") ||
|
path.contains("/api/user/refresh-token") ||
|
||||||
path.contains("/shop/list/simple");
|
path.contains("/api/shop/list/simple") ||
|
||||||
|
path.contains("/health");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
registry.addInterceptor(authInterceptor)
|
registry.addInterceptor(authInterceptor)
|
||||||
.addPathPatterns("/**")
|
.addPathPatterns("/**")
|
||||||
.excludePathPatterns(
|
.excludePathPatterns(
|
||||||
"/user/login",
|
"/api/user/login",
|
||||||
"/user/register",
|
"/api/user/register",
|
||||||
"/user/refresh-token",
|
"/api/user/refresh-token",
|
||||||
"/shop/list/simple",
|
"/api/shop/list/simple",
|
||||||
"/error"
|
"/error",
|
||||||
|
"/health/**"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user