Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d306581e34 | ||
|
|
f34ea51725 | ||
|
|
218387151f | ||
|
|
427d958a41 | ||
|
|
8b0d90cdc3 | ||
|
|
0a9d414751 | ||
|
|
f1c2e1a3d7 | ||
|
|
cfe166e8c9 | ||
|
|
29300a9448 | ||
|
|
2a24f713cb | ||
|
|
427f1f6456 | ||
|
|
c8f36e6f8e | ||
|
|
03ccd13f8f | ||
|
|
b2c0e85844 | ||
|
|
c1ec2aee5b | ||
|
|
3d173d0321 | ||
|
|
4d0a6f0a49 | ||
|
|
e41d7a6305 | ||
|
|
60af6d2023 | ||
|
|
dc16661fff | ||
|
|
f36221de05 | ||
|
|
e556b0f39d | ||
|
|
13cbf5e5ed | ||
|
|
8392b26455 | ||
|
|
c64c152124 | ||
|
|
ecc4aefd33 | ||
|
|
590a071dfb | ||
|
|
cf2d81bf9a | ||
|
|
e62f329d53 | ||
|
|
421955a844 | ||
|
|
3001ea3250 | ||
|
|
1b12703b90 | ||
|
|
e4bb9781f7 | ||
|
|
943a5a76d2 | ||
|
|
71147451bb | ||
|
|
3d88c68ed5 | ||
|
|
338e22dfca | ||
|
|
464dba2546 | ||
|
|
a3dd28dd92 | ||
|
|
9fd4943bb6 | ||
|
|
668a2dd4d8 | ||
|
|
695395ba6a | ||
|
|
a0cff53901 | ||
|
|
7d8075277d | ||
|
|
862b381e65 | ||
|
|
745ae94c49 | ||
|
|
8c60d32ac0 | ||
|
|
2f5388d0a8 | ||
|
|
88b8daa5df |
17
.env.example
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# 你的下载secret,每一次下载次数减1的时候都会根据这里的secret生成一个下载jwt token, 有效期一小时,使用该下载token有效期内可以多线程下载该文件而不会被多次扣除次数
|
||||||
|
DOWNLOAD_SECRET="your-secret-token"
|
||||||
|
PASSWORD_SALT="your-passwall-salt" # 设置密码时会把密码加盐
|
||||||
|
|
||||||
|
UPLOAD_PATH="/upload" # 上传路径
|
||||||
|
REDIS_URL="redis://redis:6379/0" # redis 地址
|
||||||
|
NODE_ENV="production" # 指定系统环境 production 或者 dev
|
||||||
|
MAX_LOCALSTORAGE_SIZE="100GB" # 指定实例最大上传容量,支持填写人类可读的值,比如1TB,500GB等
|
||||||
|
|
||||||
|
# (可选): 系统状态页面显示站长信息的 头像会使用email的gravatar头像,点击是触发mailto:your-email,不填写不显示站长信息
|
||||||
|
ADMIN_EMAIL="keven@fudaoyuan.icu"
|
||||||
|
ADMIN_NAME="keven"
|
||||||
|
|
||||||
|
# 下面的env是前端渲染用到的,SITE_URL必填,对应你的公网域名
|
||||||
|
SITE_TITLE="015"
|
||||||
|
SITE_DESC="015 是一个开源的临时内容分享平台项目, 支持文件和文本上传, 下载, 分享"
|
||||||
|
SITE_URL="http://localhost:5000"
|
||||||
BIN
.github/image/0.png
vendored
Normal file
|
After Width: | Height: | Size: 716 KiB |
BIN
.github/image/1.png
vendored
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
BIN
.github/image/2.png
vendored
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
BIN
.github/image/3.png
vendored
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
.github/image/4.png
vendored
Normal file
|
After Width: | Height: | Size: 750 KiB |
BIN
.github/image/5.png
vendored
Normal file
|
After Width: | Height: | Size: 807 KiB |
BIN
.github/image/6.png
vendored
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
@@ -13,7 +13,7 @@ WORKDIR /app
|
|||||||
COPY --from=front-deps /app/dist/ .
|
COPY --from=front-deps /app/dist/ .
|
||||||
RUN corepack enable pnpm && pnpm build
|
RUN corepack enable pnpm && pnpm build
|
||||||
|
|
||||||
FROM golang:1.23.1 AS backend-builder
|
FROM golang:1.24.3 AS backend-builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
# Download Go modules
|
# Download Go modules
|
||||||
COPY backend/go.mod backend/go.sum ./
|
COPY backend/go.mod backend/go.sum ./
|
||||||
|
|||||||
237
README-zh.md
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
<div align="center"><a name="readme-top"></a>
|
||||||
|
|
||||||
|
# 015
|
||||||
|
|
||||||
|
015 (/ˈzɪərəʊ wʌn faɪv/, "zero-one-five") 是一个支持selfhosted的临时文件分享平台。专注于提供一次性,临时的文件和文本上传,处理,分享服务。项目名称来源于DARLING in the FRANXX的 [莓](https://darling-in-the-franxx.fandom.com/wiki/Ichigo)
|
||||||
|
|
||||||
|
一个基于 Vue 3 + Nuxt 3 + Go 构建的现代文件分享网站,支持文件上传、文本分享、图片压缩、并发处理、秒传功能等,具备完整的分享管理和访问控制体系。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
[English](README.md) | 中文
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## 🌟 功能特性
|
||||||
|
|
||||||
|
### 核心功能
|
||||||
|
|
||||||
|
🖼️ **高性能文件上传** - 支持大文件切片上传,前端计算文件哈希实现秒传
|
||||||
|
📱 **响应式设计** - 基于 Tailwind V4 + Reka UI 的现代化 UI,适配各种设备
|
||||||
|
⚡ **并发处理** - 使用 Web Worker 进行前端Hash计算,后端队列系统处理任务
|
||||||
|
🌐 **多语言支持** - 完整的中英文国际化支持
|
||||||
|
🔗 **分享管理** - 灵活的分享链接生成和管理系统
|
||||||
|
|
||||||
|
### 文件处理
|
||||||
|
|
||||||
|
🔄 **智能秒传** - 基于文件哈希+文件大小的前端秒传检测,避免重复上传
|
||||||
|
📷 **图片压缩** - 自动图片压缩功能,支持多种格式
|
||||||
|
🖼️ **文件预览** - 支持图片、视频、音频、文档等多种文件类型预览
|
||||||
|
📊 **上传统计** - 实时显示上传进度和文件信息
|
||||||
|
🌈 **断点续传** - 支持上传中断后的续传功能
|
||||||
|
|
||||||
|
### 高级功能
|
||||||
|
|
||||||
|
🎛️ **分享控制** - 支持密码保护、下载次数限制、过期时间设置
|
||||||
|
🔍 **取件码系统** - 支持取件码分享,简化分享难度
|
||||||
|
⚡ **队列处理** - 基于 Redis + Asynq 的异步任务处理系统
|
||||||
|
🗂️ **文件管理** - 完整的文件生命周期管理
|
||||||
|
📷 **图片处理** - 图片压缩、格式转换等处理功能
|
||||||
|
🏷️ **下载控制** - 基于 JWT 的下载令牌管理系统
|
||||||
|
|
||||||
|
## 截图
|
||||||
|
|
||||||
|
选择文件上传页面
|
||||||
|

|
||||||
|
|
||||||
|
输入文本上传页面
|
||||||
|

|
||||||
|
|
||||||
|
选择文件上传页面 - 支持多选文件上传
|
||||||
|

|
||||||
|
|
||||||
|
文件正在上传页面 - 类似Github的展示上传进度的文件热力图
|
||||||
|

|
||||||
|
|
||||||
|
文件正在上传页面 - 类似 QbitTorrent 的展示文件上传进度的进度条
|
||||||
|

|
||||||
|
|
||||||
|
文件上传成功页面
|
||||||
|

|
||||||
|
|
||||||
|
## 🏗️ 技术架构
|
||||||
|
|
||||||
|
### 前端技术栈
|
||||||
|
|
||||||
|
- **Vue 3** - 渐进式 JavaScript 框架
|
||||||
|
- **Nuxt 3** - Vue.js 全栈框架
|
||||||
|
- **TypeScript** - 完整的类型安全
|
||||||
|
- **Tailwind CSS** - 原子化 CSS 框架
|
||||||
|
- **Reka UI** - 现代化组件库
|
||||||
|
- **Pinia** - 状态管理
|
||||||
|
- **TanStack Query** - 数据获取和缓存
|
||||||
|
- **Vue Router** - 路由管理
|
||||||
|
- **i18next** - 国际化支持
|
||||||
|
|
||||||
|
### 后端技术栈
|
||||||
|
|
||||||
|
- **Go 1.23** - 高性能服务器端语言
|
||||||
|
- **Echo** - 高性能 HTTP 框架
|
||||||
|
- **Redis** - 缓存和会话存储
|
||||||
|
- **Asynq** - 异步任务队列
|
||||||
|
- **JWT** - 身份验证
|
||||||
|
- **Zap** - 结构化日志
|
||||||
|
|
||||||
|
### 构建系统
|
||||||
|
|
||||||
|
- **Node.js** - 服务器端运行时
|
||||||
|
- **pnpm** - 快速包管理器
|
||||||
|
- **Husky** - Git hooks 管理
|
||||||
|
- **Prettier** - 代码格式化
|
||||||
|
- **Lint-staged** - 暂存文件检查
|
||||||
|
|
||||||
|
### 存储架构
|
||||||
|
|
||||||
|
- **文件存储** - 本地文件系统存储
|
||||||
|
- **Redis 缓存** - 分享信息、文件元数据缓存
|
||||||
|
- **队列系统** - 异步任务处理队列
|
||||||
|
|
||||||
|
## 🚀 快速开始
|
||||||
|
|
||||||
|
### 环境要求
|
||||||
|
|
||||||
|
- Node.js 18+
|
||||||
|
- Go 1.23+
|
||||||
|
- Redis 6+
|
||||||
|
- pnpm 9+
|
||||||
|
|
||||||
|
### 安装依赖
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 安装根目录依赖
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# 安装前端依赖
|
||||||
|
cd front && pnpm install
|
||||||
|
|
||||||
|
# 安装后端依赖
|
||||||
|
cd backend && go mod download
|
||||||
|
|
||||||
|
# 安装 Worker 依赖
|
||||||
|
cd worker && go mod download
|
||||||
|
```
|
||||||
|
|
||||||
|
### 环境配置
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 复制环境变量文件
|
||||||
|
cp .env.example .env
|
||||||
|
|
||||||
|
# 配置必要的环境变量
|
||||||
|
REDIS_URL=redis://localhost:6379
|
||||||
|
UPLOAD_PATH=/.github/uploads
|
||||||
|
download_secret=your_download_secret
|
||||||
|
```
|
||||||
|
|
||||||
|
### 启动服务
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 开发模式启动所有服务
|
||||||
|
pnpm run dev
|
||||||
|
|
||||||
|
# 或分别启动
|
||||||
|
pnpm run dev:front # 前端服务 (端口 5000)
|
||||||
|
pnpm run dev:backend # 后端服务 (端口 1323)
|
||||||
|
pnpm run dev:worker # Worker 服务
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📁 项目结构
|
||||||
|
|
||||||
|
```
|
||||||
|
015/
|
||||||
|
├── front/ # 前端应用 (Vue 3 + Nuxt 3)
|
||||||
|
│ ├── components/ # Vue 组件
|
||||||
|
│ │ ├── pages/ # 页面路由
|
||||||
|
│ │ ├── composables/ # 组合式函数
|
||||||
|
│ │ ├── i18n/ # 国际化文件
|
||||||
|
│ │ └── assets/ # 静态资源
|
||||||
|
│ └── middleware/ # 中间件
|
||||||
|
├── backend/ # 后端服务 (Go + Echo)
|
||||||
|
│ ├── internal/ # 内部包
|
||||||
|
│ │ ├── controllers/ # 控制器
|
||||||
|
│ │ ├── models/ # 数据模型
|
||||||
|
│ │ ├── services/ # 业务逻辑
|
||||||
|
│ │ └── utils/ # 工具函数
|
||||||
|
│ └── middleware/ # 中间件
|
||||||
|
├── worker/ # 异步任务处理 (Go + Asynq)
|
||||||
|
│ ├── internal/ # 内部包
|
||||||
|
│ │ ├── tasks/ # 任务处理器
|
||||||
|
│ │ └── utils/ # 工具函数
|
||||||
|
│ └── middleware/ # 中间件
|
||||||
|
└── tmp/ # 临时文件
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔧 开发指南
|
||||||
|
|
||||||
|
### 代码规范
|
||||||
|
|
||||||
|
- 使用 Prettier 进行代码格式化
|
||||||
|
- 使用 Husky + lint-staged 进行提交前检查
|
||||||
|
- 遵循 TypeScript 类型安全规范
|
||||||
|
|
||||||
|
### 提交规范
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 提交前会自动运行代码格式化
|
||||||
|
git add .
|
||||||
|
git commit -m "feat: add new feature"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 构建部署
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 构建前端
|
||||||
|
cd front && pnpm run build
|
||||||
|
|
||||||
|
# 构建后端 (需要 Go 环境)
|
||||||
|
cd backend && go build -o main .
|
||||||
|
|
||||||
|
# 构建 Worker
|
||||||
|
cd worker && go build -o worker .
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📝 开发计划
|
||||||
|
|
||||||
|
### 已完成功能 ✅
|
||||||
|
|
||||||
|
- 前端计算哈希和秒传
|
||||||
|
- 并发切片上传 (使用 Web Worker)
|
||||||
|
- 文件上传/文本上传和分享
|
||||||
|
- 上传统计页面
|
||||||
|
- 多语言支持
|
||||||
|
- 最大上传限制
|
||||||
|
- 后端队列系统和 Worker 处理文件
|
||||||
|
|
||||||
|
### 计划功能 🚧
|
||||||
|
|
||||||
|
- 断点续传 (后端计算已上传部分并返回)
|
||||||
|
- 图片格式转换和压缩
|
||||||
|
- 图片 OCR 复制
|
||||||
|
- 文档转 Markdown
|
||||||
|
- 文本翻译/总结
|
||||||
|
- 支持上传多文件
|
||||||
|
|
||||||
|
## 🤝 贡献指南
|
||||||
|
|
||||||
|
欢迎提交 Issue 和 Pull Request 来改进这个项目。
|
||||||
|
|
||||||
|
## 📄 许可证
|
||||||
|
|
||||||
|
本项目采用 AGPLV3 许可证。
|
||||||
|
|
||||||
|
## 🔗 相关链接
|
||||||
|
|
||||||
|
- [Vue 3 文档](https://vuejs.org/)
|
||||||
|
- [Nuxt 3 文档](https://nuxt.com/)
|
||||||
|
- [Echo 框架文档](https://echo.labstack.com/)
|
||||||
|
- [Asynq 文档](https://github.com/hibiken/asynq)
|
||||||
249
README.md
@@ -1,20 +1,237 @@
|
|||||||
|
<div align="center"><a name="readme-top"></a>
|
||||||
|
|
||||||
# 015
|
# 015
|
||||||
|
|
||||||
这里是send企划
|
015 (/ˈzɪərəʊ wʌn faɪv/, "zero-one-five") is a self-hosted temporary file sharing platform. Focused on providing one-time, temporary file and text upload, processing, and sharing services. The project name originates from [Ichigo](https://darling-in-the-franxx.fandom.com/wiki/Ichigo) from DARLING in the FRANXX.
|
||||||
|
|
||||||
功能:
|
A modern file sharing website built with Vue 3 + Nuxt 3 + Go, supporting file upload, text sharing, image compression, concurrent processing, instant transfer functionality, and more, featuring a complete sharing management and access control system.
|
||||||
- ✅ 前端计算hash和秒传
|
|
||||||
- ✅ 并发切片上传 (使用webWorker计算)
|
|
||||||
- ✅ 文件上传/文本上传和分享
|
|
||||||
- ✅ 上传统计页面
|
|
||||||
- ✅ 多语言支持
|
|
||||||
- ✅ 最大上传限制
|
|
||||||
- ✅ 后端有队列系统和worker处理文件
|
|
||||||
|
|
||||||
todo:
|

|
||||||
- 断点续传(后端计算已上传部分并返回)
|
|
||||||
- 图片格式转换 压缩
|
English | [中文](README-zh.md)
|
||||||
- 图片ocr 复制
|
|
||||||
- xx转markdown
|
</div>
|
||||||
- 文本翻译/总结
|
|
||||||
- 支持上传多文件
|
## 🌟 Features
|
||||||
|
|
||||||
|
### Core Functionality
|
||||||
|
|
||||||
|
🖼️ **High-Performance File Upload** - Supports large file chunked uploads with frontend file hash calculation for instant transfer
|
||||||
|
📱 **Responsive Design** - Modern UI based on Tailwind V4 + Reka UI, adapts to various devices
|
||||||
|
⚡ **Concurrent Processing** - Uses Web Worker for frontend hash calculation, backend queue system for task processing
|
||||||
|
🌐 **Multi-language Support** - Complete Chinese and English internationalization support
|
||||||
|
🔗 **Share Management** - Flexible sharing link generation and management system
|
||||||
|
|
||||||
|
### File Processing
|
||||||
|
|
||||||
|
🔄 **Smart Instant Transfer** - Frontend instant transfer detection based on file hash + file size, avoiding duplicate uploads
|
||||||
|
📷 **Image Compression** - Automatic image compression functionality supporting multiple formats
|
||||||
|
🖼️ **File Preview** - Supports preview of images, videos, audio, documents, and various file types
|
||||||
|
📊 **Upload Statistics** - Real-time display of upload progress and file information
|
||||||
|
🌈 **Resume Upload** - Supports resuming uploads after interruption
|
||||||
|
|
||||||
|
### Advanced Features
|
||||||
|
|
||||||
|
🎛️ **Share Control** - Supports password protection, download count limits, and expiration time settings
|
||||||
|
🔍 **Pickup Code System** - Supports pickup code sharing, simplifying sharing difficulty
|
||||||
|
⚡ **Queue Processing** - Asynchronous task processing system based on Redis + Asynq
|
||||||
|
🗂️ **File Management** - Complete file lifecycle management
|
||||||
|
📷 **Image Processing** - Image compression, format conversion, and other processing features
|
||||||
|
🏷️ **Download Control** - Download token management system based on JWT
|
||||||
|
|
||||||
|
## 📸 Screenshots
|
||||||
|
|
||||||
|
File selection upload page
|
||||||
|

|
||||||
|
|
||||||
|
Text input upload page
|
||||||
|

|
||||||
|
|
||||||
|
File selection upload page - supports multiple file uploads
|
||||||
|

|
||||||
|
|
||||||
|
File uploading page - similar to GitHub's file heatmap showing upload progress
|
||||||
|

|
||||||
|
|
||||||
|
File uploading page - similar to qBittorrent's progress bar showing file upload progress
|
||||||
|

|
||||||
|
|
||||||
|
File upload success page
|
||||||
|

|
||||||
|
|
||||||
|
## 🏗️ Technical Architecture
|
||||||
|
|
||||||
|
### Frontend Tech Stack
|
||||||
|
|
||||||
|
- **Vue 3** - Progressive JavaScript framework
|
||||||
|
- **Nuxt 3** - Vue.js full-stack framework
|
||||||
|
- **TypeScript** - Complete type safety
|
||||||
|
- **Tailwind CSS** - Atomic CSS framework
|
||||||
|
- **Reka UI** - Modern component library
|
||||||
|
- **Pinia** - State management
|
||||||
|
- **TanStack Query** - Data fetching and caching
|
||||||
|
- **Vue Router** - Routing management
|
||||||
|
- **i18next** - Internationalization support
|
||||||
|
|
||||||
|
### Backend Tech Stack
|
||||||
|
|
||||||
|
- **Go 1.23** - High-performance server-side language
|
||||||
|
- **Echo** - High-performance HTTP framework
|
||||||
|
- **Redis** - Caching and session storage
|
||||||
|
- **Asynq** - Asynchronous task queue
|
||||||
|
- **JWT** - Authentication
|
||||||
|
- **Zap** - Structured logging
|
||||||
|
|
||||||
|
### Build System
|
||||||
|
|
||||||
|
- **Node.js** - Server-side runtime
|
||||||
|
- **pnpm** - Fast package manager
|
||||||
|
- **Husky** - Git hooks management
|
||||||
|
- **Prettier** - Code formatting
|
||||||
|
- **Lint-staged** - Staged file checking
|
||||||
|
|
||||||
|
### Storage Architecture
|
||||||
|
|
||||||
|
- **File Storage** - Local file system storage
|
||||||
|
- **Redis Cache** - Share information and file metadata caching
|
||||||
|
- **Queue System** - Asynchronous task processing queue
|
||||||
|
|
||||||
|
## 🚀 Quick Start
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
- Node.js 18+
|
||||||
|
- Go 1.23+
|
||||||
|
- Redis 6+
|
||||||
|
- pnpm 9+
|
||||||
|
|
||||||
|
### Install Dependencies
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install root dependencies
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# Install frontend dependencies
|
||||||
|
cd front && pnpm install
|
||||||
|
|
||||||
|
# Install backend dependencies
|
||||||
|
cd backend && go mod download
|
||||||
|
|
||||||
|
# Install Worker dependencies
|
||||||
|
cd worker && go mod download
|
||||||
|
```
|
||||||
|
|
||||||
|
### Environment Configuration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Copy environment variables file
|
||||||
|
cp .env.example .env
|
||||||
|
|
||||||
|
# Configure necessary environment variables
|
||||||
|
REDIS_URL=redis://localhost:6379
|
||||||
|
UPLOAD_PATH=/.github/uploads
|
||||||
|
download_secret=your_download_secret
|
||||||
|
```
|
||||||
|
|
||||||
|
### Start Services
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start all services in development mode
|
||||||
|
pnpm run dev
|
||||||
|
|
||||||
|
# Or start separately
|
||||||
|
pnpm run dev:front # Frontend service (port 5000)
|
||||||
|
pnpm run dev:backend # Backend service (port 1323)
|
||||||
|
pnpm run dev:worker # Worker service
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📁 Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
015/
|
||||||
|
├── front/ # Frontend application (Vue 3 + Nuxt 3)
|
||||||
|
│ ├── components/ # Vue components
|
||||||
|
│ │ ├── pages/ # Page routes
|
||||||
|
│ │ ├── composables/ # Composable functions
|
||||||
|
│ │ ├── i18n/ # Internationalization files
|
||||||
|
│ │ └── assets/ # Static assets
|
||||||
|
│ └── middleware/ # Middleware
|
||||||
|
├── backend/ # Backend service (Go + Echo)
|
||||||
|
│ ├── internal/ # Internal packages
|
||||||
|
│ │ ├── controllers/ # Controllers
|
||||||
|
│ │ ├── models/ # Data models
|
||||||
|
│ │ ├── services/ # Business logic
|
||||||
|
│ │ └── utils/ # Utility functions
|
||||||
|
│ └── middleware/ # Middleware
|
||||||
|
├── worker/ # Asynchronous task processing (Go + Asynq)
|
||||||
|
│ ├── internal/ # Internal packages
|
||||||
|
│ │ ├── tasks/ # Task processors
|
||||||
|
│ │ └── utils/ # Utility functions
|
||||||
|
│ └── middleware/ # Middleware
|
||||||
|
└── tmp/ # Temporary files
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔧 Development Guide
|
||||||
|
|
||||||
|
### Code Standards
|
||||||
|
|
||||||
|
- Use Prettier for code formatting
|
||||||
|
- Use Husky + lint-staged for pre-commit checking
|
||||||
|
- Follow TypeScript type safety standards
|
||||||
|
|
||||||
|
### Commit Standards
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Code formatting will run automatically before commit
|
||||||
|
git add .
|
||||||
|
git commit -m "feat: add new feature"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build and Deploy
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build frontend
|
||||||
|
cd front && pnpm run build
|
||||||
|
|
||||||
|
# Build backend (requires Go environment)
|
||||||
|
cd backend && go build -o main .
|
||||||
|
|
||||||
|
# Build Worker
|
||||||
|
cd worker && go build -o worker .
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📝 Development Roadmap
|
||||||
|
|
||||||
|
### Completed Features ✅
|
||||||
|
|
||||||
|
- Frontend hash calculation and instant transfer
|
||||||
|
- Concurrent chunked upload (using Web Worker)
|
||||||
|
- File upload/text upload and sharing
|
||||||
|
- Upload statistics page
|
||||||
|
- Multi-language support
|
||||||
|
- Maximum upload limits
|
||||||
|
- Backend queue system and Worker file processing
|
||||||
|
|
||||||
|
### Planned Features 🚧
|
||||||
|
|
||||||
|
- Resume upload (backend calculates uploaded parts and returns)
|
||||||
|
- Image format conversion and compression
|
||||||
|
- Image OCR copy
|
||||||
|
- Document to Markdown conversion
|
||||||
|
- Text translation/summarization
|
||||||
|
- Support for multiple file uploads
|
||||||
|
|
||||||
|
## 🤝 Contributing
|
||||||
|
|
||||||
|
Welcome to submit Issues and Pull Requests to improve this project.
|
||||||
|
|
||||||
|
## 📄 License
|
||||||
|
|
||||||
|
This project is licensed under AGPLV3.
|
||||||
|
|
||||||
|
## 🔗 Related Links
|
||||||
|
|
||||||
|
- [Vue 3 Documentation](https://vuejs.org/)
|
||||||
|
- [Nuxt 3 Documentation](https://nuxt.com/)
|
||||||
|
- [Echo Framework Documentation](https://echo.labstack.com/)
|
||||||
|
- [Asynq Documentation](https://github.com/hibiken/asynq)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM golang:1.23.1 AS builder
|
FROM golang:1.24.3 AS builder
|
||||||
|
|
||||||
# Set destination for COPY
|
# Set destination for COPY
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -1,28 +1,34 @@
|
|||||||
module backend
|
module backend
|
||||||
|
|
||||||
go 1.23.1
|
go 1.24.0
|
||||||
|
|
||||||
|
toolchain go1.24.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dario.cat/mergo v1.0.1
|
dario.cat/mergo v1.0.2
|
||||||
github.com/dustin/go-humanize v1.0.1
|
github.com/dustin/go-humanize v1.0.1
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
github.com/golang-jwt/jwt/v5 v5.3.0
|
||||||
github.com/gorilla/sessions v1.4.0
|
github.com/gorilla/sessions v1.4.0
|
||||||
github.com/hibiken/asynq v0.25.1
|
github.com/hibiken/asynq v0.25.1
|
||||||
github.com/labstack/echo-contrib v0.17.3
|
github.com/labstack/echo-contrib v0.17.4
|
||||||
github.com/labstack/echo/v4 v4.13.3
|
github.com/labstack/echo/v4 v4.13.4
|
||||||
github.com/matoous/go-nanoid/v2 v2.1.0
|
github.com/matoous/go-nanoid/v2 v2.1.0
|
||||||
github.com/redis/go-redis/v9 v9.7.3
|
github.com/redis/go-redis/v9 v9.14.0
|
||||||
github.com/samber/lo v1.50.0
|
github.com/samber/lo v1.51.0
|
||||||
github.com/spf13/viper v1.20.1
|
github.com/spf13/cast v1.10.0
|
||||||
|
github.com/spf13/viper v1.21.0
|
||||||
|
github.com/stretchr/testify v1.11.1
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
golang.org/x/time v0.11.0
|
golang.org/x/crypto v0.42.0
|
||||||
|
golang.org/x/time v0.13.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||||
github.com/google/go-cmp v0.7.0 // indirect
|
github.com/google/go-cmp v0.7.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/gorilla/context v1.1.2 // indirect
|
github.com/gorilla/context v1.1.2 // indirect
|
||||||
@@ -30,21 +36,21 @@ require (
|
|||||||
github.com/labstack/gommon v0.4.2 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
github.com/sagikazarmark/locafero v0.12.0 // indirect
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
github.com/spf13/afero v1.15.0 // indirect
|
||||||
github.com/spf13/afero v1.12.0 // indirect
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
github.com/spf13/cast v1.7.1 // indirect
|
|
||||||
github.com/spf13/pflag v1.0.6 // indirect
|
|
||||||
github.com/subosito/gotenv v1.6.0 // indirect
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
golang.org/x/crypto v0.36.0 // indirect
|
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||||
golang.org/x/net v0.37.0 // indirect
|
golang.org/x/net v0.44.0 // indirect
|
||||||
golang.org/x/sys v0.31.0 // indirect
|
golang.org/x/sys v0.36.0 // indirect
|
||||||
golang.org/x/text v0.23.0 // indirect
|
golang.org/x/text v0.29.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.5 // indirect
|
google.golang.org/protobuf v1.36.9 // indirect
|
||||||
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
|
||||||
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
@@ -14,12 +14,12 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
|
|||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||||
@@ -38,10 +38,10 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
|||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/labstack/echo-contrib v0.17.3 h1:hj+qXksKZG1scSe9ksUXMtv7fZYN+PtQT+bPcYA3/TY=
|
github.com/labstack/echo-contrib v0.17.4 h1:g5mfsrJfJTKv+F5uNKCyrjLK7js+ZW6HTjg4FnDxxgk=
|
||||||
github.com/labstack/echo-contrib v0.17.3/go.mod h1:TcRBrzW8jcC4JD+5Dc/pvOyAps0rtgzj7oBqoR3nYsc=
|
github.com/labstack/echo-contrib v0.17.4/go.mod h1:9O7ZPAHUeMGTOAfg80YqQduHzt0CzLak36PZRldYrZ0=
|
||||||
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
|
github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA=
|
||||||
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
|
github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ=
|
||||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||||
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||||
github.com/matoous/go-nanoid/v2 v2.1.0 h1:P64+dmq21hhWdtvZfEAofnvJULaRR1Yib0+PnU669bE=
|
github.com/matoous/go-nanoid/v2 v2.1.0 h1:P64+dmq21hhWdtvZfEAofnvJULaRR1Yib0+PnU669bE=
|
||||||
@@ -50,34 +50,30 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP
|
|||||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
|
github.com/redis/go-redis/v9 v9.14.0 h1:u4tNCjXOyzfgeLN+vAZaW1xUooqWDqVEsZN0U01jfAE=
|
||||||
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
|
github.com/redis/go-redis/v9 v9.14.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
||||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4=
|
||||||
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI=
|
||||||
github.com/samber/lo v1.50.0 h1:XrG0xOeHs+4FQ8gJR97zDz5uOFMW7OwFWiFVzqopKgY=
|
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
||||||
github.com/samber/lo v1.50.0/go.mod h1:RjZyNk6WSnUFRKK6EyOhsRJMqft3G+pg7dCWHQCWvsc=
|
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||||
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
|
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||||
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
|
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||||
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
|
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||||
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
|
||||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
|
||||||
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
|
||||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
@@ -90,21 +86,23 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
|||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
|
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||||
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||||
|
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||||
|
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||||
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
|
golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI=
|
||||||
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
||||||
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -72,8 +72,17 @@ func VaildateShare(c echo.Context) error {
|
|||||||
if shareInfo == nil {
|
if shareInfo == nil {
|
||||||
return utils.HTTPErrorHandler(c, errors.New("分享不存在"))
|
return utils.HTTPErrorHandler(c, errors.New("分享不存在"))
|
||||||
}
|
}
|
||||||
if shareInfo.Password != "" && shareInfo.Password != r.Password {
|
if shareInfo.Password != "" {
|
||||||
return utils.HTTPErrorHandler(c, errors.New("分享密码错误"))
|
if r.Password == "" {
|
||||||
|
return utils.HTTPErrorHandler(c, errors.New("缺少分享密码"))
|
||||||
|
}
|
||||||
|
hash, err := utils.GeneratePasswordHash(r.Password)
|
||||||
|
if err != nil {
|
||||||
|
return utils.HTTPErrorHandler(c, err)
|
||||||
|
}
|
||||||
|
if hash != shareInfo.Password {
|
||||||
|
return utils.HTTPErrorHandler(c, errors.New("分享密码错误"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 如果下载次数为0,则设置为-1 防止空值问题
|
// 如果下载次数为0,则设置为-1 防止空值问题
|
||||||
if shareInfo.ViewNum < 1 {
|
if shareInfo.ViewNum < 1 {
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ func CreateUploadTask(c echo.Context) error {
|
|||||||
return utils.HTTPErrorHandler(c, errors.New("存储空间不足"))
|
return utils.HTTPErrorHandler(c, errors.New("存储空间不足"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkSize := int64(1 * 1024 * 1024)
|
ChunkSize := int64(0.25 * 1024 * 1024)
|
||||||
if r.FileSize > 500*1024*1024 {
|
// 根据文件大小动态调整块大小
|
||||||
ChunkSize = r.FileSize / 500
|
for r.FileSize/ChunkSize > 1000 {
|
||||||
|
ChunkSize *= 2
|
||||||
}
|
}
|
||||||
uploadTaskExpire := int64(3600)
|
uploadTaskExpire := int64(3600)
|
||||||
newFileInfo := models.RedisFileInfo{
|
newFileInfo := models.RedisFileInfo{
|
||||||
|
|||||||
@@ -64,17 +64,25 @@ func CreateShareInfo(c echo.Context) error {
|
|||||||
return utils.HTTPErrorHandler(c, errors.New("分享文件状态错误"))
|
return utils.HTTPErrorHandler(c, errors.New("分享文件状态错误"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
password := ""
|
||||||
|
if r.Config.Password != "" {
|
||||||
|
hash, err := utils.GeneratePasswordHash(r.Config.Password)
|
||||||
|
if err != nil {
|
||||||
|
return utils.HTTPErrorHandler(c, err)
|
||||||
|
}
|
||||||
|
password = hash
|
||||||
|
}
|
||||||
|
|
||||||
models.SetRedisShareInfo(id, models.RedisShareInfo{
|
models.SetRedisShareInfo(id, models.RedisShareInfo{
|
||||||
Data: r.Data,
|
Data: r.Data,
|
||||||
Type: r.Type,
|
Type: r.Type,
|
||||||
CreatedAt: time.Now().Unix(),
|
CreatedAt: time.Now().Unix(),
|
||||||
Owner: cc.Auth.(string),
|
Owner: cc.Auth.(string),
|
||||||
ViewNum: r.Config.ViewNum,
|
ViewNum: r.Config.ViewNum,
|
||||||
Password: r.Config.Password,
|
Password: password,
|
||||||
NotifyEmail: r.Config.NotifyEmail,
|
// NotifyEmail: r.Config.NotifyEmail,
|
||||||
FileName: r.FileName,
|
FileName: r.FileName,
|
||||||
ExpireAt: ExpireTime.Unix(),
|
ExpireAt: ExpireTime.Unix(),
|
||||||
})
|
})
|
||||||
var pickupCode string
|
var pickupCode string
|
||||||
if r.Config.HasPickupCode {
|
if r.Config.HasPickupCode {
|
||||||
@@ -153,6 +161,7 @@ func GetShareInfo(c echo.Context) error {
|
|||||||
"type": shareInfo.Type,
|
"type": shareInfo.Type,
|
||||||
"name": shareInfo.FileName,
|
"name": shareInfo.FileName,
|
||||||
"download_nums": shareInfo.ViewNum,
|
"download_nums": shareInfo.ViewNum,
|
||||||
|
"has_password": shareInfo.Password != "",
|
||||||
"expire_at": shareInfo.ExpireAt,
|
"expire_at": shareInfo.ExpireAt,
|
||||||
"owner": shareInfo.Owner,
|
"owner": shareInfo.Owner,
|
||||||
"size": fileInfo.FileSize,
|
"size": fileInfo.FileSize,
|
||||||
@@ -165,6 +174,7 @@ func GetShareInfo(c echo.Context) error {
|
|||||||
"type": shareInfo.Type,
|
"type": shareInfo.Type,
|
||||||
"name": shareInfo.FileName,
|
"name": shareInfo.FileName,
|
||||||
"download_nums": shareInfo.ViewNum,
|
"download_nums": shareInfo.ViewNum,
|
||||||
|
"has_password": shareInfo.Password != "",
|
||||||
"expire_at": shareInfo.ExpireAt,
|
"expire_at": shareInfo.ExpireAt,
|
||||||
"owner": shareInfo.Owner,
|
"owner": shareInfo.Owner,
|
||||||
})
|
})
|
||||||
|
|||||||
58
backend/internal/utils/http_result_test.go
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestHTTPSuccessHandler(t *testing.T) {
|
||||||
|
e := echo.New()
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
c := e.NewContext(req, rec)
|
||||||
|
|
||||||
|
data := map[string]interface{}{"result": "success"}
|
||||||
|
err := HTTPSuccessHandler(c, data)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, http.StatusOK, rec.Code)
|
||||||
|
|
||||||
|
var response map[string]interface{}
|
||||||
|
err = json.Unmarshal(rec.Body.Bytes(), &response)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
expected := map[string]interface{}{
|
||||||
|
"code": float64(http.StatusOK),
|
||||||
|
"message": "success",
|
||||||
|
"data": data,
|
||||||
|
}
|
||||||
|
assert.Equal(t, expected, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHTTPErrorHandler(t *testing.T) {
|
||||||
|
e := echo.New()
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
c := e.NewContext(req, rec)
|
||||||
|
|
||||||
|
err := HTTPErrorHandler(c, assert.AnError)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, http.StatusBadRequest, rec.Code)
|
||||||
|
|
||||||
|
var response map[string]interface{}
|
||||||
|
err = json.Unmarshal(rec.Body.Bytes(), &response)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
expected := map[string]interface{}{
|
||||||
|
"code": float64(http.StatusBadRequest),
|
||||||
|
"message": assert.AnError.Error(),
|
||||||
|
"data": map[string]interface{}{},
|
||||||
|
}
|
||||||
|
assert.Equal(t, expected, response)
|
||||||
|
}
|
||||||
17
backend/internal/utils/password.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/argon2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GeneratePasswordHash(password string) (string, error) {
|
||||||
|
salt := GetEnv("PASSWORD_SALT")
|
||||||
|
if salt == "" {
|
||||||
|
return "", errors.New("请配置PASSWORD_SALT")
|
||||||
|
}
|
||||||
|
hash := argon2.IDKey([]byte(password), []byte(salt), 1, 64*1024, 4, 32)
|
||||||
|
return fmt.Sprintf("%x", hash), nil
|
||||||
|
}
|
||||||
71
backend/internal/utils/password_test.go
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGeneratePasswordHash(t *testing.T) {
|
||||||
|
// 保存原始环境变量
|
||||||
|
originalSalt := os.Getenv("PASSWORD_SALT")
|
||||||
|
defer os.Setenv("PASSWORD_SALT", originalSalt)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
password string
|
||||||
|
salt string
|
||||||
|
expectError bool
|
||||||
|
errorMsg string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "PASSWORD_SALT未配置",
|
||||||
|
password: "testpassword",
|
||||||
|
salt: "",
|
||||||
|
expectError: true,
|
||||||
|
errorMsg: "请配置PASSWORD_SALT",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "正常生成哈希",
|
||||||
|
password: "testpassword123",
|
||||||
|
salt: "testsalt",
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
// 设置环境变量
|
||||||
|
if tt.salt != "" {
|
||||||
|
os.Setenv("PASSWORD_SALT", tt.salt)
|
||||||
|
} else {
|
||||||
|
os.Unsetenv("PASSWORD_SALT")
|
||||||
|
}
|
||||||
|
|
||||||
|
hash, err := GeneratePasswordHash(tt.password)
|
||||||
|
|
||||||
|
if tt.expectError {
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("期望错误,但得到了 nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err.Error() != tt.errorMsg {
|
||||||
|
t.Errorf("期望错误信息 '%s',但得到了 '%s'", tt.errorMsg, err.Error())
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("不期望错误,但得到了: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证哈希格式:argon2 32字节 = 64个十六进制字符
|
||||||
|
if len(hash) != 64 {
|
||||||
|
t.Errorf("期望哈希长度为64,但得到了 %d", len(hash))
|
||||||
|
}
|
||||||
|
assert.Equal(t, hash, "537275f995fdd46eb2e5455b8a29adccb60c5637689d29646676a5f1bffb63f3")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
24
docker-compose.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: fudaoyuanicu/015-app:latest
|
||||||
|
container_name: 015-app
|
||||||
|
volumes:
|
||||||
|
- ./uploads:/uploads
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
env_file: '.env'
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
|
||||||
|
worker:
|
||||||
|
image: fudaoyuanicu/015-worker:latest
|
||||||
|
container_name: worker
|
||||||
|
env_file: '.env'
|
||||||
|
volumes:
|
||||||
|
- ./uploads:/uploads
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
- redis
|
||||||
|
redis:
|
||||||
|
image: redis:7
|
||||||
|
container_name: redis
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
<!-- app.vue -->
|
<!-- app.vue -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineRule } from 'vee-validate';
|
import { defineRule } from 'vee-validate'
|
||||||
import { all } from '@vee-validate/rules';
|
import { all } from '@vee-validate/rules'
|
||||||
Object.entries(all).forEach(([name, rule]) => {
|
Object.entries(all).forEach(([name, rule]) => {
|
||||||
defineRule(name, rule);
|
defineRule(name, rule)
|
||||||
});
|
})
|
||||||
// @ts-check
|
// @ts-check
|
||||||
const { $serwist } = useNuxtApp();
|
// const { $serwist } = useNuxtApp();
|
||||||
$serwist?.addEventListener("installed", () => {
|
// $serwist?.addEventListener("installed", () => {
|
||||||
console.log("Serwist installed!");
|
// console.log("Serwist installed!");
|
||||||
});
|
// });
|
||||||
void $serwist?.register({ immediate: true });
|
// void $serwist?.register({ immediate: true });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<NuxtLayout>
|
<NuxtLayout>
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,53 +1,43 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { filesize } from "filesize";
|
import getFileSize from '~/lib/getFileSize'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
data: { name: string; value: string; color: string }[];
|
data: { name: string; value: string; color: string }[]
|
||||||
title: string;
|
title: string
|
||||||
}>();
|
}>()
|
||||||
const dataKeyMap = {
|
const dataKeyMap = {
|
||||||
file_size: {
|
file_size: {
|
||||||
"zh-CN": "文件大小",
|
'zh-CN': '文件大小',
|
||||||
en: "File Size",
|
en: 'File Size',
|
||||||
},
|
},
|
||||||
file_num: {
|
file_num: {
|
||||||
"zh-CN": "文件数量",
|
'zh-CN': '文件数量',
|
||||||
en: "File Num",
|
en: 'File Num',
|
||||||
},
|
},
|
||||||
processed: {
|
processed: {
|
||||||
"zh-CN": "处理数量",
|
'zh-CN': '处理数量',
|
||||||
en: "Processed",
|
en: 'Processed',
|
||||||
},
|
},
|
||||||
failed: {
|
failed: {
|
||||||
"zh-CN": "失败数量",
|
'zh-CN': '失败数量',
|
||||||
en: "Failed",
|
en: 'Failed',
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="rounded-md bg-white p-2 flex flex-col gap-2">
|
<div class="rounded-md bg-white p-2 flex flex-col gap-2">
|
||||||
<div class="text-sm font-medium">{{ title }}</div>
|
<div class="text-sm font-medium">{{ title }}</div>
|
||||||
<div v-for="(item, index) in data" :key="index">
|
<div v-for="(item, index) in data" :key="index">
|
||||||
<div class="flex flex-row items-center gap-2">
|
<div class="flex flex-row items-center gap-2">
|
||||||
<div
|
<div class="h-5 w-2 rounded-full" :style="{ backgroundColor: item.color ?? '#222' }"></div>
|
||||||
class="h-5 w-2 rounded-full"
|
<div class="text-xs font-medium">
|
||||||
:style="{ backgroundColor: item.color ?? '#222' }"
|
{{ dataKeyMap?.[item.name as keyof typeof dataKeyMap]?.['en'] ?? item.name }}
|
||||||
></div>
|
</div>
|
||||||
<div class="text-xs font-medium">
|
<div class="text-sm">
|
||||||
{{
|
{{ ['file_size']?.includes(item?.name) ? getFileSize(item.value) : item.value }}
|
||||||
dataKeyMap?.[item.name as keyof typeof dataKeyMap]?.["en"] ??
|
</div>
|
||||||
item.name
|
</div>
|
||||||
}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="text-sm">
|
|
||||||
{{
|
|
||||||
["file_size"]?.includes(item?.name)
|
|
||||||
? filesize(item.value)
|
|
||||||
: item.value
|
|
||||||
}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,120 +1,108 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
LucideShare,
|
LucideShare,
|
||||||
LucideImage,
|
LucideImage,
|
||||||
LucideBot,
|
LucideBot,
|
||||||
LucideLanguages,
|
LucideLanguages,
|
||||||
LucideFileText,
|
LucideFileText,
|
||||||
LucideImageMinus,
|
LucideImageMinus,
|
||||||
LucideArrowRightLeft,
|
LucideArrowRightLeft,
|
||||||
LucideImagePlus,
|
LucideImagePlus,
|
||||||
LucideAudioLines,
|
LucideAudioLines,
|
||||||
LucideListMusic,
|
LucideListMusic,
|
||||||
} from "lucide-vue-next";
|
} from 'lucide-vue-next'
|
||||||
import { cx } from "class-variance-authority";
|
import { cx } from 'class-variance-authority'
|
||||||
import { isObject } from "lodash-es";
|
import { isObject } from 'lodash-es'
|
||||||
import showDrawer from "@/lib/showDrawer";
|
import showDrawer from '@/lib/showDrawer'
|
||||||
import FileShareHandle from "@/components/Preprocessing/FileShareHandle.vue";
|
import FileShareHandle from '@/components/Preprocessing/FileShareHandle.vue'
|
||||||
const { t } = useI18n();
|
import type { FileShareHandleProps } from '../Preprocessing/types'
|
||||||
|
const { t } = useI18n()
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
hide: () => void;
|
hide: () => void
|
||||||
file: File;
|
file: File[]
|
||||||
onFileHandle: ({ type, config }: { type: string; config: any }) => void;
|
onFileHandle: (props: FileShareHandleProps) => void
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
const isImage = computed(() => props.file.type.startsWith("image/"));
|
const isImage = computed(() => props.file.every((r) => r?.type?.startsWith('image/')))
|
||||||
const isVideo = computed(() => props.file.type.startsWith("video/"));
|
const isVideo = computed(() => props.file.every((r) => r?.type?.startsWith('video/')))
|
||||||
const isAudio = computed(() => props.file.type.startsWith("audio/"));
|
const isAudio = computed(() => props.file.every((r) => r?.type?.startsWith('audio/')))
|
||||||
const isMedia = computed(() => isImage.value || isVideo.value || isAudio.value);
|
const isMedia = computed(() => isImage.value || isVideo.value || isAudio.value)
|
||||||
|
|
||||||
const isPDF = computed(() => props.file.type.startsWith("application/pdf"));
|
const isPDF = computed(() => props.file.every((r) => r?.type?.startsWith('application/pdf')))
|
||||||
const isDOC = computed(() => props.file.type.startsWith("application/msword"));
|
const isDOC = computed(() => props.file.every((r) => r?.type?.startsWith('application/msword')))
|
||||||
const isXLS = computed(() =>
|
const isXLS = computed(() => props.file.every((r) => r?.type?.startsWith('application/vnd.ms-excel')))
|
||||||
props.file.type.startsWith("application/vnd.ms-excel"),
|
const isPPT = computed(() => props.file.every((r) => r?.type?.startsWith('application/vnd.ms-powerpoint')))
|
||||||
);
|
const isDocument = computed(() => isPDF.value || isDOC.value || isXLS.value || isPPT.value)
|
||||||
const isPPT = computed(() =>
|
|
||||||
props.file.type.startsWith("application/vnd.ms-powerpoint"),
|
|
||||||
);
|
|
||||||
const isDocument = computed(
|
|
||||||
() => isPDF.value || isDOC.value || isXLS.value || isPPT.value,
|
|
||||||
);
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
label: t("file.handleType.file-share"),
|
label: t('file.handleType.file-share'),
|
||||||
icon: LucideShare,
|
icon: LucideShare,
|
||||||
className: "bg-green-300",
|
className: 'bg-green-300',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
showDrawer({
|
showDrawer({
|
||||||
render: ({ hide }) => h(FileShareHandle, { ...props, hide }),
|
render: ({ hide }) => h(FileShareHandle, { ...props, hide }),
|
||||||
});
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
isImage.value && {
|
||||||
isImage.value && {
|
label: t('file.handleType.file-image-compress'),
|
||||||
label: t("file.handleType.file-image-compress"),
|
icon: LucideImageMinus,
|
||||||
icon: LucideImageMinus,
|
className: 'bg-red-300',
|
||||||
className: "bg-red-300",
|
onClick: () => {
|
||||||
onClick: () => {
|
props.onFileHandle({ type: 'file-image-compress', config: {} })
|
||||||
props.onFileHandle({ type: "file-image-compress", config: {} });
|
},
|
||||||
},
|
},
|
||||||
},
|
// isImage.value && {
|
||||||
// isImage.value && {
|
// label: '图片翻译', icon: LucideLanguages, className: 'bg-orange-300', onClick: () => {
|
||||||
// label: '图片翻译', icon: LucideLanguages, className: 'bg-orange-300', onClick: () => {
|
// console.log('复制链接')
|
||||||
// console.log('复制链接')
|
// }
|
||||||
// }
|
// },
|
||||||
// },
|
// isImage.value && {
|
||||||
// isImage.value && {
|
// label: '图片超分', icon: LucideImagePlus, className: 'bg-cyan-300', onClick: () => {
|
||||||
// label: '图片超分', icon: LucideImagePlus, className: 'bg-cyan-300', onClick: () => {
|
// console.log('复制链接')
|
||||||
// console.log('复制链接')
|
// }
|
||||||
// }
|
// },
|
||||||
// },
|
// (isAudio.value || isVideo.value) && {
|
||||||
// (isAudio.value || isVideo.value) && {
|
// label: '转文本', icon: LucideListMusic, className: 'bg-cyan-300', onClick: () => {
|
||||||
// label: '转文本', icon: LucideListMusic, className: 'bg-cyan-300', onClick: () => {
|
// console.log('复制链接')
|
||||||
// console.log('复制链接')
|
// }
|
||||||
// }
|
// },
|
||||||
// },
|
// isAudio.value && {
|
||||||
// isAudio.value && {
|
// label: '语音克隆', icon: LucideAudioLines, className: 'bg-cyan-300', onClick: () => {
|
||||||
// label: '语音克隆', icon: LucideAudioLines, className: 'bg-cyan-300', onClick: () => {
|
// console.log('复制链接')
|
||||||
// console.log('复制链接')
|
// }
|
||||||
// }
|
// },
|
||||||
// },
|
// (isDocument.value || isMedia.value) && {
|
||||||
// (isDocument.value || isMedia.value) && {
|
// label: '格式转换', icon: LucideArrowRightLeft, className: 'bg-purple-300', onClick: () => {
|
||||||
// label: '格式转换', icon: LucideArrowRightLeft, className: 'bg-purple-300', onClick: () => {
|
// console.log('复制链接')
|
||||||
// console.log('复制链接')
|
// }
|
||||||
// }
|
// },
|
||||||
// },
|
|
||||||
]?.filter(isObject) as {
|
]?.filter(isObject) as {
|
||||||
label: string;
|
label: string
|
||||||
icon: any;
|
icon: any
|
||||||
className: string;
|
className: string
|
||||||
onClick: () => void;
|
onClick: () => void
|
||||||
}[];
|
}[]
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-5 p-5">
|
<div class="flex flex-col gap-5 p-5">
|
||||||
<div class="flex flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
<div
|
<div
|
||||||
v-for="item in actions"
|
v-for="item in actions"
|
||||||
:key="item.label"
|
:key="item.label"
|
||||||
class="flex flex-col items-center gap-2 max-w-20"
|
class="flex flex-col items-center gap-2 max-w-20"
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
props?.hide();
|
props?.hide()
|
||||||
item?.onClick();
|
item?.onClick()
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div :class="cx('size-14 flex justify-center items-center rounded-full mx-3', item?.className)">
|
||||||
:class="
|
<component :is="item?.icon" />
|
||||||
cx(
|
</div>
|
||||||
'size-14 flex justify-center items-center rounded-full mx-3',
|
<div class="text-xs truncate w-full text-center">{{ item?.label }}</div>
|
||||||
item?.className,
|
</div>
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<component :is="item?.icon" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs truncate w-full text-center">{{ item?.label }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
39
front/components/Drawer/PasswallShareDrawer.vue
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import VeeForm from '@/components/VeeForm.vue'
|
||||||
|
import FormButton from '@/components/Field/FormButton.vue'
|
||||||
|
import InputField from '@/components/Field/InputField.vue'
|
||||||
|
import type { FormContext, GenericObject } from 'vee-validate'
|
||||||
|
import { toast } from 'vue-sonner'
|
||||||
|
const props = defineProps<{
|
||||||
|
share_id: string
|
||||||
|
hide: any
|
||||||
|
}>()
|
||||||
|
const { getShareToken } = useMyAppShare()
|
||||||
|
|
||||||
|
const handleSubmit = async (form: FormContext<GenericObject, GenericObject>) => {
|
||||||
|
try {
|
||||||
|
const password = form.values.password
|
||||||
|
const token = await getShareToken(props.share_id, { password })
|
||||||
|
if (!token) {
|
||||||
|
toast.error('密码错误')
|
||||||
|
form.resetForm()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
props?.hide(token)
|
||||||
|
return
|
||||||
|
} catch (error) {
|
||||||
|
toast.error('密码错误')
|
||||||
|
form.resetForm()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<VeeForm>
|
||||||
|
<div class="flex flex-col gap-5">
|
||||||
|
<div class="text-xl font-bold">输入密码</div>
|
||||||
|
<InputField name="password" type="password" rules="required" placeholder="请输入密码" />
|
||||||
|
<FormButton @click="handleSubmit">提交</FormButton>
|
||||||
|
</div>
|
||||||
|
</VeeForm>
|
||||||
|
</template>
|
||||||
@@ -1,42 +1,71 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import FileUpload from "@/components/FileUpload.vue";
|
import FileUpload from '@/components/FileUpload.vue'
|
||||||
import { cx } from "class-variance-authority";
|
import { cx } from 'class-variance-authority'
|
||||||
import type { RuleExpression } from "vee-validate";
|
import type { RuleExpression } from 'vee-validate'
|
||||||
|
import Button from '../ui/button/Button.vue'
|
||||||
|
import { PlusIcon } from 'lucide-vue-next'
|
||||||
|
import { isEmpty } from 'lodash-es'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
name: string;
|
name: string
|
||||||
rules?: RuleExpression<File>;
|
rules?: RuleExpression<File[]>
|
||||||
}>();
|
}>()
|
||||||
const { value, setValue } = useField<File>(props?.name, props?.rules);
|
const { value, setValue } = useField<File[]>(props?.name, props?.rules)
|
||||||
const { t } = useI18n();
|
const { t } = useI18n()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FileUpload
|
<FileUpload
|
||||||
@onChange="
|
@onChange="
|
||||||
(file) => {
|
(file) => {
|
||||||
setValue(file);
|
// 这里没hash,我们姑且认为name和size,type都一样的为同一个文件
|
||||||
}
|
setValue([...(value?.filter((r) => r?.name !== file?.name || r?.type !== file?.type || r?.size !== file?.size) || []), file])
|
||||||
"
|
}
|
||||||
v-slot="{ isOverDropZone }"
|
"
|
||||||
>
|
v-slot="{ isOverDropZone }"
|
||||||
<div
|
|
||||||
:class="
|
|
||||||
cx(
|
|
||||||
'bg-white/50 rounded-md p-2 w-full h-40 flex flex-col items-center justify-center border border-dashed border-black/20 cursor-pointer text-gray-500 gap-3',
|
|
||||||
isOverDropZone && '!bg-green-100/50 ',
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<template v-if="!!value">
|
<div
|
||||||
<FilePreviewView :value="value" />
|
:class="
|
||||||
</template>
|
cx(
|
||||||
<template v-else>
|
'bg-white/50 rounded-md p-2 w-full min-h-40 flex flex-col items-center justify-center border border-dashed border-black/20 cursor-pointer text-gray-500 gap-3 transition-all duration-300',
|
||||||
<LucideUpload class="size-10" />
|
isOverDropZone && '!bg-green-100/50 '
|
||||||
<div class="text-sm">
|
)
|
||||||
{{ t("file.uploadFilePlaceholder") }}
|
"
|
||||||
|
>
|
||||||
|
<template v-if="!isEmpty(value)">
|
||||||
|
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-5 w-full">
|
||||||
|
<div v-for="item in value" :key="item?.name" class="flex flex-col items-center justify-center relative">
|
||||||
|
<div class="absolute top-0 right-0">
|
||||||
|
<Button
|
||||||
|
class="size-5 p-0 bg-red-500/20 hover:bg-red-500/60 text-red-500 hover:text-white"
|
||||||
|
@click="
|
||||||
|
(e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
setValue(
|
||||||
|
value?.filter((r) => r?.name !== item?.name || r?.type !== item?.type || r?.size !== item?.size) || []
|
||||||
|
)
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideX class="size-3" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<FilePreviewView :value="item" />
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col items-center justify-center opacity-50 gap-1">
|
||||||
|
<div class="size-16 flex justify-center items-center rounded-xl bg-white/80">
|
||||||
|
<PlusIcon class="size-7" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">添加更多</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<LucideUpload class="size-10" />
|
||||||
|
<div class="text-sm">
|
||||||
|
{{ t('file.uploadFilePlaceholder') }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</FileUpload>
|
||||||
</div>
|
|
||||||
</FileUpload>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<Field :name="props.name" v-slot="{ field }">
|
<Field :name="props.name" v-slot="{ field }">
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<Label v-if="props.label">{{ props.label }}</Label>
|
<Label v-if="props.label">{{ props.label }}</Label>
|
||||||
<Input v-bind="field" :placeholder="props.placeholder" :class="props.class" />
|
<Input v-bind="{ ...field, ...$attrs }" />
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Label } from '@/components/ui/label'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
name: string
|
name: string
|
||||||
label?: string
|
label?: string
|
||||||
placeholder?: string
|
|
||||||
class?: string
|
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { cx } from 'class-variance-authority'
|
||||||
export type filePreview = {
|
export type filePreview = {
|
||||||
type: string
|
type: string
|
||||||
name: string
|
name: string
|
||||||
@@ -8,6 +9,7 @@ export type filePreview = {
|
|||||||
import { LucideFileAudio, LucideFileVideo, LucideFile, LucideFileCode, LucideFileArchive, LucideFileText } from 'lucide-vue-next'
|
import { LucideFileAudio, LucideFileVideo, LucideFile, LucideFileCode, LucideFileArchive, LucideFileText } from 'lucide-vue-next'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
file: File | filePreview
|
file: File | filePreview
|
||||||
|
class?: string
|
||||||
}>()
|
}>()
|
||||||
const imageUrl = computed(() => {
|
const imageUrl = computed(() => {
|
||||||
if (props?.file?.type?.startsWith('image/') && props?.file instanceof File) {
|
if (props?.file?.type?.startsWith('image/') && props?.file instanceof File) {
|
||||||
@@ -30,15 +32,20 @@ const fileIcon = computed(() => {
|
|||||||
if (baseType === 'audio') {
|
if (baseType === 'audio') {
|
||||||
return LucideFileAudio
|
return LucideFileAudio
|
||||||
}
|
}
|
||||||
if (baseType === 'text' || ["json", "ld+json", "html"]?.includes(type)) {
|
if (baseType === 'text' || ['json', 'ld+json', 'html']?.includes(type)) {
|
||||||
return LucideFileCode
|
return LucideFileCode
|
||||||
}
|
}
|
||||||
if (['pdf', 'msword',
|
if (
|
||||||
'vnd.openxmlformats-officedocument.wordprocessingml.document',
|
[
|
||||||
'vnd.ms-excel',
|
'pdf',
|
||||||
'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
'msword',
|
||||||
'vnd.ms-powerpoint',
|
'vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
'vnd.openxmlformats-officedocument.presentationml.presentation'].includes(type)) {
|
'vnd.ms-excel',
|
||||||
|
'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
'vnd.ms-powerpoint',
|
||||||
|
'vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||||
|
].includes(type)
|
||||||
|
) {
|
||||||
return LucideFileText
|
return LucideFileText
|
||||||
}
|
}
|
||||||
if (['zip', 'vnd.rar', 'x-tar', 'gz', 'bz2', 'x-7z-compressed'].includes(type)) {
|
if (['zip', 'vnd.rar', 'x-tar', 'gz', 'bz2', 'x-7z-compressed'].includes(type)) {
|
||||||
@@ -51,11 +58,10 @@ const fileIcon = computed(() => {
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="!!imageUrl" class="flex max-w-30 max-h-20">
|
<div v-if="!!imageUrl" class="flex max-w-30 max-h-20">
|
||||||
<div class="object-contain m-auto h-full">
|
<div class="object-contain m-auto h-full">
|
||||||
<img :src="imageUrl" class="w-full h-full border border-black/20 rounded" />
|
<img :src="imageUrl" class="w-full h-full border border-black/20 rounded" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!imageUrl" class="size-16 flex justify-center items-center rounded-xl bg-white/80">
|
<div v-if="!imageUrl" :class="cx('flex justify-center items-center rounded-xl bg-white/80 size-16', props?.class)">
|
||||||
<component :is="fileIcon" class="size-10" />
|
<component :is="fileIcon" class="size-[62.5%]" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { filesize } from 'filesize'
|
import getFileSize from '~/lib/getFileSize'
|
||||||
import type { filePreview } from './FileIcon.vue';
|
import type { filePreview } from './FileIcon.vue'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
value: File | filePreview
|
value: File | filePreview
|
||||||
}>()
|
}>()
|
||||||
@@ -17,6 +17,6 @@ const fileInfo = computed(() => {
|
|||||||
<div class="truncate">{{ fileInfo?.name }}</div>
|
<div class="truncate">{{ fileInfo?.name }}</div>
|
||||||
<div>{{ `.${fileInfo?.ext}` }}</div>
|
<div>{{ `.${fileInfo?.ext}` }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs opacity-50">{{ filesize(value?.size ?? 0) }}</div>
|
<div class="text-xs opacity-50">{{ getFileSize(value?.size ?? 0) }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
44
front/components/FileUploadBlockProgressView.vue
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { Graphics } from 'pixi.js'
|
||||||
|
import type { PixiExpose } from '@/components/Pixi.vue'
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
size?: number
|
||||||
|
data?: { chunks: Record<number, { status: 'success' | 'error' | 'processing'; createdAt: number }>; chunkLength: number }
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
size: 16,
|
||||||
|
data: () => ({ chunks: [], chunkLength: 0 }),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
const pixiRef = ref<PixiExpose>()
|
||||||
|
const width = computed(() => pixiRef.value?.width || 0)
|
||||||
|
const height = computed(() => pixiRef.value?.height || 0)
|
||||||
|
watchEffect(() => {
|
||||||
|
console.log('data', props.data)
|
||||||
|
})
|
||||||
|
const renderGraphics = (graphics: Graphics) => {
|
||||||
|
graphics.clear()
|
||||||
|
Object.entries(props?.data?.chunks || {})?.map(([index, item]) => {
|
||||||
|
const { status, createdAt } = item || {}
|
||||||
|
const size = width.value / props.data?.chunkLength
|
||||||
|
const x = Number(index) * size
|
||||||
|
graphics.rect(x, 0, size, height.value)
|
||||||
|
let color = 0x60a5fa
|
||||||
|
if (status === 'success') {
|
||||||
|
color = 0x4ade80
|
||||||
|
}
|
||||||
|
if (status === 'error') {
|
||||||
|
color = 0xf87171
|
||||||
|
}
|
||||||
|
graphics.fill(color)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Pixi ref="pixiRef">
|
||||||
|
<graphics @render="renderGraphics" />
|
||||||
|
</Pixi>
|
||||||
|
</template>
|
||||||
62
front/components/FileUploadHeatMapView.vue
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { Graphics } from 'pixi.js'
|
||||||
|
import type { PixiExpose } from '@/components/Pixi.vue'
|
||||||
|
|
||||||
|
let props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
size?: number
|
||||||
|
gap?: number
|
||||||
|
data?: { chunks: Record<number, { status: 'success' | 'error' | 'processing'; createdAt: number }>; chunkLength: number }
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
size: 16,
|
||||||
|
gap: 4,
|
||||||
|
data: () => ({ chunks: [], chunkLength: 0 }),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
const pixiRef = ref<PixiExpose>()
|
||||||
|
const width = computed(() => pixiRef.value?.width)
|
||||||
|
const height = computed(() => pixiRef.value?.height)
|
||||||
|
|
||||||
|
const size = ref(props.size)
|
||||||
|
const gap = ref(props.gap)
|
||||||
|
const itemsPerRow = ref(0)
|
||||||
|
const itemsPerCol = computed(() => Math.ceil(props?.data?.chunkLength / itemsPerRow.value))
|
||||||
|
watchEffect(() => {
|
||||||
|
if (!width?.value || !height?.value || !pixiRef.value) return
|
||||||
|
itemsPerRow.value = (width.value + gap.value) / (props.size + gap.value)
|
||||||
|
if (itemsPerRow.value - Math.floor(itemsPerRow.value) > 0.5) {
|
||||||
|
itemsPerRow.value = Math.floor(itemsPerRow.value)
|
||||||
|
} else {
|
||||||
|
itemsPerRow.value = Math.ceil(itemsPerRow.value)
|
||||||
|
}
|
||||||
|
size.value = (width.value - (itemsPerRow.value - 1) * gap.value) / itemsPerRow.value
|
||||||
|
pixiRef.value.contentHeight = itemsPerCol.value * (size.value + gap.value) - gap.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const renderGraphics = (graphics: Graphics) => {
|
||||||
|
graphics.clear()
|
||||||
|
Object.entries(props?.data?.chunks || {})?.map(([index, item]) => {
|
||||||
|
const { status, createdAt } = item || {}
|
||||||
|
const row = Math.floor(Number(index) / itemsPerRow.value)
|
||||||
|
const col = Number(index) % itemsPerRow.value
|
||||||
|
const x = col * (size.value + gap.value)
|
||||||
|
const y = row * (size.value + gap.value)
|
||||||
|
graphics.roundRect(x, y, size.value, size.value, 4)
|
||||||
|
let color = 0x60a5fa
|
||||||
|
if (status === 'success') {
|
||||||
|
color = 0x4ade80
|
||||||
|
}
|
||||||
|
if (status === 'error') {
|
||||||
|
color = 0xf87171
|
||||||
|
}
|
||||||
|
graphics.fill(color)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Pixi ref="pixiRef">
|
||||||
|
<graphics @render="renderGraphics" />
|
||||||
|
</Pixi>
|
||||||
|
</template>
|
||||||
@@ -1,33 +1,36 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import { Drawer, DrawerContent } from '@/components/ui/drawer'
|
||||||
Drawer,
|
|
||||||
DrawerContent,
|
|
||||||
} from '@/components/ui/drawer'
|
|
||||||
import { createVNode } from 'vue'
|
import { createVNode } from 'vue'
|
||||||
import useStore from '@/composables/useStore'
|
import useStore from '@/composables/useStore'
|
||||||
|
|
||||||
const store = useStore('drawer')
|
const store = useStore()
|
||||||
const drawer = computed(() => store?._get('drawer'))
|
const currentDrawer = computed(() => store.drawer?.[store.drawer?.length - 1])
|
||||||
const currentDrawer = computed(() => drawer?.value?.[drawer?.value?.length - 1])
|
|
||||||
|
|
||||||
const render = computed(() => currentDrawer?.value?.render)
|
const render = computed(() => currentDrawer?.value?.render)
|
||||||
|
const hide = computed(() => currentDrawer?.value?.onClose)
|
||||||
const Children = () =>
|
const Children = () =>
|
||||||
createVNode(render.value, {
|
render.value
|
||||||
hide: () => store?._set('drawer', drawer?.value?.slice(0, -1)),
|
? createVNode(render.value, {
|
||||||
})
|
hide: hide?.value,
|
||||||
|
})
|
||||||
|
: null
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Drawer :open="!!store?._get('drawer')?.[store?._get('drawer')?.length - 1]" @update:open="(open) => {
|
<Drawer
|
||||||
if (!open && drawer?.length > 0) {
|
:open="!!store.drawer?.[store.drawer?.length - 1]"
|
||||||
store?._set('drawer', drawer?.slice(0, -1))
|
@update:open="
|
||||||
}
|
(open) => {
|
||||||
}">
|
if (!open && store?.drawer?.length && hide) {
|
||||||
<DrawerContent>
|
hide()
|
||||||
<div class="mx-auto w-full max-w-sm pb-10">
|
}
|
||||||
<Children />
|
}
|
||||||
</div>
|
"
|
||||||
</DrawerContent>
|
>
|
||||||
</Drawer>
|
<DrawerContent>
|
||||||
|
<div class="mx-auto w-full max-w-sm pb-10 px-3">
|
||||||
|
<Children />
|
||||||
|
</div>
|
||||||
|
</DrawerContent>
|
||||||
|
</Drawer>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,47 +1,216 @@
|
|||||||
<script lang="ts" setup>
|
<script setup lang="ts">
|
||||||
import CircularProgress from '@/components/CircularProgress.vue'
|
import { LucidePlay, LucideSettings, LucideSquare } from 'lucide-vue-next'
|
||||||
import { chunk, get, shuffle, times } from 'lodash-es'
|
import Button from '@/components/ui/button/Button.vue'
|
||||||
|
import FileUploadBlockProgressView from '@/components/FileUploadBlockProgressView.vue'
|
||||||
|
import { motion } from 'motion-v'
|
||||||
|
import getFileSize from '~/lib/getFileSize'
|
||||||
import { cx } from 'class-variance-authority'
|
import { cx } from 'class-variance-authority'
|
||||||
import { filesize } from 'filesize'
|
import asyncWorker from '@/lib/asyncWorker'
|
||||||
|
import calcFileHashWorker from '@/lib/calcFileHashWorker?worker'
|
||||||
|
import { clamp, get, groupBy, isEmpty, isNumber, isString, sample, shuffle, times } from 'lodash-es'
|
||||||
|
import { nanoid } from 'nanoid'
|
||||||
import { toast } from 'vue-sonner'
|
import { toast } from 'vue-sonner'
|
||||||
import asyncWorker from '~/lib/asyncWorker'
|
import dayjs from 'dayjs'
|
||||||
import calcFileHashWorker from '~/lib/calcFileHashWorker?worker'
|
import showDrawer from '~/lib/showDrawer'
|
||||||
const props = defineProps<{
|
import FileUploadSpeedInfoView from './FileUploadSpeedInfoView.vue'
|
||||||
data: { file: File; config: any; handle_type: string }
|
import getFileChunk from '~/lib/getFileChunk'
|
||||||
}>()
|
import type { FileHandleKey } from '~/components/Preprocessing/types'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
data: { file: File[]; config: Record<string, any>; handle_type: FileHandleKey }
|
||||||
|
}>()
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'change', key: string): void
|
(e: 'change', key: string): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const form = useFormContext()
|
const form = useFormContext()
|
||||||
|
|
||||||
const step = ref<'hash' | 'upload'>('hash')
|
const selectedFile = ref()
|
||||||
const calcHashTime = ref(0)
|
const uploadfiles = ref<
|
||||||
const chunkSize = ref(0)
|
|
||||||
const fileSliceUploadStatusList = ref<
|
|
||||||
{
|
{
|
||||||
status: string
|
fileId: string
|
||||||
index: number
|
id?: string // 后端文件id
|
||||||
|
file: File
|
||||||
|
status: 'start' | 'pause' | 'finish' | 'error'
|
||||||
|
hash?: string
|
||||||
|
procressType: 'hash' | 'create' | 'upload' | 'finish'
|
||||||
|
uploadInfo?: {
|
||||||
|
chunks: Record<number, { status: 'success' | 'error' | 'processing'; createdAt: number }>
|
||||||
|
chunkLength: number
|
||||||
|
ChunkSize: number
|
||||||
|
}
|
||||||
|
queue: {
|
||||||
|
taskId: string
|
||||||
|
taskType: 'hash' | 'create' | 'chunk' | 'upload' | 'finish'
|
||||||
|
queueType: 'sync' | 'async' // sync任务禁止并发
|
||||||
|
index?: number
|
||||||
|
retry?: number
|
||||||
|
}[]
|
||||||
}[]
|
}[]
|
||||||
>([])
|
>([])
|
||||||
|
const selectedUploadfile = computed(() => uploadfiles.value.find((item) => item.fileId === selectedFile.value))
|
||||||
|
const selectedUploadfileChunk = computed(() => Object.values(selectedUploadfile.value?.uploadInfo?.chunks || {}))
|
||||||
|
const selectedUploadfileViewMode = ref<'progress' | 'heatmap'>('progress')
|
||||||
|
|
||||||
const successCount = computed(() => fileSliceUploadStatusList.value.filter((item) => item.status === 'success').length)
|
const procressTaskList = ref<Map<string, any>>(new Map())
|
||||||
const alreadyUploadSize = computed(() => successCount.value * chunkSize.value)
|
const activeTaskList = computed(() => uploadfiles.value.filter((r) => r.queue.length > 0 && r.status === 'start'))
|
||||||
const uploadProgress = computed(() => Math.round((alreadyUploadSize.value / (props?.data?.file?.size || 0)) * 100))
|
const activeTaskAllQueue = computed(() => activeTaskList.value.flatMap((r) => r.queue))
|
||||||
|
const batchNum = ref(3)
|
||||||
|
|
||||||
const { error } = useAsyncState(async () => {
|
const totalTaskStatus = computed(() => {
|
||||||
const { file } = props.data || {}
|
if (uploadfiles.value.some((r) => r.status === 'start')) {
|
||||||
if (!file) return
|
return 'start'
|
||||||
const { size, type = 'application/octet-stream' } = file || {}
|
|
||||||
const now = Date.now()
|
|
||||||
const res = await asyncWorker(calcFileHashWorker, { data: { file } })
|
|
||||||
const { hash } = res?.data || {}
|
|
||||||
if (hash) {
|
|
||||||
step.value = 'upload'
|
|
||||||
calcHashTime.value = Date.now() - now
|
|
||||||
}
|
}
|
||||||
|
if (uploadfiles.value.some((r) => r.status === 'pause')) {
|
||||||
|
return 'pause'
|
||||||
|
}
|
||||||
|
return 'disabled'
|
||||||
|
})
|
||||||
|
const totalUploadProgress = computed(() => {
|
||||||
|
const successCount = uploadfiles.value.reduce((acc, curr) => {
|
||||||
|
const { status, uploadInfo } = curr || {}
|
||||||
|
if (status === 'finish') return acc
|
||||||
|
const { chunks } = uploadInfo || {}
|
||||||
|
return acc + Object.entries(chunks || {}).filter(([index, chunk]) => chunk.status === 'success').length
|
||||||
|
}, 0)
|
||||||
|
const totalCount = uploadfiles.value.reduce((acc, curr) => {
|
||||||
|
const { status, uploadInfo } = curr || {}
|
||||||
|
if (status === 'finish') return acc
|
||||||
|
const { chunkLength } = uploadInfo || {}
|
||||||
|
return acc + (chunkLength || 0)
|
||||||
|
}, 0)
|
||||||
|
return ((successCount || 0) / (totalCount || 0)) * 100
|
||||||
|
})
|
||||||
|
|
||||||
|
const counter = useInterval(1000)
|
||||||
|
const speedChartData = ref<Record<number, { createdAt: number; value: number }[]>>({})
|
||||||
|
watch(counter, () => {
|
||||||
|
const speed = uploadfiles.value?.flatMap((item) => {
|
||||||
|
const { chunks, ChunkSize } = item?.uploadInfo || {}
|
||||||
|
return Object.entries(chunks || {})
|
||||||
|
.filter(([index, chunk]) => chunk.status === 'success' && dayjs().unix() - 60 < chunk.createdAt)
|
||||||
|
?.map(([index, chunk]) => {
|
||||||
|
const { createdAt } = chunk || {}
|
||||||
|
return {
|
||||||
|
createdAt,
|
||||||
|
value: ChunkSize || 0,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
speedChartData.value = groupBy(speed, 'createdAt')
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
props.data.file.forEach((file) => {
|
||||||
|
uploadfiles.value.push({
|
||||||
|
fileId: `${file.name}_${file.size}`,
|
||||||
|
file,
|
||||||
|
status: 'start',
|
||||||
|
procressType: 'hash',
|
||||||
|
queue: [
|
||||||
|
{ taskType: 'hash', queueType: 'sync', taskId: nanoid() },
|
||||||
|
{ taskType: 'create', queueType: 'sync', taskId: nanoid() },
|
||||||
|
{ taskType: 'chunk', queueType: 'sync', taskId: nanoid() },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const { error, execute, isLoading } = useAsyncState(
|
||||||
|
async () => {
|
||||||
|
while (activeTaskAllQueue.value.length > 0) {
|
||||||
|
const taskList = uploadfiles?.value?.filter((r) => r.queue.length > 0 && r.status === 'start')
|
||||||
|
await Promise.all(
|
||||||
|
times(batchNum.value, async (i: number) => {
|
||||||
|
const file = sample(taskList)
|
||||||
|
const { fileId, queue } = file || {}
|
||||||
|
if (!fileId) return
|
||||||
|
const task = get(queue, '0')
|
||||||
|
if (!task) return
|
||||||
|
const { taskId, index, queueType, taskType, retry } = task || {}
|
||||||
|
if (procressTaskList.value.has(taskId)) return
|
||||||
|
procressTaskList.value.set(taskId, task)
|
||||||
|
|
||||||
|
const uploadFileIndex = uploadfiles.value.findIndex((r) => r.fileId === file?.fileId)
|
||||||
|
|
||||||
|
if (queueType === 'async') {
|
||||||
|
if (!!retry && retry >= 3) {
|
||||||
|
toast.error('上传错误', {
|
||||||
|
description: `文件 ${file?.file?.name} 的${index}分块经过多次尝试依然上传失败, 我们已经终止该文件上传`,
|
||||||
|
})
|
||||||
|
uploadfiles.value[uploadFileIndex].status = 'error'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uploadfiles.value[uploadFileIndex]?.queue.shift()
|
||||||
|
}
|
||||||
|
// console.log('[start]', taskType, taskId, queueType)
|
||||||
|
try {
|
||||||
|
if (taskType === 'hash') {
|
||||||
|
await handleHash(fileId)
|
||||||
|
}
|
||||||
|
if (taskType === 'create') {
|
||||||
|
await handleCreate(fileId)
|
||||||
|
}
|
||||||
|
if (taskType === 'chunk') {
|
||||||
|
await handleChunk(fileId)
|
||||||
|
}
|
||||||
|
if (taskType === 'upload' && isNumber(index)) {
|
||||||
|
await handleUpload(fileId, index)
|
||||||
|
}
|
||||||
|
if (taskType === 'finish') {
|
||||||
|
await handleFinish(fileId)
|
||||||
|
}
|
||||||
|
// console.log('[finish]', taskType, taskId)
|
||||||
|
if (queueType === 'sync') {
|
||||||
|
uploadfiles.value[uploadFileIndex]?.queue.shift()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('error', error)
|
||||||
|
// todo 重新加入队列
|
||||||
|
if (queueType === 'async') {
|
||||||
|
uploadfiles.value[uploadFileIndex]?.queue.push({ ...task, retry: (task?.retry || 0) + 1 })
|
||||||
|
toast.warning('上传错误', {
|
||||||
|
description: `文件 ${file?.file?.name} 的${index}分块上传失败, 我们将在稍后再次尝试上传`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (queueType === 'sync') {
|
||||||
|
uploadfiles.value[uploadFileIndex].status = 'error'
|
||||||
|
toast.error('上传错误', {
|
||||||
|
description: `文件${file?.file?.name}上传失败, 请重试`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
procressTaskList.value.delete(taskId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
{ immediate: false }
|
||||||
|
)
|
||||||
|
|
||||||
|
watchEffect(async () => {
|
||||||
|
if (activeTaskAllQueue.value.length > 0 && !isLoading.value) {
|
||||||
|
execute()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleHash = async (fileId: string) => {
|
||||||
|
const uploadfile = uploadfiles.value.find((item) => item.fileId === fileId)
|
||||||
|
if (!uploadfile?.file) return
|
||||||
|
uploadfile.procressType = 'hash'
|
||||||
|
const res = await asyncWorker(calcFileHashWorker, { data: { file: uploadfile.file } })
|
||||||
|
const { hash } = res?.data || {}
|
||||||
|
uploadfile.hash = hash
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCreate = async (fileId: string) => {
|
||||||
|
const uploadfile = uploadfiles.value.find((item) => item.fileId === fileId)
|
||||||
|
if (!uploadfile?.file) return
|
||||||
|
const { hash, file } = uploadfile || {}
|
||||||
|
if (!hash) return
|
||||||
|
uploadfile.procressType = 'create'
|
||||||
|
const { size, type = 'application/octet-stream' } = file || {}
|
||||||
const createData = await $fetch<{
|
const createData = await $fetch<{
|
||||||
data: {
|
data: {
|
||||||
id: string
|
id: string
|
||||||
@@ -52,66 +221,82 @@ const { error } = useAsyncState(async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
size,
|
size,
|
||||||
mime_type: get(type, '', 'application/octet-stream'),
|
mime_type: type || 'application/octet-stream',
|
||||||
hash,
|
hash,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const { id, chunk_size, type: createType } = createData?.data || {}
|
const { id, chunk_size, type: createType } = createData?.data || {}
|
||||||
|
uploadfile.id = id
|
||||||
|
uploadfile.uploadInfo = {
|
||||||
|
chunks: {},
|
||||||
|
chunkLength: Math.ceil(size / chunk_size),
|
||||||
|
ChunkSize: chunk_size,
|
||||||
|
}
|
||||||
if (createType !== 'init') {
|
if (createType !== 'init') {
|
||||||
// 文件存在
|
// 文件存在
|
||||||
form.setFieldValue('file_id', id)
|
uploadfile.status = 'finish'
|
||||||
emit('change', 'result')
|
uploadfile.procressType = 'finish'
|
||||||
|
uploadfile.queue = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
chunkSize.value = chunk_size
|
}
|
||||||
const chunks = Math.ceil(size / chunk_size)
|
|
||||||
fileSliceUploadStatusList.value = times(chunks, (i) => ({
|
|
||||||
status: 'pending',
|
|
||||||
index: i,
|
|
||||||
}))
|
|
||||||
|
|
||||||
const readChunk = (start: number): Promise<ArrayBuffer> => {
|
const handleChunk = async (fileId: string) => {
|
||||||
const fileReader = new FileReader()
|
const uploadfile = uploadfiles.value.find((item) => item.fileId === fileId)
|
||||||
return new Promise((resolve, reject) => {
|
if (!uploadfile?.file) return
|
||||||
const chunk = file.slice(start, start + chunk_size)
|
const { chunkLength } = uploadfile.uploadInfo || {}
|
||||||
fileReader.onload = (e) => resolve(e.target?.result as ArrayBuffer)
|
if (!chunkLength) return
|
||||||
fileReader.onerror = reject
|
|
||||||
fileReader.readAsArrayBuffer(chunk)
|
uploadfile.procressType = 'upload'
|
||||||
})
|
const tasks = shuffle(
|
||||||
|
times(chunkLength, (i: number) => ({ taskType: 'upload' as const, queueType: 'async' as const, taskId: nanoid(), index: i }))
|
||||||
|
)
|
||||||
|
uploadfile.queue.push(...tasks)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleUpload = async (fileId: string, index: number) => {
|
||||||
|
const uploadfile = uploadfiles.value.find((item) => item.fileId === fileId)
|
||||||
|
if (!uploadfile?.file) return
|
||||||
|
const { id, uploadInfo } = uploadfile || {}
|
||||||
|
const { chunkLength, ChunkSize } = uploadInfo || {}
|
||||||
|
if (!ChunkSize || !id) return
|
||||||
|
|
||||||
|
if (uploadfile.procressType !== 'upload') uploadfile.procressType = 'upload'
|
||||||
|
let chunkInfo = uploadfile.uploadInfo?.chunks?.[index]
|
||||||
|
if (!chunkInfo) {
|
||||||
|
uploadfile.uploadInfo!.chunks[index] = {
|
||||||
|
status: 'processing',
|
||||||
|
createdAt: dayjs().unix(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const chunkedUploadTasks = chunk(shuffle([...fileSliceUploadStatusList.value]), 3)
|
const chunk = await getFileChunk(uploadfile.file, index * ChunkSize, ChunkSize)
|
||||||
for (let i = 0; i < chunkedUploadTasks?.length; i++) {
|
const formData = new FormData()
|
||||||
await Promise.all(
|
formData.append('file', new Blob([chunk]))
|
||||||
chunkedUploadTasks?.[i]?.map(async (item: any) => {
|
formData.append('index', (index + 1).toString())
|
||||||
const { index } = item || {}
|
formData.append('id', id)
|
||||||
try {
|
const res = await $fetch<{
|
||||||
const chunk = await readChunk(index * chunk_size)
|
code: number
|
||||||
// console.log('chunk', chunk)
|
}>('/api/file/slice', {
|
||||||
const formData = new FormData()
|
method: 'POST',
|
||||||
formData.append('file', new Blob([chunk]))
|
body: formData,
|
||||||
formData.append('index', index + 1)
|
})
|
||||||
formData.append('id', id)
|
const { code } = res || {}
|
||||||
fileSliceUploadStatusList.value[index].status = 'uploading'
|
if (code !== 200) {
|
||||||
const res = await $fetch<{
|
throw new Error('上传失败')
|
||||||
code: number
|
|
||||||
}>('/api/file/slice', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData,
|
|
||||||
})
|
|
||||||
const { code } = res || {}
|
|
||||||
if (code !== 200) {
|
|
||||||
throw new Error('上传失败')
|
|
||||||
}
|
|
||||||
fileSliceUploadStatusList.value[index].status = 'success'
|
|
||||||
} catch (error) {
|
|
||||||
console.log('error', error)
|
|
||||||
// fileSliceStatusList.value[index].status = 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
const r = await $fetch<{
|
uploadfile.uploadInfo!.chunks[index].status = 'success'
|
||||||
|
if (Object.entries(uploadfile.uploadInfo!.chunks || {}).filter(([index, chunk]) => chunk.status === 'success').length === chunkLength) {
|
||||||
|
uploadfile.queue.push({ taskType: 'finish', queueType: 'sync', taskId: nanoid() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleFinish = async (fileId: string) => {
|
||||||
|
const uploadfile = uploadfiles.value.find((item) => item.fileId === fileId)
|
||||||
|
if (!uploadfile?.file) return
|
||||||
|
uploadfile.procressType = 'finish'
|
||||||
|
const { id } = uploadfile || {}
|
||||||
|
const res = await $fetch<{
|
||||||
code: number
|
code: number
|
||||||
}>('/api/file/finish', {
|
}>('/api/file/finish', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -119,62 +304,264 @@ const { error } = useAsyncState(async () => {
|
|||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (r?.code !== 200) {
|
if (res?.code !== 200) {
|
||||||
throw new Error('上传失败')
|
throw new Error('上传失败')
|
||||||
}
|
}
|
||||||
form.setFieldValue('file_id', id)
|
uploadfile.status = 'finish'
|
||||||
emit('change', 'result')
|
}
|
||||||
}, null)
|
|
||||||
|
|
||||||
watch(error, (newVal) => {
|
watchEffect(() => {
|
||||||
if (newVal) {
|
if (!isEmpty(uploadfiles.value) && uploadfiles.value.every((r) => r.status === 'finish')) {
|
||||||
toast.error('上传失败')
|
// console.log('change', uploadfiles.value)
|
||||||
|
form.setFieldValue(
|
||||||
|
'files',
|
||||||
|
uploadfiles.value.map((item) => {
|
||||||
|
const { id, file } = item || {}
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
file,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
emit('change', 'result')
|
||||||
}
|
}
|
||||||
emit('change', 'input')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
uploadfiles.value = []
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleShowSpeedInfo = () => {
|
||||||
|
showDrawer({
|
||||||
|
render: ({ hide }) => h(FileUploadSpeedInfoView, { hide }),
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-3">
|
<div class="grid grid-cols-4 gap-5">
|
||||||
<div class="text-xl font-normal">正在上传</div>
|
<div class="rounded-xl p-3 bg-white/80 flex flex-col gap-2 col-span-4 md:col-span-3 h-32 md:h-auto">
|
||||||
<div class="flex flex-col items-center gap-4 md:flex-row md:justify-evenly">
|
<div class="flex flex-col gap-1">
|
||||||
<div :class="cx('flex flex-row items-center gap-5', step !== 'hash' && 'opacity-50')">
|
<div @click="handleShowSpeedInfo" class="flex flex-row gap-1 items-center text-xs opacity-70">
|
||||||
<div class="flex flex-col gap-0.5 items-center">
|
总上传进度
|
||||||
<div class="text-xs opacity-50">1.计算hash</div>
|
<LucideInfo class="size-3" />
|
||||||
<div class="text-3xl font-light">
|
</div>
|
||||||
<LucideLoaderCircle v-if="step === 'hash'" class="size-5 my-1 animate-spin" />
|
<div class="text-2xl font-bold">
|
||||||
<div v-else>{{ calcHashTime }}ms</div>
|
{{
|
||||||
</div>
|
`${
|
||||||
|
getFileSize(
|
||||||
|
Object.entries(speedChartData)
|
||||||
|
?.filter((r) => dayjs().unix() - 60 < parseInt(r[0]))
|
||||||
|
?.reduce((acc, curr) => acc + curr[1]?.reduce((_acc, _curr) => _acc + _curr.value, 0), 0) / 60
|
||||||
|
) ?? 0
|
||||||
|
}/s`
|
||||||
|
}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div :class="cx('flex flex-row items-center gap-5 min-w-32', step !== 'upload' && 'opacity-50')">
|
<div class="flex-1 relative overflow-hidden flex flex-row gap-0.5 justify-end items-end">
|
||||||
<CircularProgress :size="80" :value="step !== 'upload' ? 0 : uploadProgress" />
|
<motion.div
|
||||||
<div class="flex flex-col gap-0.5 items-center">
|
class="w-2 shrink-0 bg-primary relative"
|
||||||
<div class="text-xs opacity-50">2.上传文件</div>
|
:style="{
|
||||||
<div class="text-3xl font-light">{{ step !== 'upload' ? 0 : uploadProgress }}%</div>
|
height: `${(i[1]?.reduce((acc, curr) => acc + curr.value, 0) / Math.max(...Object.entries(speedChartData)?.map((r) => r[1]?.reduce((acc, curr) => acc + curr.value, 0)))) * 100}%`,
|
||||||
<div class="text-sm opacity-50" v-if="alreadyUploadSize">
|
}"
|
||||||
{{ filesize(alreadyUploadSize) }} / {{ filesize(data?.file?.size) }}
|
:layoutId="i[0]"
|
||||||
|
v-for="i in Object.entries(speedChartData)"
|
||||||
|
:key="i[0]"
|
||||||
|
:initial="{ x: 10, opacity: 0 }"
|
||||||
|
:animate="{ x: 0, opacity: 1 }"
|
||||||
|
:transition="{ duration: 1 }"
|
||||||
|
>
|
||||||
|
</motion.div>
|
||||||
|
<!-- <BarChart class="h-full" :data="data" index="time" :categories="['value']" :showTooltip="false"
|
||||||
|
:showLegend="false" :showXAxis="false" :showYAxis="false" :showGrid="false" :groupMaxWidth="10" /> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="rounded-xl col-span-4 md:col-span-1 bg-white/80 h-32 md:h-auto md:aspect-square flex flex-col gap-2 relative overflow-hidden">
|
||||||
|
<div class="absolute top-0 left-0 w-full h-full z-[0] flex flex-col justify-end">
|
||||||
|
<div class="w-full bg-green-100 border-t border-green-500" :style="`height: ${totalUploadProgress || 0}%`"></div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col gap-2 justify-between p-3 h-full relative z-[1]">
|
||||||
|
<div class="flex flex-col gap-1">
|
||||||
|
<div class="text-xs opacity-70">总上传进度</div>
|
||||||
|
<div class="text-4xl font-bold">{{ (totalUploadProgress || 0).toFixed(1) }}%</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
<Button
|
||||||
|
class="aspect-square hover:text-white p-0 bg-green-200 hover:bg-green-300 text-green-500"
|
||||||
|
:disabled="['start', 'disabled'].includes(totalTaskStatus)"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
uploadfiles.forEach((r) => {
|
||||||
|
r.status = 'start'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucidePlay class="size-1/2" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
class="aspect-square hover:text-white p-0 bg-orange-200 hover:bg-orange-300 text-orange-500"
|
||||||
|
:disabled="['pause', 'disabled'].includes(totalTaskStatus)"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
uploadfiles.forEach((r) => {
|
||||||
|
r.status = 'pause'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideSquare class="size-1/2" />
|
||||||
|
</Button>
|
||||||
|
<!-- <Button class="aspect-square bg-blue-200 hover:bg-blue-300 text-blue-500 hover:text-white p-0">
|
||||||
|
<LucideSettings class="size-1/2" />
|
||||||
|
</Button> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-span-4 flex flex-col bg-white/80 rounded-xl p-3 text-md gap-5">
|
||||||
|
<div>文件列表</div>
|
||||||
|
<div class="flex flex-col -mx-3 text-sm">
|
||||||
|
<div class="grid grid-cols-[2fr_6rem_6rem] md:grid-cols-[2fr_6rem_6rem_4fr] gap-2 border-b border-black/20 pb-2 px-3">
|
||||||
|
<div>文件名</div>
|
||||||
|
<div>文件大小</div>
|
||||||
|
<div @click="handleShowSpeedInfo" class="flex flex-row gap-1 items-center">
|
||||||
|
上传速度
|
||||||
|
<LucideInfo class="size-3" />
|
||||||
|
</div>
|
||||||
|
<div class="hidden md:block">进度</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
:class="
|
||||||
|
cx(
|
||||||
|
'grid grid-cols-[2fr_6rem_6rem] md:grid-cols-[2fr_6rem_6rem_4fr] gap-2 py-2 border-b border-black/20 items-center hover:bg-primary/30 px-3 cursor-pointer',
|
||||||
|
selectedFile === item?.fileId && 'bg-primary text-white hover:!bg-primary'
|
||||||
|
)
|
||||||
|
"
|
||||||
|
v-for="(item, index) in uploadfiles"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
if (selectedFile === item?.fileId) {
|
||||||
|
selectedFile = null
|
||||||
|
} else {
|
||||||
|
selectedFile = item?.fileId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div class="flex flex-row gap-2 items-center grow md:grow-0 overflow-hidden">
|
||||||
|
<Button
|
||||||
|
class="size-8 p-0 hover:bg-white/50"
|
||||||
|
variant="ghost"
|
||||||
|
:disabled="['finish']?.includes(item?.procressType)"
|
||||||
|
@click="
|
||||||
|
(e: Event) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
if (item?.status === 'start') {
|
||||||
|
uploadfiles[index].status = 'pause'
|
||||||
|
} else {
|
||||||
|
uploadfiles[index].status = 'start'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideArrowUpFromLine class="size-4 text-green-500" v-if="item?.status === 'start'" />
|
||||||
|
<LucideSquare class="size-4 text-gray-500" v-if="item?.status === 'pause'" />
|
||||||
|
<LucideCircleX class="size-4 text-red-500" v-if="item?.status === 'error'" />
|
||||||
|
<LucideCheckCircle class="size-4 text-green-500" v-if="item?.status === 'finish'" />
|
||||||
|
</Button>
|
||||||
|
<div class="truncate">{{ item?.file?.name }}</div>
|
||||||
|
</div>
|
||||||
|
<div>{{ getFileSize(item?.file?.size) }}</div>
|
||||||
|
<div>
|
||||||
|
{{
|
||||||
|
`${getFileSize(
|
||||||
|
(Object.entries(item?.uploadInfo?.chunks || {})?.filter(
|
||||||
|
([, chunk]) => chunk.status === 'success' && dayjs().unix() - 60 < chunk.createdAt
|
||||||
|
)?.length /
|
||||||
|
60) *
|
||||||
|
(item?.uploadInfo?.ChunkSize || 0)
|
||||||
|
)} /s`
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex flex-row gap-2 items-center col-span-3 md:col-span-1"
|
||||||
|
v-if="['hash', 'create', 'chunk']?.includes(item?.procressType)"
|
||||||
|
>
|
||||||
|
<LucideLoaderCircle class="size-4 animate-spin" />
|
||||||
|
<div>正在{{ item?.procressType }}中...</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-2 items-center col-span-3 md:col-span-1" v-if="item?.procressType === 'finish'">
|
||||||
|
{{ item?.status === 'finish' ? '云端已有相同hash文件, 秒传成功' : null }}
|
||||||
|
{{ item?.status === 'error' ? '上传失败,请稍后重试' : null }}
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-2 items-center col-span-3 md:col-span-1" v-if="item?.procressType === 'upload'">
|
||||||
|
<div class="rounded-full bg-white/50 w-full h-2 overflow-hidden border border-white">
|
||||||
|
<div
|
||||||
|
class="h-full bg-primary"
|
||||||
|
:style="`width: ${clamp(
|
||||||
|
((Object.entries(item?.uploadInfo?.chunks || {})?.filter(([index, chunk]) => chunk.status === 'success')
|
||||||
|
?.length || 0) /
|
||||||
|
(item?.uploadInfo?.chunkLength || 0)) *
|
||||||
|
100,
|
||||||
|
0,
|
||||||
|
100
|
||||||
|
)}%`"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{
|
||||||
|
clamp(
|
||||||
|
((Object.entries(item?.uploadInfo?.chunks || {})?.filter(([index, chunk]) => chunk.status === 'success')
|
||||||
|
?.length || 0) /
|
||||||
|
(item?.uploadInfo?.chunkLength || 0)) *
|
||||||
|
100,
|
||||||
|
0,
|
||||||
|
100
|
||||||
|
)?.toFixed(2)
|
||||||
|
}}%
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-2 items-baseline">
|
<div class="col-span-4 flex flex-col bg-white/80 rounded-xl p-3 gap-5" v-if="selectedFile">
|
||||||
<div class="text-md font-normal">详细信息</div>
|
<div>上传详情</div>
|
||||||
<div class="text-xs opacity-50" v-if="step === 'upload' && fileSliceUploadStatusList?.length > 0">
|
<div class="grid grid-cols-3 text-sm gap-3">
|
||||||
当前正在上传分块{{ `${successCount}/${Math.ceil(data?.file?.size / chunkSize)}` }} 并发:3
|
<div>
|
||||||
|
区块: {{ selectedUploadfile?.uploadInfo?.chunkLength }} x {{ getFileSize(selectedUploadfile?.uploadInfo?.ChunkSize as number) }}
|
||||||
|
</div>
|
||||||
|
<div class="truncate col-span-2">hash: {{ selectedUploadfile?.hash }}</div>
|
||||||
|
<div>已完成: {{ selectedUploadfileChunk?.filter((r) => r.status === 'success')?.length || 0 }}</div>
|
||||||
|
<div>已丢弃: {{ selectedUploadfileChunk?.filter((r) => r.status === 'error')?.length || 0 }}</div>
|
||||||
|
<div>
|
||||||
|
待完成:
|
||||||
|
{{ (selectedUploadfile?.uploadInfo?.chunkLength || 0) - (selectedUploadfileChunk?.length || 0) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-span-3 flex flex-row justify-between items-center">
|
||||||
|
<div class="text-md font-bold">{{ selectedUploadfileViewMode === 'progress' ? '区块进度条' : '区块热力图' }}</div>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
class="ml-auto text-xs"
|
||||||
|
@click="selectedUploadfileViewMode = selectedUploadfileViewMode === 'progress' ? 'heatmap' : 'progress'"
|
||||||
|
>
|
||||||
|
<LucideArrowDownUp class="size-4" />
|
||||||
|
{{ selectedUploadfileViewMode === 'progress' ? '热力图' : '进度条' }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div class="h-7 col-span-3 flex flex-row gap-2 items-center" v-if="selectedUploadfileViewMode === 'progress'">
|
||||||
|
<div class="flex-1 h-full">
|
||||||
|
<FileUploadBlockProgressView :data="selectedUploadfile?.uploadInfo" />
|
||||||
|
</div>
|
||||||
|
{{
|
||||||
|
clamp(((selectedUploadfileChunk?.length || 0) / (selectedUploadfile?.uploadInfo?.chunkLength || 0)) * 100, 0, 100)?.toFixed(
|
||||||
|
2
|
||||||
|
)
|
||||||
|
}}%
|
||||||
|
</div>
|
||||||
|
<div v-if="selectedUploadfileViewMode === 'heatmap'" class="col-span-3 bg-black/5 rounded p-2">
|
||||||
|
<FileUploadHeatMapView :size="12" :data="selectedUploadfile?.uploadInfo" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row flex-wrap gap-1">
|
|
||||||
<div
|
|
||||||
v-for="i in fileSliceUploadStatusList"
|
|
||||||
:class="
|
|
||||||
cx(
|
|
||||||
'rounded size-4 ',
|
|
||||||
i.status === 'pending' && 'bg-white/90',
|
|
||||||
i.status === 'uploading' && 'bg-yellow-500',
|
|
||||||
i.status === 'success' && 'bg-green-500'
|
|
||||||
)
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
8
front/components/Home/File/FileUploadSpeedInfoView.vue
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex flex-col gap-2 pt-3">
|
||||||
|
<div class="text-xl font-bold">上传速度如何计算</div>
|
||||||
|
<div class="opacity-75">
|
||||||
|
上传速度根据当前秒上传了 <b>文件区块的数量</b> * <b>每个文件区块的大小</b> 估算而来,可能与真实上传速度有一定的误差,仅供参考
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -11,5 +11,5 @@ const renderHtml = computed(() => {
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div :class="cx('prose', props?.class)" v-html="renderHtml" />
|
<div :class="cx('prose prose-sm [&>*]:outline-none prose-p:my-1 prose-headings:my-2 prose-pre:mb-0', props?.class)" v-html="renderHtml" />
|
||||||
</template>
|
</template>
|
||||||
47
front/components/Pixi.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Application } from 'vue3-pixi'
|
||||||
|
import { useElementSize, useDevicePixelRatio } from '@vueuse/core'
|
||||||
|
|
||||||
|
export interface PixiExpose {
|
||||||
|
app: Application
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
contentHeight: number
|
||||||
|
ref: HTMLElement
|
||||||
|
}
|
||||||
|
|
||||||
|
const containerRef = ref<HTMLElement>()
|
||||||
|
const app = ref<Application>()
|
||||||
|
const { width: windowWidth, height: windowHeight } = useWindowSize()
|
||||||
|
const { width: containerWidth, height: containerHeight } = useElementSize(containerRef)
|
||||||
|
const width = computed(() => Math.min(containerWidth.value, windowWidth.value))
|
||||||
|
const contentHeight = ref(0)
|
||||||
|
const height = computed(() => {
|
||||||
|
if (!contentHeight.value) return Math.min(containerHeight.value, windowHeight.value)
|
||||||
|
if (containerHeight.value > contentHeight.value) return contentHeight.value
|
||||||
|
return contentHeight.value
|
||||||
|
})
|
||||||
|
const { pixelRatio } = useDevicePixelRatio()
|
||||||
|
const resolution = computed(() => pixelRatio.value ?? 1)
|
||||||
|
watchEffect(() => {
|
||||||
|
if (app.value?.app?.renderer) {
|
||||||
|
app.value?.app?.renderer?.resize(width.value, height.value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
app,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
contentHeight,
|
||||||
|
ref: containerRef,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div ref="containerRef" class="w-full h-full">
|
||||||
|
<Application :width="width" :height="height" :resolution="resolution" ref="app" autoDensity antialias :backgroundAlpha="0">
|
||||||
|
<slot :width="width" :height="height" />
|
||||||
|
</Application>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import SwitchField from '../Field/SwitchField.vue';
|
import SwitchField from '../Field/SwitchField.vue'
|
||||||
import InputField from '../Field/InputField.vue';
|
import InputField from '../Field/InputField.vue'
|
||||||
import SelectField from '../Field/SelectField.vue';
|
import SelectField from '../Field/SelectField.vue'
|
||||||
import FormButton from '../Field/FormButton.vue';
|
import FormButton from '../Field/FormButton.vue'
|
||||||
|
import type { FileShareHandleProps } from './types'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
hide: () => void
|
hide: () => void
|
||||||
file: File
|
file: File[]
|
||||||
onFileHandle: ({ type, config }: { type: string, config: any }) => void
|
onFileHandle: (props: FileShareHandleProps) => void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -16,51 +16,74 @@ const props = defineProps<{
|
|||||||
<div class="flex flex-col gap-3">
|
<div class="flex flex-col gap-3">
|
||||||
<h2 class="text-lg font-bold">分享选项</h2>
|
<h2 class="text-lg font-bold">分享选项</h2>
|
||||||
<div class="flex flex-row items-center gap-2 text-sm">
|
<div class="flex flex-row items-center gap-2 text-sm">
|
||||||
|
<SelectField
|
||||||
<SelectField name="download_nums" label="下载次数" :options="[
|
name="download_nums"
|
||||||
{ label: '1次下载', value: 1 },
|
label="下载次数"
|
||||||
{ label: '2次下载', value: 2 },
|
:options="[
|
||||||
{ label: '3次下载', value: 3 },
|
{ label: '1次下载', value: 1 },
|
||||||
{ label: '5次下载', value: 5 },
|
{ label: '2次下载', value: 2 },
|
||||||
{ label: '10次下载', value: 10 },
|
{ label: '3次下载', value: 3 },
|
||||||
]" />
|
{ label: '5次下载', value: 5 },
|
||||||
|
{ label: '10次下载', value: 10 },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
或
|
或
|
||||||
<SelectField name="expire_time" label="过期时间" :options="[
|
<SelectField
|
||||||
{ label: '5分钟', value: 5 },
|
name="expire_time"
|
||||||
{ label: '1小时', value: 60 },
|
label="过期时间"
|
||||||
{ label: '1天', value: 1440 },
|
:options="[
|
||||||
{ label: '3天', value: 4320 },
|
{ label: '5分钟', value: 5 },
|
||||||
]" />
|
{ label: '1小时', value: 60 },
|
||||||
|
{ label: '1天', value: 1440 },
|
||||||
|
{ label: '3天', value: 4320 },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
后过期
|
后过期
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<div class="flex flex-row gap-3 min-h-9">
|
<div class="flex flex-row gap-3 min-h-9">
|
||||||
<SwitchField name="has_pickup_code" label="取件码" :rules="((value: boolean) => {
|
<SwitchField
|
||||||
if (!!value) {
|
name="has_pickup_code"
|
||||||
setFieldValue('has_password', false)
|
label="取件码"
|
||||||
}
|
:rules="
|
||||||
return true
|
(value: boolean) => {
|
||||||
})" />
|
if (!!value) {
|
||||||
|
setFieldValue('has_password', false)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-3 min-h-9">
|
<div class="flex flex-row gap-3 min-h-9">
|
||||||
<SwitchField name="has_password" label="密码保护" :rules="((value: boolean) => {
|
<SwitchField
|
||||||
if (!!value) {
|
name="has_password"
|
||||||
setFieldValue('has_pickup_code', false)
|
label="密码保护"
|
||||||
}
|
:rules="
|
||||||
return true
|
(value: boolean) => {
|
||||||
})" />
|
if (!!value) {
|
||||||
|
setFieldValue('has_pickup_code', false)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
<InputField v-if="!!values.has_password" name="password" placeholder="请输入密码" rules="required" />
|
<InputField v-if="!!values.has_password" name="password" placeholder="请输入密码" rules="required" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-3 min-h-9">
|
<div class="flex flex-row gap-3 min-h-9">
|
||||||
<SwitchField name="has_notify" label="下载通知" />
|
<SwitchField name="has_notify" label="下载通知" />
|
||||||
<InputField v-if="!!values.has_notify" name="notify_email" placeholder="请输入邮箱"
|
<InputField v-if="!!values.has_notify" name="notify_email" placeholder="请输入邮箱" rules="required" />
|
||||||
rules="required" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<FormButton @click="async (form) => {
|
<FormButton
|
||||||
onFileHandle({ type: 'file-share', config: values })
|
@click="
|
||||||
hide()
|
async (form) => {
|
||||||
}">提交</FormButton>
|
onFileHandle({ type: 'file-share', config: values })
|
||||||
|
hide()
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>提交</FormButton
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</VeeForm>
|
</VeeForm>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import SwitchField from '../Field/SwitchField.vue';
|
import SwitchField from '../Field/SwitchField.vue'
|
||||||
import InputField from '../Field/InputField.vue';
|
import InputField from '../Field/InputField.vue'
|
||||||
import SelectField from '../Field/SelectField.vue';
|
import SelectField from '../Field/SelectField.vue'
|
||||||
import FormButton from '../Field/FormButton.vue';
|
import FormButton from '../Field/FormButton.vue'
|
||||||
|
import type { TextShareHandleProps } from './types'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
hide: () => void
|
hide: () => void
|
||||||
text: string
|
text: string
|
||||||
onTextHandle: ({ type, config }: { type: string, config: any }) => void
|
onTextHandle: (props: TextShareHandleProps) => void
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -15,51 +16,74 @@ const props = defineProps<{
|
|||||||
<div class="flex flex-col gap-3">
|
<div class="flex flex-col gap-3">
|
||||||
<h2 class="text-lg font-bold">分享选项</h2>
|
<h2 class="text-lg font-bold">分享选项</h2>
|
||||||
<div class="flex flex-row items-center gap-2 text-sm">
|
<div class="flex flex-row items-center gap-2 text-sm">
|
||||||
|
<SelectField
|
||||||
<SelectField name="download_nums" label="浏览次数" :options="[
|
name="download_nums"
|
||||||
{ label: '1次浏览', value: 1 },
|
label="浏览次数"
|
||||||
{ label: '2次浏览', value: 2 },
|
:options="[
|
||||||
{ label: '3次浏览', value: 3 },
|
{ label: '1次浏览', value: 1 },
|
||||||
{ label: '5次浏览', value: 5 },
|
{ label: '2次浏览', value: 2 },
|
||||||
{ label: '10次浏览', value: 10 },
|
{ label: '3次浏览', value: 3 },
|
||||||
]" />
|
{ label: '5次浏览', value: 5 },
|
||||||
|
{ label: '10次浏览', value: 10 },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
或
|
或
|
||||||
<SelectField name="expire_time" label="过期时间" :options="[
|
<SelectField
|
||||||
{ label: '5分钟', value: 5 },
|
name="expire_time"
|
||||||
{ label: '1小时', value: 60 },
|
label="过期时间"
|
||||||
{ label: '1天', value: 1440 },
|
:options="[
|
||||||
{ label: '3天', value: 4320 },
|
{ label: '5分钟', value: 5 },
|
||||||
]" />
|
{ label: '1小时', value: 60 },
|
||||||
|
{ label: '1天', value: 1440 },
|
||||||
|
{ label: '3天', value: 4320 },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
后过期
|
后过期
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<div class="flex flex-row gap-3 min-h-9">
|
<div class="flex flex-row gap-3 min-h-9">
|
||||||
<SwitchField name="has_pickup_code" label="取件码" :rules="((value: boolean) => {
|
<SwitchField
|
||||||
if (!!value) {
|
name="has_pickup_code"
|
||||||
setFieldValue('has_password', false)
|
label="取件码"
|
||||||
}
|
:rules="
|
||||||
return true
|
(value: boolean) => {
|
||||||
})" />
|
if (!!value) {
|
||||||
|
setFieldValue('has_password', false)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-3 min-h-9">
|
<div class="flex flex-row gap-3 min-h-9">
|
||||||
<SwitchField name="has_password" label="密码保护" :rules="((value: boolean) => {
|
<SwitchField
|
||||||
if (!!value) {
|
name="has_password"
|
||||||
setFieldValue('has_pickup_code', false)
|
label="密码保护"
|
||||||
}
|
:rules="
|
||||||
return true
|
(value: boolean) => {
|
||||||
})" />
|
if (!!value) {
|
||||||
|
setFieldValue('has_pickup_code', false)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
<InputField v-if="!!values.has_password" name="password" placeholder="请输入密码" rules="required" />
|
<InputField v-if="!!values.has_password" name="password" placeholder="请输入密码" rules="required" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-3 min-h-9">
|
<div class="flex flex-row gap-3 min-h-9">
|
||||||
<SwitchField name="has_notify" label="已读通知" />
|
<SwitchField name="has_notify" label="已读通知" />
|
||||||
<InputField v-if="!!values.has_notify" name="notify_email" placeholder="请输入邮箱"
|
<InputField v-if="!!values.has_notify" name="notify_email" placeholder="请输入邮箱" rules="required" />
|
||||||
rules="required" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<FormButton @click="async (form) => {
|
<FormButton
|
||||||
onTextHandle({ type: 'text-share', config: values })
|
@click="
|
||||||
hide()
|
async (form) => {
|
||||||
}">提交</FormButton>
|
onTextHandle({ type: 'text-share', config: values })
|
||||||
|
hide()
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>提交</FormButton
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</VeeForm>
|
</VeeForm>
|
||||||
</template>
|
</template>
|
||||||
5
front/components/Preprocessing/types.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export type FileHandleKey = 'file-share' | 'file-image-compress'
|
||||||
|
export type FileShareHandleProps = { type: FileHandleKey; config: Record<string, any> }
|
||||||
|
|
||||||
|
export type TextHandleKey = 'text-share'
|
||||||
|
export type TextShareHandleProps = { type: TextHandleKey; config: Record<string, any> }
|
||||||
@@ -1,152 +1,216 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button'
|
||||||
import FilePreviewView from "@/components/FilePreviewView.vue";
|
import FilePreviewView from '@/components/FilePreviewView.vue'
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input'
|
||||||
import { useClipboard } from "@vueuse/core";
|
import { useClipboard } from '@vueuse/core'
|
||||||
import { toast } from "vue-sonner";
|
import { toast } from 'vue-sonner'
|
||||||
import { useQuery } from "@tanstack/vue-query";
|
import { useQuery } from '@tanstack/vue-query'
|
||||||
import useMyAppShare from "@/composables/useMyAppShare";
|
import useMyAppShare from '@/composables/useMyAppShare'
|
||||||
import useMyAppConfig from "@/composables/useMyAppConfig";
|
import useMyAppConfig from '@/composables/useMyAppConfig'
|
||||||
import dayjs from "dayjs";
|
import dayjs from 'dayjs'
|
||||||
import relativeTime from "dayjs/plugin/relativeTime";
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
import "dayjs/locale/zh-cn"; // 导入中文语言包
|
import 'dayjs/locale/zh-cn' // 导入中文语言包
|
||||||
import showDrawer from "@/lib/showDrawer";
|
import showDrawer from '@/lib/showDrawer'
|
||||||
import QrCoreDrawer from "@/components/Drawer/QrCoreDrawer.vue";
|
import QrCoreDrawer from '@/components/Drawer/QrCoreDrawer.vue'
|
||||||
dayjs.extend(relativeTime); // 扩展 relativeTime 插件
|
import { h } from 'vue'
|
||||||
dayjs.locale("zh-cn"); // 设置语言为中文
|
import { cx } from 'class-variance-authority'
|
||||||
|
import type { FileHandleKey } from '../Preprocessing/types'
|
||||||
|
dayjs.extend(relativeTime) // 扩展 relativeTime 插件
|
||||||
|
dayjs.locale('zh-cn') // 设置语言为中文
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
data: { file: File; config: any; handle_type: string; file_id: string };
|
data: { files: { id: string; file: File }[]; config: Record<string, any>; handle_type: FileHandleKey }
|
||||||
}>();
|
}>()
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: "change", key: string): void;
|
(e: 'change', key: string): void
|
||||||
}>();
|
}>()
|
||||||
const { createFileShare } = useMyAppShare();
|
const { createFileShare } = useMyAppShare()
|
||||||
const { data } = useQuery({
|
const { data } = useQuery({
|
||||||
queryKey: ["create-share", props?.data?.file_id],
|
queryKey: ['create-share', ...props?.data?.files?.map((item) => item.id)],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { file_id, config, file } = props?.data || {};
|
const { files, config } = props?.data || {}
|
||||||
const { name } = file || {};
|
const data = await createFileShare({
|
||||||
const data = await createFileShare({
|
files: files?.map((item) => {
|
||||||
file_id,
|
const { id, file } = item || {}
|
||||||
config,
|
return { id, name: file.name }
|
||||||
file_name: name,
|
}),
|
||||||
});
|
config: config as any,
|
||||||
return data?.data;
|
})
|
||||||
},
|
return data?.map((item) => item?.data)
|
||||||
});
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const appConfig = useMyAppConfig();
|
const selectedFile = ref<string | undefined>()
|
||||||
const url = computed(() => {
|
const selectedFileShare = computed(() => {
|
||||||
const { id } = data?.value || {};
|
return data?.value?.find((item) => item?.id === selectedFile.value)
|
||||||
return `${appConfig?.value?.site_url}/s/${id}`;
|
})
|
||||||
});
|
watchEffect(() => {
|
||||||
|
if (data?.value && data?.value?.length === 1 && !!data?.value?.[0]?.id) {
|
||||||
|
selectedFile.value = data.value[0].id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const { copy } = useClipboard();
|
watchEffect(() => {
|
||||||
|
console.log('data', data?.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
const appConfig = useMyAppConfig()
|
||||||
|
const getShareUrl = (id: string) => {
|
||||||
|
return `${appConfig?.value?.site_url}/s/${id}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const { copy } = useClipboard()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-3">
|
<div class="flex flex-col gap-3">
|
||||||
<h2 class="text-lg">上传成功</h2>
|
<h2 class="text-lg">上传成功</h2>
|
||||||
<div class="flex flex-col gap-3 items-center">
|
<div class="flex flex-col gap-3 items-center">
|
||||||
<div class="flex flex-col h-30 items-center">
|
<div v-if="data?.length === 1" class="flex flex-col h-30 items-center">
|
||||||
<FilePreviewView :value="props?.data?.file" />
|
<FilePreviewView :value="props?.data?.files?.[0]?.file" />
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="flex flex-col md:flex-row gap-5 rounded-md p-5 bg-white/20 backdrop-blur-xl w-full"
|
|
||||||
>
|
|
||||||
<div class="flex flex-col gap-2 flex-1">
|
|
||||||
<div class="text-sm font-semibold">信息</div>
|
|
||||||
<div class="grid grid-cols-2 gap-2">
|
|
||||||
<div class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1">
|
|
||||||
<div class="text-xs font-semibold">下载次数</div>
|
|
||||||
<div class="text-3xl font-light">{{ data?.download_nums }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="rounded-xl flex flex-col bg-black/5 px-3 py-2 gap-1">
|
<div v-else class="flex flex-col gap-2 w-full p-5 bg-white/20 backdrop-blur-xl rounded-md">
|
||||||
<div class="text-xs font-semibold">过期时间</div>
|
<div class="text-sm font-semibold">文件列表</div>
|
||||||
<div class="text-md font-light">
|
<div
|
||||||
{{
|
v-for="file in data"
|
||||||
dayjs(data?.expire_at * 1000).format("YYYY-MM-DD HH:mm:ss")
|
:class="
|
||||||
}}
|
cx(
|
||||||
</div>
|
'flex flex-row justify-between items-center gap-1 rounded-md p-2 border border-black/10 w-full cursor-pointer',
|
||||||
</div>
|
selectedFile === file?.id && 'bg-primary text-white'
|
||||||
<div
|
)
|
||||||
class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1"
|
"
|
||||||
v-if="data?.pickup_code"
|
@click="selectedFile = file?.id"
|
||||||
>
|
|
||||||
<div class="flex flex-row justify-between w-full items-center">
|
|
||||||
<div class="text-xs font-semibold">提取码</div>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
class="bg-white/70 p-0 size-6"
|
|
||||||
size="icon"
|
|
||||||
@click="
|
|
||||||
() => {
|
|
||||||
copy(data?.pickup_code);
|
|
||||||
toast.success('复制成功');
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<LucideCopy class="size-3" />
|
<div class="flex flex-row items-center gap-2 flex-1 min-w-0">
|
||||||
</Button>
|
<FileIcon
|
||||||
</div>
|
:file="props?.data?.files?.[data?.findIndex((i) => i?.id === file?.id) as number]?.file"
|
||||||
<div class="flex flex-row gap-2">
|
:class="cx('!size-7 !rounded-md shrink-0', selectedFile === file?.id && '!bg-white/50')"
|
||||||
<div v-for="s in data?.pickup_code" class="text-2xl font-light">
|
/>
|
||||||
{{ s }}
|
<div class="text-sm flex-1 truncate">{{ file?.file_name }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row items-center gap-2 shrink-0">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
:class="cx('bg-white/70', selectedFile === file?.id && '!bg-white/30 border-none hover:text-white/80')"
|
||||||
|
size="icon"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
copy(getShareUrl(file?.id as string))
|
||||||
|
toast.success('复制成功')
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideCopy />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
:class="cx('bg-white/70', selectedFile === file?.id && '!bg-white/30 border-none hover:text-white/80')"
|
||||||
|
size="icon"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
showDrawer({
|
||||||
|
render: ({ ...rest }) =>
|
||||||
|
h(QrCoreDrawer, {
|
||||||
|
...rest,
|
||||||
|
data: getShareUrl(file?.id as string),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideQrCode />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div v-if="!!selectedFileShare" class="flex flex-col md:flex-row gap-5 rounded-md p-5 bg-white/20 backdrop-blur-xl w-full">
|
||||||
</div>
|
<div class="flex flex-col gap-2 flex-1">
|
||||||
<div class="flex flex-col gap-5 flex-1">
|
<div class="text-sm font-semibold">信息</div>
|
||||||
<div class="text-sm font-semibold">链接</div>
|
<div class="grid grid-cols-2 gap-2">
|
||||||
<div class="flex flex-row gap-2">
|
<div class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1">
|
||||||
<Input v-model="url" class="bg-white/70" readonly />
|
<div class="text-xs font-semibold">下载次数</div>
|
||||||
<Button
|
<div class="text-3xl font-light">{{ selectedFileShare?.download_nums }}</div>
|
||||||
variant="outline"
|
</div>
|
||||||
class="bg-white/70"
|
<div class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1">
|
||||||
size="icon"
|
<div class="text-xs font-semibold">过期时间</div>
|
||||||
@click="
|
<div class="text-md font-light">
|
||||||
() => {
|
{{ dayjs((selectedFileShare?.expire_at || 0) * 1000).format('YYYY-MM-DD HH:mm:ss') }}
|
||||||
copy(url);
|
</div>
|
||||||
toast.success('复制成功');
|
</div>
|
||||||
}
|
<div class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1" v-if="selectedFileShare?.pickup_code">
|
||||||
"
|
<div class="flex flex-row justify-between w-full items-center">
|
||||||
>
|
<div class="text-xs font-semibold">提取码</div>
|
||||||
<LucideCopy />
|
<Button
|
||||||
</Button>
|
variant="outline"
|
||||||
|
class="bg-white/70 p-0 size-6"
|
||||||
|
size="icon"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
copy(selectedFileShare?.pickup_code as string)
|
||||||
|
toast.success('复制成功')
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideCopy class="size-3" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
<div v-for="s in selectedFileShare?.pickup_code" class="text-2xl font-light">
|
||||||
|
{{ s }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col gap-5 flex-1">
|
||||||
|
<div class="text-sm font-semibold">链接</div>
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
<Input :model-value="getShareUrl(selectedFileShare?.id as string)" class="bg-white/70" readonly />
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
class="bg-white/70"
|
||||||
|
size="icon"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
copy(getShareUrl(selectedFileShare?.id as string))
|
||||||
|
toast.success('复制成功')
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideCopy />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
class="bg-white/70"
|
||||||
|
size="icon"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
showDrawer({
|
||||||
|
render: ({ ...rest }) =>
|
||||||
|
h(QrCoreDrawer, {
|
||||||
|
...rest,
|
||||||
|
data: getShareUrl(selectedFileShare?.id as string),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideQrCode />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
class="w-40 hover:bg-primary/90"
|
||||||
class="bg-white/70"
|
@click="
|
||||||
size="icon"
|
() => {
|
||||||
@click="
|
emit('change', 'input')
|
||||||
() => {
|
}
|
||||||
showDrawer({
|
"
|
||||||
render: ({ ...rest }) =>
|
|
||||||
h(QrCoreDrawer, {
|
|
||||||
...rest,
|
|
||||||
data: url,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<LucideQrCode />
|
返回首页
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
class="hover:bg-white/50 w-40"
|
|
||||||
@click="
|
|
||||||
() => {
|
|
||||||
emit('change', 'input');
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
|
||||||
确定
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,193 +1,166 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useQuery } from "@tanstack/vue-query";
|
import { useQuery } from '@tanstack/vue-query'
|
||||||
import { AsyncButton, Button } from "@/components/ui/button";
|
import { AsyncButton, Button } from '@/components/ui/button'
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
import { filesize } from "filesize";
|
import { filesize } from 'filesize'
|
||||||
import useMyAppShare from "@/composables/useMyAppShare";
|
import useMyAppShare from '@/composables/useMyAppShare'
|
||||||
import { toast } from "vue-sonner";
|
import { toast } from 'vue-sonner'
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: "change", key: string): void;
|
(e: 'change', key: string): void
|
||||||
}>();
|
}>()
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
data: { file: File; config: any; handle_type: string; file_id: string };
|
data: { file: File; config: any; handle_type: string; file_id: string }
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
const { data } = useQuery({
|
const { data } = useQuery({
|
||||||
queryKey: ["create-image-compress", props?.data?.file_id],
|
queryKey: ['create-image-compress', props?.data?.file_id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { file_id } = props?.data || {};
|
const { file_id } = props?.data || {}
|
||||||
const data = await $fetch<{
|
const data = await $fetch<{
|
||||||
code: number;
|
code: number
|
||||||
data: {
|
data: {
|
||||||
id?: string;
|
id?: string
|
||||||
};
|
}
|
||||||
}>(`/api/image/compress`, {
|
}>(`/api/image/compress`, {
|
||||||
method: "POST",
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
file_id,
|
file_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
return data?.data;
|
return data?.data
|
||||||
},
|
},
|
||||||
staleTime: Infinity,
|
staleTime: Infinity,
|
||||||
});
|
})
|
||||||
|
|
||||||
const taskId = computed(() => data?.value?.id);
|
const taskId = computed(() => data?.value?.id)
|
||||||
|
|
||||||
const { data: taskData, refetch } = useQuery({
|
const { data: taskData, refetch } = useQuery({
|
||||||
queryKey: ["image-compress-task", taskId],
|
queryKey: ['image-compress-task', taskId],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const data = await $fetch<{
|
const data = await $fetch<{
|
||||||
code: number;
|
code: number
|
||||||
data: {
|
data: {
|
||||||
result: {
|
result: {
|
||||||
old_file: {
|
old_file: {
|
||||||
id: string;
|
id: string
|
||||||
size: number;
|
size: number
|
||||||
};
|
}
|
||||||
new_file: {
|
new_file: {
|
||||||
id: string;
|
id: string
|
||||||
size: number;
|
size: number
|
||||||
};
|
}
|
||||||
}[];
|
}[]
|
||||||
status: "success" | "retry" | "archived";
|
status: 'success' | 'retry' | 'archived'
|
||||||
err?: {
|
err?: {
|
||||||
message?: string;
|
message?: string
|
||||||
retry?: number;
|
retry?: number
|
||||||
max_retry?: number;
|
max_retry?: number
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
}>(`/api/image/compress/${taskId.value}`);
|
}>(`/api/image/compress/${taskId.value}`)
|
||||||
return data?.data;
|
return data?.data
|
||||||
},
|
},
|
||||||
enabled: !!taskId.value,
|
enabled: !!taskId.value,
|
||||||
});
|
})
|
||||||
|
|
||||||
const { downloadFile, createFileShare } = useMyAppShare();
|
const { downloadFileByShareId, createFileShare } = useMyAppShare()
|
||||||
|
|
||||||
const { counter, pause } = useInterval(2000, { controls: true });
|
const { counter, pause } = useInterval(2000, { controls: true })
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => counter.value,
|
() => counter.value,
|
||||||
() => {
|
() => {
|
||||||
if (["success", "archived"].includes(taskData.value?.status ?? "")) {
|
if (['success', 'archived'].includes(taskData.value?.status ?? '')) {
|
||||||
pause();
|
pause()
|
||||||
return;
|
return
|
||||||
|
}
|
||||||
|
refetch()
|
||||||
}
|
}
|
||||||
refetch();
|
)
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => taskData.value?.err?.retry,
|
() => taskData.value?.err?.retry,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
if (!oldVal || !newVal || !taskData.value?.err?.max_retry) {
|
if (!oldVal || !newVal || !taskData.value?.err?.max_retry) {
|
||||||
return;
|
return
|
||||||
|
}
|
||||||
|
if (newVal <= taskData.value?.err?.max_retry) {
|
||||||
|
toast.error(`处理错误: ${taskData.value?.err?.message}, 将再次重试`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (newVal <= taskData.value?.err?.max_retry) {
|
)
|
||||||
toast.error(`处理错误: ${taskData.value?.err?.message}, 将再次重试`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-3">
|
<div class="flex flex-col gap-3">
|
||||||
<h2 class="text-lg">上传成功</h2>
|
<h2 class="text-lg">上传成功</h2>
|
||||||
<div class="flex flex-col gap-1 items-center">
|
<div class="flex flex-col gap-1 items-center">
|
||||||
<div class="flex flex-col h-30 items-center justify-center">
|
<div class="flex flex-col h-30 items-center justify-center">
|
||||||
<FilePreviewView :value="props?.data?.file" />
|
<FilePreviewView :value="props?.data?.file" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="taskData?.status === 'success'"
|
|
||||||
class="flex flex-col gap-2"
|
|
||||||
v-for="item in taskData?.result"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="bg-white/80 p-2 rounded-md w-full flex flex-row items-center justify-between gap-2"
|
|
||||||
>
|
|
||||||
<div class="flex flex-row gap-2 items-center max-w-2/3">
|
|
||||||
<div
|
|
||||||
class="flex flex-row items-center justify-center rounded-md bg-black/5 p-2"
|
|
||||||
>
|
|
||||||
<LucideImage />
|
|
||||||
</div>
|
|
||||||
<div class="truncate w-auto">{{ props?.data?.file?.name }}</div>
|
|
||||||
<div class="flex flex-row gap-2 items-center text-sm shrink-0">
|
|
||||||
<span class="opacity-75">{{
|
|
||||||
filesize(item.new_file.size ?? 0)
|
|
||||||
}}</span>
|
|
||||||
<span
|
|
||||||
class="bg-green-200 text-green-600 rounded-md px-1 py-0.5 flex flex-row gap-1 items-center text-xs"
|
|
||||||
>
|
|
||||||
<LucideChevronDown class="size-4" />
|
|
||||||
{{
|
|
||||||
((1 - item.new_file.size / item.old_file.size) * 100).toFixed(
|
|
||||||
2,
|
|
||||||
)
|
|
||||||
}}%
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<AsyncButton
|
<div v-if="taskData?.status === 'success'" class="flex flex-col gap-2" v-for="item in taskData?.result">
|
||||||
variant="outline"
|
<div class="bg-white/80 p-2 rounded-md w-full flex flex-row items-center justify-between gap-2">
|
||||||
class="bg-black/5"
|
<div class="flex flex-row gap-2 items-center max-w-2/3">
|
||||||
size="icon"
|
<div class="flex flex-row items-center justify-center rounded-md bg-black/5 p-2">
|
||||||
@click="
|
<LucideImage />
|
||||||
async () => {
|
</div>
|
||||||
const data = await createFileShare({
|
<div class="truncate w-auto">{{ props?.data?.file?.name }}</div>
|
||||||
file_id: item.new_file.id,
|
<div class="flex flex-row gap-2 items-center text-sm shrink-0">
|
||||||
config: {
|
<span class="opacity-75">{{ filesize(item.new_file.size ?? 0) }}</span>
|
||||||
download_nums: 1,
|
<span class="bg-green-200 text-green-600 rounded-md px-1 py-0.5 flex flex-row gap-1 items-center text-xs">
|
||||||
expire_time: 60,
|
<LucideChevronDown class="size-4" />
|
||||||
has_pickup_code: false,
|
{{ ((1 - item.new_file.size / item.old_file.size) * 100).toFixed(2) }}%
|
||||||
has_password: false,
|
</span>
|
||||||
},
|
</div>
|
||||||
file_name: props?.data?.file?.name,
|
</div>
|
||||||
});
|
<AsyncButton
|
||||||
const { id } = data?.data || {};
|
variant="outline"
|
||||||
if (!id) {
|
class="bg-black/5"
|
||||||
return;
|
size="icon"
|
||||||
}
|
@click="
|
||||||
await downloadFile(id);
|
async () => {
|
||||||
}
|
const data = await createFileShare({
|
||||||
"
|
file_id: item.new_file.id,
|
||||||
>
|
config: {
|
||||||
<LucideDownload />
|
download_nums: 1,
|
||||||
</AsyncButton>
|
expire_time: 60,
|
||||||
</div>
|
has_pickup_code: false,
|
||||||
</div>
|
has_password: false,
|
||||||
<div
|
},
|
||||||
v-else-if="taskData?.status !== 'retry' && !!taskData?.err?.message"
|
file_name: props?.data?.file?.name,
|
||||||
class="flex flex-col gap-2"
|
})
|
||||||
>
|
const { id } = data?.data || {}
|
||||||
<div
|
if (!id) {
|
||||||
class="w-full h-16 flex flex-row items-center gap-3 bg-white/80 rounded-md p-2"
|
return
|
||||||
>
|
}
|
||||||
<div
|
try {
|
||||||
class="size-10 flex items-center justify-center rounded-md bg-red-200"
|
await downloadFileByShareId(id)
|
||||||
>
|
} catch (error: any) {
|
||||||
<LucideAlertTriangle class="size-5 text-red-600" />
|
toast.error(error?.data?.message || error?.message || error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideDownload />
|
||||||
|
</AsyncButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-sm">
|
<div v-else-if="taskData?.status !== 'retry' && !!taskData?.err?.message" class="flex flex-col gap-2">
|
||||||
{{
|
<div class="w-full h-16 flex flex-row items-center gap-3 bg-white/80 rounded-md p-2">
|
||||||
`经过 ${taskData?.err?.retry} 次重试后任务处理失败: ${taskData?.err?.message}`
|
<div class="size-10 flex items-center justify-center rounded-md bg-red-200">
|
||||||
}}
|
<LucideAlertTriangle class="size-5 text-red-600" />
|
||||||
|
</div>
|
||||||
|
<div class="text-sm">
|
||||||
|
{{ `经过 ${taskData?.err?.retry} 次重试后任务处理失败: ${taskData?.err?.message}` }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row justify-center">
|
||||||
|
<Button @click="emit('change', 'input')"> 返回首页 </Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="flex flex-row justify-center">
|
|
||||||
<Button @click="emit('change', 'input')"> 返回首页 </Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div v-else="taskData?.status !== 'retry' && !!taskData?.err?.message" class="flex flex-col gap-2">
|
||||||
v-else="taskData?.status !== 'retry' && !!taskData?.err?.message"
|
<Skeleton class="w-full h-16 flex flex-row items-center justify-between" v-for="i in 3" />
|
||||||
class="flex flex-col gap-2"
|
</div>
|
||||||
>
|
|
||||||
<Skeleton
|
|
||||||
class="w-full h-16 flex flex-row items-center justify-between"
|
|
||||||
v-for="i in 3"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,45 +1,37 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import FileShareResult from "@/components/Result/FileShareResult.vue";
|
import FileShareResult from '@/components/Result/FileShareResult.vue'
|
||||||
import TextShareResult from "@/components/Result/TextShareResult.vue";
|
import TextShareResult from '@/components/Result/TextShareResult.vue'
|
||||||
import ImageCompressResult from "@/components/Result/ImageCompressResult.vue";
|
import ImageCompressResult from '@/components/Result/ImageCompressResult.vue'
|
||||||
|
import type { FileHandleKey, TextHandleKey } from '../Preprocessing/types'
|
||||||
|
|
||||||
type basehandleData = { config: any; handle_type: string };
|
type basehandleData = { config: Record<string, any> }
|
||||||
|
|
||||||
type filehandleData = { file: File; file_id: string } & basehandleData;
|
type filehandleData = { files: { id: string; file: File }[]; handle_type: FileHandleKey } & basehandleData
|
||||||
type texthandleData = { text: string } & basehandleData;
|
type texthandleData = { text: string; handle_type: TextHandleKey } & basehandleData
|
||||||
|
type handleKey = 'file-share' | 'text-share' | 'file-image-compress'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
data: filehandleData | texthandleData;
|
data: filehandleData | texthandleData
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: "change", key: string): void;
|
(e: 'change', key: string): void
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
const handleList = [
|
const handleList: { component: Component<{ data: filehandleData | texthandleData }>; key: handleKey }[] = [
|
||||||
{ component: FileShareResult, key: "file-share" },
|
{ component: FileShareResult, key: 'file-share' },
|
||||||
{ component: TextShareResult, key: "text-share" },
|
{ component: TextShareResult, key: 'text-share' },
|
||||||
{ component: ImageCompressResult, key: "file-image-compress" },
|
{ component: ImageCompressResult, key: 'file-image-compress' },
|
||||||
];
|
]
|
||||||
|
|
||||||
const activeHandle = computed(() => {
|
const activeHandle = computed(() => {
|
||||||
return handleList.find((item) => item.key === props?.data?.handle_type);
|
return handleList.find((item) => item.key === props?.data?.handle_type)
|
||||||
});
|
})
|
||||||
// vue这个ts蠢的没边了,本来想写component: FileShareResult | TextShareResult,结果不行
|
// vue这个ts蠢的没边了,本来想写component: FileShareResult | TextShareResult,结果不行
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<component
|
<component v-if="'file' in data" :is="activeHandle?.component" :data="data" @change="(key: string) => emit('change', key)" />
|
||||||
v-if="'file' in data"
|
<component v-if="'text' in data" :is="activeHandle?.component" :data="data" @change="(key: string) => emit('change', key)" />
|
||||||
:is="activeHandle?.component"
|
</div>
|
||||||
:data="data"
|
|
||||||
@change="(key: string) => emit('change', key)"
|
|
||||||
/>
|
|
||||||
<component
|
|
||||||
v-if="'text' in data"
|
|
||||||
:is="activeHandle?.component"
|
|
||||||
:data="data"
|
|
||||||
@change="(key: string) => emit('change', key)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,99 +1,145 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button'
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input'
|
||||||
import { useClipboard } from "@vueuse/core";
|
import { useClipboard } from '@vueuse/core'
|
||||||
import { toast } from "vue-sonner";
|
import { toast } from 'vue-sonner'
|
||||||
import { useQuery } from "@tanstack/vue-query";
|
import { useQuery } from '@tanstack/vue-query'
|
||||||
import useMyAppShare from "@/composables/useMyAppShare";
|
import useMyAppShare from '@/composables/useMyAppShare'
|
||||||
import useMyAppConfig from "@/composables/useMyAppConfig";
|
import useMyAppConfig from '@/composables/useMyAppConfig'
|
||||||
import showDrawer from "@/lib/showDrawer";
|
import showDrawer from '@/lib/showDrawer'
|
||||||
import QrCoreDrawer from "@/components/Drawer/QrCoreDrawer.vue";
|
import QrCoreDrawer from '@/components/Drawer/QrCoreDrawer.vue'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import { h } from 'vue'
|
||||||
|
import type { TextHandleKey } from '../Preprocessing/types'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
data: { text: string; config: any; handle_type: string };
|
data: { text: string; config: Record<string, any>; handle_type: TextHandleKey }
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: "change", key: string): void;
|
(e: 'change', key: string): void
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
const { createTextShare } = useMyAppShare();
|
const { createTextShare } = useMyAppShare()
|
||||||
const { data } = useQuery({
|
const { data } = useQuery({
|
||||||
queryKey: ["create-share", props?.data?.text],
|
queryKey: ['create-share', props?.data?.text],
|
||||||
queryFn: async () => {
|
staleTime: Infinity,
|
||||||
const { config, text } = props?.data || {};
|
queryFn: async () => {
|
||||||
const data = await createTextShare({
|
const { config, text } = props?.data || {}
|
||||||
text,
|
const data = await createTextShare({
|
||||||
config,
|
text,
|
||||||
});
|
config,
|
||||||
return data?.data;
|
})
|
||||||
},
|
return data?.data
|
||||||
});
|
},
|
||||||
const appConfig = useMyAppConfig();
|
})
|
||||||
|
const appConfig = useMyAppConfig()
|
||||||
const url = computed(() => {
|
const url = computed(() => {
|
||||||
const { id } = data?.value || {};
|
const { id } = data?.value || {}
|
||||||
return `${appConfig?.value?.site_url}/s/${id}`;
|
return `${appConfig?.value?.site_url}/s/${id}`
|
||||||
});
|
})
|
||||||
|
|
||||||
const { copy } = useClipboard();
|
const { copy } = useClipboard()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-3">
|
<div class="flex flex-col gap-3">
|
||||||
<div class="flex flex-col md:flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
<div class="flex flex-row justify-between md:basis-1/2">
|
<div class="flex flex-row justify-between w-full">
|
||||||
<h2 class="text-lg">分享成功</h2>
|
<h2 class="text-lg">分享成功</h2>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
class="bg-white/70"
|
class="bg-white/70"
|
||||||
size="icon"
|
size="icon"
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
emit('change', 'input');
|
emit('change', 'input')
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<LucideHome />
|
<LucideHome />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-2 flex-1">
|
</div>
|
||||||
<Input v-model="url" class="bg-white/70" readonly />
|
<div class="flex flex-col md:flex-row gap-5 rounded-md p-5 bg-white/20 backdrop-blur-xl w-full">
|
||||||
<Button
|
<div class="flex flex-col gap-2 flex-1">
|
||||||
variant="outline"
|
<div class="text-sm font-semibold">信息</div>
|
||||||
class="bg-white/70"
|
<div class="grid grid-cols-2 gap-2">
|
||||||
size="icon"
|
<div class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1">
|
||||||
@click="
|
<div class="text-xs font-semibold">下载次数</div>
|
||||||
() => {
|
<div class="text-3xl font-light">{{ data?.download_nums }}</div>
|
||||||
copy(url);
|
</div>
|
||||||
toast.success('复制成功');
|
<div class="rounded-xl flex flex-col bg-black/5 px-3 py-2 gap-1">
|
||||||
}
|
<div class="text-xs font-semibold">过期时间</div>
|
||||||
"
|
<div class="text-md font-light">
|
||||||
>
|
{{ dayjs((data?.expire_at ?? 0) * 1000).format('YYYY-MM-DD HH:mm:ss') }}
|
||||||
<LucideCopy />
|
</div>
|
||||||
</Button>
|
</div>
|
||||||
<Button
|
<div class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1" v-if="data?.pickup_code">
|
||||||
variant="outline"
|
<div class="flex flex-row justify-between w-full items-center">
|
||||||
class="bg-white/70"
|
<div class="text-xs font-semibold">提取码</div>
|
||||||
size="icon"
|
<Button
|
||||||
@click="
|
variant="outline"
|
||||||
() => {
|
class="bg-white/70 p-0 size-6"
|
||||||
showDrawer({
|
size="icon"
|
||||||
render: ({ ...rest }) =>
|
@click="
|
||||||
h(QrCoreDrawer, {
|
() => {
|
||||||
...rest,
|
copy(data?.pickup_code as string)
|
||||||
data: url,
|
toast.success('复制成功')
|
||||||
}),
|
}
|
||||||
});
|
"
|
||||||
}
|
>
|
||||||
"
|
<LucideCopy class="size-3" />
|
||||||
>
|
</Button>
|
||||||
<LucideQrCode />
|
</div>
|
||||||
</Button>
|
<div class="flex flex-row gap-2">
|
||||||
</div>
|
<div v-for="s in data?.pickup_code" class="text-2xl font-light">
|
||||||
|
{{ s }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col gap-5 flex-1">
|
||||||
|
<div class="text-sm font-semibold">链接</div>
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
<Input v-model="url" class="bg-white/70" readonly />
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
class="bg-white/70"
|
||||||
|
size="icon"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
copy(url)
|
||||||
|
toast.success('复制成功')
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideCopy />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
class="bg-white/70"
|
||||||
|
size="icon"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
showDrawer({
|
||||||
|
render: ({ ...rest }) =>
|
||||||
|
h(QrCoreDrawer, {
|
||||||
|
...rest,
|
||||||
|
data: url,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LucideQrCode />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2 class="text-md">内容</h2>
|
||||||
|
<MarkdownRender class="prose rounded-md bg-white/70 p-3 w-full max-w-full min-h-[30vh]" :markdown="props?.data?.text" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
class="prose rounded-md bg-white/70 p-3 w-full max-w-full min-h-[30vh]"
|
|
||||||
v-html="props?.data?.text"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,69 +1,81 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import AsyncButton from "@/components/ui/button/AsyncButton.vue";
|
import AsyncButton from '@/components/ui/button/AsyncButton.vue'
|
||||||
import dayjs from "dayjs";
|
import dayjs from 'dayjs'
|
||||||
import duration from "dayjs/plugin/duration";
|
import duration from 'dayjs/plugin/duration'
|
||||||
import relativeTime from "dayjs/plugin/relativeTime";
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
import { isBoolean } from "lodash-es";
|
import { isBoolean } from 'lodash-es'
|
||||||
import { LucideCheck, LucideX } from "lucide-vue-next";
|
import { LucideCheck, LucideX } from 'lucide-vue-next'
|
||||||
import { useQueryClient } from "@tanstack/vue-query";
|
import { useQueryClient } from '@tanstack/vue-query'
|
||||||
dayjs.extend(duration);
|
import showDrawer from '~/lib/showDrawer'
|
||||||
dayjs.extend(relativeTime);
|
import { toast } from 'vue-sonner'
|
||||||
|
import PasswallShareDrawer from '~/components/Drawer/PasswallShareDrawer.vue'
|
||||||
|
dayjs.extend(duration)
|
||||||
|
dayjs.extend(relativeTime)
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
data: any;
|
data: any
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient()
|
||||||
const { downloadFile } = useMyAppShare();
|
const { downloadFile, getShareToken } = useMyAppShare()
|
||||||
|
|
||||||
const handleDownload = async () => {
|
const handleDownload = async () => {
|
||||||
const { id } = props?.data || {};
|
const { id } = props?.data || {}
|
||||||
await downloadFile(id);
|
try {
|
||||||
queryClient.invalidateQueries({ queryKey: ["share", id] });
|
let token = null
|
||||||
};
|
if (props?.data?.has_password) {
|
||||||
|
token = await showDrawer({
|
||||||
|
render: ({ ...rest }) => h(PasswallShareDrawer, { ...rest, share_id: id }),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
token = await getShareToken(id)
|
||||||
|
}
|
||||||
|
if (!token) {
|
||||||
|
throw new Error('获取token失败')
|
||||||
|
}
|
||||||
|
downloadFile(token)
|
||||||
|
} catch (error: any) {
|
||||||
|
toast.error(error?.data?.message || error?.message || error)
|
||||||
|
} finally {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['share', id] })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const expireSeconds = computed(() => {
|
const expireSeconds = computed(() => {
|
||||||
return dayjs(props?.data?.expire_at * 10e2).unix() - dayjs().unix();
|
return dayjs(props?.data?.expire_at * 10e2).unix() - dayjs().unix()
|
||||||
});
|
})
|
||||||
|
|
||||||
const { remaining, start } = useCountdown(expireSeconds.value);
|
const { remaining, start } = useCountdown(expireSeconds.value)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
start();
|
start()
|
||||||
});
|
})
|
||||||
|
|
||||||
const fileShareInfo = computed(() => {
|
const fileShareInfo = computed(() => {
|
||||||
return [
|
return [
|
||||||
{ label: "需要密码", value: props?.data?.has_password ?? false },
|
{ label: '需要密码', value: props?.data?.has_password ?? false },
|
||||||
{
|
{
|
||||||
label: "过期时间",
|
label: '过期时间',
|
||||||
value: dayjs.duration(remaining.value, "seconds").format(`D天 HH:mm:ss`),
|
value: dayjs.duration(remaining.value, 'seconds').format(`D天 HH:mm:ss`),
|
||||||
},
|
},
|
||||||
{ label: "剩余下载次数", value: props?.data?.download_nums ?? 0 },
|
{ label: '剩余下载次数', value: props?.data?.download_nums ?? 0 },
|
||||||
];
|
]
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-5 items-center">
|
<div class="flex flex-col gap-5 items-center">
|
||||||
<h1 class="text-xl font-bold">下载文件</h1>
|
<h1 class="text-xl font-bold">下载文件</h1>
|
||||||
<FilePreviewView :value="props?.data" />
|
<FilePreviewView :value="props?.data" />
|
||||||
<div class="flex flex-col gap-2 md:flex-row w-full">
|
<div class="flex flex-col gap-2 md:flex-row w-full">
|
||||||
<div
|
<div class="flex flex-row md:flex-col md:gap-1 justify-between items-center md:flex-1" v-for="item in fileShareInfo">
|
||||||
class="flex flex-row md:flex-col md:gap-1 justify-between items-center md:flex-1"
|
<div class="text-xs opacity-75">{{ item?.label }}</div>
|
||||||
v-for="item in fileShareInfo"
|
<component v-if="isBoolean(item?.value)" :is="item?.value ? LucideCheck : LucideX" class="size-6" />
|
||||||
>
|
<div v-else class="md:text-xl">{{ item?.value }}</div>
|
||||||
<div class="text-xs opacity-75">{{ item?.label }}</div>
|
</div>
|
||||||
<component
|
</div>
|
||||||
v-if="isBoolean(item?.value)"
|
<div class="w-full">
|
||||||
:is="item?.value ? LucideCheck : LucideX"
|
<AsyncButton @click="handleDownload" class="w-full">下载</AsyncButton>
|
||||||
class="size-6"
|
</div>
|
||||||
/>
|
|
||||||
<div v-else class="md:text-xl">{{ item?.value }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full">
|
|
||||||
<AsyncButton @click="handleDownload" class="w-full">下载</AsyncButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,93 +1,106 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import dayjs from "dayjs";
|
import dayjs from 'dayjs'
|
||||||
import AsyncButton from "@/components/ui/button/AsyncButton.vue";
|
import AsyncButton from '@/components/ui/button/AsyncButton.vue'
|
||||||
import duration from "dayjs/plugin/duration";
|
import duration from 'dayjs/plugin/duration'
|
||||||
import relativeTime from "dayjs/plugin/relativeTime";
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
import { isBoolean } from "lodash-es";
|
import { isBoolean } from 'lodash-es'
|
||||||
import { LucideCheck, LucideX } from "lucide-vue-next";
|
import { LucideCheck, LucideX } from 'lucide-vue-next'
|
||||||
import { cx } from "class-variance-authority";
|
import { cx } from 'class-variance-authority'
|
||||||
import { toast } from "vue-sonner";
|
import { toast } from 'vue-sonner'
|
||||||
import MarkdownRender from "@/components/MarkdownRender.vue";
|
import MarkdownRender from '@/components/MarkdownRender.vue'
|
||||||
dayjs.extend(duration);
|
import { Button } from '@/components/ui/button'
|
||||||
dayjs.extend(relativeTime);
|
import { LucideCopy } from 'lucide-vue-next'
|
||||||
|
import { useClipboard } from '@vueuse/core'
|
||||||
|
import showDrawer from '~/lib/showDrawer'
|
||||||
|
import PasswallShareDrawer from '~/components/Drawer/PasswallShareDrawer.vue'
|
||||||
|
|
||||||
|
dayjs.extend(duration)
|
||||||
|
dayjs.extend(relativeTime)
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
data: any;
|
data: any
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
const { getShareToken } = useMyAppShare();
|
const { getShareToken } = useMyAppShare()
|
||||||
|
|
||||||
const expireSeconds = computed(() => {
|
const expireSeconds = computed(() => {
|
||||||
return dayjs(props?.data?.expire_at * 10e2).unix() - dayjs().unix();
|
return dayjs(props?.data?.expire_at * 10e2).unix() - dayjs().unix()
|
||||||
});
|
})
|
||||||
|
|
||||||
const { remaining, start } = useCountdown(expireSeconds.value);
|
const { remaining, start } = useCountdown(expireSeconds.value)
|
||||||
|
|
||||||
|
const { copy } = useClipboard()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
start();
|
start()
|
||||||
});
|
})
|
||||||
|
|
||||||
const fileShareInfo = computed(() => {
|
const fileShareInfo = computed(() => {
|
||||||
return [
|
return [
|
||||||
{ label: "需要密码", value: props?.data?.has_password ?? false },
|
{ label: '需要密码', value: props?.data?.has_password ?? false },
|
||||||
{
|
{
|
||||||
label: "过期时间",
|
label: '过期时间',
|
||||||
value: dayjs.duration(remaining.value, "seconds").format(`D天 HH:mm:ss`),
|
value: dayjs.duration(remaining.value, 'seconds').format(`D天 HH:mm:ss`),
|
||||||
},
|
},
|
||||||
{ label: "剩余浏览次数", value: props?.data?.download_nums ?? 0 },
|
{ label: '剩余浏览次数', value: props?.data?.download_nums ?? 0 },
|
||||||
];
|
]
|
||||||
});
|
})
|
||||||
const previewText = ref<string | null>(null);
|
const previewText = ref<string | null>(null)
|
||||||
|
|
||||||
const handlePreview = async () => {
|
const handlePreview = async () => {
|
||||||
try {
|
try {
|
||||||
const token = await getShareToken(props?.data?.id);
|
let token = null
|
||||||
const r = await $fetch<{
|
if (props?.data?.has_password) {
|
||||||
code: number;
|
token = await showDrawer({
|
||||||
data: {
|
render: ({ ...rest }) => h(PasswallShareDrawer, { ...rest, share_id: props?.data?.id }),
|
||||||
data: string;
|
})
|
||||||
};
|
} else {
|
||||||
}>(`/api/download?token=${token}`);
|
token = await getShareToken(props?.data?.id)
|
||||||
previewText.value = r?.data?.data;
|
}
|
||||||
} catch (error) {
|
const r = await $fetch<{
|
||||||
toast.error((error as any)?.data?.message || error);
|
code: number
|
||||||
}
|
data: {
|
||||||
};
|
data: string
|
||||||
|
}
|
||||||
|
}>(`/api/download?token=${token}`)
|
||||||
|
previewText.value = r?.data?.data
|
||||||
|
} catch (error: any) {
|
||||||
|
toast.error(error?.data?.message || error?.message || error)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div :class="cx('flex flex-col max-h-full', !!previewText ? 'gap-3' : 'gap-16 items-center')">
|
||||||
:class="
|
<div :class="cx('flex flex-row w-full', !!previewText ? 'justify-between' : 'justify-center')">
|
||||||
cx(
|
<h1 class="text-xl">查看文本</h1>
|
||||||
'flex flex-col max-h-full',
|
<Button
|
||||||
!!previewText ? 'gap-3' : 'gap-16 items-center',
|
v-if="!!previewText"
|
||||||
)
|
variant="outline"
|
||||||
"
|
size="icon"
|
||||||
>
|
@click="
|
||||||
<h1 class="text-xl">查看文本</h1>
|
() => {
|
||||||
<template v-if="!previewText">
|
copy(previewText as string)
|
||||||
<div class="flex flex-col gap-2 md:flex-row w-full">
|
toast.success('复制成功')
|
||||||
<div
|
}
|
||||||
class="flex flex-row md:flex-col md:gap-1 justify-between items-center md:flex-1"
|
"
|
||||||
v-for="item in fileShareInfo"
|
>
|
||||||
>
|
<LucideCopy />
|
||||||
<div class="text-xs opacity-75">{{ item?.label }}</div>
|
</Button>
|
||||||
<component
|
|
||||||
v-if="isBoolean(item?.value)"
|
|
||||||
:is="item?.value ? LucideCheck : LucideX"
|
|
||||||
class="size-6"
|
|
||||||
/>
|
|
||||||
<div v-else class="md:text-xl">{{ item?.value }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<template v-if="!previewText">
|
||||||
<div class="w-full">
|
<div class="flex flex-col gap-2 md:flex-row w-full">
|
||||||
<AsyncButton @click="handlePreview" class="w-full">浏览</AsyncButton>
|
<div class="flex flex-row md:flex-col md:gap-1 justify-between items-center md:flex-1" v-for="item in fileShareInfo">
|
||||||
</div>
|
<div class="text-xs opacity-75">{{ item?.label }}</div>
|
||||||
</template>
|
<component v-if="isBoolean(item?.value)" :is="item?.value ? LucideCheck : LucideX" class="size-6" />
|
||||||
<template v-else>
|
<div v-else class="md:text-xl">{{ item?.value }}</div>
|
||||||
<MarkdownRender
|
</div>
|
||||||
:markdown="previewText"
|
</div>
|
||||||
class="rounded-md bg-white/70 p-3 w-full max-w-full min-h-80 overflow-y-auto"
|
<div class="w-full">
|
||||||
/>
|
<AsyncButton @click="handlePreview" class="w-full">浏览</AsyncButton>
|
||||||
</template>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<MarkdownRender :markdown="previewText" class="rounded-md bg-white/70 p-3 w-full max-w-full min-h-80 overflow-y-auto" />
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,40 +1,51 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Editor, EditorContent } from '@tiptap/vue-3'
|
import { Editor, EditorContent } from '@tiptap/vue-3'
|
||||||
import StarterKit from '@tiptap/starter-kit'
|
import StarterKit from '@tiptap/starter-kit'
|
||||||
import { Markdown } from 'tiptap-markdown';
|
import { Markdown } from 'tiptap-markdown'
|
||||||
import Placeholder from '@tiptap/extension-placeholder'
|
import Placeholder from '@tiptap/extension-placeholder'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: string
|
modelValue?: string
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:modelValue', value: string): void
|
(e: 'update:modelValue', value: string): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const editor = ref<Editor | undefined>(undefined)
|
const editor = ref<Editor | undefined>(undefined)
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
editor.value = new Editor({
|
editor.value = new Editor({
|
||||||
content: props.modelValue,
|
content: props.modelValue,
|
||||||
extensions: [StarterKit, Markdown.configure({
|
extensions: [
|
||||||
transformPastedText: true,
|
StarterKit,
|
||||||
transformCopiedText: true
|
Markdown.configure({
|
||||||
}), Placeholder.configure({
|
transformPastedText: true,
|
||||||
placeholder: props.placeholder ?? ''
|
transformCopiedText: true,
|
||||||
})],
|
}),
|
||||||
onUpdate: () => {
|
Placeholder.configure({
|
||||||
// HTML
|
placeholder: props.placeholder ?? '',
|
||||||
emit('update:modelValue', editor.value?.storage?.markdown?.getMarkdown() ?? '')
|
}),
|
||||||
|
// CommandsPlugin,
|
||||||
|
],
|
||||||
|
onUpdate: () => {
|
||||||
|
emit('update:modelValue', editor.value?.storage?.markdown?.getMarkdown() ?? '')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(value) => {
|
||||||
|
if (value !== editor.value?.storage?.markdown?.getMarkdown()) {
|
||||||
|
editor.value?.commands.setContent(value ?? '')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
})
|
|
||||||
watch(() => props.modelValue, (value) => {
|
|
||||||
editor.value?.commands.setContent(value)
|
|
||||||
})
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
editor.value?.destroy()
|
editor.value?.destroy()
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<editor-content :editor="editor" class="prose prose-sm bg-white/50 rounded-md p-2 [&>*]:outline-none prose-p:my-1" />
|
<editor-content
|
||||||
|
:editor="editor"
|
||||||
|
class="prose prose-sm bg-white/50 rounded-md p-2 [&>*]:outline-none prose-p:my-1 prose-headings:my-2 prose-pre:mb-0"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,98 +1,114 @@
|
|||||||
import { toast } from "vue-sonner";
|
import { times } from 'lodash-es'
|
||||||
|
import { toast } from 'vue-sonner'
|
||||||
|
declare const window: any
|
||||||
|
let shareIdTokenMap: WeakMap<{ share_id: string }, string>
|
||||||
|
|
||||||
let shareIdTokenMap: WeakMap<{ share_id: string }, string>;
|
const getShareToken = async (
|
||||||
|
share_id: string,
|
||||||
const getShareToken = async (share_id: string): Promise<string | undefined> => {
|
options?: {
|
||||||
if (!shareIdTokenMap) {
|
password?: string
|
||||||
shareIdTokenMap = new WeakMap();
|
|
||||||
}
|
|
||||||
let token = shareIdTokenMap.get({ share_id });
|
|
||||||
if (!token) {
|
|
||||||
const data = await $fetch<{
|
|
||||||
code: number;
|
|
||||||
message: string;
|
|
||||||
data: {
|
|
||||||
token?: string;
|
|
||||||
};
|
|
||||||
}>(`/api/download`, {
|
|
||||||
method: "POST",
|
|
||||||
body: {
|
|
||||||
share_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (!data?.data?.token) {
|
|
||||||
throw new Error(data?.message || "获取token失败");
|
|
||||||
}
|
}
|
||||||
token = data.data.token;
|
): Promise<string | undefined> => {
|
||||||
shareIdTokenMap.set({ share_id }, token);
|
if (!shareIdTokenMap) {
|
||||||
}
|
shareIdTokenMap = new WeakMap()
|
||||||
return token;
|
}
|
||||||
};
|
let token = shareIdTokenMap.get({ share_id })
|
||||||
|
const { password } = options || {}
|
||||||
const downloadFile = async (share_id: string) => {
|
|
||||||
try {
|
|
||||||
const token = await getShareToken(share_id);
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error("获取token失败");
|
const data = await $fetch<{
|
||||||
return;
|
code: number
|
||||||
|
message: string
|
||||||
|
data: {
|
||||||
|
token?: string
|
||||||
|
}
|
||||||
|
}>(`/api/download`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: {
|
||||||
|
share_id,
|
||||||
|
password,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (!data?.data?.token) {
|
||||||
|
throw new Error(data?.message || '获取token失败')
|
||||||
|
}
|
||||||
|
token = data.data.token
|
||||||
|
shareIdTokenMap.set({ share_id }, token)
|
||||||
}
|
}
|
||||||
(window as any)?.open(`/api/download?token=${token}`);
|
return token
|
||||||
} catch (e) {
|
}
|
||||||
toast.error((e as any)?.data?.message || e);
|
|
||||||
}
|
const downloadFile = (token: string) => {
|
||||||
};
|
window?.open(`/api/download?token=${token}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadFileByShareId = async (share_id: string) => {
|
||||||
|
const token = await getShareToken(share_id)
|
||||||
|
if (!token) {
|
||||||
|
throw new Error('获取token失败')
|
||||||
|
}
|
||||||
|
return downloadFile(token)
|
||||||
|
}
|
||||||
|
|
||||||
const createShare = async (data: any) => {
|
const createShare = async (data: any) => {
|
||||||
return await $fetch<{
|
return await $fetch<{
|
||||||
code: number;
|
code: number
|
||||||
data: {
|
data: {
|
||||||
id?: string;
|
id?: string
|
||||||
};
|
download_nums?: number
|
||||||
}>(`/api/share`, {
|
expire_at?: number
|
||||||
method: "POST",
|
file_name?: string
|
||||||
body: data,
|
pickup_code?: string
|
||||||
});
|
}
|
||||||
};
|
}>(`/api/share`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const createFileShare = async (data: {
|
const createFileShare = async (data: {
|
||||||
file_id: string;
|
files: { id: string; name: string }[]
|
||||||
config: {
|
config: {
|
||||||
download_nums: number;
|
download_nums: number
|
||||||
expire_time: number;
|
expire_time: number
|
||||||
has_pickup_code?: boolean;
|
has_pickup_code?: boolean
|
||||||
has_password?: boolean;
|
has_password?: boolean
|
||||||
pickup_code?: string;
|
pickup_code?: string
|
||||||
password?: string;
|
password?: string
|
||||||
notify_email?: string;
|
notify_email?: string
|
||||||
};
|
}
|
||||||
file_name: string;
|
|
||||||
}) => {
|
}) => {
|
||||||
const { file_id, config, file_name } = data || {};
|
const { files, config } = data || {}
|
||||||
return await createShare({
|
return await Promise.all(
|
||||||
type: "file",
|
times(files.length, async (i) => {
|
||||||
data: file_id,
|
const { id, name } = files[i]
|
||||||
config,
|
return await createShare({
|
||||||
file_name,
|
type: 'file',
|
||||||
});
|
data: id,
|
||||||
};
|
config,
|
||||||
|
file_name: name,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const createTextShare = async (data: { text: string; config: any }) => {
|
const createTextShare = async (data: { text: string; config: any }) => {
|
||||||
const { text, config } = data || {};
|
const { text, config } = data || {}
|
||||||
return await createShare({
|
return await createShare({
|
||||||
type: "text",
|
type: 'text',
|
||||||
data: text,
|
data: text,
|
||||||
config,
|
config,
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
const useMyAppShare = () => {
|
const useMyAppShare = () => {
|
||||||
return {
|
return {
|
||||||
downloadFile,
|
downloadFile,
|
||||||
createShare,
|
downloadFileByShareId,
|
||||||
createFileShare,
|
createShare,
|
||||||
createTextShare,
|
createFileShare,
|
||||||
getShareToken,
|
createTextShare,
|
||||||
};
|
getShareToken,
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default useMyAppShare;
|
export default useMyAppShare
|
||||||
|
|||||||
@@ -4,22 +4,44 @@ type UseSeoProps = {
|
|||||||
}
|
}
|
||||||
const useSeo = async (props: UseSeoProps = {}) => {
|
const useSeo = async (props: UseSeoProps = {}) => {
|
||||||
const { head, seo } = props || {}
|
const { head, seo } = props || {}
|
||||||
const { data } = await useFetch<any>('/config')
|
const seoMeta = ref<any>()
|
||||||
const seoMeta = computed(() => data.value?.data)
|
if (import.meta.server) {
|
||||||
const { title } = head || {}
|
const { SITE_TITLE, SITE_DESC, SITE_URL } = process.env || {}
|
||||||
useHead({
|
seoMeta.value = {
|
||||||
...head,
|
site_title: SITE_TITLE,
|
||||||
title: title ? `${title} - ${seoMeta?.value?.site_title}` : seoMeta?.value?.site_title,
|
site_desc: SITE_DESC,
|
||||||
})
|
site_url: SITE_URL,
|
||||||
useSeoMeta({
|
}
|
||||||
...seo,
|
const { title } = head || {}
|
||||||
title: seoMeta?.value?.site_title,
|
useHead({
|
||||||
description: seoMeta?.value?.site_desc,
|
link: [
|
||||||
ogTitle: seoMeta?.value?.site_title,
|
{ rel: 'icon', href: '/logo.png', sizes: 'any' },
|
||||||
ogDescription: seoMeta?.value?.site_desc,
|
// { rel: 'icon', href: '/favicon.svg', sizes: 'any', type: 'image/svg+xml' },
|
||||||
// ogImage: seoMeta?.value?.site_url,
|
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/logo.png' },
|
||||||
// twitterCard: 'summary_large_image',
|
],
|
||||||
})
|
meta: [
|
||||||
|
// used on some mobile browsers
|
||||||
|
{ name: 'theme-color', content: '#395276' },
|
||||||
|
],
|
||||||
|
...head,
|
||||||
|
title: title ? `${title} - ${seoMeta?.value?.site_title}` : seoMeta?.value?.site_title,
|
||||||
|
})
|
||||||
|
useSeoMeta({
|
||||||
|
...seo,
|
||||||
|
title: seoMeta?.value?.site_title,
|
||||||
|
description: seoMeta?.value?.site_desc,
|
||||||
|
ogTitle: seoMeta?.value?.site_title,
|
||||||
|
ogDescription: seoMeta?.value?.site_desc,
|
||||||
|
ogImage: {
|
||||||
|
url: `${seoMeta?.value?.site_url}/logo.png`,
|
||||||
|
width: 1024,
|
||||||
|
height: 1024,
|
||||||
|
alt: 'logo',
|
||||||
|
type: 'image/png',
|
||||||
|
},
|
||||||
|
twitterCard: 'summary',
|
||||||
|
})
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,17 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { cloneDeep, get, isEmpty, isUndefined, set,isString } from 'lodash-es'
|
|
||||||
|
|
||||||
type StoreType = Record<string, any>
|
type renderComponent = Component | ((props: { hide: () => null }) => VNode)
|
||||||
|
|
||||||
const initState: StoreType = {}
|
type StoreProps = {
|
||||||
// 做了一点小小的改进,可以传入key,会自动初始化,如果不初始化的话容易导致不存在值而丢失响应式
|
tiptapCommandsView?: any
|
||||||
const useStore = (key?: string) => {
|
drawer?: { render?: renderComponent; onClose: (data?: any) => void; key: string }[]
|
||||||
const store = defineStore('store', {
|
|
||||||
state: () => ({
|
|
||||||
...initState,
|
|
||||||
}),
|
|
||||||
actions: {
|
|
||||||
_get(path?: string) {
|
|
||||||
if (isEmpty(path) || isUndefined(path)) {
|
|
||||||
return this.$state
|
|
||||||
}
|
|
||||||
return get(this.$state, path)
|
|
||||||
},
|
|
||||||
_set(path: string, value: any) {
|
|
||||||
const newState = cloneDeep(this.$state)
|
|
||||||
set(newState, path, value)
|
|
||||||
this.$patch(newState)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
persist: true,
|
|
||||||
})()
|
|
||||||
if (!isEmpty(key) && isString(key) && isUndefined(store?._get(key))) {
|
|
||||||
console.log('reset', key, store?._get(key))
|
|
||||||
store?._set(key, undefined)
|
|
||||||
}
|
|
||||||
return store
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const useStore = defineStore<any, StoreProps>('store', () => {
|
||||||
|
return {
|
||||||
|
tiptapCommandsView: null,
|
||||||
|
drawer: [],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
export default useStore
|
export default useStore
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { NuxtError } from "#app";
|
import type { NuxtError } from '#app'
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from 'vue-i18n'
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button'
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
error: Object as () => NuxtError,
|
error: Object as () => NuxtError,
|
||||||
});
|
})
|
||||||
|
console.error(props.error, 'error')
|
||||||
const handleError = () => clearError({ redirect: "/" });
|
const handleError = () => clearError({ redirect: '/' })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NuxtLayout>
|
<NuxtLayout>
|
||||||
<div
|
<div class="rounded-xl p-5 bg-white/50 backdrop-blur-xl w-full lg:w-200 flex flex-col items-center justify-center min-h-[50vh] mt-5 gap-10">
|
||||||
class="rounded-xl p-5 bg-white/50 backdrop-blur-xl w-full lg:w-200 flex flex-col items-center justify-center min-h-[50vh] mt-5 gap-10"
|
<div class="font-bold text-5xl">{{ error?.statusCode }}</div>
|
||||||
>
|
<Button @click="handleError">{{ t('btn.backToHome') }}</Button>
|
||||||
<div class="font-bold text-5xl">{{ error?.statusCode }}</div>
|
</div>
|
||||||
<Button @click="handleError">{{ t("btn.backToHome") }}</Button>
|
</NuxtLayout>
|
||||||
</div>
|
|
||||||
</NuxtLayout>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Toaster } from "vue-sonner";
|
import { Toaster } from 'vue-sonner'
|
||||||
await useSeo();
|
await useSeo()
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="h-screen w-screen">
|
<div class="h-screen w-screen">
|
||||||
<GlobalDrawer />
|
<GlobalDrawer />
|
||||||
<Toaster position="top-center" richColors closeButton />
|
<Toaster position="top-center" richColors closeButton />
|
||||||
<img
|
<img
|
||||||
class="w-full h-full object-cover absolute inset-0 -z-[1]"
|
class="w-full h-full object-cover absolute inset-0 -z-[1] bg-gradient-to-bl from-primary/40 to-primary"
|
||||||
src="https://img.fudaoyuan.icu/api/1/random/?scale_min=1.5&webp=true&md=false&format=302"
|
src="https://img.fudaoyuan.icu/api/1/random/?scale_min=1.5&webp=true&md=false&format=302"
|
||||||
/>
|
/>
|
||||||
<div
|
<div class="h-full w-full flex flex-col items-center lg:p-10 p-5 overflow-y-auto">
|
||||||
class="h-full w-full flex flex-col items-center lg:p-10 p-5 overflow-y-auto"
|
<Navbar />
|
||||||
>
|
<slot />
|
||||||
<Navbar />
|
</div>
|
||||||
<slot />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
21
front/lib/asyncRetry.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import asyncWait from './asyncWait'
|
||||||
|
|
||||||
|
interface AsyncRetryOptions {
|
||||||
|
retryCount?: number
|
||||||
|
delay?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const asyncRetry = async <T>(fn: () => Promise<T>, options: AsyncRetryOptions = {}) => {
|
||||||
|
const { retryCount = 3, delay = 1000 } = options || {}
|
||||||
|
await asyncWait(delay)
|
||||||
|
try {
|
||||||
|
return await fn()
|
||||||
|
} catch (error) {
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return await asyncRetry(fn, { retryCount: retryCount - 1, delay: delay * 2 })
|
||||||
|
}
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default asyncRetry
|
||||||
13
front/lib/asyncTimeout.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import asyncWait from './asyncWait'
|
||||||
|
|
||||||
|
const asyncTimeout = <T>(fn: () => Promise<T>, ms: number) => {
|
||||||
|
return Promise.race([
|
||||||
|
fn(),
|
||||||
|
async () => {
|
||||||
|
await asyncWait(ms)
|
||||||
|
throw new Error('timeout')
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
export default asyncTimeout
|
||||||
11
front/lib/getFileChunk.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const getFileChunk = (file: File, start: number, chunk_size: number): Promise<ArrayBuffer> => {
|
||||||
|
const fileReader = new FileReader()
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const chunk = file.slice(start, start + chunk_size)
|
||||||
|
fileReader.onload = (e) => resolve(e.target?.result as ArrayBuffer)
|
||||||
|
fileReader.onerror = reject
|
||||||
|
fileReader.readAsArrayBuffer(chunk)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default getFileChunk
|
||||||
7
front/lib/getFileSize.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { filesize } from 'filesize'
|
||||||
|
|
||||||
|
const getFileSize = (size: number) => {
|
||||||
|
return filesize(size, { standard: 'jedec' })
|
||||||
|
}
|
||||||
|
|
||||||
|
export default getFileSize
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
interface DrawerProps {
|
interface DrawerProps {
|
||||||
render: (props: { hide: () => void }) => Component
|
render: (props: { hide: () => void }) => Component
|
||||||
}
|
}
|
||||||
|
|
||||||
const showDrawer = (props: DrawerProps) => {
|
const showDrawer = (props: DrawerProps) => {
|
||||||
const { render } = props || {}
|
const key = Math.random().toString(36).slice(2, 8)
|
||||||
const store = useStore()
|
return new Promise<void>((res) => {
|
||||||
store?._set('drawer', [...(store?._get('drawer')?.value || []), { render }])
|
const { render } = props || {}
|
||||||
|
const onClose = (data?: any) => {
|
||||||
|
store.drawer = (store.drawer ?? [])?.filter((item: any) => item.key !== key)
|
||||||
|
res(data)
|
||||||
|
}
|
||||||
|
const store = useStore()
|
||||||
|
store.drawer = [...(store.drawer || []), { render, onClose, key }]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default showDrawer
|
export default showDrawer
|
||||||
|
|||||||
@@ -1,40 +1,45 @@
|
|||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
compatibilityDate: "2024-04-03",
|
compatibilityDate: '2024-04-03',
|
||||||
devtools: { enabled: true },
|
devtools: { enabled: true },
|
||||||
css: ["@/assets/css/main.css"],
|
css: ['@/assets/css/main.css'],
|
||||||
modules: [
|
modules: [
|
||||||
// '@serwist/nuxt',
|
// '@serwist/nuxt',
|
||||||
"@vueuse/nuxt",
|
'@vueuse/nuxt',
|
||||||
"motion-v/nuxt",
|
'motion-v/nuxt',
|
||||||
"nuxt-lucide-icons",
|
'nuxt-lucide-icons',
|
||||||
"shadcn-nuxt",
|
'shadcn-nuxt',
|
||||||
"@vee-validate/nuxt",
|
'@vee-validate/nuxt',
|
||||||
"@pinia/nuxt",
|
'@pinia/nuxt',
|
||||||
"@nuxt/image",
|
'@nuxt/image',
|
||||||
"@nuxtjs/i18n",
|
'@nuxtjs/i18n',
|
||||||
],
|
'vue3-pixi-nuxt',
|
||||||
// serwist: {},
|
|
||||||
i18n: {
|
|
||||||
strategy: "no_prefix",
|
|
||||||
defaultLocale: "en",
|
|
||||||
locales: [
|
|
||||||
{ code: "zh-CN", name: "中文(简体)", file: "zh-CN.json" },
|
|
||||||
{ code: "en", name: "English", file: "en.json" },
|
|
||||||
],
|
],
|
||||||
},
|
// serwist: {},
|
||||||
vite: {
|
i18n: {
|
||||||
plugins: [tailwindcss()],
|
strategy: 'no_prefix',
|
||||||
},
|
defaultLocale: 'en',
|
||||||
nitro: {
|
locales: [
|
||||||
routeRules: {
|
{ code: 'zh-CN', name: '中文(简体)', file: 'zh-CN.json' },
|
||||||
"/api/**": {
|
{ code: 'en', name: 'English', file: 'en.json' },
|
||||||
proxy: process.env.API_BASE_URL || "http://127.0.0.1:1323/**",
|
],
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
vite: {
|
||||||
devServer: {
|
transformMixedEsModules: true,
|
||||||
port: 5000,
|
plugins: [tailwindcss()],
|
||||||
},
|
optimizeDeps: {
|
||||||
});
|
include: ['eventemitter3'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nitro: {
|
||||||
|
routeRules: {
|
||||||
|
'/api/**': {
|
||||||
|
proxy: process.env.API_BASE_URL || 'http://127.0.0.1:1323/**',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
devServer: {
|
||||||
|
port: 5000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|||||||
@@ -12,60 +12,65 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxt/image": "1.10.0",
|
"@nuxt/image": "1.10.0",
|
||||||
"@nuxtjs/i18n": "9.5.5",
|
"@nuxtjs/i18n": "9.5.5",
|
||||||
"@pinia/nuxt": "^0.11.0",
|
"@pinia/nuxt": "^0.11.2",
|
||||||
"@tailwindcss/postcss": "^4.1.3",
|
"@tailwindcss/postcss": "^4.1.13",
|
||||||
"@tailwindcss/vite": "^4.1.3",
|
"@tailwindcss/vite": "^4.1.13",
|
||||||
"@tanstack/vue-query": "^5.76.0",
|
"@tanstack/vue-query": "^5.90.1",
|
||||||
"@tiptap/extension-blockquote": "^2.11.7",
|
"@tiptap/extension-blockquote": "^2.26.1",
|
||||||
"@tiptap/extension-bold": "^2.11.7",
|
"@tiptap/extension-bold": "^2.26.1",
|
||||||
"@tiptap/extension-heading": "^2.11.7",
|
"@tiptap/extension-heading": "^2.26.1",
|
||||||
"@tiptap/extension-italic": "^2.11.7",
|
"@tiptap/extension-italic": "^2.26.1",
|
||||||
"@tiptap/extension-paragraph": "^2.11.7",
|
"@tiptap/extension-paragraph": "^2.26.1",
|
||||||
"@tiptap/extension-placeholder": "^2.11.7",
|
"@tiptap/extension-placeholder": "^2.26.1",
|
||||||
"@tiptap/extension-strike": "^2.11.7",
|
"@tiptap/extension-strike": "^2.26.1",
|
||||||
"@tiptap/extension-text": "^2.11.7",
|
"@tiptap/extension-text": "^2.26.1",
|
||||||
"@tiptap/pm": "^2.11.7",
|
"@tiptap/pm": "^2.26.1",
|
||||||
"@tiptap/starter-kit": "^2.11.7",
|
"@tiptap/starter-kit": "^2.26.1",
|
||||||
"@tiptap/vue-3": "^2.11.7",
|
"@tiptap/vue-3": "^2.26.1",
|
||||||
"@unovis/ts": "^1.5.1",
|
"@unovis/ts": "^1.6.1",
|
||||||
"@unovis/vue": "^1.5.1",
|
"@unovis/vue": "^1.6.1",
|
||||||
"@vee-validate/nuxt": "^4.15.0",
|
"@vee-validate/nuxt": "^4.15.1",
|
||||||
"@vee-validate/rules": "^4.15.0",
|
"@vee-validate/rules": "^4.15.1",
|
||||||
"axios": "^1.8.4",
|
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.18",
|
||||||
"filesize": "^10.1.6",
|
"filesize": "^10.1.6",
|
||||||
"js-md5": "^0.8.3",
|
"js-md5": "^0.8.3",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"lucide-vue-next": "^0.487.0",
|
"lucide-vue-next": "^0.542.0",
|
||||||
"markdown-it": "^14.1.0",
|
"markdown-it": "^14.1.0",
|
||||||
"motion-v": "1.0.0-beta.2",
|
"motion-v": "^1.7.1",
|
||||||
"nuxt": "^3.17.4",
|
"nanoid": "^5.1.6",
|
||||||
|
"nuxt": "4.1.2",
|
||||||
"nuxt-lucide-icons": "1.0.5",
|
"nuxt-lucide-icons": "1.0.5",
|
||||||
"pinia": "^3.0.2",
|
"pinia": "^3.0.3",
|
||||||
|
"pixi.js": "^8.13.2",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"reka-ui": "^2.2.0",
|
"reka-ui": "^2.5.0",
|
||||||
"shadcn-nuxt": "2.0.1",
|
"shadcn-nuxt": "2.0.1",
|
||||||
"spark-md5": "^3.0.2",
|
"spark-md5": "^3.0.2",
|
||||||
"tailwind-merge": "^3.2.0",
|
"tailwind-merge": "^3.3.1",
|
||||||
"tailwindcss": "^4.1.3",
|
"tailwindcss": "^4.1.13",
|
||||||
"tiptap-markdown": "^0.8.10",
|
"tiptap-markdown": "^0.8.10",
|
||||||
"tw-animate-css": "^1.2.5",
|
"tw-animate-css": "^1.3.8",
|
||||||
"vaul-vue": "^0.4.1",
|
"vaul-vue": "^0.4.1",
|
||||||
"vue": "^3.5.16",
|
"vue": "^3.5.21",
|
||||||
"vue-router": "^4.5.1",
|
"vue-router": "^4.5.1",
|
||||||
"vue-sonner": "^1.3.2"
|
"vue-sonner": "^1.3.2",
|
||||||
|
"vue3-pixi": "1.0.0-beta.2"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
|
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
|
||||||
|
"resolutions": {
|
||||||
|
"esbuild": "0.25.6"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxtjs/tailwindcss": "^6.13.2",
|
"@tailwindcss/typography": "^0.5.18",
|
||||||
"@tailwindcss/typography": "^0.5.16",
|
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/markdown-it": "^14.1.2",
|
"@types/markdown-it": "^14.1.2",
|
||||||
"@types/qrcode": "^1.5.5",
|
"@types/qrcode": "^1.5.5",
|
||||||
"@types/spark-md5": "^3.0.5",
|
"@types/spark-md5": "^3.0.5",
|
||||||
"@vueuse/core": "^13.0.0",
|
"@vueuse/core": "^13.9.0",
|
||||||
"@vueuse/nuxt": "^13.0.0"
|
"@vueuse/nuxt": "^13.9.0",
|
||||||
|
"vue3-pixi-nuxt": "1.0.0-beta.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { cx } from 'class-variance-authority'
|
|||||||
import { useQuery } from '@tanstack/vue-query'
|
import { useQuery } from '@tanstack/vue-query'
|
||||||
import { Skeleton } from '@/components/ui/skeleton'
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
import AboutChartTooltip from '@/components/AboutChartTooltip.vue'
|
import AboutChartTooltip from '@/components/AboutChartTooltip.vue'
|
||||||
import { filesize } from 'filesize'
|
import getFileSize from '~/lib/getFileSize'
|
||||||
import SparkMD5 from 'spark-md5'
|
import SparkMD5 from 'spark-md5'
|
||||||
import useMyAppConfig from '@/composables/useMyAppConfig'
|
import useMyAppConfig from '@/composables/useMyAppConfig'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
@@ -137,8 +137,8 @@ const users = computed(() => {
|
|||||||
<div class="rounded-xl bg-white/50 flex-1 flex flex-col p-3">
|
<div class="rounded-xl bg-white/50 flex-1 flex flex-col p-3">
|
||||||
<div class="opacity-75 text-xs">{{ t('about.storage') }}</div>
|
<div class="opacity-75 text-xs">{{ t('about.storage') }}</div>
|
||||||
<div class="text-right flex flex-row items-baseline">
|
<div class="text-right flex flex-row items-baseline">
|
||||||
<span class="text-lg font-semibold">{{ filesize(currentFileSize ?? 0) }}</span>
|
<span class="text-lg font-semibold">{{ getFileSize(currentFileSize ?? 0) }}</span>
|
||||||
<span class="text-md opacity-75">/ {{ filesize(data?.max_limit?.file_size ?? 0) }}</span>
|
<span class="text-md opacity-75">/ {{ getFileSize(data?.max_limit?.file_size ?? 0) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<Progress class="h-1" :model-value="(currentFileSize / (data?.max_limit?.file_size ?? 0)) * 100" />
|
<Progress class="h-1" :model-value="(currentFileSize / (data?.max_limit?.file_size ?? 0)) * 100" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
77
front/pages/dev.vue
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Button, AsyncButton } from '@/components/ui/button'
|
||||||
|
import asyncWait from '~/lib/asyncWait'
|
||||||
|
import { toast } from 'vue-sonner'
|
||||||
|
import showDrawer from '~/lib/showDrawer'
|
||||||
|
import { h } from 'vue'
|
||||||
|
import VeeForm from '@/components/VeeForm.vue'
|
||||||
|
import InputField from '@/components/Field/InputField.vue'
|
||||||
|
import FormButton from '@/components/Field/FormButton.vue'
|
||||||
|
import SelectField from '@/components/Field/SelectField.vue'
|
||||||
|
import SwitchField from '@/components/Field/SwitchField.vue'
|
||||||
|
|
||||||
|
const { NODE_ENV } = process.env || {}
|
||||||
|
const isDev = NODE_ENV === 'development'
|
||||||
|
if (!isDev) {
|
||||||
|
navigateTo('/')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="rounded-xl p-5 bg-white/50 backdrop-blur-xl w-full lg:w-200 my-5 flex flex-col gap-5">
|
||||||
|
<h1>Dev</h1>
|
||||||
|
<div class="flex flex-row gap-5 items-center">
|
||||||
|
<Button
|
||||||
|
@click="
|
||||||
|
async () => {
|
||||||
|
await showDrawer({
|
||||||
|
render: ({ ...rest }) => h('div', { style: { height: '30vh' } }, '内容'),
|
||||||
|
})
|
||||||
|
toast.success('被关闭')
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>普通按钮(showDrawer)</Button
|
||||||
|
>
|
||||||
|
<AsyncButton
|
||||||
|
variant="outline"
|
||||||
|
@click="
|
||||||
|
async () => {
|
||||||
|
await asyncWait(3000)
|
||||||
|
toast.success('成功')
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>异步按钮</AsyncButton
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<VeeForm
|
||||||
|
:initialValues="{
|
||||||
|
select: '1',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<div class="flex flex-col gap-5 bg-white p-5 rounded-xl">
|
||||||
|
<div>表单测试</div>
|
||||||
|
<InputField name="input" label="input" rules="required" />
|
||||||
|
<SelectField
|
||||||
|
name="select"
|
||||||
|
label="select"
|
||||||
|
:options="[
|
||||||
|
{ label: 'one', value: '1' },
|
||||||
|
{ label: 'two', value: '2' },
|
||||||
|
]"
|
||||||
|
rules="required"
|
||||||
|
/>
|
||||||
|
<SwitchField name="switch" label="我同意xxx" :rules="(v: any) => !!v" />
|
||||||
|
<FormButton
|
||||||
|
@click="
|
||||||
|
async (form) => {
|
||||||
|
console.log('form值', form.values)
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
获取表单值(console.log)
|
||||||
|
</FormButton>
|
||||||
|
</div>
|
||||||
|
</VeeForm>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<style scoped></style>
|
||||||
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 2.0 MiB |
68
package.json
@@ -1,36 +1,36 @@
|
|||||||
{
|
{
|
||||||
"name": "015",
|
"name": "015",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm-run-all -p dev:front dev:backend dev:worker",
|
"dev": "npm-run-all -p dev:front dev:backend dev:worker",
|
||||||
"dev:front": "cd front && pnpm run dev",
|
"dev:front": "cd front && pnpm run dev",
|
||||||
"dev:backend": "cd backend && air",
|
"dev:backend": "cd backend && air",
|
||||||
"dev:worker": "cd worker && air",
|
"dev:worker": "cd worker && air",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"prepare": "husky"
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"front"
|
"front"
|
||||||
],
|
],
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "npx lint-staged"
|
"pre-commit": "npx lint-staged"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.vue": "prettier --write",
|
"*.vue": "prettier --write",
|
||||||
"*.ts": "prettier --write",
|
"*.ts": "prettier --write",
|
||||||
"*.json": "prettier --write"
|
"*.json": "prettier --write"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"husky": "^9.1.6",
|
"husky": "^9.1.7",
|
||||||
"lint-staged": "^15.2.10",
|
"lint-staged": "^15.5.2",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^3.3.3"
|
"prettier": "^3.6.2"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
|
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
|
||||||
}
|
}
|
||||||
|
|||||||
8707
pnpm-lock.yaml
generated
@@ -1,6 +1,6 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM golang:1.23.1 AS builder
|
FROM golang:1.24.3 AS builder
|
||||||
|
|
||||||
# Set destination for COPY
|
# Set destination for COPY
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -1,34 +1,36 @@
|
|||||||
module worker
|
module worker
|
||||||
|
|
||||||
go 1.23.1
|
go 1.24.0
|
||||||
|
|
||||||
|
toolchain go1.24.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dario.cat/mergo v1.0.2
|
dario.cat/mergo v1.0.2
|
||||||
github.com/hibiken/asynq v0.25.1
|
github.com/hibiken/asynq v0.25.1
|
||||||
github.com/redis/go-redis/v9 v9.7.0
|
github.com/redis/go-redis/v9 v9.14.0
|
||||||
github.com/samber/lo v1.50.0
|
github.com/samber/lo v1.51.0
|
||||||
github.com/spf13/cast v1.8.0
|
github.com/spf13/cast v1.10.0
|
||||||
github.com/spf13/viper v1.20.1
|
github.com/spf13/viper v1.21.0
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
github.com/sagikazarmark/locafero v0.12.0 // indirect
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
github.com/spf13/afero v1.15.0 // indirect
|
||||||
github.com/spf13/afero v1.12.0 // indirect
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
github.com/spf13/pflag v1.0.6 // indirect
|
|
||||||
github.com/subosito/gotenv v1.6.0 // indirect
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
go.uber.org/multierr v1.10.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
golang.org/x/sys v0.29.0 // indirect
|
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||||
golang.org/x/text v0.22.0 // indirect
|
golang.org/x/sys v0.36.0 // indirect
|
||||||
golang.org/x/time v0.8.0 // indirect
|
golang.org/x/text v0.29.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.1 // indirect
|
golang.org/x/time v0.13.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
google.golang.org/protobuf v1.36.9 // indirect
|
||||||
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
|
|||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
@@ -26,52 +26,50 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
|||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
|
github.com/redis/go-redis/v9 v9.14.0 h1:u4tNCjXOyzfgeLN+vAZaW1xUooqWDqVEsZN0U01jfAE=
|
||||||
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
|
github.com/redis/go-redis/v9 v9.14.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
||||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4=
|
||||||
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI=
|
||||||
github.com/samber/lo v1.50.0 h1:XrG0xOeHs+4FQ8gJR97zDz5uOFMW7OwFWiFVzqopKgY=
|
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
||||||
github.com/samber/lo v1.50.0/go.mod h1:RjZyNk6WSnUFRKK6EyOhsRJMqft3G+pg7dCWHQCWvsc=
|
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||||
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
|
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||||
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
|
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||||
github.com/spf13/cast v1.8.0 h1:gEN9K4b8Xws4EX0+a0reLmhq8moKn7ntRlQYgjPeCDk=
|
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||||
github.com/spf13/cast v1.8.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
|
||||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
|
||||||
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
|
||||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
|
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||||
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||||
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
|
golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI=
|
||||||
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||||
|
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
||||||
|
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||