Skip to content

Commit 5082011

Browse files
committed
fix
修复注册用户时密码低于6位时的提醒
1 parent a0b9c49 commit 5082011

9 files changed

Lines changed: 634 additions & 634 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

backend/package-lock.json

Lines changed: 594 additions & 625 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"@cloudflare/workers-types": "^4.20240117.0",
18-
"wrangler": "^3.22.1"
18+
"wrangler": "^4.84.0"
1919
},
2020
"keywords": [
2121
"cloudflare",

backend/src/handlers/memos.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,18 @@ app.patch('/:id', async (c) => {
11411141
return errorResponse('Failed to update memo', 500);
11421142
}
11431143

1144+
if (body.content !== undefined) {
1145+
await db.prepare(`
1146+
DELETE FROM memo_tags
1147+
WHERE memo_id = ?
1148+
`).bind(id).run();
1149+
1150+
const tagNames = extractTagNamesFromMemoContent(body.content);
1151+
for (const tagName of tagNames) {
1152+
await attachTagToMemo(db, id, tagName, memo.creator_id);
1153+
}
1154+
}
1155+
11441156
// 处理附件:删除指定的附件
11451157
if (body.deleteResourceIds && Array.isArray(body.deleteResourceIds)) {
11461158
for (const resourceId of body.deleteResourceIds) {
@@ -1312,6 +1324,16 @@ app.put('/:id', async (c) => {
13121324
return errorResponse('Failed to update memo', 500);
13131325
}
13141326

1327+
await db.prepare(`
1328+
DELETE FROM memo_tags
1329+
WHERE memo_id = ?
1330+
`).bind(id).run();
1331+
1332+
const tagNames = extractTagNamesFromMemoContent(body.content);
1333+
for (const tagName of tagNames) {
1334+
await attachTagToMemo(db, id, tagName, memo.creator_id);
1335+
}
1336+
13151337
// 处理附件:删除指定的附件
13161338
if (body.deleteResourceIds && Array.isArray(body.deleteResourceIds)) {
13171339
for (const resourceId of body.deleteResourceIds) {

backend/src/utils/tags.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const CODE_BLOCK_REG = /```[\s\S]*?```/g;
33
const INLINE_CODE_REG = /`[^`\n]*`/g;
44
const MARKDOWN_LINK_REG = /!?\[[^\]]*\]\([^)]+\)/g;
55
const PLAIN_LINK_REG = /(?:https?|chrome|edge):\/\/\S+/g;
6-
const TAG_NAME_REG = /#([^\s#,]+)/g;
6+
const TAG_NAME_REG = /(^|[\s(\[{"'<,.;:!?])#([^\s#,]+)/g;
77

88
function buildTagSelectColumns(schema) {
99
return [
@@ -59,7 +59,7 @@ export function extractTagNamesFromMemoContent(content) {
5959

6060
const sanitizedContent = stripIgnoredTagSegments(content);
6161
const tagMatches = [...sanitizedContent.matchAll(TAG_NAME_REG)];
62-
return [...new Set(tagMatches.map((match) => match[1]))];
62+
return [...new Set(tagMatches.map((match) => match[2]))];
6363
}
6464

6565
export async function findTagByName(db, tagName, creatorId = null) {

frontend/src/labs/marked/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { matcher } from "./matcher";
2-
import { blockElementParserList, inlineElementParserList } from "./parser";
2+
import { blockElementParserList, inlineElementParserList, TAG_REG } from "./parser";
33

44
type Parser = {
55
name: string;
@@ -150,7 +150,10 @@ export const getMatchedTagNames = (markdownStr: string): string[] => {
150150

151151
for (const node of getMatchedNodes(markdownStr)) {
152152
if (node.parserName === "tag") {
153-
tagNameSet.add(node.matchedContent.slice(1));
153+
const matchResult = matcher(node.matchedContent, TAG_REG);
154+
if (matchResult) {
155+
tagNameSet.add(matchResult[2]);
156+
}
154157
}
155158
}
156159

frontend/src/labs/marked/parser/Tag.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import { matcher } from "../matcher";
22

3-
export const TAG_REG = /#([^\s#,]+)/;
3+
export const TAG_REG = /(^|[\s(\[{"'<,.;:!?])#([^\s#,]+)/;
44

55
const renderer = (rawStr: string) => {
66
const matchResult = matcher(rawStr, TAG_REG);
77
if (!matchResult) {
88
return rawStr;
99
}
1010

11-
return <span className="tag-span">#{matchResult[1]}</span>;
11+
return (
12+
<>
13+
{matchResult[1]}
14+
<span className="tag-span">#{matchResult[2]}</span>
15+
</>
16+
);
1217
};
1318

1419
export default {

frontend/src/pages/SignUp.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const SignUp = () => {
6464
}
6565
} catch (error: any) {
6666
console.error(error);
67-
toast.error(error.response.data.message || error.message || t("message.signup-failed"));
67+
toast.error(error?.response?.data?.message || error?.response?.data?.error || error?.message || t("message.signup-failed"));
6868
}
6969
actionBtnLoadingState.setFinish();
7070
};
@@ -114,7 +114,6 @@ const SignUp = () => {
114114
type="submit"
115115
disabled={actionBtnLoadingState.isLoading}
116116
loading={actionBtnLoadingState.isLoading}
117-
onClick={handleSignUpButtonClick}
118117
>
119118
{t("common.sign-up")}
120119
</Button>

frontend/src/router/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { lazy } from "react";
22
import { createBrowserRouter } from "react-router-dom";
33
import App from "@/App";
4+
import Loading from "@/pages/Loading";
45
import { initialGlobalState } from "@/store/module";
56
import AuthStatusProvider from "./AuthStatusProvider";
67

@@ -34,6 +35,7 @@ const router = createBrowserRouter([
3435
path: "/",
3536
element: <App />,
3637
loader: () => initialGlobalStateLoader(),
38+
hydrateFallbackElement: <Loading />,
3739
children: [
3840
{
3941
path: "/auth",

0 commit comments

Comments
 (0)