mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	feat: 全局设置是否启用artifacts
This commit is contained in:
		@@ -21,6 +21,7 @@ import {
 | 
			
		||||
} from "./artifacts";
 | 
			
		||||
import { useChatStore } from "../store";
 | 
			
		||||
import { IconButton } from "./button";
 | 
			
		||||
import { useAppConfig } from "../store/config";
 | 
			
		||||
 | 
			
		||||
export function Mermaid(props: { code: string }) {
 | 
			
		||||
  const ref = useRef<HTMLDivElement>(null);
 | 
			
		||||
@@ -92,7 +93,9 @@ export function PreCode(props: { children: any }) {
 | 
			
		||||
    }
 | 
			
		||||
  }, 600);
 | 
			
		||||
 | 
			
		||||
  const enableArtifacts = session.mask?.enableArtifacts !== false;
 | 
			
		||||
  const config = useAppConfig();
 | 
			
		||||
  const enableArtifacts =
 | 
			
		||||
    session.mask?.enableArtifacts !== false && config.enableArtifacts;
 | 
			
		||||
 | 
			
		||||
  //Wrap the paragraph for plain-text
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
 
 | 
			
		||||
@@ -166,21 +166,23 @@ export function MaskConfig(props: {
 | 
			
		||||
          ></input>
 | 
			
		||||
        </ListItem>
 | 
			
		||||
 | 
			
		||||
        <ListItem
 | 
			
		||||
          title={Locale.Mask.Config.Artifacts.Title}
 | 
			
		||||
          subTitle={Locale.Mask.Config.Artifacts.SubTitle}
 | 
			
		||||
        >
 | 
			
		||||
          <input
 | 
			
		||||
            aria-label={Locale.Mask.Config.Artifacts.Title}
 | 
			
		||||
            type="checkbox"
 | 
			
		||||
            checked={props.mask.enableArtifacts !== false}
 | 
			
		||||
            onChange={(e) => {
 | 
			
		||||
              props.updateMask((mask) => {
 | 
			
		||||
                mask.enableArtifacts = e.currentTarget.checked;
 | 
			
		||||
              });
 | 
			
		||||
            }}
 | 
			
		||||
          ></input>
 | 
			
		||||
        </ListItem>
 | 
			
		||||
        {globalConfig.enableArtifacts && (
 | 
			
		||||
          <ListItem
 | 
			
		||||
            title={Locale.Mask.Config.Artifacts.Title}
 | 
			
		||||
            subTitle={Locale.Mask.Config.Artifacts.SubTitle}
 | 
			
		||||
          >
 | 
			
		||||
            <input
 | 
			
		||||
              aria-label={Locale.Mask.Config.Artifacts.Title}
 | 
			
		||||
              type="checkbox"
 | 
			
		||||
              checked={props.mask.enableArtifacts !== false}
 | 
			
		||||
              onChange={(e) => {
 | 
			
		||||
                props.updateMask((mask) => {
 | 
			
		||||
                  mask.enableArtifacts = e.currentTarget.checked;
 | 
			
		||||
                });
 | 
			
		||||
              }}
 | 
			
		||||
            ></input>
 | 
			
		||||
          </ListItem>
 | 
			
		||||
        )}
 | 
			
		||||
 | 
			
		||||
        {!props.shouldSyncFromGlobal ? (
 | 
			
		||||
          <ListItem
 | 
			
		||||
 
 | 
			
		||||
@@ -1465,6 +1465,20 @@ export function Settings() {
 | 
			
		||||
              }
 | 
			
		||||
            ></input>
 | 
			
		||||
          </ListItem>
 | 
			
		||||
 | 
			
		||||
          <ListItem title="artifact" subTitle="artifacts">
 | 
			
		||||
            <input
 | 
			
		||||
              aria-label="artifacts"
 | 
			
		||||
              type="checkbox"
 | 
			
		||||
              checked={config.enableArtifacts}
 | 
			
		||||
              onChange={(e) =>
 | 
			
		||||
                updateConfig(
 | 
			
		||||
                  (config) =>
 | 
			
		||||
                    (config.enableArtifacts = e.currentTarget.checked),
 | 
			
		||||
                )
 | 
			
		||||
              }
 | 
			
		||||
            ></input>
 | 
			
		||||
          </ListItem>
 | 
			
		||||
        </List>
 | 
			
		||||
 | 
			
		||||
        <SyncItems />
 | 
			
		||||
 
 | 
			
		||||
@@ -50,6 +50,8 @@ export const DEFAULT_CONFIG = {
 | 
			
		||||
  enableAutoGenerateTitle: true,
 | 
			
		||||
  sidebarWidth: DEFAULT_SIDEBAR_WIDTH,
 | 
			
		||||
 | 
			
		||||
  enableArtifacts: true, // show artifacts config
 | 
			
		||||
 | 
			
		||||
  disablePromptHint: false,
 | 
			
		||||
 | 
			
		||||
  dontShowMaskSplashScreen: false, // dont show splash screen when create chat
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user