From d1a47297bfefac5fd6597a0140e192284c3ce87a Mon Sep 17 00:00:00 2001 From: wenyongda Date: Thu, 10 Jul 2025 16:57:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=BC=80=E5=8F=91=E5=8F=8D?= =?UTF-8?q?=E5=90=91=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 8 +- app/components/chat-with-history/hooks.tsx | 2 +- app/components/chat-with-history/index.tsx | 2 +- app/login/page.tsx | 140 ++++++++++----------- app/styles/globals.css | 14 +-- next.config.js | 6 +- package.json | 1 + 7 files changed, 86 insertions(+), 87 deletions(-) diff --git a/.env.local b/.env.local index a1bb5db..5bb7ce5 100644 --- a/.env.local +++ b/.env.local @@ -1,8 +1,8 @@ # APP ID -NEXT_PUBLIC_APP_ID=8f005d85-a520-4b64-82d7-09f76104cc80 +NEXT_PUBLIC_APP_ID=c36db3aa-20a6-4421-8e62-c9af03020088 # APP API key -NEXT_PUBLIC_APP_KEY=app-9o5BfmyoyKiNui9Pe855xasf +NEXT_PUBLIC_APP_KEY=app-WN8APQeButq9jIRj2g5D7r22 # API url prefix -NEXT_PUBLIC_API_URL=http://192.168.6.37:180/v1 +NEXT_PUBLIC_API_URL=http://192.168.6.35:180/v1 -NEXT_PUBLIC_BASE_API_URL=http://192.168.6.9:8085 +NEXT_PUBLIC_BASE_API_URL=http://127.0.0.1:8085 diff --git a/app/components/chat-with-history/hooks.tsx b/app/components/chat-with-history/hooks.tsx index d2df323..51ba979 100644 --- a/app/components/chat-with-history/hooks.tsx +++ b/app/components/chat-with-history/hooks.tsx @@ -564,7 +564,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => { // 调用 Java 接口 const javaResponse = await fetch( - `${process.env.NEXT_PUBLIC_BASE_API_URL}/api/conversation/feedback`, + `/dev-api/api/conversation/feedback`, { method: "POST", headers: { diff --git a/app/components/chat-with-history/index.tsx b/app/components/chat-with-history/index.tsx index f873b38..9f3cfa2 100644 --- a/app/components/chat-with-history/index.tsx +++ b/app/components/chat-with-history/index.tsx @@ -199,7 +199,7 @@ const ChatWithHistoryWrapWithCheckToken: FC = ({ if (!accessToken) { router.replace("/login"); } else { - fetch(`${process.env.NEXT_PUBLIC_BASE_API_URL}/getInfo`, { + fetch(`/dev-api/getInfo`, { method: "GET", headers: { Authorization: `Bearer ${accessToken}`, diff --git a/app/login/page.tsx b/app/login/page.tsx index 85db12a..6b0afa9 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -1,70 +1,70 @@ -'use client' -import { useState } from 'react' -import { useRouter } from 'next/navigation' - -export default function LoginPage() { - const [username, setUsername] = useState('') - const [password, setPassword] = useState('') - const [error, setError] = useState('') - const router = useRouter() - const [loading, setLoading] = useState(false) // 新增加载状态 - - const handleLogin = async (e: React.FormEvent) => { - e.preventDefault() - setLoading(true) // 开始加载 - fetch(`${process.env.NEXT_PUBLIC_BASE_API_URL}/login`, { - method: 'post', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ username, password }), - }).then(res => res.json()).then(data => { - if (data.code === 200) { - localStorage.setItem('token', data.token) - document.cookie = `username=${username}; path=/` // 新增cookie设置 - router.push('/') - } else { - setError('登录失败,请检查凭证') - setLoading(false) - } - }) - } - - return ( -
-
-

Login

-
-
- - setUsername(e.target.value)} - required - /> -
-
- - setPassword(e.target.value)} - required - /> -
- {error &&

{error}

} - -
-
-
- ) -} +'use client' +import { useState } from 'react' +import { useRouter } from 'next/navigation' + +export default function LoginPage() { + const [username, setUsername] = useState('') + const [password, setPassword] = useState('') + const [error, setError] = useState('') + const router = useRouter() + const [loading, setLoading] = useState(false) // 新增加载状态 + + const handleLogin = async (e: React.FormEvent) => { + e.preventDefault() + setLoading(true) // 开始加载 + fetch(`/dev-api/login`, { + method: 'post', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ username, password }), + }).then(res => res.json()).then(data => { + if (data.code === 200) { + localStorage.setItem('token', data.token) + document.cookie = `username=${username}; path=/` // 新增cookie设置 + router.push('/') + } else { + setError('登录失败,请检查凭证') + setLoading(false) + } + }) + } + + return ( +
+
+

Login

+
+
+ + setUsername(e.target.value)} + required + /> +
+
+ + setPassword(e.target.value)} + required + /> +
+ {error &&

{error}

} + +
+
+
+ ) +} diff --git a/app/styles/globals.css b/app/styles/globals.css index 573523f..9d0a45d 100644 --- a/app/styles/globals.css +++ b/app/styles/globals.css @@ -1,11 +1,13 @@ @import "preflight.css"; -@tailwind base; -@tailwind components; - @import '../../themes/light.css'; @import '../../themes/dark.css'; @import "../../themes/manual-light.css"; @import "../../themes/manual-dark.css"; +@import "../components/base/button/index.css"; +@import "../components/base/action-button/index.css"; +@import "../components/base/modal/index.css"; +@tailwind base; +@tailwind components; html { color-scheme: light; @@ -680,8 +682,4 @@ button:focus-within { display: none; } -@import "../components/base/button/index.css"; -@import "../components/base/action-button/index.css"; -@import "../components/base/modal/index.css"; - -@tailwind utilities; \ No newline at end of file +@tailwind utilities; diff --git a/next.config.js b/next.config.js index 20649ea..1ff07fd 100644 --- a/next.config.js +++ b/next.config.js @@ -22,10 +22,10 @@ const nextConfig = { async rewrites() { return [ { - source: "/dev-api/:path*", - destination: "http://192.168.6.9:8085/:path*", + source: '/dev-api/:path*', + destination: `${process.env.NEXT_PUBLIC_BASE_API_URL}/:path*`, }, - ]; + ] }, }; diff --git a/package.json b/package.json index c216b45..ddcbc79 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "@types/react-dom": "^19.0.3", "@types/react-syntax-highlighter": "^15.5.13", "ahooks": "^3.8.4", + "antd": "^5.26.4", "axios": "^1.7.9", "class-variance-authority": "^0.7.1", "classnames": "^2.5.1",