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