mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 11:36:38 +08:00
api调整
This commit is contained in:
parent
1ce9258c70
commit
b86383e91c
@ -24,7 +24,6 @@ export function AuthPage() {
|
|||||||
const goChat = () => navigate(Path.Chat);
|
const goChat = () => navigate(Path.Chat);
|
||||||
const resetAccessCode = () => {
|
const resetAccessCode = () => {
|
||||||
accessStore.update((access) => {
|
accessStore.update((access) => {
|
||||||
access.openaiApiKey = "";
|
|
||||||
access.accessCode = "";
|
access.accessCode = "";
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -47,18 +46,29 @@ export function AuthPage() {
|
|||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
},
|
},
|
||||||
body: formData.toString(),
|
body: formData.toString(),
|
||||||
|
credentials: "include", // 处理cookies
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.status.code === 0 && data.result === true) {
|
if (data.status.code === 0 && data.result === true) {
|
||||||
// 登录成功逻辑
|
// 登录成功逻辑
|
||||||
accessStore.update((access) => {
|
// 从响应中读取 session cookies
|
||||||
access.accessCode = data.accessCode; // 如果需要从响应中获取 accessCode 的话
|
const cookies = response.headers.get("Set-Cookie");
|
||||||
});
|
|
||||||
|
if (cookies) {
|
||||||
|
console.log("Session cookies:", cookies);
|
||||||
|
|
||||||
|
accessStore.update((access) => {
|
||||||
|
access.accessCode = cookies; // 将cookies赋值给access.accessCode
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.warn("No cookies found in the response.");
|
||||||
|
showToast(Locale.Login.LoginFail);
|
||||||
|
}
|
||||||
goChat(); // 导航到聊天页面或其他逻辑
|
goChat(); // 导航到聊天页面或其他逻辑
|
||||||
} else {
|
} else {
|
||||||
// 登录失败
|
// 登录失败
|
||||||
|
@ -18,7 +18,7 @@ export const BAIDU_BASE_URL = "https://aip.baidubce.com";
|
|||||||
|
|
||||||
export const BAIDU_OATUH_URL = `${BAIDU_BASE_URL}/oauth/2.0/token`;
|
export const BAIDU_OATUH_URL = `${BAIDU_BASE_URL}/oauth/2.0/token`;
|
||||||
|
|
||||||
export const BASE_URL = `https://buoucoding.com/ai`;
|
export const BASE_URL = `https://buoucoding.com/ai/api`;
|
||||||
|
|
||||||
export enum Login {
|
export enum Login {
|
||||||
Register = "/register",
|
Register = "/register",
|
||||||
|
@ -24,7 +24,7 @@ const cn = {
|
|||||||
ConfirmPassword: "确认密码",
|
ConfirmPassword: "确认密码",
|
||||||
Login: "登录",
|
Login: "登录",
|
||||||
Register: "注册",
|
Register: "注册",
|
||||||
LoginFail: "登录失败,请检查用户名和密码",
|
LoginFail: "登录成功,但未找到会话信息。",
|
||||||
SystemFail: "请求失败,请重试",
|
SystemFail: "请求失败,请重试",
|
||||||
ResisterSuc: "注册成功,请登录",
|
ResisterSuc: "注册成功,请登录",
|
||||||
ResisterFail: "注册失败,请稍后重试",
|
ResisterFail: "注册失败,请稍后重试",
|
||||||
|
Loading…
Reference in New Issue
Block a user