yinxia.yang 1 dag geleden
bovenliggende
commit
b6460e3528
3 gewijzigde bestanden met toevoegingen van 20 en 20 verwijderingen
  1. 1 1
      .env.development
  2. 1 1
      .env.production
  3. 18 18
      src/views/Login/index.vue

+ 1 - 1
.env.development

@@ -2,7 +2,7 @@ VITE_USE_MOCK=false
 
 # 主服务
 VITE_API_BASE_URL=/api
-VITE_API_WMS_URL=http://wms.mangoo.hobbystocks.cn
+VITE_API_WMS_URL=https://wms.mangoo.hobbystocks.cn
 
 
 # 授权服务

+ 1 - 1
.env.production

@@ -2,7 +2,7 @@ VITE_USE_MOCK=false
 
 # 主服务
 VITE_API_BASE_URL=/api
-VITE_API_WMS_URL=http://wms.mangoo.hobbystocks.cn
+VITE_API_WMS_URL=https://wms.mangoo.hobbystocks.cn
 
 
 # 授权服务

+ 18 - 18
src/views/Login/index.vue

@@ -7,7 +7,7 @@ import { jwtDecode } from 'jwt-decode'
 import MockLogin from '../Login.vue'
 import { api } from '../../api'
 import {
-	clearOAuthTemp, consumeOAuthTransaction,
+	clearAuthInfo, getCachedOAuthState, clearOAuthTemp, consumeOAuthTransaction,
 	getCachedVerifier, getOAuthLoginUrl,
 	getToken, mockLogin, setAuthInfo
 } from '../../utils/auth'
@@ -71,23 +71,23 @@ function showError(error: unknown) {
 
 async function handleCallback(code: string, state: string | null, authError: string | null) {
 	// 清理 URL 中的 OAuth 临时参数,避免刷新页面重复使用
-	// const query = new URLSearchParams(location.search)
-	// for (const key of ['code', 'state', 'error', 'error_description', 'session_state', 'iss']) {
-	// 	query.delete(key)
-	// }
-	// const remaining = query.toString()
-	// history.replaceState(history.state, '', `${location.pathname}${remaining ? `?${remaining}` : ''}`)
-
-	// sessionStorage.removeItem('oauth_no_auto_redirect')
-	// clearAuthInfo()
-
-	// const cachedState = getCachedOAuthState()
-	// if (!state || !cachedState || state !== cachedState) {
-	// 	ElMessage.warning('登录状态校验失败,准备重新发起认证')
-	// 	clearOAuthTemp()
-	// 	authorize()
-	// 	return
-	// }
+	const query = new URLSearchParams(location.search)
+	for (const key of ['code', 'state', 'error', 'error_description', 'session_state', 'iss']) {
+		query.delete(key)
+	}
+	const remaining = query.toString()
+	history.replaceState(history.state, '', `${location.pathname}${remaining ? `?${remaining}` : ''}`)
+
+	sessionStorage.removeItem('oauth_no_auto_redirect')
+	clearAuthInfo()
+
+	const cachedState = getCachedOAuthState()
+	if (!state || !cachedState || state !== cachedState) {
+		ElMessage.warning('登录状态校验失败,准备重新发起认证')
+		clearOAuthTemp()
+		authorize()
+		return
+	}
 
 	const codeVerifier = getCachedVerifier()
 	if (!codeVerifier) {