Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 3, 2024
2 parents 79863c4 + a8c65e3 commit 52178cf
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/api/tencent/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function handle(
export const GET = handle;
export const POST = handle;

export const runtime = "nodejs";
export const runtime = "edge";
export const preferredRegion = [
"arn1",
"bom1",
Expand Down
12 changes: 9 additions & 3 deletions app/components/home.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,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 {
Expand Down
26 changes: 26 additions & 0 deletions app/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLElement>;
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 (
<>
<pre ref={ref}>
Expand Down
15 changes: 7 additions & 8 deletions app/components/sd/sd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -64,14 +63,14 @@ function getSdTaskStatus(item: any) {
return (
<p className={styles["line-1"]} title={item.error} style={{ color: color }}>
<span>
{locales.Sd.Status.Name}: {s}
{Locale.Sd.Status.Name}: {s}
</span>
{item.status === "error" && (
<span
className="clickable"
onClick={() => {
showModal({
title: locales.Sd.Detail,
title: Locale.Sd.Detail,
children: (
<div style={{ color: color, userSelect: "text" }}>
{item.error}
Expand Down Expand Up @@ -189,13 +188,13 @@ export function Sd() {
className={styles["sd-img-item-info"]}
>
<p className={styles["line-1"]}>
{locales.SdPanel.Prompt}:{" "}
{Locale.SdPanel.Prompt}:{" "}
<span
className="clickable"
title={item.params.prompt}
onClick={() => {
showModal({
title: locales.Sd.Detail,
title: Locale.Sd.Detail,
children: (
<div style={{ userSelect: "text" }}>
{item.params.prompt}
Expand All @@ -208,7 +207,7 @@ export function Sd() {
</span>
</p>
<p>
{locales.SdPanel.AIModel}: {item.model_name}
{Locale.SdPanel.AIModel}: {item.model_name}
</p>
{getSdTaskStatus(item)}
<p>{item.created_at}</p>
Expand All @@ -219,7 +218,7 @@ export function Sd() {
icon={<PromptIcon />}
onClick={() => {
showModal({
title: locales.Sd.GenerateParams,
title: Locale.Sd.GenerateParams,
children: (
<div style={{ userSelect: "text" }}>
{Object.keys(item.params).map((key) => {
Expand Down Expand Up @@ -325,7 +324,7 @@ export function Sd() {
);
})
) : (
<div>{locales.Sd.EmptyRecord}</div>
<div>{Locale.Sd.EmptyRecord}</div>
)}
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions app/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ export function SideBarHeader(props: {
return (
<Fragment>
<div className={styles["sidebar-header"]} data-tauri-drag-region>
<div className={styles["sidebar-title"]} data-tauri-drag-region>
{title}
<div className={styles["sidebar-title-container"]}>
<div className={styles["sidebar-title"]} data-tauri-drag-region>
{title}
</div>
<div className={styles["sidebar-sub-title"]}>{subTitle}</div>
</div>
<div className={styles["sidebar-sub-title"]}>{subTitle}</div>
<div className={styles["sidebar-logo"] + " no-dark"}>{logo}</div>
</div>
{children}
Expand Down
9 changes: 6 additions & 3 deletions app/utils/tencent.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { createHash, createHmac } from "node:crypto";
import hash from "hash.js";

// 使用 SHA-256 和 secret 进行 HMAC 加密
function sha256(message: any, secret = "", encoding?: string) {
return createHmac("sha256", secret)
return hash
.hmac(hash.sha256 as any, secret)
.update(message)
.digest(encoding as any);
}

// 使用 SHA-256 进行哈希
function getHash(message: any, encoding = "hex") {
return createHash("sha256")
return hash
.sha256()
.update(message)
.digest(encoding as any);
}
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 & next dev",
"mask:watch": "npx watch \"yarn mask\" app/masks",
"dev": "concurrently -r \"yarn run mask:watch\" \"next dev\"",
"build": "yarn mask && 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",
Expand All @@ -26,6 +26,7 @@
"@vercel/speed-insights": "^1.0.2",
"emoji-picker-react": "^4.9.2",
"fuse.js": "^7.0.0",
"hash.js": "^1.1.7",
"heic2any": "^0.0.4",
"html-to-image": "^1.11.11",
"lodash-es": "^4.17.21",
Expand Down Expand Up @@ -55,6 +56,7 @@
"@types/react-dom": "^18.2.7",
"@types/react-katex": "^3.0.0",
"@types/spark-md5": "^3.0.4",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"eslint": "^8.49.0",
"eslint-config-next": "13.4.19",
Expand Down
Loading

0 comments on commit 52178cf

Please sign in to comment.