Skip to content

Commit db2e281

Browse files
committed
feat: restructure application layout, move component directory, and add new features
1 parent d9d491f commit db2e281

File tree

43 files changed

+1452
-905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1452
-905
lines changed

Diff for: README.md

+35-15
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,51 @@
44
55
这是一个开源的在线工具,主要由 ChatGPT 完成编程。我将把之前的本地应用处理工具在线化,并分享在这里。
66

7-
工具链接:<https://tools.newzone.top>
7+
在线链接:<https://tools.newzone.top>
8+
9+
## 工具列表
10+
11+
### JsonTranslate i18n 翻译器
12+
13+
[JsonTranslate](https://tools.newzone.top/json-translate) 是一款高效的多语言 JSON 翻译工具,专为开发者和内容创作者设计。支持 Google Translate、DeepL 和 DeepLX 翻译 API,助力快速实现项目的国际化和本地化。无论您是在开发多语言网站、应用程序还是处理多语言数据集,JsonTranslate 都能提供简便的解决方案,轻松将 JSON 文件中的内容翻译为多种目标语言。了解更多可查看[使用教程](https://newzone.top/apps/devdocs/json-translate.html)
14+
15+
![](https://img.newzone.top/2023-12-18-16-09-04.gif?imageMogr2/format/webp "JsonTranslate 使用示例")
16+
17+
### 其它
18+
19+
- [SRT 字幕翻译](https://tools.newzone.top/sublabel-translator):自动字幕翻译,支持多种语言的字幕文件转换。
20+
21+
- [正则匹配](https://tools.newzone.top/regex-matcher):使用正则表达式匹配文本。
22+
23+
- [文本分割](https://tools.newzone.top/text-splitter):将长文本按照特定规则进行分割。
24+
25+
- [JSON 键值替换工具](https://tools.newzone.top/json-value-transformer):将 JSON 中指定键的值替换为另一个指定键的值。
26+
27+
- [JSON 键值互换工具](https://tools.newzone.top/json-value-swapper):在 JSON 中互换指定的两个键的值。
28+
29+
- [JSON 节点插入工具](https://tools.newzone.top/json-node-inserter):在 JSON 中的指定位置插入新的节点。
30+
31+
- [JSON 节点批量编辑](https://tools.newzone.top/json-node-edit):批量编辑 JSON 节点的值。
32+
33+
- [JSON 值提取工具](https://tools.newzone.top/json-value-extractor):从 JSON 数据中批量提取特定键名的值。
34+
35+
- [Flare 书签解析工具](https://tools.newzone.top/data-parser/flare):将书签数据转换为 Flare 格式,并可互相转换。
36+
37+
- [IMGPrompt 数据转换器](https://tools.newzone.top/data-parser/img-prompt):为 IMGPrompt 数据处理设计,通过自定义对象与属性批量生成 JSON 数据。
38+
39+
- [JSON 数据匹配更新](https://tools.newzone.top/json-match-update):使用两个不同的 JSON 数据,根据它们的键名进行匹配,并使用另一个指定键名的值进行更新的工具。
840

941
## 生成命令
1042

1143
v1:
1244

13-
```txt
45+
```bash
1446
Please act as a Senior Frontend developer and create a a project using Create Next App, yarn, Ant Design, axios. In this project, implement a feature that displays Chinese text on the screen. Apply styling using Ant Design. Please provide all relevant code snippets for each task and explain how they work. Your first task is [项目要求]
1547
```
1648

1749
v2:
1850

19-
```txt
51+
```bash
2052
Please assist me in building a frontend project with specific technologies and features. Your expertise as a Senior Frontend Developer will be appreciated. Here are the detailed tasks:
2153

2254
1. Setup a new project using Create Next App, yarn, Ant Design, axios.
@@ -28,18 +60,6 @@ Please assist me in building a frontend project with specific technologies and f
2860
Please provide all relevant code snippets for each task and explain how they work. Your first task is [项目要求]
2961
```
3062

31-
## 工具说明
32-
33-
### JsonTranslate i18n 翻译器
34-
35-
JsonTranslate 是一款高效的多语言 JSON 翻译工具,专为开发者和内容创作者设计。支持 Google Translate、DeepL 和 DeepLX 翻译 API,助力快速实现项目的国际化和本地化。无论您是在开发多语言网站、应用程序还是处理多语言数据集,JsonTranslate 都能提供简便的解决方案,轻松将 JSON 文件中的内容翻译为多种目标语言。了解更多可查看[使用教程](https://newzone.top/apps/devdocs/json-translate.html)
36-
37-
![](https://img.newzone.top/2023-12-18-16-09-04.gif?imageMogr2/format/webp "JsonTranslate 使用示例")
38-
39-
### 批量文本处理器
40-
41-
批量文本处理器除了支持正则匹配和 JSON 节点提取,还可以在多条件匹配时使用条件语句执行不同的文本处理操作。例如,匹配 `<h4>``</h4>` 之间的文本执行文本处理操作 1,匹配 `<h5>``</h5>` 之间的文本执行文本处理操作 2,如果都没有匹配到则直接输出文本。批量文本处理器适合从大量数据中提取文本,并按照特定规则进行处理和输出。
42-
4363
## Deploy
4464

4565
System Requirements:

Diff for: package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tools-by-ai",
3-
"version": "1.1.8",
3+
"version": "1.2.0",
44
"license": "MIT",
55
"scripts": {
66
"dev": "next dev",
@@ -11,9 +11,9 @@
1111
"dependencies": {
1212
"@ant-design/nextjs-registry": "^1.0.0",
1313
"@next/third-parties": "14.2.3",
14-
"antd": "^5.17.4",
14+
"antd": "^5.18.0",
1515
"http-proxy-middleware": "^3.0.0",
16-
"jsonpath-plus": "^8.1.0",
16+
"jsonpath-plus": "^9.0.0",
1717
"next": "14.2.3",
1818
"react": "^18",
1919
"react-dom": "^18"
@@ -26,7 +26,7 @@
2626
"eslint": "^8",
2727
"eslint-config-next": "14.2.3",
2828
"postcss": "^8",
29-
"tailwindcss": "^3.4.3",
29+
"tailwindcss": "^3.4.4",
3030
"typescript": "^5.4.5"
3131
}
3232
}

Diff for: src/app/components/JsonWeightUpdater.tsx renamed to src/app/(json)/json-match-update/client.tsx

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
"use client";
2+
13
import { useState } from "react";
24
import { Input, Button, Typography, message, Row, Col, Space } from "antd";
5+
import { CopyOutlined } from "@ant-design/icons";
36
import { copyToClipboard } from "@/app/components/copyToClipboard";
47

5-
const JsonWeightUpdater = () => {
8+
const { Title, Paragraph } = Typography;
9+
10+
const ClientPage = () => {
611
const [jsonInput, setJsonInput] = useState("");
712
const [countJson, setCountJson] = useState("");
813
const [result, setResult] = useState("");
914

10-
// 新增的 state
1115
const [idField, setIdField] = useState("id");
1216
const [weightField, setWeightField] = useState("weight");
1317
const [cardIdField, setCardIdField] = useState("card_id");
@@ -45,30 +49,33 @@ const JsonWeightUpdater = () => {
4549

4650
return (
4751
<>
48-
<Typography.Paragraph type="secondary" style={{ fontSize: "14px", marginBottom: "20px" }}>
49-
请在输入框中输入原始 JSON 数据和计数 JSON
50-
数据,然后点击“匹配”按钮。工具会根据计数数据中的「card_id」与原始数据中的「id」匹配,并将对应计数数据的「count」值更新到原始数据中的「weight」值。处理成功后,页面会显示处理后的内容,并在“匹配结果框”中显示结果。用户可以根据需要点击“复制结果”按钮,将结果复制到剪贴板。
51-
</Typography.Paragraph>
52+
<Title level={2}>JSON 数据匹配更新</Title>
53+
<Paragraph type="secondary">
54+
输入原始 JSON和待匹配
55+
JSON,然后点击“匹配”按钮。工具会根据待匹配数据中的「card_id」与原始数据中的「id」匹配,并将对应待匹配数据的「count」值更新到原始数据中的「weight」值。处理成功后,页面会显示处理后的JSON文本。点击“复制结果”按钮,即可将结果复制到剪贴板。
56+
</Paragraph>
5257
<Row gutter={[16, 16]}>
5358
<Col xs={24} md={12}>
5459
<Input.TextArea placeholder="输入原始JSON数据" value={jsonInput} onChange={(e) => setJsonInput(e.target.value)} rows={3} />
55-
<Input.TextArea placeholder="输入计数JSON数据" value={countJson} onChange={(e) => setCountJson(e.target.value)} rows={2} style={{ marginTop: "5px" }} />
60+
<Input.TextArea placeholder="输入待匹配JSON数据" value={countJson} onChange={(e) => setCountJson(e.target.value)} rows={2} style={{ marginTop: "5px" }} />
5661
</Col>
5762
<Col xs={24} md={12}>
5863
<Space style={{ display: "flex", marginBottom: 8 }} align="baseline">
5964
匹配键名:
6065
<Input placeholder="原始数据 ID 字段名" value={idField} onChange={(e) => setIdField(e.target.value)} />
61-
<Input placeholder="计数数据 card_id 字段名" value={cardIdField} onChange={(e) => setCardIdField(e.target.value)} style={{ marginTop: "5px" }} />
66+
<Input placeholder="待匹配数据 card_id 字段名" value={cardIdField} onChange={(e) => setCardIdField(e.target.value)} style={{ marginTop: "5px" }} />
6267
</Space>
6368
<Space style={{ display: "flex", marginBottom: 8 }} align="baseline">
6469
更新键名:
6570
<Input placeholder="原始数据 weight 字段名" value={weightField} onChange={(e) => setWeightField(e.target.value)} />
66-
<Input placeholder="计数数据 count 字段名" value={countField} onChange={(e) => setCountField(e.target.value)} />
71+
<Input placeholder="待匹配数据 count 字段名" value={countField} onChange={(e) => setCountField(e.target.value)} />
6772
</Space>
68-
<Button onClick={handleUpdate} style={{ marginRight: "10px" }}>
73+
<Button type="primary" onClick={handleUpdate} style={{ marginRight: "10px" }}>
6974
更新
7075
</Button>
71-
<Button onClick={() => copyToClipboard(result)}>复制结果</Button>
76+
<Button icon={<CopyOutlined />} onClick={() => copyToClipboard(result)}>
77+
复制结果
78+
</Button>
7279
</Col>
7380
</Row>
7481
<Row style={{ marginTop: "10px" }}>
@@ -80,4 +87,4 @@ const JsonWeightUpdater = () => {
8087
);
8188
};
8289

83-
export default JsonWeightUpdater;
90+
export default ClientPage;

Diff for: src/app/(json)/json-match-update/page.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import ClientPage from "./client";
2+
3+
import type { Metadata } from "next";
4+
5+
export const metadata: Metadata = {
6+
title: "JSON 数据匹配更新工具|Tools by AI",
7+
description: "将计数 JSON 数据与原始 JSON 数据匹配,并自动更新权重值。支持自定义字段名,操作简单,处理快速。支持多种权重数据格式。",
8+
keywords: "JSON工具, JSON数据更新, JSON匹配工具, JSON数据处理, JSON自动更新, 数据处理工具, JSON解析, JSON编辑器",
9+
};
10+
11+
export default function Page() {
12+
return <ClientPage />;
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
1-
import React, { useState } from "react";
2-
import { Row, Col, Button, Form, Input, message, Typography, Card, Space, Checkbox } from "antd";
1+
"use client";
2+
3+
import React, { useState, useCallback } from "react";
4+
import { Row, Col, Button, Form, Input, message, Typography, Card, Space, Checkbox, Tooltip } from "antd";
5+
import { CopyOutlined } from "@ant-design/icons";
36
import { JSONPath } from "jsonpath-plus";
47
import { preprocessJson } from "@/app/components/preprocessJson";
58
import { copyToClipboard } from "@/app/components/copyToClipboard";
69

7-
const JsonEdit = () => {
8-
const [jsonInput, setJsonInput] = useState<string>("");
9-
const [jsonOutput, setJsonOutput] = useState<any>({});
10-
const [prefix, setPrefix] = useState<string>("");
11-
const [suffix, setSuffix] = useState<string>("");
12-
const [findText, setFindText] = useState<string>("");
13-
const [replaceText, setReplaceText] = useState<string>("");
10+
const { Title, Paragraph } = Typography;
11+
12+
const languages = {
13+
zh: "Chinese",
14+
en: "English",
15+
ja: "Japanese",
16+
ko: "Korean",
17+
es: "Spanish",
18+
fr: "French",
19+
de: "German",
20+
it: "Italian",
21+
ru: "Russian",
22+
pt: "Portuguese",
23+
hi: "Hindi",
24+
ar: "Arabic",
25+
bn: "Bengali",
26+
};
1427

15-
const [jsonPath, setJsonPath] = useState<string>("");
28+
const ClientPage = () => {
29+
const [jsonInput, setJsonInput] = useState("");
30+
const [jsonOutput, setJsonOutput] = useState("");
31+
const [prefix, setPrefix] = useState("");
32+
const [suffix, setSuffix] = useState("");
33+
const [findText, setFindText] = useState("");
34+
const [replaceText, setReplaceText] = useState("");
35+
const [jsonPath, setJsonPath] = useState("");
1636
const [isVariableReplace, setIsVariableReplace] = useState(false);
1737

18-
const languages = {
19-
zh: "Chinese",
20-
en: "English",
21-
ja: "Japanese",
22-
ko: "Korean",
23-
es: "Spanish",
24-
fr: "French",
25-
de: "German",
26-
it: "Italian",
27-
ru: "Russian",
28-
pt: "Portuguese",
29-
hi: "Hindi",
30-
ar: "Arabic",
31-
bn: "Bengali",
32-
};
38+
const handleInputChange = useCallback((setter) => (e) => setter(e.target.value), []);
3339

3440
const applyPrefixSuffix = (value, path) => {
3541
let newValue = value;
@@ -49,7 +55,7 @@ const JsonEdit = () => {
4955
return newValue;
5056
};
5157

52-
const handleEdit = () => {
58+
const handleEdit = useCallback(() => {
5359
if (!jsonInput) {
5460
message.error("JSON Input 不能为空");
5561
return;
@@ -79,61 +85,61 @@ const JsonEdit = () => {
7985
let nodePathArray = JSONPath.toPathArray(node.path);
8086
if (nodePathArray && nodePathArray.length > 0) {
8187
let currentNode = jsonObject;
82-
// 遍历路径数组,直到到达倒数第二个元素
8388
for (let i = 1; i < nodePathArray.length - 1; i++) {
8489
currentNode = currentNode[nodePathArray[i]];
8590
}
86-
// 应用 applyPrefixSuffix 函数并更新值
8791
currentNode[nodePathArray[nodePathArray.length - 1]] = applyPrefixSuffix(node.value, nodePathArray.join("."));
8892
}
8993
});
9094
});
9195

9296
setJsonOutput(JSON.stringify(jsonObject, null, 2));
93-
};
97+
}, [jsonInput, jsonPath, findText, replaceText, prefix, suffix, isVariableReplace]);
9498

9599
return (
96100
<>
97-
<Typography.Paragraph type="secondary" style={{ fontSize: "14px" }}>
98-
在 JSON 中查找节点并编辑它们的值,你可以为找到的节点的值添加前缀、后缀或进行替换操作。节点的查找支持批量操作,可以使用逗号来分割节点。
99-
</Typography.Paragraph>
101+
<Title level={2}>JSON 节点批量编辑</Title>
102+
<Paragraph type="secondary">
103+
在 JSON
104+
中查找节点并编辑它们的值,你可以为找到的节点的值添加前缀、后缀或进行替换操作。节点的查找支持批量操作,可以使用逗号来分割节点。请注意,本工具只支持第一层的子键,不支持嵌套子键内的键名互换。
105+
</Paragraph>
100106
<Row gutter={16}>
101107
<Col xs={24} lg={12}>
102108
<Card title="输入区">
103109
<Form.Item label="🔍JSON节点">
104-
<Input value={jsonPath} onChange={(e) => setJsonPath(e.target.value)} placeholder="Enter the JSONPaths, separated by commas" />
110+
<Input value={jsonPath} onChange={handleInputChange(setJsonPath)} placeholder="Enter the JSONPaths, separated by commas" />
105111
</Form.Item>
106112
<Form.Item label="添加前缀">
107-
<Input value={prefix} onChange={(e) => setPrefix(e.target.value)} placeholder="Enter a prefix to add to all output keys" />
113+
<Input value={prefix} onChange={handleInputChange(setPrefix)} placeholder="Enter a prefix to add to all output keys" />
108114
</Form.Item>
109115
<Form.Item label="添加后缀">
110-
<Input value={suffix} onChange={(e) => setSuffix(e.target.value)} placeholder="Enter a suffix to add to all output keys" />
116+
<Input value={suffix} onChange={handleInputChange(setSuffix)} placeholder="Enter a suffix to add to all output keys" />
111117
</Form.Item>
112-
<Space style={{ display: "flex", marginBottom: 8 }} align="baseline">
118+
<Space>
113119
<Form.Item label="查找文本">
114-
<Input value={findText} onChange={(e) => setFindText(e.target.value)} placeholder="Find in the JSON node" />
120+
<Input value={findText} onChange={handleInputChange(setFindText)} placeholder="Find in the JSON node" />
115121
</Form.Item>
116122
<Form.Item label="替换文本">
117-
<Input value={replaceText} onChange={(e) => setReplaceText(e.target.value)} placeholder="Replace the found text" />
123+
<Input value={replaceText} onChange={handleInputChange(setReplaceText)} placeholder="Replace the found text" />
118124
</Form.Item>
119-
<Form.Item>
125+
<Tooltip title="根据当前节点的语言代码(如 zh、en、ja 等),将找到的文本替换为对应语言的名称。例如,en 节点会将指定文本替换为 English,zh 节点则替换为 Chinese。">
120126
<Checkbox checked={isVariableReplace} onChange={(e) => setIsVariableReplace(e.target.checked)}>
121-
变量替换
127+
多语言变量替换
122128
</Checkbox>
123-
</Form.Item>
129+
</Tooltip>
124130
</Space>
125131
<Form.Item>
126-
<Input.TextArea placeholder="JSON Input" value={jsonInput} onChange={(e) => setJsonInput(e.target.value)} rows={10} />
132+
<Input.TextArea placeholder="JSON Input" value={jsonInput} onChange={handleInputChange(setJsonInput)} rows={10} />
127133
</Form.Item>
128134
</Card>
129135
</Col>
130136
<Col xs={24} lg={12}>
131137
<Card title="结果区">
132138
<Button onClick={handleEdit} style={{ marginBottom: "16px" }}>
133-
Edit JSON
139+
编辑 JSON
134140
</Button>
135-
<Button onClick={() => copyToClipboard(jsonOutput)} style={{ marginLeft: "16px", marginBottom: "16px" }}>
136-
Copy Result
141+
<Button icon={<CopyOutlined />} onClick={() => copyToClipboard(jsonOutput)} style={{ marginLeft: "16px", marginBottom: "16px" }}>
142+
复制结果
137143
</Button>
138144
<Form.Item>
139145
<Input.TextArea placeholder="JSON Output" value={jsonOutput} rows={10} readOnly />
@@ -145,4 +151,4 @@ const JsonEdit = () => {
145151
);
146152
};
147153

148-
export default JsonEdit;
154+
export default ClientPage;

Diff for: src/app/(json)/json-node-edit/page.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import ClientPage from "./client";
2+
3+
import type { Metadata } from "next";
4+
5+
export const metadata: Metadata = {
6+
title: "JSON节点批量编辑|Tools by AI",
7+
description: "使用本工具轻松编辑JSON节点,支持批量添加前缀、后缀或替换操作",
8+
keywords: "JSON编辑, 批量编辑JSON, JSON工具, 前缀后缀添加, 文本替换, 变量编辑",
9+
};
10+
11+
export default function Page() {
12+
return <ClientPage />;
13+
}

0 commit comments

Comments
 (0)