mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 21:56:38 +08:00
fix build bug
This commit is contained in:
parent
cd0366392a
commit
f72aadc35d
@ -367,11 +367,13 @@ export function getClientApi(provider: ServiceProvider | string): ClientApi {
|
||||
"| Type:",
|
||||
typeof provider,
|
||||
"| Browser:",
|
||||
navigator.userAgent.includes("Edge")
|
||||
? "Edge"
|
||||
: navigator.userAgent.includes("Safari")
|
||||
? "Safari"
|
||||
: "Other",
|
||||
typeof navigator !== "undefined"
|
||||
? navigator.userAgent.includes("Edge")
|
||||
? "Edge"
|
||||
: navigator.userAgent.includes("Safari")
|
||||
? "Safari"
|
||||
: "Other"
|
||||
: "SSR",
|
||||
);
|
||||
|
||||
// Standardize the provider name to match Enum case (TitleCase)
|
||||
|
@ -967,7 +967,9 @@ export function DeleteImageButton(props: { deleteImage: () => void }) {
|
||||
}
|
||||
|
||||
export function ShortcutKeyModal(props: { onClose: () => void }) {
|
||||
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
|
||||
const isMac =
|
||||
typeof navigator !== "undefined" &&
|
||||
navigator.platform.toUpperCase().indexOf("MAC") >= 0;
|
||||
const shortcuts = [
|
||||
{
|
||||
title: Locale.Chat.ShortcutKey.newChat,
|
||||
|
@ -97,6 +97,9 @@ function setItem(key: string, value: string) {
|
||||
|
||||
function getLanguage() {
|
||||
try {
|
||||
if (typeof navigator === "undefined") {
|
||||
return DEFAULT_LANG;
|
||||
}
|
||||
const locale = new Intl.Locale(navigator.language).maximize();
|
||||
const region = locale?.region?.toLowerCase();
|
||||
// 1. check region code in ALL_LANGS
|
||||
|
@ -1,6 +1,13 @@
|
||||
import { Analytics } from "@vercel/analytics/react";
|
||||
import { Home } from "./components/home";
|
||||
import { getServerSideConfig } from "./config/server";
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
const Home = dynamic(
|
||||
() => import("./components/home").then((mod) => ({ default: mod.Home })),
|
||||
{
|
||||
ssr: false,
|
||||
},
|
||||
);
|
||||
|
||||
const serverConfig = getServerSideConfig();
|
||||
|
||||
|
@ -492,7 +492,10 @@ export const useChatStore = createPersistStore(
|
||||
);
|
||||
|
||||
// Add detailed browser and session logging
|
||||
console.log("[onUserInput] Browser:", navigator.userAgent);
|
||||
console.log(
|
||||
"[onUserInput] Browser:",
|
||||
typeof navigator !== "undefined" ? navigator.userAgent : "SSR",
|
||||
);
|
||||
console.log(
|
||||
"[onUserInput] Full modelConfig:",
|
||||
JSON.stringify(modelConfig, null, 2),
|
||||
|
@ -20,8 +20,8 @@ export function trimTopic(topic: string) {
|
||||
return (
|
||||
topic
|
||||
// fix for gemini
|
||||
.replace(/^["“”*]+|["“”*]+$/g, "")
|
||||
.replace(/[,。!?”“"、,.!?*]*$/, "")
|
||||
.replace(/^["""*]+|["""*]+$/g, "")
|
||||
.replace(/[,。!?""""、,.!?*]*$/, "")
|
||||
);
|
||||
}
|
||||
|
||||
@ -114,6 +114,9 @@ export function readFromFile() {
|
||||
}
|
||||
|
||||
export function isIOS() {
|
||||
if (typeof navigator === "undefined") {
|
||||
return false;
|
||||
}
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
return /iphone|ipad|ipod/.test(userAgent);
|
||||
}
|
||||
|
@ -69,7 +69,8 @@ export function fetch(url: string, options?: RequestInit): Promise<Response> {
|
||||
const headers: Record<string, string> = {
|
||||
Accept: "application/json, text/plain, */*",
|
||||
"Accept-Language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
|
||||
"User-Agent": navigator.userAgent,
|
||||
"User-Agent":
|
||||
typeof navigator !== "undefined" ? navigator.userAgent : "NextChat",
|
||||
};
|
||||
for (const item of new Headers(_headers || {})) {
|
||||
headers[item[0]] = item[1];
|
||||
|
Loading…
Reference in New Issue
Block a user