CatPtain commited on
Commit
04ad860
·
verified ·
1 Parent(s): ce7a540

Upload 3 files

Browse files
Files changed (3) hide show
  1. .gitignore +56 -0
  2. Dockerfile +42 -0
  3. README.md +149 -10
.gitignore ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dependencies
2
+ node_modules/
3
+ */node_modules/
4
+
5
+ # Production builds
6
+ dist/
7
+ build/
8
+
9
+ # Environment variables
10
+ .env
11
+ .env.local
12
+ .env.development.local
13
+ .env.test.local
14
+ .env.production.local
15
+
16
+ # Logs
17
+ logs
18
+ *.log
19
+ npm-debug.log*
20
+ yarn-debug.log*
21
+ yarn-error.log*
22
+
23
+ # Runtime data
24
+ pids
25
+ *.pid
26
+ *.seed
27
+ *.pid.lock
28
+
29
+ # Coverage directory used by tools like istanbul
30
+ coverage/
31
+
32
+ # OS generated files
33
+ .DS_Store
34
+ .DS_Store?
35
+ ._*
36
+ .Spotlight-V100
37
+ .Trashes
38
+ ehthumbs.db
39
+ Thumbs.db
40
+
41
+ # Editor directories and files
42
+ .vscode/
43
+ .idea/
44
+ *.suo
45
+ *.ntvs*
46
+ *.njsproj
47
+ *.sln
48
+ *.sw?
49
+
50
+ # Package files
51
+ *.tgz
52
+ *.zip
53
+
54
+ # Temporary files
55
+ tmp/
56
+ temp/
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:18-alpine
2
+
3
+ # 安装必要的系统依赖
4
+ RUN apk add --no-cache bash curl
5
+
6
+ # 设置工作目录
7
+ WORKDIR /app
8
+
9
+ # 复制package.json文件
10
+ COPY backend/package*.json ./backend/
11
+ COPY frontend/package*.json ./frontend/
12
+
13
+ # 安装后端依赖
14
+ WORKDIR /app/backend
15
+ RUN npm ci --only=production
16
+
17
+ # 安装前端依赖并构建
18
+ WORKDIR /app/frontend
19
+ RUN npm ci
20
+ COPY frontend/ ./
21
+ RUN npm run build
22
+
23
+ # 复制后端代码
24
+ WORKDIR /app
25
+ COPY backend/ ./backend/
26
+
27
+ # 复制脚本文件
28
+ COPY deploy.sh start.sh ./
29
+ RUN chmod +x ./deploy.sh ./start.sh
30
+
31
+ # 设置工作目录为后端
32
+ WORKDIR /app/backend
33
+
34
+ # 暴露端口
35
+ EXPOSE 7860
36
+
37
+ # 健康检查
38
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
39
+ CMD curl -f http://localhost:7860/api/health || exit 1
40
+
41
+ # 启动应用
42
+ CMD ["npm", "start"]
README.md CHANGED
@@ -1,10 +1,149 @@
1
- ---
2
- title: PPTist Cybercity
3
- emoji: 🏢
4
- colorFrom: gray
5
- colorTo: green
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ title: PPTist Huggingface
2
+ emoji: 📊
3
+ colorFrom: blue
4
+ colorTo: purple
5
+ sdk: docker
6
+ pinned: false
7
+ license: agpl-3.0
8
+ app_port: 7860
9
+
10
+ models:
11
+ - sentence-transformers/all-MiniLM-L6-v2
12
+
13
+ tags:
14
+ - presentation
15
+ - ppt
16
+ - powerpoint
17
+ - slides
18
+ - editor
19
+
20
+ # PPTist Huggingface Space
21
+
22
+ 一个基于 PPTist 的在线演示文稿编辑器,部署在 Huggingface Space 上,支持多用户登录和 GitHub 数据存储。
23
+
24
+ ## 🎯 项目特点
25
+
26
+ - **多用户支持**: 内置4个测试账号(PS01-PS04)
27
+ - **GitHub存储**: 使用GitHub仓库作为数据存储后端
28
+ - **公网分享**: 每个PPT页面都有独立的公网URL
29
+ - **完整功能**: 保留PPTist的所有编辑和展示功能
30
+ - **Docker部署**: 一键部署到Huggingface Space
31
+
32
+ ## 🔑 测试账号
33
+
34
+ | 用户名 | 密码 | 角色 |
35
+ |--------|------|------|
36
+ | PS01 | admin_cybercity2025 | 管理员 |
37
+ | PS02 | cybercity2025 | 用户 |
38
+ | PS03 | cybercity2025 | 用户 |
39
+ | PS04 | cybercity2025 | 用户 |
40
+
41
+ ## 🚀 部署说明
42
+
43
+ ### 环境变量配置
44
+
45
+ 在 Huggingface Space 的 Settings 中设置以下环境变量:
46
+
47
+ ```bash
48
+ GITHUB_TOKEN=你的GitHub访问令牌
49
+ GITHUB_REPOS=https://github.com/CaPaCaptain/PPTist_huggingface_db
50
+ JWT_SECRET=pptist-secret-key-2025-huggingface
51
+ NODE_ENV=production
52
+ ```
53
+
54
+ ### GitHub 仓库设置
55
+
56
+ 1. 创建一个 GitHub 仓库用于存储 PPT 数据
57
+ 2. 生成 GitHub Personal Access Token,需要 `repo` 权限
58
+ 3. 在仓库中创建 `users/` 目录结构
59
+
60
+ ### 数据存储结构
61
+
62
+ ```
63
+ 仓库根目录/
64
+ ├── users/
65
+ │ ├── PS01/
66
+ │ │ ├── ppt1.json
67
+ │ │ └── ppt2.json
68
+ │ ├── PS02/
69
+ │ │ └── presentation.json
70
+ │ └── ...
71
+ ```
72
+
73
+ ## 📡 API 接口
74
+
75
+ ### 认证接口
76
+ - `POST /api/auth/login` - 用户登录
77
+ - `GET /api/auth/verify` - 验证token
78
+ - `GET /api/auth/user` - 获取用户信息
79
+
80
+ ### PPT管理接口
81
+ - `GET /api/ppt/list` - 获取PPT列表
82
+ - `GET /api/ppt/:pptId` - 获取PPT数据
83
+ - `POST /api/ppt/save` - 保存PPT
84
+ - `POST /api/ppt/create` - 创建新PPT
85
+ - `DELETE /api/ppt/:pptId` - 删除PPT
86
+ - `POST /api/ppt/:pptId/copy` - 复制PPT
87
+
88
+ ### 公共分享接口
89
+ - `GET /api/public/view/:userId/:pptId/:slideIndex` - 公开访问单页
90
+ - `GET /api/public/ppt/:userId/:pptId` - 公开访问完整PPT
91
+ - `POST /api/public/generate-share-link` - 生成分享链接
92
+
93
+ ## 🔧 本地开发
94
+
95
+ 1. 克隆项目:
96
+ ```bash
97
+ git clone <repository-url>
98
+ cd PPtist-Huggingface
99
+ ```
100
+
101
+ 2. 安装依赖:
102
+ ```bash
103
+ # 后端
104
+ cd backend
105
+ npm install
106
+
107
+ # 前端
108
+ cd ../frontend
109
+ npm install
110
+ ```
111
+
112
+ 3. 配置环境变量:
113
+ ```bash
114
+ cp backend/.env.example backend/.env
115
+ # 编辑 .env 文件,填入你的配置
116
+ ```
117
+
118
+ 4. 启动开发服务器:
119
+ ```bash
120
+ # 启动后端 (端口 7860)
121
+ cd backend
122
+ npm run dev
123
+
124
+ # 启动前端 (端口 5173)
125
+ cd frontend
126
+ npm run dev
127
+ ```
128
+
129
+ ## 🏗️ 系统架构
130
+
131
+ ```
132
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
133
+ │ 前端 Vue3 │ │ 后端 Express │ │ GitHub 仓库 │
134
+ │ PPTist UI │────│ JWT认证 │────│ JSON数据存储 │
135
+ │ Vite构建 │ │ RESTful API │ │ 版本控制 │
136
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
137
+ ```
138
+
139
+ ## 🌐 公网分享功能
140
+
141
+ 每个PPT页面都可以生成公网访问链接:
142
+
143
+ - **单页链接**: `https://your-space.hf.space/api/public/view/PS01/ppt-id/0`
144
+ - **完整PPT**: `https://your-space.hf.space/api/public/ppt/PS01/ppt-id`
145
+ - **前端查看**: `https://your-space.hf.space/public/PS01/ppt-id/0`
146
+
147
+ ## 📝 许可证
148
+
149
+ 本项目基于 AGPL-3.0 许可证开源。