소스 검색

更新文档

yichael 3 주 전
부모
커밋
10e811dd06
2개의 변경된 파일23개의 추가작업 그리고 102개의 파일을 삭제
  1. 23 23
      doc/CODING_STANDARDS.md
  2. 0 79
      doc/JSON_CRUD.md

+ 23 - 23
doc/CODING_STANDARDS.md

@@ -1,39 +1,39 @@
-# Coding Standards
+# 编码规范
 
-## 1. Meaningful variable names, file names, folder names. Use abbreviations for words over ten characters. Abbreviations must be over three characters.
+## 1. 变量名、文件名、文件夹名要有意义。超过十个字符的单词使用缩写。缩写必须超过三个字符。
 
-- ✅ `update-btn` (refresh button), `device-list`, `user-profile-settings` (profile = abbreviation)
-- ❌ `btn` (too vague), `d1` (meaningless), `temp` (unclear), `us` (abbreviation too short)
+- ✅ `update-btn` (刷新按钮), `device-list`, `user-profile-settings` (profile = 缩写)
+- ❌ `btn` (太模糊), `d1` (无意义), `temp` (不清楚), `us` (缩写太短)
 
-## 2. Use hyphens (`-`) for multi-word names.
+## 2. 多词名称使用连字符 (`-`)。
 
-## 3. Comments: One Function, One Comment, English Only
+## 3. 注释:一个函数,一个注释
 
-## 4. Use functions to separate different logic. Avoid writing too much logic in a single function.
+## 4. 使用函数来分离不同的逻辑。避免在单个函数中编写过多逻辑。
 
-## 5. Never use try-catch. Let errors crash.
+## 5. 永远不要使用 try-catch。让错误崩溃。
 
-## 6. GUI components must split into three files:
+## 6. GUI 组件必须拆分为三个文件:
 
-- `.jsx`: Layout only (no logic, no styles)
-- `.js`: Logic only (functions, state, business logic)
-- `.scss`: Styles only (no logic, no JSX)
+- `.jsx`: 仅布局(无逻辑,无样式)
+- `.js`: 仅逻辑(函数、状态、业务逻辑)
+- `.scss`: 仅样式(无逻辑,无 JSX)
 
-**Never write logic or inline styles in `.jsx` files.**
+**永远不要在 `.jsx` 文件中编写逻辑或内联样式。**
 
-## 7. Use the least code to implement functionality. 
+## 7. 使用最少的代码来实现功能。
 
-## 8. Do not add any `console.log` statements in production code.
+## 8. 不要在生产代码中添加任何 `console.log` 语句。
 
-## 9. Do not create script files unnecessarily. If you can call PowerShell directly, use PowerShell instead of creating a separate script file.
+## 9. 不要不必要地创建脚本文件。如果可以直接调用 PowerShell,使用 PowerShell 而不是创建单独的脚本文件。
 
-## 10. If you need to create any new files, you must ask first.
+## 10. 如果需要创建任何新文件,必须先询问。
 
-## 11. Use `switch` statements instead of multiple `if-else` chains when checking the same variable against multiple values.
+## 11. 当检查同一变量与多个值进行比较时,使用 `switch` 语句而不是多个 `if-else` 链。
 
-## 12. Prefer Early Return Over Else Blocks
+## 12. 优先使用提前返回而不是 else 块
 
-Prefer early return pattern:
+优先使用提前返回模式:
 ```javascript
 if (condition) { 
     ...
@@ -41,7 +41,7 @@ if (condition) {
 }
 ```
 
-Instead of:
+而不是:
 ```javascript
 if (condition) {
     ...
@@ -50,6 +50,6 @@ if (condition) {
 }
 ```
 
-## 13. No Existence Checks
+## 13. 不进行存在性检查
 
-Do not add if statements to check if directories exist, files exist, or if parsing succeeded. Let errors crash.
+不要添加 if 语句来检查目录是否存在、文件是否存在或解析是否成功。让错误崩溃。

+ 0 - 79
doc/JSON_CRUD.md

@@ -1,79 +0,0 @@
-# JSON 增删改查简单指南
-
-## 基本说明
-
-所有 JSON 文件保存在 `static` 目录下,使用相对路径即可。
-
-## 增(Create)- 创建文件
-
-```javascript
-await window.electronAPI.runNodejsScript('json-parser', 'create', 'device_list.json', JSON.stringify({devices: []}))
-```
-
-## 查(Read)- 读取文件
-
-```javascript
-const result = await window.electronAPI.runNodejsScript('json-parser', 'read', 'device_list.json')
-const jsonData = JSON.parse(result.stdout).data
-```
-
-**文件不存在时:** `result.stdout` 为空字符串 `''`
-
-## 改(Update)- 更新文件
-
-```javascript
-await window.electronAPI.runNodejsScript('json-parser', 'update', 'device_list.json', JSON.stringify({devices: ['192.168.1.1', '192.168.1.2']}))
-```
-
-## 删(Delete)- 删除元素
-
-删除数组中的元素:
-
-```javascript
-// 1. 读取
-const result = await window.electronAPI.runNodejsScript('json-parser', 'read', 'device_list.json')
-const jsonData = JSON.parse(result.stdout).data
-
-// 2. 过滤删除
-const filtered = jsonData.devices.filter(ip => ip !== '192.168.1.1')
-
-// 3. 更新
-await window.electronAPI.runNodejsScript('json-parser', 'update', 'device_list.json', JSON.stringify({devices: filtered}))
-```
-
-## 完整示例
-
-### 添加设备到数组
-
-```javascript
-// 读取
-const result = await window.electronAPI.runNodejsScript('json-parser', 'read', 'device_list.json')
-const jsonData = result.stdout === '' ? {devices: []} : JSON.parse(result.stdout).data
-
-// 添加
-jsonData.devices.push('192.168.1.3')
-
-// 更新
-await window.electronAPI.runNodejsScript('json-parser', 'update', 'device_list.json', JSON.stringify({devices: jsonData.devices}))
-```
-
-### 删除设备从数组
-
-```javascript
-// 读取
-const result = await window.electronAPI.runNodejsScript('json-parser', 'read', 'device_list.json')
-const jsonData = JSON.parse(result.stdout).data
-
-// 删除
-const filtered = jsonData.devices.filter(ip => ip !== '192.168.1.3')
-
-// 更新
-await window.electronAPI.runNodejsScript('json-parser', 'update', 'device_list.json', JSON.stringify({devices: filtered}))
-```
-
-### 检查文件是否存在
-
-```javascript
-const result = await window.electronAPI.runNodejsScript('json-parser', 'check', 'device_list.json')
-const exists = JSON.parse(result.stdout).exists
-```