Initial commit - DesignerCEP Project with Caddy deployment

This commit is contained in:
zuowei1216
2025-12-19 21:27:17 +08:00
commit 8ea58fe480
170 changed files with 47469 additions and 0 deletions

311
tempdocs/常用命令.md Normal file
View File

@@ -0,0 +1,311 @@
# DesignerCEP 常用命令
## 🏗️ 三层架构说明
```
┌────────────────────────────────────────┐
│ 第 1 层Shell登录层
│ - 本地file:// 协议CEP 扩展) │
│ - 服务器http://127.0.0.1:8000/shell/ │
│ - 作用:登录、下载、启动 │
└────────────────────────────────────────┘
┌────────────────────────────────────────┐
│ 第 2 层Core业务层
│ - http://127.0.0.1:8000/core/vX.X.X/ │
│ - 作用:所有业务功能 │
└────────────────────────────────────────┘
┌────────────────────────────────────────┐
│ 第 3 层Server后端服务器
│ - http://127.0.0.1:8000/api/v1/ │
│ - 作用API、核心算法、数据库 │
└────────────────────────────────────────┘
```
---
## 📦 构建命令
### 开发模式
```bash
cd D:\main\DesignerCEP\Designer
npm run dev # 启动开发服务器Core
```
### 构建 Core业务层
```bash
cd D:\main\DesignerCEP\Designer
npm run build:core # 构建 Core 应用
```
### 构建 Shell登录层
```bash
cd D:\main\DesignerCEP\Designer
npm run build:shell # 构建 Shell登录、更新、加载 Core
# 构建后部署到服务器
cd ..
Copy-Item -Path "Designer\dist" -Destination "Server\Designer\dist" -Recurse -Force
```
---
## 🚀 发布命令
### 自动发布 Core推荐
```bash
cd D:\main\DesignerCEP
python auto_deploy_core.py --version v1.1.2 # 只构建打包
python auto_deploy_core.py --version v1.1.2 --update-db # 构建打包 + 更新数据库
python auto_deploy_core.py --version v1.1.2 --update-db --skip-clean # 不清除缓存
```
### 手动发布步骤
```bash
# 1. 构建
cd D:\main\DesignerCEP\Designer
npm run build:core
# 2. 重命名入口文件
cd dist_core
ren index-core.html index.html
# 3. 打包 ZIP
# 把 dist_core 目录打包成 core-v1.1.2.zip
# 4. 上传到 Server/archives/
```
---
## 🗄️ 服务器命令
### 启动后端服务
```bash
cd D:\main\DesignerCEP\Server
python main.py # 启动 FastAPI 服务器
python -m uvicorn app.main:app --reload # 或使用 uvicorn推荐
```
### 更新数据库版本
```bash
cd D:\main\DesignerCEP\Server
python update_version.py
```
### 部署 Shell 到服务器
```bash
# 1. 构建 Shell
cd D:\main\DesignerCEP\Designer
npm run build:shell
# 2. 复制到服务器
cd ..
Copy-Item -Path "Designer\dist" -Destination "Server\Designer\dist" -Recurse -Force
# 3. 重启服务器
cd Server
python -m uvicorn app.main:app --reload
```
**验证:** 访问 `http://127.0.0.1:8000/` 应该自动跳转到 Shell 登录页
---
## 🧹 清理命令
### 清除客户端缓存
```powershell
Remove-Item -Recurse -Force "$env:APPDATA\DesignerCache"
```
### 清除 CEP 扩展缓存
```powershell
Remove-Item -Recurse -Force "$env:APPDATA\Adobe\CEP\extensions\Designer"
Remove-Item -Recurse -Force "$env:APPDATA\Adobe\CEP\extensions\Designer-dev"
```
---
## 📁 重要目录
| 目录 | 说明 |
|------|------|
| `Designer/src/view/` | Core Vue 页面组件 |
| `Designer/src/launcher/` | Shell 源代码(登录、更新器)|
| `Designer/src/api/jsxApi/inline/` | 内联 JSX 函数 |
| `Designer/dist_core/` | Core 构建输出 |
| `Designer/dist/` | Shell 构建输出 |
| `Server/Designer/dist/` | Shell 服务器部署目录 ⭐ |
| `Server/archives/` | Core 版本 ZIP 包存放 |
| `%APPDATA%\DesignerCache\` | 客户端 Core 缓存目录 |
---
## 🌐 URL 访问路径
| URL | 说明 | 文件位置 |
|-----|------|---------|
| `http://127.0.0.1:8000/` | 根路径(自动跳转) | 重定向到 Shell |
| `http://127.0.0.1:8000/shell/` | Shell 登录页 | `Server/Designer/dist/` |
| `http://127.0.0.1:8000/core/v1.2.4/` | Core 业务页 | `%APPDATA%\DesignerCache\v1.2.4\` |
| `http://127.0.0.1:8000/api/v1/` | 后端 API | Server 代码 |
| `http://127.0.0.1:8000/download/` | Core 下载 | `Server/archives/` |
---
## 🔧 开发新功能
### 📝 添加纯前端 JSX 功能
#### 1. 在 layer.ts 添加函数
```typescript
// Designer/src/api/jsxApi/inline/layer.ts
export async function (): Promise<JSXResponse> {
const jsx = `
try {
// JSX 代码
return JSXUtils.stringify({ success: true });
} catch (error) {
return JSXUtils.stringify({ error: error.toString() });
}
`;
return evalInlineJSX(jsx);
}
```
#### 2. 在 Home.vue 调用
```typescript
import * as Layer from '@/api/jsxApi/inline/layer';
const handle新功能 = async () => {
const res = await Layer.();
if (res.success) {
Message.success('成功');
}
};
```
---
### 🔐 添加混合架构功能(前端 + 后端)
**适用场景:** 需要保护核心算法、AI 计算、复杂数学模型等
#### 1. 后端实现Server/app/api/v1/jsx_demo.py
```python
class YourFeatureRequest(BaseModel):
param1: str
param2: int
@router.post("/your-feature")
async def your_feature(
request: YourFeatureRequest,
x_api_key: Optional[str] = Header(None)
):
# 验证 API Key
if not validate_api_key(x_api_key):
raise HTTPException(403, "无效的 API Key")
# 🔒 核心算法(客户端看不到)
result = complex_algorithm(request.param1, request.param2)
return {"success": True, "result": result}
```
#### 2. 前端实现Designer/src/api/jsxApi/inline/your-feature.ts
```typescript
export async function yourFeature(param1: string, param2: number): Promise<JSXResponse> {
// 1. 发送到服务器计算
const response = await fetch(`${config.apiBaseUrl}/jsx_demo/your-feature`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'demo_key_123' // 🔐 API Key
},
body: JSON.stringify({ param1, param2 })
});
const serverResult = await response.json();
// 2. 应用服务器结果到 PS
const jsx = `
// 使用 serverResult 执行 PS 操作
`;
return evalInlineJSX(jsx);
}
```
**参考文档:**
- `tempdocs/framework_guide.md` - 完整框架说明
- `tempdocs/quick_start_template.md` - 快速开发模板
---
## 🧪 测试命令
### 测试混合架构 Demo
```bash
# 1. 启动后端
cd D:\main\DesignerCEP\Server
python -m uvicorn app.main:app --reload
# 2. 在 PS 中创建图层,名称为数学表达式
# 如87-98, 100+200
# 3. 点击"智能配色"按钮
# 前端会获取图层名称 → 发送到服务器计算 → 显示结果
```
### 测试 API Key 验证
```bash
# 使用 curl 测试
curl -X POST http://127.0.0.1:8000/api/v1/jsx_demo/calculate \
-H "Content-Type: application/json" \
-H "X-API-Key: demo_key_123" \
-d '{"expression": "87-98"}'
```
---
## 🔄 完整发布流程
### 发布新版本 Core
```bash
# 1. 修改代码
# 2. 构建 + 打包 + 更新数据库(一键完成)
cd D:\main\DesignerCEP
python auto_deploy_core.py --version v1.2.5 --update-db
# 3. 清除客户端缓存(测试用)
Remove-Item -Recurse -Force "$env:APPDATA\DesignerCache"
# 4. 重新登录测试
```
### 更新 Shell
```bash
# 1. 构建 Shell
cd D:\main\DesignerCEP\Designer
npm run build:shell
# 2. 部署到服务器
cd ..
Copy-Item -Path "Designer\dist" -Destination "Server\Designer\dist" -Recurse -Force
# 3. 重启后端(如果使用 --reload 会自动重启)
```
---
## 📚 相关文档
| 文档 | 说明 |
|------|------|
| `混合架构开发框架指南.md` | 混合架构框架完整指南 |
| `混合架构快速开发模板.md` | 5 分钟快速开发模板 |
| `混合方案Demo说明.md` | 混合方案 Demo 说明 |
| `许可证验证接口文档.md` | 许可证验证接口文档 |
| `后端部署Shell指南.md` | Shell 服务器部署指南 |
| `API密钥使用指南.md` | API Key 使用指南 |