Merge branch 'main' of https://github.com/ChatGPTNextWeb/NextChat into feature-dsmodels-20250228

This commit is contained in:
wangjianhua
2025-09-19 15:14:25 +08:00
42 changed files with 1728 additions and 94 deletions

View File

@@ -29,11 +29,11 @@ type HTMLPreviewProps = {
onLoad?: (title?: string) => void;
};
export type HTMLPreviewHander = {
export type HTMLPreviewHandler = {
reload: () => void;
};
export const HTMLPreview = forwardRef<HTMLPreviewHander, HTMLPreviewProps>(
export const HTMLPreview = forwardRef<HTMLPreviewHandler, HTMLPreviewProps>(
function HTMLPreview(props, ref) {
const iframeRef = useRef<HTMLIFrameElement>(null);
const [frameId, setFrameId] = useState<string>(nanoid());
@@ -207,7 +207,7 @@ export function Artifacts() {
const [code, setCode] = useState("");
const [loading, setLoading] = useState(true);
const [fileName, setFileName] = useState("");
const previewRef = useRef<HTMLPreviewHander>(null);
const previewRef = useRef<HTMLPreviewHandler>(null);
useEffect(() => {
if (id) {

View File

@@ -17,7 +17,7 @@ import { showImageModal, FullScreen } from "./ui-lib";
import {
ArtifactsShareButton,
HTMLPreview,
HTMLPreviewHander,
HTMLPreviewHandler,
} from "./artifacts";
import { useChatStore } from "../store";
import { IconButton } from "./button";
@@ -73,7 +73,7 @@ export function Mermaid(props: { code: string }) {
export function PreCode(props: { children: any }) {
const ref = useRef<HTMLPreElement>(null);
const previewRef = useRef<HTMLPreviewHander>(null);
const previewRef = useRef<HTMLPreviewHandler>(null);
const [mermaidCode, setMermaidCode] = useState("");
const [htmlCode, setHtmlCode] = useState("");
const { height } = useWindowSize();

View File

@@ -75,6 +75,7 @@ import {
ChatGLM,
DeepSeek,
SiliconFlow,
AI302,
Huawei,
} from "../constant";
import { Prompt, SearchService, usePromptStore } from "../store/prompt";
@@ -1458,6 +1459,46 @@ export function Settings() {
</ListItem>
</>
);
const ai302ConfigComponent = accessStore.provider === ServiceProvider["302.AI"] && (
<>
<ListItem
title={Locale.Settings.Access.AI302.Endpoint.Title}
subTitle={
Locale.Settings.Access.AI302.Endpoint.SubTitle +
AI302.ExampleEndpoint
}
>
<input
aria-label={Locale.Settings.Access.AI302.Endpoint.Title}
type="text"
value={accessStore.ai302Url}
placeholder={AI302.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.ai302Url = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.AI302.ApiKey.Title}
subTitle={Locale.Settings.Access.AI302.ApiKey.SubTitle}
>
<PasswordInput
aria-label={Locale.Settings.Access.AI302.ApiKey.Title}
value={accessStore.ai302ApiKey}
type="text"
placeholder={Locale.Settings.Access.AI302.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.ai302ApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
);
const huaweiConfigComponent = accessStore.provider ===
ServiceProvider.Huawei && (
<>
@@ -1864,6 +1905,7 @@ export function Settings() {
{chatglmConfigComponent}
{siliconflowConfigComponent}
{huaweiConfigComponent}
{ai302ConfigComponent}
</>
)}
</>