浏览代码

登陆参数添加redirectUrl

李富豪 5 月之前
父节点
当前提交
17693baec0
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      app/components/home.tsx

+ 5 - 5
app/components/home.tsx

@@ -311,11 +311,11 @@ export function Home() {
     useAccessStore.getState().fetch();
   }, []);
 
-  const jkLogin = async (code: string, url: string) => {
-    console.log(code, '使用code换取token');
-    console.log(url, '登录成功后要跳转回登陆前的页面');
+  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', { code: code });
+      const res = await api.post('jk_code_login', data);
       localStorage.setItem('userInfo', JSON.stringify(res.data));
       window.open(url, '_self');
     } catch (error) {
@@ -334,7 +334,7 @@ export function Home() {
 
     if (fullUrl.includes(originUrl + '/?code') && code && state) {// 通过code登陆
       if (!userInfo) {
-        jkLogin(code, state);
+        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';