Browse Source

同意登录接入优化

huiqi 5 tháng trước cách đây
mục cha
commit
fd5e508363
1 tập tin đã thay đổi với 11 bổ sung6 xóa
  1. 11 6
      app/components/home.tsx

+ 11 - 6
app/components/home.tsx

@@ -1,5 +1,7 @@
 "use client";
 
+import { Modal} from "antd";
+
 require("../polyfill");
 import { useState, useEffect } from "react";
 import {
@@ -312,15 +314,18 @@ export function Home() {
   }, []);
 
   const jkLogin = async (data: { code: string, redirectUrl: string }, url: string) => {
-    console.log(data, '换取token');
-    console.log(url, '跳转回登陆前的页面');
     try {
       const res = await api.post('jk_code_login', data);
+      console.log(res,'res')
       localStorage.setItem('userInfo', JSON.stringify(res.data));
       window.open(url, '_self');
-    } catch (error) {
-      const originUrl = window.location.origin;
-      window.open(originUrl, '_self');
+    } catch (error:any) {
+      Modal.error({
+        title: '登录失败',
+        content: error.msg,
+      })
+      // const originUrl = window.location.origin;
+      // window.open(originUrl, '_self');
     }
   }
 
@@ -337,7 +342,7 @@ export function Home() {
         jkLogin({ code: code, redirectUrl: encodeURIComponent(originUrl) }, state);
       }
     } else {
-      const loginUrl = 'https://esctest.sribs.com.cn/esc-sso/oauth2.0/authorize?client_id=e971e84b574c40b2&response_type=code';
+      const loginUrl = 'https://esctest.sribs.com.cn/esc-sso/oauth2.0/authorize?client_id=e97f94cf93761f4d69e8&response_type=code';
       const externalLoginUrl = loginUrl + `&redirect_uri=${encodeURIComponent(originUrl)}&state=${encodeURIComponent(fullUrl)}`;
       if (!userInfo) {
         window.open(externalLoginUrl, '_self');