|
|
il y a 2 mois | |
|---|---|---|
| .github | il y a 2 mois | |
| backend | il y a 2 mois | |
| frontend | il y a 2 mois | |
| .gitattributes | il y a 2 mois | |
| .gitignore | il y a 2 mois | |
| CLAUDE.md | il y a 2 mois | |
| CONTRIBUTING.md | il y a 2 mois | |
| LICENSE | il y a 2 mois | |
| README.md | il y a 2 mois | |
| deploy.bat | il y a 2 mois | |
| deploy.sh | il y a 2 mois | |
| prompt.txt | il y a 2 mois | |
| snapshot-prompts.txt | il y a 2 mois |
一个简洁、安全的临时文件分享平台。无需注册,上传即分享。
| 层级 | 技术 |
|---|---|
| 前端 | Vue 3.3 + Vue Router 4 + Pinia + Axios |
| 后端 | Spring Boot 2.7.18 + MyBatis + JPA + Java 17 |
| 数据库 | SQLite(默认)/ MySQL 8.0+ |
| 构建 | Maven + npm |
复制配置模板并按需修改:
cd backend/src/main/resources
cp application.properties.example application.properties
# 如需 MySQL,还需:
cp application-mysql.properties.example application-mysql.properties
# 编辑 application-mysql.properties 填入数据库密码
构建并启动:
Windows:
deploy.bat
Linux / macOS:
chmod +x deploy.sh && ./deploy.sh
构建完成后启动:
cd backend
java -jar target/snapshot-backend-1.0.0.jar
访问 http://localhost:7626 即可使用。
首次启动默认使用 SQLite,无需安装任何数据库。
项目通过 Spring Profile 切换数据库,配置位于 backend/src/main/resources/application.properties:
# 使用 SQLite(默认,零配置)
spring.profiles.active=dev,sqlite
# 使用 MySQL
# spring.profiles.active=dev,mysql
无需任何额外配置,启动时自动在 data/ 目录创建数据库文件。适合个人使用或轻量部署。
创建数据库:
mysql -uroot -p < backend/src/main/resources/sql/create.sql
修改 application-mysql.properties 中的数据库连接信息:
spring.datasource.url=jdbc:mysql://localhost:3306/snapshot?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=your_password
切换 Profile 为 dev,mysql
snapshot/
├── backend/ # Spring Boot 后端
│ ├── src/main/java/com/snapshot/
│ │ ├── config/ # 配置(CORS、SQLite方言、MyBatis、数据库初始化)
│ │ ├── controller/ # REST 控制器
│ │ ├── dto/ # 数据传输对象
│ │ ├── entity/ # JPA 实体类
│ │ ├── exception/ # 全局异常处理
│ │ ├── mapper/ # MyBatis Mapper 接口
│ │ ├── repository/ # JPA Repository
│ │ ├── service/ # 业务逻辑
│ │ └── util/ # 工具类(ID生成、密码哈希)
│ ├── src/main/resources/
│ │ ├── mapper/ # MyBatis XML 映射
│ │ ├── sql/ # 数据库初始化脚本
│ │ ├── static/ # 前端构建产物(一体化部署)
│ │ ├── application.properties # 主配置
│ │ ├── application-mysql.properties # MySQL 配置
│ │ └── application-sqlite.properties # SQLite 配置
│ └── pom.xml
│
├── frontend/ # Vue 3 前端
│ ├── src/
│ │ ├── api/ # API 接口封装
│ │ ├── components/ # 组件(Markdown渲染、代码高亮、Toast)
│ │ ├── router/ # 路由配置
│ │ ├── stores/ # Pinia 状态管理
│ │ ├── styles/ # 全局样式
│ │ ├── views/ # 页面(Home、Share、NotFound)
│ │ ├── config.js # 前端配置(启动时从后端获取)
│ │ └── main.js
│ └── package.json
│
├── api/
│ └── API_DOCUMENT.md # RESTful API 接口文档
└── deploy.bat / deploy.sh # 一体化部署脚本
完整接口文档请参考 API_DOCUMENT.md。
| 分类 | 方法 | 端点 | 说明 |
|---|---|---|---|
| 配置 | GET | /api/config |
获取前端配置 |
| 上传 | POST | /api/upload |
创建上传记录 |
| 上传 | POST | /api/upload/{id}/files |
上传文件 |
| 上传 | GET | /api/upload/{id} |
获取上传详情 |
| 上传 | DELETE | /api/upload/{id} |
删除上传记录 |
| 上传 | GET | /api/upload/resolve/{prefix} |
前缀解析ID |
| 分享 | GET | /api/share/{id} |
访问分享内容 |
| 分享 | POST | /api/share/{id}/verify |
密码验证 |
| 分享 | GET | /api/share/{id}/file/{fileId} |
下载单个文件 |
| 分享 | GET | /api/share/{id}/download-all |
ZIP打包下载 |
所有核心配置集中在 application.properties,前端在启动时通过 /api/config 自动获取:
# 服务端口
server.port=7626
# 文件限制(前端自动读取)
app.file.max-size=524288000 # 单文件最大 500MB
app.file.max-count=10 # 最多 10 个文件
# 存储路径
app.file.upload-dir=./uploads
# ID生成
app.id.length=8
app.id.charset=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
# 过期清理(每2小时)
app.cleanup.cron=0 0 */2 * * ?
app.cleanup.enabled=true
修改配置后重启后端即可生效,无需重新构建前端。