Skip to content

Commit af1088e

Browse files
committed
2 parents f5ac5bf + a8c65e3 commit af1088e

File tree

8 files changed

+170
-26
lines changed

8 files changed

+170
-26
lines changed

app/api/tencent/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function handle(
4343
export const GET = handle;
4444
export const POST = handle;
4545

46-
export const runtime = "nodejs";
46+
export const runtime = "edge";
4747
export const preferredRegion = [
4848
"arn1",
4949
"bom1",

app/components/home.module.scss

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,18 @@
137137
position: relative;
138138
padding-top: 20px;
139139
padding-bottom: 20px;
140+
display: flex;
141+
justify-content: space-between;
142+
align-items: center;
140143
}
141144

142145
.sidebar-logo {
143-
position: absolute;
144-
right: 0;
145-
bottom: 18px;
146+
display: inline-flex;
147+
}
148+
149+
.sidebar-title-container {
150+
display: inline-flex;
151+
flex-direction: column;
146152
}
147153

148154
.sidebar-title {

app/components/markdown.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,32 @@ export function PreCode(props: { children: any }) {
9696
[plugins],
9797
);
9898

99+
//Wrap the paragraph for plain-text
100+
useEffect(() => {
101+
if (ref.current) {
102+
const codeElements = ref.current.querySelectorAll(
103+
"code",
104+
) as NodeListOf<HTMLElement>;
105+
const wrapLanguages = [
106+
"",
107+
"md",
108+
"markdown",
109+
"text",
110+
"txt",
111+
"plaintext",
112+
"tex",
113+
"latex",
114+
];
115+
codeElements.forEach((codeElement) => {
116+
let languageClass = codeElement.className.match(/language-(\w+)/);
117+
let name = languageClass ? languageClass[1] : "";
118+
if (wrapLanguages.includes(name)) {
119+
codeElement.style.whiteSpace = "pre-wrap";
120+
}
121+
});
122+
}
123+
}, []);
124+
99125
return (
100126
<>
101127
<pre ref={ref}>

app/components/sd/sd.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import CopyIcon from "@/app/icons/copy.svg";
2323
import PromptIcon from "@/app/icons/prompt.svg";
2424
import ResetIcon from "@/app/icons/reload.svg";
2525
import { useSdStore } from "@/app/store/sd";
26-
import locales from "@/app/locales";
2726
import LoadingIcon from "@/app/icons/three-dots.svg";
2827
import ErrorIcon from "@/app/icons/delete.svg";
2928
import SDIcon from "@/app/icons/sd.svg";
@@ -64,14 +63,14 @@ function getSdTaskStatus(item: any) {
6463
return (
6564
<p className={styles["line-1"]} title={item.error} style={{ color: color }}>
6665
<span>
67-
{locales.Sd.Status.Name}: {s}
66+
{Locale.Sd.Status.Name}: {s}
6867
</span>
6968
{item.status === "error" && (
7069
<span
7170
className="clickable"
7271
onClick={() => {
7372
showModal({
74-
title: locales.Sd.Detail,
73+
title: Locale.Sd.Detail,
7574
children: (
7675
<div style={{ color: color, userSelect: "text" }}>
7776
{item.error}
@@ -189,13 +188,13 @@ export function Sd() {
189188
className={styles["sd-img-item-info"]}
190189
>
191190
<p className={styles["line-1"]}>
192-
{locales.SdPanel.Prompt}:{" "}
191+
{Locale.SdPanel.Prompt}:{" "}
193192
<span
194193
className="clickable"
195194
title={item.params.prompt}
196195
onClick={() => {
197196
showModal({
198-
title: locales.Sd.Detail,
197+
title: Locale.Sd.Detail,
199198
children: (
200199
<div style={{ userSelect: "text" }}>
201200
{item.params.prompt}
@@ -208,7 +207,7 @@ export function Sd() {
208207
</span>
209208
</p>
210209
<p>
211-
{locales.SdPanel.AIModel}: {item.model_name}
210+
{Locale.SdPanel.AIModel}: {item.model_name}
212211
</p>
213212
{getSdTaskStatus(item)}
214213
<p>{item.created_at}</p>
@@ -219,7 +218,7 @@ export function Sd() {
219218
icon={<PromptIcon />}
220219
onClick={() => {
221220
showModal({
222-
title: locales.Sd.GenerateParams,
221+
title: Locale.Sd.GenerateParams,
223222
children: (
224223
<div style={{ userSelect: "text" }}>
225224
{Object.keys(item.params).map((key) => {
@@ -325,7 +324,7 @@ export function Sd() {
325324
);
326325
})
327326
) : (
328-
<div>{locales.Sd.EmptyRecord}</div>
327+
<div>{Locale.Sd.EmptyRecord}</div>
329328
)}
330329
</div>
331330
</div>

app/components/sidebar.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@ export function SideBarHeader(props: {
171171
return (
172172
<Fragment>
173173
<div className={styles["sidebar-header"]} data-tauri-drag-region>
174-
<div className={styles["sidebar-title"]} data-tauri-drag-region>
175-
{title}
174+
<div className={styles["sidebar-title-container"]}>
175+
<div className={styles["sidebar-title"]} data-tauri-drag-region>
176+
{title}
177+
</div>
178+
<div className={styles["sidebar-sub-title"]}>{subTitle}</div>
176179
</div>
177-
<div className={styles["sidebar-sub-title"]}>{subTitle}</div>
178180
<div className={styles["sidebar-logo"] + " no-dark"}>{logo}</div>
179181
</div>
180182
{children}

app/utils/tencent.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import { createHash, createHmac } from "node:crypto";
1+
import hash from "hash.js";
2+
23
// 使用 SHA-256 和 secret 进行 HMAC 加密
34
function sha256(message: any, secret = "", encoding?: string) {
4-
return createHmac("sha256", secret)
5+
return hash
6+
.hmac(hash.sha256 as any, secret)
57
.update(message)
68
.digest(encoding as any);
79
}
810

911
// 使用 SHA-256 进行哈希
1012
function getHash(message: any, encoding = "hex") {
11-
return createHash("sha256")
13+
return hash
14+
.sha256()
1215
.update(message)
1316
.digest(encoding as any);
1417
}

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"license": "mit",
55
"scripts": {
66
"mask": "npx tsx app/masks/build.ts",
7-
"mask:watch": "npx watch 'yarn mask' app/masks",
8-
"dev": "yarn run mask:watch & next dev",
7+
"mask:watch": "npx watch \"yarn mask\" app/masks",
8+
"dev": "concurrently -r \"yarn run mask:watch\" \"next dev\"",
99
"build": "yarn mask && cross-env BUILD_MODE=standalone next build",
1010
"start": "next start",
1111
"lint": "next lint",
1212
"export": "yarn mask && cross-env BUILD_MODE=export BUILD_APP=1 next build",
13-
"export:dev": "yarn mask:watch & cross-env BUILD_MODE=export BUILD_APP=1 next dev",
14-
"app:dev": "yarn mask:watch & yarn tauri dev",
13+
"export:dev": "concurrently -r \"yarn mask:watch\" \"cross-env BUILD_MODE=export BUILD_APP=1 next dev\"",
14+
"app:dev": "concurrently -r \"yarn mask:watch\" \"yarn tauri dev\"",
1515
"app:build": "yarn mask && yarn tauri build",
1616
"prompts": "node ./scripts/fetch-prompts.mjs",
1717
"prepare": "husky install",
@@ -26,6 +26,7 @@
2626
"@vercel/speed-insights": "^1.0.2",
2727
"emoji-picker-react": "^4.9.2",
2828
"fuse.js": "^7.0.0",
29+
"hash.js": "^1.1.7",
2930
"heic2any": "^0.0.4",
3031
"html-to-image": "^1.11.11",
3132
"lodash-es": "^4.17.21",
@@ -55,6 +56,7 @@
5556
"@types/react-dom": "^18.2.7",
5657
"@types/react-katex": "^3.0.0",
5758
"@types/spark-md5": "^3.0.4",
59+
"concurrently": "^8.2.2",
5860
"cross-env": "^7.0.3",
5961
"eslint": "^8.49.0",
6062
"eslint-config-next": "13.4.19",

0 commit comments

Comments
 (0)