yinxia.yang 1 dzień temu
rodzic
commit
db1980f68f
3 zmienionych plików z 42 dodań i 18 usunięć
  1. 23 0
      public/forward.html
  2. 2 1
      src/router/index.ts
  3. 17 17
      src/views/Login/index.vue

+ 23 - 0
public/forward.html

@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+
+<body>
+    <div>......</div>
+    <script>
+        // 获取所有url参数,并拼接参数转发到http://www.baidu.com
+        var url = window.location.href;
+        var params = url.split('?')[1];
+        var newUrl = `${window.location.origin}/#/login?` + params;
+        // 跳转页面
+        window.location.replace(newUrl);
+    </script>
+</body>
+
+</html>

+ 2 - 1
src/router/index.ts

@@ -9,7 +9,8 @@ import Outbound from '../views/Outbound.vue'
 import Ledger from '../views/Ledger.vue'
 
 export const router = createRouter({ history: createWebHistory(), routes: [
-  { path: '/', redirect: '/dashboard' }, { path: '/login', component: Login },
+  { path: '/login', component: Login },
+  { path: '/', redirect: '/dashboard' }, 
   { path: '/dashboard', component: Dashboard, meta: { title: '工作台' } },
   { path: '/master', component: Master, meta: { title: '基础资料管理' } },
   { path: '/sku', component: Sku, meta: { title: '商品 / SKU 管理' } },

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

@@ -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) {