mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-02-23 17:59:49 +08:00
update
This commit is contained in:
parent
8030e71a5a
commit
ef4665cd8b
@ -293,9 +293,7 @@ export function fetch(
|
|||||||
options?: Record<string, unknown>,
|
options?: Record<string, unknown>,
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
if (window.__TAURI__) {
|
if (window.__TAURI__) {
|
||||||
return tauriStreamFetch(url, options)
|
return tauriStreamFetch(url, options);
|
||||||
.then((res) => res.text())
|
|
||||||
.then((data) => ({ data }));
|
|
||||||
// const payload = options?.body || options?.data;
|
// const payload = options?.body || options?.data;
|
||||||
// return tauriFetch(url, {
|
// return tauriFetch(url, {
|
||||||
// ...options,
|
// ...options,
|
||||||
@ -319,7 +317,9 @@ export function adapter(config: Record<string, unknown>) {
|
|||||||
const fetchUrl = params
|
const fetchUrl = params
|
||||||
? `${path}?${new URLSearchParams(params as any).toString()}`
|
? `${path}?${new URLSearchParams(params as any).toString()}`
|
||||||
: path;
|
: path;
|
||||||
return fetch(fetchUrl as string, { ...rest, responseType: "text" });
|
return fetch(fetchUrl as string, { ...rest, responseType: "text" })
|
||||||
|
.then((res) => res.text())
|
||||||
|
.then((data) => ({ data }));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function safeLocalStorage(): {
|
export function safeLocalStorage(): {
|
||||||
|
@ -85,7 +85,15 @@ export function fetch(url: string, options?: RequestInit): Promise<any> {
|
|||||||
.then((res: StreamResponse) => {
|
.then((res: StreamResponse) => {
|
||||||
request_id = res.request_id;
|
request_id = res.request_id;
|
||||||
const { status, status_text: statusText, headers } = res;
|
const { status, status_text: statusText, headers } = res;
|
||||||
return new Response(ts.readable, { status, statusText, headers });
|
const response = new Response(ts.readable, {
|
||||||
|
status,
|
||||||
|
statusText,
|
||||||
|
headers,
|
||||||
|
});
|
||||||
|
if (status >= 300) {
|
||||||
|
setTimeout(close, 50);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error("stream error", e);
|
console.error("stream error", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user