diff --git a/app/command.ts b/app/command.ts index e515e5f0b..bea4e06f3 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 2d9d75b07..405fdb335 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -839,7 +839,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 diff --git a/app/components/home.module.scss b/app/components/home.module.scss index be83e548c..7d5c21685 100644 --- a/app/components/home.module.scss +++ b/app/components/home.module.scss @@ -143,12 +143,18 @@ position: relative; padding-top: 20px; padding-bottom: 20px; + display: flex; + justify-content: space-between; + align-items: center; } .sidebar-logo { - position: absolute; - right: 0; - bottom: 18px; + display: inline-flex; +} + +.sidebar-title-container { + display: inline-flex; + flex-direction: column; } .sidebar-title { diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index bd5366d94..0f6a37803 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -96,6 +96,32 @@ export function PreCode(props: { children: any }) { [plugins], ); + //Wrap the paragraph for plain-text + useEffect(() => { + if (ref.current) { + const codeElements = ref.current.querySelectorAll( + "code", + ) as NodeListOf; + const wrapLanguages = [ + "", + "md", + "markdown", + "text", + "txt", + "plaintext", + "tex", + "latex", + ]; + codeElements.forEach((codeElement) => { + let languageClass = codeElement.className.match(/language-(\w+)/); + let name = languageClass ? languageClass[1] : ""; + if (wrapLanguages.includes(name)) { + codeElement.style.whiteSpace = "pre-wrap"; + } + }); + } + }, []); + return ( <>
diff --git a/app/components/sd/sd.tsx b/app/components/sd/sd.tsx
index 9e5595900..c51d03027 100644
--- a/app/components/sd/sd.tsx
+++ b/app/components/sd/sd.tsx
@@ -23,7 +23,6 @@ import CopyIcon from "@/app/icons/copy.svg";
 import PromptIcon from "@/app/icons/prompt.svg";
 import ResetIcon from "@/app/icons/reload.svg";
 import { useSdStore } from "@/app/store/sd";
-import locales from "@/app/locales";
 import LoadingIcon from "@/app/icons/three-dots.svg";
 import ErrorIcon from "@/app/icons/delete.svg";
 import SDIcon from "@/app/icons/sd.svg";
@@ -64,14 +63,14 @@ function getSdTaskStatus(item: any) {
   return (
     

- {locales.Sd.Status.Name}: {s} + {Locale.Sd.Status.Name}: {s} {item.status === "error" && ( { showModal({ - title: locales.Sd.Detail, + title: Locale.Sd.Detail, children: (

{item.error} @@ -191,13 +190,13 @@ export function Sd() { className={styles["sd-img-item-info"]} >

- {locales.SdPanel.Prompt}:{" "} + {Locale.SdPanel.Prompt}:{" "} { showModal({ - title: locales.Sd.Detail, + title: Locale.Sd.Detail, children: (

{item.params.prompt} @@ -210,7 +209,7 @@ export function Sd() {

- {locales.SdPanel.AIModel}: {item.model_name} + {Locale.SdPanel.AIModel}: {item.model_name}

{getSdTaskStatus(item)}

{item.created_at}

@@ -221,7 +220,7 @@ export function Sd() { icon={} onClick={() => { showModal({ - title: locales.Sd.GenerateParams, + title: Locale.Sd.GenerateParams, children: (
{Object.keys(item.params).map((key) => { @@ -327,7 +326,7 @@ export function Sd() { ); }) ) : ( -
{locales.Sd.EmptyRecord}
+
{Locale.Sd.EmptyRecord}
)}
diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index 93fbadd7d..b37b628cb 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -196,10 +196,12 @@ export function SideBarHeader(props: { return (
-
- {title} +
+
+ {title} +
+
{subTitle}
-
{subTitle}
{logo}
{children} diff --git a/package.json b/package.json index e7cde4800..c6aefee24 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,14 @@ "license": "mit", "scripts": { "mask": "npx tsx app/masks/build.ts", - "mask:watch": "npx watch 'yarn mask' app/masks", - "dev": "yarn run mask:watch & npx prisma generate && npx prisma db push && next dev --hostname 0.0.0.0 --port 23000", + "mask:watch": "npx watch \"yarn mask\" app/masks", + "dev": "npx prisma generate && npx prisma db push && concurrently -r \"yarn run mask:watch\" \"next dev --hostname 0.0.0.0 --port 23000\"", "build": "yarn mask && npx next telemetry disable && npx prisma generate && cross-env BUILD_MODE=standalone next build", "start": "next start", "lint": "next lint", "export": "yarn mask && cross-env BUILD_MODE=export BUILD_APP=1 next build", - "export:dev": "yarn mask:watch & cross-env BUILD_MODE=export BUILD_APP=1 next dev", - "app:dev": "yarn mask:watch & yarn tauri dev", + "export:dev": "concurrently -r \"yarn mask:watch\" \"cross-env BUILD_MODE=export BUILD_APP=1 next dev\"", + "app:dev": "concurrently -r \"yarn mask:watch\" \"yarn tauri dev\"", "app:build": "yarn mask && yarn tauri build", "prompts": "node ./scripts/fetch-prompts.mjs", "prepare": "husky install", @@ -75,6 +75,7 @@ "@types/react-highlight-words": "0.20.0", "@types/react-katex": "^3.0.0", "@types/spark-md5": "^3.0.4", + "concurrently": "^8.2.2", "autoprefixer": "^10.4.17", "cross-env": "^7.0.3", "date-fns": "^3.6.0",