Просмотр исходного кода

修改免登录,修改Siderbar中的按钮

Ryuiso 16 часов назад
Родитель
Сommit
92c9ea1cd5
2 измененных файлов с 65 добавлено и 71 удалено
  1. 13 19
      app/components/home.tsx
  2. 52 52
      app/components/sidebar.tsx

+ 13 - 19
app/components/home.tsx

@@ -376,18 +376,12 @@ export function Home() {
 
   useEffect(() => {
     // ==============
-    // 环境开关:暂时屏蔽 toUninLogin 跳转验证
-    // 说明:设置 NEXT_PUBLIC_DISABLE_UNIN_LOGIN=1 时,跳过所有统一登录跳转
-    // 用法:
-    //  1) 临时禁用:NEXT_PUBLIC_DISABLE_UNIN_LOGIN=1 yarn dev
-    //  2) 或在 .env.local 中加入 NEXT_PUBLIC_DISABLE_UNIN_LOGIN=1
+    // 屏蔽统一登录验证逻辑
+    // 说明:直接返回,跳过所有统一登录跳转和验证
     // ==============
-    // const DISABLE_UNIN_LOGIN = typeof process !== 'undefined' && process.env.NEXT_PUBLIC_DISABLE_UNIN_LOGIN === '1';
-    // if (DISABLE_UNIN_LOGIN) {
-    //   console.log('[Home] 统一登录验证已禁用,跳过 toUninLogin 验证');
-    //   return;
-    // }
-
+    console.log('[Home] 统一登录验证已禁用,应用可在不登录情况下使用');
+    return;
+    
     // const loginRes = { "nickName": "建科咨询虚拟账号", "userId": "2222331845498970571", "token": "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjAyMDE4Mzg0LTFmNjctNDhkYi05NjNiLTJkOGNhMDMxNTkzMiJ9.zTkTv8gDgJN7tfyxJko_zG1VsESlZACeYkpdMbITqnIpIfvHkZo8l8_Kcv6zo77GnuDyzdpOEt-GzPufD2Ye8A" };
     // if (loginRes) {
     //   return localStorage.setItem('userInfo', JSON.stringify(loginRes));
@@ -405,7 +399,7 @@ export function Home() {
       if (window.history.replaceState) {
         const cleanUrl = window.location.href.split("#")[0];
         // http://localhost:4000/#/knowledgeChat?showMenu=true&chatMode=LOCAL&appId=2965620717148049408&userId=8&nickName=test&token=eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQ3M2QzOWI0LTVhOGYtNGYxZS1iOGY
-        window.history.replaceState({}, document.title, `${cleanUrl}#/knowledgeChat?showMenu=true&chatMode=LOCAL&&appId=${urlHachParams.get('appId')}`);
+        window.history.replaceState({}, document.title, `${cleanUrl}#/knowledgeChat?showMenu=true&chatMode=LOCAL&&appId=${urlHachParams.get('appId')!}`);
       }
     }
 
@@ -421,7 +415,7 @@ export function Home() {
 
     if (fullUrl.includes(originUrl + '/?code') && code && state) {// 通过code登陆
       if (!userInfo) {
-        jkLogin({ code: code, redirectUrl: encodeURIComponent(originUrl) }, state);
+        jkLogin({ code: code!, redirectUrl: encodeURIComponent(originUrl) }, state!);
       }
     } else {
 
@@ -447,12 +441,12 @@ export function Home() {
           return;
         }
         frameLogin({
-          clientId: clientId,
-          workspaceId: workspaceId,
-          workspaceName: workspaceName,
-          userName: username,
-          timestamp: timestamp,
-          signature: signature
+          clientId: clientId!,
+          workspaceId: workspaceId!,
+          workspaceName: workspaceName!,
+          userName: username!,
+          timestamp: timestamp!,
+          signature: signature!
         }, originUrl, fullUrl);
 
       } else {

+ 52 - 52
app/components/sidebar.tsx

@@ -581,65 +581,65 @@ export const SideBar = (props: { className?: string }) => {
             <div className={styles["sidebar-action-group"]}>
               <Button
                 className={styles["sidebar-action-button"]}
-                icon={<HomeOutlined />}
+                icon={<PlusOutlined />}
                 onClick={() => {
                   navigate({ pathname: '/' });
                 }}
-              >
-                回到首页
-              </Button>
-              <Button
-                className={styles["sidebar-action-button"]}
-                icon={<PlusOutlined />}
-                onClick={async () => {
-                  chatStore.clearSessions();
-                  chatStore.updateCurrentSession((value) => {
-                    value.appId = globalStore.selectedAppId;
-                  });
-                  if (isMobileScreen) {
-                    closeSidebar();
-                  }
-                  if (getType() === 'bigModel') {
-                    navigate({ pathname: '/newChat' });
-                  } else {
-                    navigate({ pathname: '/newDeepseekChat' });
-                  }
-                  if (getType() === 'bigModel') {
-                    if (chatStore.chatMode === 'LOCAL') {
-                      await fetchChatList(chatStore.chatMode);
-                    } else {
-                      await fetchChatList();
-                    }
-                  } else {
-                    await fetchChatList();
-                  }
-                }}
               >
                 新建对话
               </Button>
+              {/*<Button*/}
+              {/*  className={styles["sidebar-action-button"]}*/}
+              {/*  icon={<PlusOutlined />}*/}
+              {/*  onClick={async () => {*/}
+              {/*    chatStore.clearSessions();*/}
+              {/*    chatStore.updateCurrentSession((value) => {*/}
+              {/*      value.appId = globalStore.selectedAppId;*/}
+              {/*    });*/}
+              {/*    if (isMobileScreen) {*/}
+              {/*      closeSidebar();*/}
+              {/*    }*/}
+              {/*    if (getType() === 'bigModel') {*/}
+              {/*      navigate({ pathname: '/newChat' });*/}
+              {/*    } else {*/}
+              {/*      navigate({ pathname: '/newDeepseekChat' });*/}
+              {/*    }*/}
+              {/*    if (getType() === 'bigModel') {*/}
+              {/*      if (chatStore.chatMode === 'LOCAL') {*/}
+              {/*        await fetchChatList(chatStore.chatMode);*/}
+              {/*      } else {*/}
+              {/*        await fetchChatList();*/}
+              {/*      }*/}
+              {/*    } else {*/}
+              {/*      await fetchChatList();*/}
+              {/*    }*/}
+              {/*  }}*/}
+              {/*>*/}
+              {/*  新建对话*/}
+              {/*</Button>*/}
             </div>
-            <div className={styles["sidebar-action-group"]}>
-              <Button
-                className={styles["sidebar-action-button"]}
-                icon={<AppstoreOutlined />}
-                onClick={() => {
-                  setDrawerType('all');
-                  setDrawerOpen(true);
-                }}
-              >
-                我的应用
-              </Button>
-              <Button
-                className={styles["sidebar-action-button"]}
-                icon={<StarOutlined />}
-                onClick={() => {
-                  setDrawerType('collect');
-                  setDrawerOpen(true);
-                }}
-              >
-                我的收藏
-              </Button>
-            </div>
+            {/*<div className={styles["sidebar-action-group"]}>*/}
+            {/*  <Button*/}
+            {/*    className={styles["sidebar-action-button"]}*/}
+            {/*    icon={<AppstoreOutlined />}*/}
+            {/*    onClick={() => {*/}
+            {/*      setDrawerType('all');*/}
+            {/*      setDrawerOpen(true);*/}
+            {/*    }}*/}
+            {/*  >*/}
+            {/*    我的应用*/}
+            {/*  </Button>*/}
+            {/*  <Button*/}
+            {/*    className={styles["sidebar-action-button"]}*/}
+            {/*    icon={<StarOutlined />}*/}
+            {/*    onClick={() => {*/}
+            {/*      setDrawerType('collect');*/}
+            {/*      setDrawerOpen(true);*/}
+            {/*    }}*/}
+            {/*  >*/}
+            {/*    我的收藏*/}
+            {/*  </Button>*/}
+            {/*</div>*/}
           </SideBarHeader>
           <div style={{
             fontSize: 12,