diff --git a/app/command.ts b/app/command.ts
index e515e5f0bb4..bea4e06f381 100644
--- a/app/command.ts
+++ b/app/command.ts
@@ -41,13 +41,16 @@ interface ChatCommands {
del?: Command;
}
-export const ChatCommandPrefix = ":";
+// Compatible with Chinese colon character ":"
+export const ChatCommandPrefix = /^[::]/;
export function useChatCommand(commands: ChatCommands = {}) {
function extract(userInput: string) {
- return (
- userInput.startsWith(ChatCommandPrefix) ? userInput.slice(1) : userInput
- ) as keyof ChatCommands;
+ const match = userInput.match(ChatCommandPrefix);
+ if (match) {
+ return userInput.slice(1) as keyof ChatCommands;
+ }
+ return userInput as keyof ChatCommands;
}
function search(userInput: string) {
@@ -57,7 +60,7 @@ export function useChatCommand(commands: ChatCommands = {}) {
.filter((c) => c.startsWith(input))
.map((c) => ({
title: desc[c as keyof ChatCommands],
- content: ChatCommandPrefix + c,
+ content: ":" + c,
}));
}
diff --git a/app/components/chat.tsx b/app/components/chat.tsx
index bb4b611ad79..ade30967584 100644
--- a/app/components/chat.tsx
+++ b/app/components/chat.tsx
@@ -732,6 +732,7 @@ function _Chat() {
const session = chatStore.currentSession();
const config = useAppConfig();
const fontSize = config.fontSize;
+ const fontFamily = config.fontFamily;
const [showExport, setShowExport] = useState(false);
@@ -811,7 +812,7 @@ function _Chat() {
// clear search results
if (n === 0) {
setPromptHints([]);
- } else if (text.startsWith(ChatCommandPrefix)) {
+ } else if (text.match(ChatCommandPrefix)) {
setPromptHints(chatCommands.search(text));
} else if (!config.disablePromptHint && n < SEARCH_TEXT_LIMIT) {
// check if need to trigger auto completion
@@ -1482,6 +1483,7 @@ function _Chat() {
setUserInput(getMessageTextContent(message));
}}
fontSize={fontSize}
+ fontFamily={fontFamily}
parentRef={scrollRef}
defaultShow={i >= messages.length - 6}
/>
@@ -1576,6 +1578,7 @@ function _Chat() {
autoFocus={autoFocus}
style={{
fontSize: config.fontSize,
+ fontFamily: config.fontFamily,
}}
/>
{attachImages.length != 0 && (
diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx
index 8210f61fb8f..1771cc9b013 100644
--- a/app/components/exporter.tsx
+++ b/app/components/exporter.tsx
@@ -583,6 +583,7 @@ export function ImagePreviewer(props: {
{getMessageImages(m).length == 1 && (
diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx
index c12daed6468..1531d2ff0e0 100644
--- a/app/components/markdown.tsx
+++ b/app/components/markdown.tsx
@@ -232,6 +232,7 @@ export function Markdown(
content: string;
loading?: boolean;
fontSize?: number;
+ fontFamily?: string;
parentRef?: RefObject;
defaultShow?: boolean;
} & React.DOMAttributes,
@@ -243,6 +244,7 @@ export function Markdown(
className="markdown-body"
style={{
fontSize: `${props.fontSize ?? 14}px`,
+ fontFamily: props.fontFamily || "inherit",
}}
ref={mdRef}
onContextMenu={props.onContextMenu}
diff --git a/app/components/settings.tsx b/app/components/settings.tsx
index 3197812259e..93976ac4551 100644
--- a/app/components/settings.tsx
+++ b/app/components/settings.tsx
@@ -1316,6 +1316,22 @@ export function Settings() {
>
+
+
+ updateConfig(
+ (config) => (config.fontFamily = e.currentTarget.value),
+ )
+ }
+ >
+
+