更新优化

This commit is contained in:
24kycj
2025-12-12 00:10:13 +08:00
parent 026d564c92
commit 50ff0d347a
34 changed files with 8669 additions and 7884 deletions
+116
View File
@@ -0,0 +1,116 @@
# 加密脚本使用说明
## 📁 文件说明
- `encrypt-electron.js` - 主加密脚本
- `encrypt-electron-win.bat` - Windows 批处理脚本
- `encrypt-electron.sh` - Linux/Mac Shell 脚本
- `cleanup-jsc.js` - 清理 .jsc 文件脚本
- `cleanup.js` - 清理源文件脚本(备份到 .backup)
- `restore.js` - 恢复源文件脚本(从 .backup)
- `module-map.json` - **模块文件名映射配置**(位于 `lib` 目录)
## 🔧 模块文件名映射配置
### 功能说明
`module-map.json` 允许你自定义加密后生成的文件名。这对于:
- 版本管理:不同版本使用不同的文件名
- 安全加固:使用不易猜测的文件名
- 多版本共存:同时保留多个版本的加密文件
### 配置文件结构
```json
{
"mappings": {
"design1": {
"core": "core", // 原文件名 → 加密后文件名(不含扩展名)
"output": "output",
"ui": "ui"
},
"design2": {
"core": "core",
"output": "output",
"ui": "ui"
},
"main": {
"index": "index",
"design1": "design1",
"design2": "design2"
}
}
}
```
### 使用示例
#### 示例 1:添加版本号
```json
{
"mappings": {
"design1": {
"core": "core_v2",
"output": "output_v2",
"ui": "ui_v2"
}
}
}
```
加密后会生成:`core_v2.jsc`, `output_v2.jsc`, `ui_v2.jsc`
#### 示例 2:使用随机名称
```json
{
"mappings": {
"design1": {
"core": "a1b2c3",
"output": "x9y8z7",
"ui": "m5n6o4"
}
}
}
```
加密后会生成:`a1b2c3.jsc`, `x9y8z7.jsc`, `m5n6o4.jsc`
### 使用步骤
1. **修改配置文件**
```bash
# 编辑 lib/module-map.json
# 修改 mappings 中的值
```
2. **运行加密脚本**
```bash
npm run encrypt:win # Windows
npm run encrypt:linux # Linux/Mac
```
3. **验证结果**
- 检查 `lib/design1/` 和 `lib/design2/` 目录
- 确认生成了映射后的 `.jsc` 文件
### ⚠️ 注意事项
1. **唯一性**:确保映射值唯一,避免文件名冲突
2. **重新加密**:修改配置后必须重新运行加密脚本
3. **备份**:修改前建议备份配置文件
4. **兼容性**:映射后的文件名会在运行时自动识别,无需修改代码
5. **清理**:清理脚本会自动识别映射后的文件名
### 🔄 恢复默认
如果不想使用映射,将所有值改回原文件名即可:
```json
{
"mappings": {
"design1": {
"core": "core",
"output": "output",
"ui": "ui"
}
}
}
```