本地开发反向代理
This commit is contained in:
parent
a7370d4e8c
commit
d1a47297bf
@ -1,8 +1,8 @@
|
|||||||
# APP ID
|
# APP ID
|
||||||
NEXT_PUBLIC_APP_ID=8f005d85-a520-4b64-82d7-09f76104cc80
|
NEXT_PUBLIC_APP_ID=c36db3aa-20a6-4421-8e62-c9af03020088
|
||||||
# APP API key
|
# APP API key
|
||||||
NEXT_PUBLIC_APP_KEY=app-9o5BfmyoyKiNui9Pe855xasf
|
NEXT_PUBLIC_APP_KEY=app-WN8APQeButq9jIRj2g5D7r22
|
||||||
# API url prefix
|
# 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
|
||||||
|
|||||||
@ -564,7 +564,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
|
|||||||
|
|
||||||
// 调用 Java 接口
|
// 调用 Java 接口
|
||||||
const javaResponse = await fetch(
|
const javaResponse = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_BASE_API_URL}/api/conversation/feedback`,
|
`/dev-api/api/conversation/feedback`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -199,7 +199,7 @@ const ChatWithHistoryWrapWithCheckToken: FC<ChatWithHistoryWrapProps> = ({
|
|||||||
if (!accessToken) {
|
if (!accessToken) {
|
||||||
router.replace("/login");
|
router.replace("/login");
|
||||||
} else {
|
} else {
|
||||||
fetch(`${process.env.NEXT_PUBLIC_BASE_API_URL}/getInfo`, {
|
fetch(`/dev-api/getInfo`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
|||||||
@ -1,70 +1,70 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const [username, setUsername] = useState('')
|
const [username, setUsername] = useState('')
|
||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState('')
|
||||||
const [error, setError] = useState('')
|
const [error, setError] = useState('')
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [loading, setLoading] = useState(false) // 新增加载状态
|
const [loading, setLoading] = useState(false) // 新增加载状态
|
||||||
|
|
||||||
const handleLogin = async (e: React.FormEvent) => {
|
const handleLogin = async (e: React.FormEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setLoading(true) // 开始加载
|
setLoading(true) // 开始加载
|
||||||
fetch(`${process.env.NEXT_PUBLIC_BASE_API_URL}/login`, {
|
fetch(`/dev-api/login`, {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ username, password }),
|
body: JSON.stringify({ username, password }),
|
||||||
}).then(res => res.json()).then(data => {
|
}).then(res => res.json()).then(data => {
|
||||||
if (data.code === 200) {
|
if (data.code === 200) {
|
||||||
localStorage.setItem('token', data.token)
|
localStorage.setItem('token', data.token)
|
||||||
document.cookie = `username=${username}; path=/` // 新增cookie设置
|
document.cookie = `username=${username}; path=/` // 新增cookie设置
|
||||||
router.push('/')
|
router.push('/')
|
||||||
} else {
|
} else {
|
||||||
setError('登录失败,请检查凭证')
|
setError('登录失败,请检查凭证')
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-100 flex items-center justify-center">
|
<div className="min-h-screen bg-gray-100 flex items-center justify-center">
|
||||||
<div className="bg-white p-8 rounded-lg shadow-md w-96">
|
<div className="bg-white p-8 rounded-lg shadow-md w-96">
|
||||||
<h1 className="text-2xl font-bold mb-6 text-center">Login</h1>
|
<h1 className="text-2xl font-bold mb-6 text-center">Login</h1>
|
||||||
<form onSubmit={handleLogin}>
|
<form onSubmit={handleLogin}>
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<label className="block text-sm font-medium mb-1">Username</label>
|
<label className="block text-sm font-medium mb-1">Username</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="w-full px-3 py-2 border rounded-md"
|
className="w-full px-3 py-2 border rounded-md"
|
||||||
value={username}
|
value={username}
|
||||||
onChange={e => setUsername(e.target.value)}
|
onChange={e => setUsername(e.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<label className="block text-sm font-medium mb-1">Password</label>
|
<label className="block text-sm font-medium mb-1">Password</label>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
className="w-full px-3 py-2 border rounded-md"
|
className="w-full px-3 py-2 border rounded-md"
|
||||||
value={password}
|
value={password}
|
||||||
onChange={e => setPassword(e.target.value)}
|
onChange={e => setPassword(e.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{error && <p className="text-red-500 text-sm mb-4">{error}</p>}
|
{error && <p className="text-red-500 text-sm mb-4">{error}</p>}
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={loading} // 禁用按钮
|
disabled={loading} // 禁用按钮
|
||||||
className={`w-full bg-blue-500 text-white py-2 px-4 rounded-md transition-colors ${!loading && 'hover:bg-blue-600'}`}
|
className={`w-full bg-blue-500 text-white py-2 px-4 rounded-md transition-colors ${!loading && 'hover:bg-blue-600'}`}
|
||||||
>
|
>
|
||||||
{loading ? 'Loading...' : 'Sign In'}
|
{loading ? 'Loading...' : 'Sign In'}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
@import "preflight.css";
|
@import "preflight.css";
|
||||||
@tailwind base;
|
|
||||||
@tailwind components;
|
|
||||||
|
|
||||||
@import '../../themes/light.css';
|
@import '../../themes/light.css';
|
||||||
@import '../../themes/dark.css';
|
@import '../../themes/dark.css';
|
||||||
@import "../../themes/manual-light.css";
|
@import "../../themes/manual-light.css";
|
||||||
@import "../../themes/manual-dark.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 {
|
html {
|
||||||
color-scheme: light;
|
color-scheme: light;
|
||||||
@ -680,8 +682,4 @@ button:focus-within {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@import "../components/base/button/index.css";
|
@tailwind utilities;
|
||||||
@import "../components/base/action-button/index.css";
|
|
||||||
@import "../components/base/modal/index.css";
|
|
||||||
|
|
||||||
@tailwind utilities;
|
|
||||||
|
|||||||
@ -22,10 +22,10 @@ const nextConfig = {
|
|||||||
async rewrites() {
|
async rewrites() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
source: "/dev-api/:path*",
|
source: '/dev-api/:path*',
|
||||||
destination: "http://192.168.6.9:8085/:path*",
|
destination: `${process.env.NEXT_PUBLIC_BASE_API_URL}/:path*`,
|
||||||
},
|
},
|
||||||
];
|
]
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,7 @@
|
|||||||
"@types/react-dom": "^19.0.3",
|
"@types/react-dom": "^19.0.3",
|
||||||
"@types/react-syntax-highlighter": "^15.5.13",
|
"@types/react-syntax-highlighter": "^15.5.13",
|
||||||
"ahooks": "^3.8.4",
|
"ahooks": "^3.8.4",
|
||||||
|
"antd": "^5.26.4",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"classnames": "^2.5.1",
|
"classnames": "^2.5.1",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user