mirror of
https://github.com/keven1024/015.git
synced 2026-06-07 12:54:34 +00:00
Compare commits
41 Commits
0.0.1-alph
...
0.0.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3001ea3250 | ||
|
|
1b12703b90 | ||
|
|
e4bb9781f7 | ||
|
|
943a5a76d2 | ||
|
|
71147451bb | ||
|
|
3d88c68ed5 | ||
|
|
338e22dfca | ||
|
|
464dba2546 | ||
|
|
a3dd28dd92 | ||
|
|
9fd4943bb6 | ||
|
|
668a2dd4d8 | ||
|
|
695395ba6a | ||
|
|
a0cff53901 | ||
|
|
7d8075277d | ||
|
|
862b381e65 | ||
|
|
745ae94c49 | ||
|
|
8c60d32ac0 | ||
|
|
2f5388d0a8 | ||
|
|
88b8daa5df | ||
|
|
7a3d03c41f | ||
|
|
0bdea93726 | ||
|
|
f4740f4373 | ||
|
|
1ac21b3dd0 | ||
|
|
76457a6e88 | ||
|
|
41e9df5ee8 | ||
|
|
7f5149566c | ||
|
|
24b4b2dc93 | ||
|
|
9b1b89056d | ||
|
|
46e3cf529c | ||
|
|
3c18fcf8ff | ||
|
|
58403a291a | ||
|
|
28154d09ad | ||
|
|
d77fc85fd3 | ||
|
|
c971e92905 | ||
|
|
a484f8926b | ||
|
|
bee32be989 | ||
|
|
ba7a648cbe | ||
|
|
a0de112853 | ||
|
|
ddcf53d456 | ||
|
|
bbd451f027 | ||
|
|
edf0fe471d |
@@ -17,7 +17,8 @@ steps:
|
||||
- ${DRONE_TAG}
|
||||
- latest
|
||||
build_args:
|
||||
- BUILD_TAG=${DRONE_TAG}
|
||||
- VERSION=${DRONE_TAG}
|
||||
- BUILD_TIME=${DRONE_BUILD_FINISHED}
|
||||
- name: build-worker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
|
||||
16
.env.example
Normal file
16
.env.example
Normal file
@@ -0,0 +1,16 @@
|
||||
# 你的下载secret,每一次下载次数减1的时候都会根据这里的secret生成一个下载jwt token, 有效期一小时,使用该下载token有效期内可以多线程下载该文件而不会被多次扣除次数
|
||||
DOWNLOAD_SECRET="your-secret-token"
|
||||
|
||||
UPLOAD_PATH="/upload" # 上传路径
|
||||
REDIS_URL="redis://127.0.0.1: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"
|
||||
9
.prettierrc
Normal file
9
.prettierrc
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 4,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"printWidth": 150,
|
||||
"jsxBracketSameLine": false,
|
||||
"bracketSameLine": false
|
||||
}
|
||||
@@ -2,7 +2,7 @@ FROM node:22-alpine AS front-base
|
||||
|
||||
# Install dependencies only when needed
|
||||
FROM front-base AS front-deps
|
||||
RUN apk add --no-cache libc6-compat
|
||||
RUN apk add --no-cache gcompat
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN corepack enable pnpm && pnpm i && pnpm --filter=015-front deploy dist
|
||||
@@ -26,7 +26,8 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o backend
|
||||
|
||||
|
||||
FROM front-base AS runner
|
||||
ARG BUILD_TAG
|
||||
ARG VERSION
|
||||
ARG BUILD_TIME
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache curl openssl
|
||||
ENV NODE_ENV production
|
||||
@@ -43,6 +44,8 @@ COPY 015.sh /app/015.sh
|
||||
ENV PORT=80 HOST=0.0.0.0
|
||||
ENV SITE_URL="http://localhost"
|
||||
ENV UPLOAD_PATH="/uploads"
|
||||
ENV VERSION=${VERSION}
|
||||
ENV BUILD_TIME=${BUILD_TIME}
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
|
||||
219
README.md
219
README.md
@@ -1,3 +1,220 @@
|
||||
# 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.
|
||||
|
||||

|
||||
|
||||
## 🌟 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
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 🏗️ 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=./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
|
||||
│ ├── 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)
|
||||
|
||||
@@ -6,7 +6,6 @@ require (
|
||||
dario.cat/mergo v1.0.1
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
||||
github.com/googollee/go-socket.io v1.7.0
|
||||
github.com/gorilla/sessions v1.4.0
|
||||
github.com/hibiken/asynq v0.25.1
|
||||
github.com/labstack/echo-contrib v0.17.3
|
||||
@@ -14,8 +13,10 @@ require (
|
||||
github.com/matoous/go-nanoid/v2 v2.1.0
|
||||
github.com/redis/go-redis/v9 v9.7.3
|
||||
github.com/samber/lo v1.50.0
|
||||
github.com/spf13/cast v1.7.1
|
||||
github.com/spf13/viper v1.20.1
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/crypto v0.39.0
|
||||
golang.org/x/time v0.11.0
|
||||
)
|
||||
|
||||
@@ -24,13 +25,10 @@ require (
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||
github.com/gofrs/uuid v4.0.0+incompatible // indirect
|
||||
github.com/gomodule/redigo v1.8.4 // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/context v1.1.2 // indirect
|
||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/labstack/gommon v0.4.2 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@@ -39,16 +37,14 @@ require (
|
||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.12.0 // 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/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.37.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.26.0 // indirect
|
||||
google.golang.org/protobuf v1.36.5 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -6,7 +6,6 @@ github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
@@ -19,28 +18,20 @@ github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/
|
||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/gomodule/redigo v1.8.4 h1:Z5JUg94HMTR1XpwBaSH4vq3+PNSIykBLxMdglbw10gg=
|
||||
github.com/gomodule/redigo v1.8.4/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
||||
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/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googollee/go-socket.io v1.7.0 h1:ODcQSAvVIPvKozXtUGuJDV3pLwdpBLDs1Uoq/QHIlY8=
|
||||
github.com/googollee/go-socket.io v1.7.0/go.mod h1:0vGP8/dXR9SZUMMD4+xxaGo/lohOw3YWMh2WRiWeKxg=
|
||||
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
|
||||
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
|
||||
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||
github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzqQ=
|
||||
github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2emc7lT5ik=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hibiken/asynq v0.25.1 h1:phj028N0nm15n8O2ims+IvJ2gz4k2auvermngh9JhTw=
|
||||
github.com/hibiken/asynq v0.25.1/go.mod h1:pazWNOLBu0FEynQRBvHA26qdIKRSmfdIfUm4HdsLmXg=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
@@ -85,8 +76,6 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
||||
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
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=
|
||||
@@ -101,15 +90,15 @@ 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/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
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=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
|
||||
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
|
||||
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
|
||||
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
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.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
|
||||
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||
@@ -117,7 +106,5 @@ google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojt
|
||||
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-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
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 {
|
||||
return utils.HTTPErrorHandler(c, errors.New("分享不存在"))
|
||||
}
|
||||
if shareInfo.Password != "" && shareInfo.Password != r.Password {
|
||||
return utils.HTTPErrorHandler(c, errors.New("分享密码错误"))
|
||||
if shareInfo.Password != "" {
|
||||
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 防止空值问题
|
||||
if shareInfo.ViewNum < 1 {
|
||||
|
||||
@@ -40,6 +40,27 @@ func CreateUploadTask(c echo.Context) error {
|
||||
"chunk_size": fileInfo.ChunkSize,
|
||||
})
|
||||
}
|
||||
maxStorageSize, err := utils.GetFileSize(utils.GetEnv("MAX_LOCALSTORAGE_SIZE"))
|
||||
if err != nil {
|
||||
return utils.HTTPErrorHandler(c, err)
|
||||
}
|
||||
fileInfoMap, err := models.GetRedisFileInfoAll()
|
||||
if err != nil {
|
||||
return utils.HTTPErrorHandler(c, err)
|
||||
}
|
||||
totalSize := int64(0)
|
||||
for _, value := range fileInfoMap {
|
||||
var fileInfo models.RedisFileInfo
|
||||
err := json.Unmarshal([]byte(value), &fileInfo)
|
||||
if err != nil {
|
||||
return utils.HTTPErrorHandler(c, err)
|
||||
}
|
||||
totalSize += fileInfo.FileSize
|
||||
}
|
||||
if totalSize+r.FileSize > int64(maxStorageSize) {
|
||||
return utils.HTTPErrorHandler(c, errors.New("存储空间不足"))
|
||||
}
|
||||
|
||||
ChunkSize := int64(1 * 1024 * 1024)
|
||||
if r.FileSize > 500*1024*1024 {
|
||||
ChunkSize = r.FileSize / 500
|
||||
@@ -56,7 +77,7 @@ func CreateUploadTask(c echo.Context) error {
|
||||
CreatedAt: time.Now().Unix(),
|
||||
Expire: uploadTaskExpire,
|
||||
}
|
||||
err := models.SetRedisFileInfo(fileId, newFileInfo)
|
||||
err = models.SetRedisFileInfo(fileId, newFileInfo)
|
||||
if err != nil {
|
||||
return utils.HTTPErrorHandler(c, err)
|
||||
}
|
||||
|
||||
@@ -64,17 +64,25 @@ func CreateShareInfo(c echo.Context) error {
|
||||
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{
|
||||
Data: r.Data,
|
||||
Type: r.Type,
|
||||
CreatedAt: time.Now().Unix(),
|
||||
Owner: cc.Auth.(string),
|
||||
ViewNum: r.Config.ViewNum,
|
||||
Password: r.Config.Password,
|
||||
NotifyEmail: r.Config.NotifyEmail,
|
||||
FileName: r.FileName,
|
||||
ExpireAt: ExpireTime.Unix(),
|
||||
Data: r.Data,
|
||||
Type: r.Type,
|
||||
CreatedAt: time.Now().Unix(),
|
||||
Owner: cc.Auth.(string),
|
||||
ViewNum: r.Config.ViewNum,
|
||||
Password: password,
|
||||
// NotifyEmail: r.Config.NotifyEmail,
|
||||
FileName: r.FileName,
|
||||
ExpireAt: ExpireTime.Unix(),
|
||||
})
|
||||
var pickupCode string
|
||||
if r.Config.HasPickupCode {
|
||||
@@ -153,6 +161,7 @@ func GetShareInfo(c echo.Context) error {
|
||||
"type": shareInfo.Type,
|
||||
"name": shareInfo.FileName,
|
||||
"download_nums": shareInfo.ViewNum,
|
||||
"has_password": shareInfo.Password != "",
|
||||
"expire_at": shareInfo.ExpireAt,
|
||||
"owner": shareInfo.Owner,
|
||||
"size": fileInfo.FileSize,
|
||||
@@ -165,6 +174,7 @@ func GetShareInfo(c echo.Context) error {
|
||||
"type": shareInfo.Type,
|
||||
"name": shareInfo.FileName,
|
||||
"download_nums": shareInfo.ViewNum,
|
||||
"has_password": shareInfo.Password != "",
|
||||
"expire_at": shareInfo.ExpireAt,
|
||||
"owner": shareInfo.Owner,
|
||||
})
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type FileChartData struct {
|
||||
@@ -83,7 +84,8 @@ func GetStat(c echo.Context) error {
|
||||
})
|
||||
|
||||
return utils.HTTPSuccessHandler(c, map[string]any{
|
||||
"version": "0.1.0",
|
||||
"version": utils.GetEnvWithDefault("VERSION", "dev"),
|
||||
"build_time": cast.ToInt(utils.GetEnvWithDefault("BUILD_TIME", cast.ToString(time.Now().Unix()))),
|
||||
"max_limit": map[string]any{
|
||||
"file_size": maxStorageSize,
|
||||
},
|
||||
|
||||
17
backend/internal/utils/password.go
Normal file
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
|
||||
}
|
||||
221
docs/README-zh.md
Normal file
221
docs/README-zh.md
Normal file
@@ -0,0 +1,221 @@
|
||||
# 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 构建的现代文件分享网站,支持文件上传、文本分享、图片压缩、并发处理、秒传功能等,具备完整的分享管理和访问控制体系。
|
||||
|
||||

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

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 🏗️ 技术架构
|
||||
|
||||
### 前端技术栈
|
||||
|
||||
- **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=./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)
|
||||
BIN
docs/image/0.png
Normal file
BIN
docs/image/0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
BIN
docs/image/1.webp
Normal file
BIN
docs/image/1.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
BIN
docs/image/2.webp
Normal file
BIN
docs/image/2.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 654 KiB |
BIN
docs/image/3.png
Normal file
BIN
docs/image/3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
BIN
docs/image/4.png
Normal file
BIN
docs/image/4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
@@ -50,7 +50,7 @@
|
||||
--card-foreground: oklch(0.129 0.042 264.695);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.129 0.042 264.695);
|
||||
--primary: oklch(0.208 0.042 265.755);
|
||||
--primary: oklch(0.4349 0.0673 257.47);
|
||||
--primary-foreground: oklch(0.984 0.003 247.858);
|
||||
--secondary: oklch(0.968 0.007 247.896);
|
||||
--secondary-foreground: oklch(0.208 0.042 265.755);
|
||||
|
||||
39
front/components/Drawer/PasswallShareDrawer.vue
Normal file
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>
|
||||
20
front/components/Drawer/QrCoreDrawer.vue
Normal file
20
front/components/Drawer/QrCoreDrawer.vue
Normal file
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import QRCode from "qrcode";
|
||||
const props = defineProps<{
|
||||
hide: () => void;
|
||||
data: any;
|
||||
}>();
|
||||
const { state } = useAsyncState(async () => {
|
||||
return await QRCode.toDataURL(props.data);
|
||||
}, null);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-5">
|
||||
<div class="text-xl font-bold">分享二维码</div>
|
||||
<div class="flex flex-row justify-center">
|
||||
<img :src="state" v-if="!!state" />
|
||||
<Skeleton class="size-20" v-else />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,17 +1,15 @@
|
||||
<template>
|
||||
<Field :name="props.name" v-slot="{ field }">
|
||||
<div class="flex flex-col gap-2">
|
||||
<Label v-if="props.label">{{ props.label }}</Label>
|
||||
<Input v-bind="field" :placeholder="props.placeholder" :class="props.class" />
|
||||
</div>
|
||||
</Field>
|
||||
<Field :name="props.name" v-slot="{ field }">
|
||||
<div class="flex flex-col gap-2">
|
||||
<Label v-if="props.label">{{ props.label }}</Label>
|
||||
<Input v-bind="{ ...field, ...$attrs }" />
|
||||
</div>
|
||||
</Field>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { Input } from '@/components/ui/input'
|
||||
const props = defineProps<{
|
||||
name: string
|
||||
label?: string
|
||||
placeholder?: string
|
||||
class?: string
|
||||
name: string
|
||||
label?: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Drawer,
|
||||
DrawerContent,
|
||||
} from '@/components/ui/drawer'
|
||||
import { Drawer, DrawerContent } from '@/components/ui/drawer'
|
||||
import { createVNode } from 'vue'
|
||||
import useStore from '@/composables/useStore'
|
||||
|
||||
@@ -10,24 +7,29 @@ const store = useStore('drawer')
|
||||
const drawer = computed(() => store?._get('drawer'))
|
||||
const currentDrawer = computed(() => drawer?.value?.[drawer?.value?.length - 1])
|
||||
|
||||
const render = computed(() => currentDrawer?.value?.render)
|
||||
const render = computed<() => Component>(() => currentDrawer?.value?.render)
|
||||
const hide = computed<() => void>(() => currentDrawer?.value?.onClose)
|
||||
const Children = () =>
|
||||
createVNode(render.value, {
|
||||
hide: () => store?._set('drawer', drawer?.value?.slice(0, -1)),
|
||||
})
|
||||
|
||||
createVNode(render.value, {
|
||||
hide: hide?.value,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer :open="!!store?._get('drawer')?.[store?._get('drawer')?.length - 1]" @update:open="(open) => {
|
||||
if (!open && drawer?.length > 0) {
|
||||
store?._set('drawer', drawer?.slice(0, -1))
|
||||
}
|
||||
}">
|
||||
<DrawerContent>
|
||||
<div class="mx-auto w-full max-w-sm pb-10">
|
||||
<Children />
|
||||
</div>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
</template>
|
||||
<Drawer
|
||||
:open="!!drawer?.[drawer?.length - 1]"
|
||||
@update:open="
|
||||
(open) => {
|
||||
if (!open && drawer?.length > 0) {
|
||||
hide()
|
||||
}
|
||||
}
|
||||
"
|
||||
>
|
||||
<DrawerContent>
|
||||
<div class="mx-auto w-full max-w-sm pb-10">
|
||||
<Children />
|
||||
</div>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
</template>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script lang="ts" setup>
|
||||
import CircularProgress from '@/components/CircularProgress.vue'
|
||||
import { chunk, shuffle, times } from 'lodash-es';
|
||||
import { chunk, get, shuffle, times } from 'lodash-es'
|
||||
import { cx } from 'class-variance-authority'
|
||||
import calcFileHash from '@/lib/calcFileHash';
|
||||
import { filesize } from 'filesize';
|
||||
import { filesize } from 'filesize'
|
||||
import { toast } from 'vue-sonner'
|
||||
import asyncWorker from '~/lib/asyncWorker'
|
||||
import calcFileHashWorker from '~/lib/calcFileHashWorker?worker'
|
||||
const props = defineProps<{
|
||||
data: { file: File, config: any, handle_type: string }
|
||||
data: { file: File; config: any; handle_type: string }
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -17,21 +19,24 @@ const form = useFormContext()
|
||||
const step = ref<'hash' | 'upload'>('hash')
|
||||
const calcHashTime = ref(0)
|
||||
const chunkSize = ref(0)
|
||||
const fileSliceUploadStatusList = ref<{
|
||||
status: string
|
||||
index: number
|
||||
}[]>([])
|
||||
const fileSliceUploadStatusList = ref<
|
||||
{
|
||||
status: string
|
||||
index: number
|
||||
}[]
|
||||
>([])
|
||||
|
||||
const successCount = computed(() => fileSliceUploadStatusList.value.filter((item) => item.status === 'success').length)
|
||||
const alreadyUploadSize = computed(() => successCount.value * chunkSize.value)
|
||||
const uploadProgress = computed(() => Math.round(alreadyUploadSize.value / (props?.data?.file?.size || 0) * 100))
|
||||
const alreadyUploadSize = computed(() => Math.min(successCount.value * chunkSize.value, props?.data?.file?.size))
|
||||
const uploadProgress = computed(() => Math.round((alreadyUploadSize.value / (props?.data?.file?.size || 0)) * 100))
|
||||
|
||||
useAsyncState(async () => {
|
||||
const { error } = useAsyncState(async () => {
|
||||
const { file } = props.data || {}
|
||||
if (!file) return
|
||||
const { size, type } = file || {}
|
||||
const { size, type = 'application/octet-stream' } = file || {}
|
||||
const now = Date.now()
|
||||
const hash = await calcFileHash({ file })
|
||||
const res = await asyncWorker(calcFileHashWorker, { data: { file } })
|
||||
const { hash } = res?.data || {}
|
||||
if (hash) {
|
||||
step.value = 'upload'
|
||||
calcHashTime.value = Date.now() - now
|
||||
@@ -47,70 +52,72 @@ useAsyncState(async () => {
|
||||
method: 'POST',
|
||||
body: {
|
||||
size,
|
||||
mime_type: type,
|
||||
mime_type: get(type, '', 'application/octet-stream'),
|
||||
hash,
|
||||
}
|
||||
},
|
||||
})
|
||||
const { id, chunk_size, type: createType } = createData?.data || {}
|
||||
if (createType !== 'init') {
|
||||
// 文件存在
|
||||
form.setFieldValue('file_id', id)
|
||||
emit('change', 'result')
|
||||
return;
|
||||
return
|
||||
}
|
||||
chunkSize.value = chunk_size
|
||||
const chunks = Math.ceil(size / chunk_size);
|
||||
const chunks = Math.ceil(size / chunk_size)
|
||||
fileSliceUploadStatusList.value = times(chunks, (i) => ({
|
||||
status: 'pending',
|
||||
index: i
|
||||
index: i,
|
||||
}))
|
||||
|
||||
const readChunk = (start: number): Promise<ArrayBuffer> => {
|
||||
const fileReader = new FileReader();
|
||||
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);
|
||||
});
|
||||
};
|
||||
const chunk = file.slice(start, start + chunk_size)
|
||||
fileReader.onload = (e) => resolve(e.target?.result as ArrayBuffer)
|
||||
fileReader.onerror = reject
|
||||
fileReader.readAsArrayBuffer(chunk)
|
||||
})
|
||||
}
|
||||
|
||||
const chunkedUploadTasks = chunk(shuffle([...fileSliceUploadStatusList.value]), 3)
|
||||
for (let i = 0; i < chunkedUploadTasks?.length; i++) {
|
||||
await Promise.all(chunkedUploadTasks?.[i]?.map(async (item: any) => {
|
||||
const { index } = item || {}
|
||||
try {
|
||||
const chunk = await readChunk(index * chunk_size);
|
||||
// console.log('chunk', chunk)
|
||||
const formData = new FormData()
|
||||
formData.append('file', new Blob([chunk]))
|
||||
formData.append('index', index + 1)
|
||||
formData.append('id', id)
|
||||
fileSliceUploadStatusList.value[index].status = 'uploading'
|
||||
const res = await $fetch<{
|
||||
code: number
|
||||
}>('/api/file/slice', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
const { code } = res || {}
|
||||
if (code !== 200) {
|
||||
throw new Error('上传失败')
|
||||
await Promise.all(
|
||||
chunkedUploadTasks?.[i]?.map(async (item: any) => {
|
||||
const { index } = item || {}
|
||||
try {
|
||||
const chunk = await readChunk(index * chunk_size)
|
||||
// console.log('chunk', chunk)
|
||||
const formData = new FormData()
|
||||
formData.append('file', new Blob([chunk]))
|
||||
formData.append('index', index + 1)
|
||||
formData.append('id', id)
|
||||
fileSliceUploadStatusList.value[index].status = 'uploading'
|
||||
const res = await $fetch<{
|
||||
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'
|
||||
}
|
||||
fileSliceUploadStatusList.value[index].status = 'success'
|
||||
} catch (error) {
|
||||
console.log('error', error)
|
||||
// fileSliceStatusList.value[index].status = 'error'
|
||||
}
|
||||
}))
|
||||
})
|
||||
)
|
||||
}
|
||||
const r = await $fetch<{
|
||||
code: number
|
||||
}>('/api/file/finish', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
id
|
||||
}
|
||||
id,
|
||||
},
|
||||
})
|
||||
if (r?.code !== 200) {
|
||||
throw new Error('上传失败')
|
||||
@@ -118,13 +125,19 @@ useAsyncState(async () => {
|
||||
form.setFieldValue('file_id', id)
|
||||
emit('change', 'result')
|
||||
}, null)
|
||||
|
||||
watch(error, (newVal) => {
|
||||
if (newVal) {
|
||||
toast.error('上传失败')
|
||||
}
|
||||
emit('change', 'input')
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="text-xl font-normal">正在上传</div>
|
||||
<div class="flex flex-col items-center gap-4 md:flex-row md:justify-evenly">
|
||||
<div :class="cx('flex flex-row items-center gap-5', step !== 'hash' && 'opacity-50')">
|
||||
|
||||
<div class="flex flex-col gap-0.5 items-center">
|
||||
<div class="text-xs opacity-50">1.计算hash</div>
|
||||
<div class="text-3xl font-light">
|
||||
@@ -138,21 +151,30 @@ useAsyncState(async () => {
|
||||
<div class="flex flex-col gap-0.5 items-center">
|
||||
<div class="text-xs opacity-50">2.上传文件</div>
|
||||
<div class="text-3xl font-light">{{ step !== 'upload' ? 0 : uploadProgress }}%</div>
|
||||
<div class="text-sm opacity-50" v-if="alreadyUploadSize">{{ filesize(alreadyUploadSize) }} / {{ filesize(data?.file?.size) }}</div>
|
||||
<div class="text-sm opacity-50" v-if="alreadyUploadSize">
|
||||
{{ filesize(alreadyUploadSize) }} / {{ filesize(data?.file?.size) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row gap-2 items-baseline">
|
||||
<div class="text-md font-normal">详细信息</div>
|
||||
<div class="text-xs opacity-50" v-if="step === 'upload' && fileSliceUploadStatusList?.length > 0">当前正在上传分块{{ `${successCount}/${Math.ceil(data?.file?.size / chunkSize)}` }} 并发:3</div>
|
||||
<div class="text-xs opacity-50" v-if="step === 'upload' && fileSliceUploadStatusList?.length > 0">
|
||||
当前正在上传分块{{ `${successCount}/${Math.ceil(data?.file?.size / chunkSize)}` }} 并发:3
|
||||
</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
|
||||
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>
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -5,14 +5,23 @@ import { Input } from "@/components/ui/input";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import { toast } from "vue-sonner";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import useAppShare from "@/composables/useShare";
|
||||
import useMyAppShare from "@/composables/useMyAppShare";
|
||||
import useMyAppConfig from "@/composables/useMyAppConfig";
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import "dayjs/locale/zh-cn"; // 导入中文语言包
|
||||
import showDrawer from "@/lib/showDrawer";
|
||||
import QrCoreDrawer from "@/components/Drawer/QrCoreDrawer.vue";
|
||||
dayjs.extend(relativeTime); // 扩展 relativeTime 插件
|
||||
dayjs.locale("zh-cn"); // 设置语言为中文
|
||||
|
||||
const props = defineProps<{
|
||||
data: { file: File; config: any; handle_type: string; file_id: string };
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: "change", key: string): void;
|
||||
}>();
|
||||
const { createFileShare } = useAppShare();
|
||||
const { createFileShare } = useMyAppShare();
|
||||
const { data } = useQuery({
|
||||
queryKey: ["create-share", props?.data?.file_id],
|
||||
queryFn: async () => {
|
||||
@@ -27,7 +36,7 @@ const { data } = useQuery({
|
||||
},
|
||||
});
|
||||
|
||||
const appConfig = useAppConfig();
|
||||
const appConfig = useMyAppConfig();
|
||||
const url = computed(() => {
|
||||
const { id } = data?.value || {};
|
||||
return `${appConfig?.value?.site_url}/s/${id}`;
|
||||
@@ -43,28 +52,92 @@ const { copy } = useClipboard();
|
||||
<div class="flex flex-col h-30 items-center">
|
||||
<FilePreviewView :value="props?.data?.file" />
|
||||
</div>
|
||||
<div class="flex flex-row gap-2">
|
||||
<Input v-model="url" class="bg-white/70" />
|
||||
<Button
|
||||
variant="outline"
|
||||
class="bg-white/70"
|
||||
size="icon"
|
||||
@click="
|
||||
() => {
|
||||
copy(url);
|
||||
toast.success('复制成功');
|
||||
}
|
||||
"
|
||||
>
|
||||
<LucideCopy />
|
||||
</Button>
|
||||
<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 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 * 1000).format("YYYY-MM-DD HH:mm:ss")
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1"
|
||||
v-if="data?.pickup_code"
|
||||
>
|
||||
<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" />
|
||||
</Button>
|
||||
</div>
|
||||
<div class="flex flex-row gap-2">
|
||||
<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">
|
||||
<LucideQrCode />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
class="bg-white/70"
|
||||
size="icon"
|
||||
@click="
|
||||
() => {
|
||||
showDrawer({
|
||||
render: ({ ...rest }) =>
|
||||
h(QrCoreDrawer, {
|
||||
...rest,
|
||||
data: url,
|
||||
}),
|
||||
});
|
||||
}
|
||||
"
|
||||
>
|
||||
<LucideQrCode />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
class="hover:bg-white/50 w-40"
|
||||
@click="
|
||||
() => {
|
||||
|
||||
@@ -1,193 +1,166 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import { AsyncButton, Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { filesize } from "filesize";
|
||||
import useAppShare from "~/composables/useShare";
|
||||
import { toast } from "vue-sonner";
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { AsyncButton, Button } from '@/components/ui/button'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { filesize } from 'filesize'
|
||||
import useMyAppShare from '@/composables/useMyAppShare'
|
||||
import { toast } from 'vue-sonner'
|
||||
const emit = defineEmits<{
|
||||
(e: "change", key: string): void;
|
||||
}>();
|
||||
(e: 'change', key: string): void
|
||||
}>()
|
||||
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({
|
||||
queryKey: ["create-image-compress", props?.data?.file_id],
|
||||
queryFn: async () => {
|
||||
const { file_id } = props?.data || {};
|
||||
const data = await $fetch<{
|
||||
code: number;
|
||||
data: {
|
||||
id?: string;
|
||||
};
|
||||
}>(`/api/image/compress`, {
|
||||
method: "POST",
|
||||
body: {
|
||||
file_id,
|
||||
},
|
||||
});
|
||||
return data?.data;
|
||||
},
|
||||
staleTime: Infinity,
|
||||
});
|
||||
queryKey: ['create-image-compress', props?.data?.file_id],
|
||||
queryFn: async () => {
|
||||
const { file_id } = props?.data || {}
|
||||
const data = await $fetch<{
|
||||
code: number
|
||||
data: {
|
||||
id?: string
|
||||
}
|
||||
}>(`/api/image/compress`, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
file_id,
|
||||
},
|
||||
})
|
||||
return data?.data
|
||||
},
|
||||
staleTime: Infinity,
|
||||
})
|
||||
|
||||
const taskId = computed(() => data?.value?.id);
|
||||
const taskId = computed(() => data?.value?.id)
|
||||
|
||||
const { data: taskData, refetch } = useQuery({
|
||||
queryKey: ["image-compress-task", taskId],
|
||||
queryFn: async () => {
|
||||
const data = await $fetch<{
|
||||
code: number;
|
||||
data: {
|
||||
result: {
|
||||
old_file: {
|
||||
id: string;
|
||||
size: number;
|
||||
};
|
||||
new_file: {
|
||||
id: string;
|
||||
size: number;
|
||||
};
|
||||
}[];
|
||||
status: "success" | "retry" | "archived";
|
||||
err?: {
|
||||
message?: string;
|
||||
retry?: number;
|
||||
max_retry?: number;
|
||||
};
|
||||
};
|
||||
}>(`/api/image/compress/${taskId.value}`);
|
||||
return data?.data;
|
||||
},
|
||||
enabled: !!taskId.value,
|
||||
});
|
||||
queryKey: ['image-compress-task', taskId],
|
||||
queryFn: async () => {
|
||||
const data = await $fetch<{
|
||||
code: number
|
||||
data: {
|
||||
result: {
|
||||
old_file: {
|
||||
id: string
|
||||
size: number
|
||||
}
|
||||
new_file: {
|
||||
id: string
|
||||
size: number
|
||||
}
|
||||
}[]
|
||||
status: 'success' | 'retry' | 'archived'
|
||||
err?: {
|
||||
message?: string
|
||||
retry?: number
|
||||
max_retry?: number
|
||||
}
|
||||
}
|
||||
}>(`/api/image/compress/${taskId.value}`)
|
||||
return data?.data
|
||||
},
|
||||
enabled: !!taskId.value,
|
||||
})
|
||||
|
||||
const { downloadFile, createFileShare } = useAppShare();
|
||||
const { downloadFileByShareId, createFileShare } = useMyAppShare()
|
||||
|
||||
const { counter, pause } = useInterval(2000, { controls: true });
|
||||
const { counter, pause } = useInterval(2000, { controls: true })
|
||||
|
||||
watch(
|
||||
() => counter.value,
|
||||
() => {
|
||||
if (["success", "archived"].includes(taskData.value?.status ?? "")) {
|
||||
pause();
|
||||
return;
|
||||
() => counter.value,
|
||||
() => {
|
||||
if (['success', 'archived'].includes(taskData.value?.status ?? '')) {
|
||||
pause()
|
||||
return
|
||||
}
|
||||
refetch()
|
||||
}
|
||||
refetch();
|
||||
},
|
||||
);
|
||||
)
|
||||
|
||||
watch(
|
||||
() => taskData.value?.err?.retry,
|
||||
(newVal, oldVal) => {
|
||||
if (!oldVal || !newVal || !taskData.value?.err?.max_retry) {
|
||||
return;
|
||||
() => taskData.value?.err?.retry,
|
||||
(newVal, oldVal) => {
|
||||
if (!oldVal || !newVal || !taskData.value?.err?.max_retry) {
|
||||
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>
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<h2 class="text-lg">上传成功</h2>
|
||||
<div class="flex flex-col gap-1 items-center">
|
||||
<div class="flex flex-col h-30 items-center justify-center">
|
||||
<FilePreviewView :value="props?.data?.file" />
|
||||
</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 class="flex flex-col gap-3">
|
||||
<h2 class="text-lg">上传成功</h2>
|
||||
<div class="flex flex-col gap-1 items-center">
|
||||
<div class="flex flex-col h-30 items-center justify-center">
|
||||
<FilePreviewView :value="props?.data?.file" />
|
||||
</div>
|
||||
</div>
|
||||
<AsyncButton
|
||||
variant="outline"
|
||||
class="bg-black/5"
|
||||
size="icon"
|
||||
@click="
|
||||
async () => {
|
||||
const data = await createFileShare({
|
||||
file_id: item.new_file.id,
|
||||
config: {
|
||||
download_nums: 1,
|
||||
expire_time: 60,
|
||||
has_pickup_code: false,
|
||||
has_password: false,
|
||||
},
|
||||
file_name: props?.data?.file?.name,
|
||||
});
|
||||
const { id } = data?.data || {};
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
await downloadFile(id);
|
||||
}
|
||||
"
|
||||
>
|
||||
<LucideDownload />
|
||||
</AsyncButton>
|
||||
</div>
|
||||
</div>
|
||||
<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"
|
||||
>
|
||||
<div
|
||||
class="size-10 flex items-center justify-center rounded-md bg-red-200"
|
||||
>
|
||||
<LucideAlertTriangle class="size-5 text-red-600" />
|
||||
<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>
|
||||
<AsyncButton
|
||||
variant="outline"
|
||||
class="bg-black/5"
|
||||
size="icon"
|
||||
@click="
|
||||
async () => {
|
||||
const data = await createFileShare({
|
||||
file_id: item.new_file.id,
|
||||
config: {
|
||||
download_nums: 1,
|
||||
expire_time: 60,
|
||||
has_pickup_code: false,
|
||||
has_password: false,
|
||||
},
|
||||
file_name: props?.data?.file?.name,
|
||||
})
|
||||
const { id } = data?.data || {}
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await downloadFileByShareId(id)
|
||||
} catch (error: any) {
|
||||
toast.error(error?.data?.message || error?.message || error)
|
||||
}
|
||||
}
|
||||
"
|
||||
>
|
||||
<LucideDownload />
|
||||
</AsyncButton>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm">
|
||||
{{
|
||||
`经过 ${taskData?.err?.retry} 次重试后任务处理失败: ${taskData?.err?.message}`
|
||||
}}
|
||||
<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">
|
||||
<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 class="flex flex-row justify-center">
|
||||
<Button @click="emit('change', 'input')"> 返回首页 </Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else="taskData?.status !== 'retry' && !!taskData?.err?.message"
|
||||
class="flex flex-col gap-2"
|
||||
>
|
||||
<Skeleton
|
||||
class="w-full h-16 flex flex-row items-center justify-between"
|
||||
v-for="i in 3"
|
||||
/>
|
||||
<div v-else="taskData?.status !== 'retry' && !!taskData?.err?.message" class="flex flex-col gap-2">
|
||||
<Skeleton class="w-full h-16 flex flex-row items-center justify-between" v-for="i in 3" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,79 +1,143 @@
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import { toast } from "vue-sonner";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import useAppShare from "@/composables/useShare";
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { useClipboard } from '@vueuse/core'
|
||||
import { toast } from 'vue-sonner'
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import useMyAppShare from '@/composables/useMyAppShare'
|
||||
import useMyAppConfig from '@/composables/useMyAppConfig'
|
||||
import showDrawer from '@/lib/showDrawer'
|
||||
import QrCoreDrawer from '@/components/Drawer/QrCoreDrawer.vue'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const props = defineProps<{
|
||||
data: { text: string; config: any; handle_type: string };
|
||||
}>();
|
||||
data: { text: string; config: any; handle_type: string }
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "change", key: string): void;
|
||||
}>();
|
||||
(e: 'change', key: string): void
|
||||
}>()
|
||||
|
||||
const { createTextShare } = useAppShare();
|
||||
const { createTextShare } = useMyAppShare()
|
||||
const { data } = useQuery({
|
||||
queryKey: ["create-share", props?.data?.text],
|
||||
queryFn: async () => {
|
||||
const { config, text } = props?.data || {};
|
||||
const data = await createTextShare({
|
||||
text,
|
||||
config,
|
||||
});
|
||||
return data?.data;
|
||||
},
|
||||
});
|
||||
const appConfig = useAppConfig();
|
||||
queryKey: ['create-share', props?.data?.text],
|
||||
staleTime: Infinity,
|
||||
queryFn: async () => {
|
||||
const { config, text } = props?.data || {}
|
||||
const data = await createTextShare({
|
||||
text,
|
||||
config,
|
||||
})
|
||||
return data?.data
|
||||
},
|
||||
})
|
||||
const appConfig = useMyAppConfig()
|
||||
const url = computed(() => {
|
||||
const { id } = data?.value || {};
|
||||
return `${appConfig?.value?.site_url}/s/${id}`;
|
||||
});
|
||||
const { id } = data?.value || {}
|
||||
return `${appConfig?.value?.site_url}/s/${id}`
|
||||
})
|
||||
|
||||
const { copy } = useClipboard();
|
||||
const { copy } = useClipboard()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex flex-row justify-between">
|
||||
<h2 class="text-lg">分享成功</h2>
|
||||
<div class="flex flex-row gap-2 basis-1/2">
|
||||
<Button
|
||||
variant="outline"
|
||||
class="bg-white/70"
|
||||
size="icon"
|
||||
@click="
|
||||
() => {
|
||||
emit('change', 'input');
|
||||
}
|
||||
"
|
||||
>
|
||||
<LucideHome />
|
||||
</Button>
|
||||
<Input v-model="url" class="bg-white/70" />
|
||||
<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">
|
||||
<LucideQrCode />
|
||||
</Button>
|
||||
</div>
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex flex-row gap-2">
|
||||
<div class="flex flex-row justify-between w-full">
|
||||
<h2 class="text-lg">分享成功</h2>
|
||||
<Button
|
||||
variant="outline"
|
||||
class="bg-white/70"
|
||||
size="icon"
|
||||
@click="
|
||||
() => {
|
||||
emit('change', 'input')
|
||||
}
|
||||
"
|
||||
>
|
||||
<LucideHome />
|
||||
</Button>
|
||||
</div>
|
||||
</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 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') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-xl flex flex-col bg-black/10 px-3 py-2 gap-1" v-if="data?.pickup_code">
|
||||
<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 as string)
|
||||
toast.success('复制成功')
|
||||
}
|
||||
"
|
||||
>
|
||||
<LucideCopy class="size-3" />
|
||||
</Button>
|
||||
</div>
|
||||
<div class="flex flex-row gap-2">
|
||||
<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
|
||||
class="prose rounded-md bg-white/70 p-3 w-full max-w-full"
|
||||
v-html="props?.data?.text"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import AsyncButton from '@/components/ui/button/AsyncButton.vue'
|
||||
import dayjs from 'dayjs';
|
||||
import duration from 'dayjs/plugin/duration';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import { isBoolean } from 'lodash-es';
|
||||
import { LucideCheck, LucideX } from 'lucide-vue-next';
|
||||
import { useQueryClient } from '@tanstack/vue-query';
|
||||
import dayjs from 'dayjs'
|
||||
import duration from 'dayjs/plugin/duration'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { isBoolean } from 'lodash-es'
|
||||
import { LucideCheck, LucideX } from 'lucide-vue-next'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import showDrawer from '~/lib/showDrawer'
|
||||
import { toast } from 'vue-sonner'
|
||||
import PasswallShareDrawer from '~/components/Drawer/PasswallShareDrawer.vue'
|
||||
dayjs.extend(duration)
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
@@ -14,33 +17,35 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { downloadFile, getShareToken } = useMyAppShare()
|
||||
|
||||
const handleDownload = async () => {
|
||||
const { id } = props?.data || {}
|
||||
const data = await $fetch<{
|
||||
code: number
|
||||
data: {
|
||||
token?: string
|
||||
try {
|
||||
let token = null
|
||||
if (props?.data?.has_password) {
|
||||
token = await showDrawer({
|
||||
render: ({ ...rest }) => h(PasswallShareDrawer, { ...rest, share_id: id }),
|
||||
})
|
||||
} else {
|
||||
token = await getShareToken(id)
|
||||
}
|
||||
}>(`/api/download`, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
share_id: id
|
||||
if (!token) {
|
||||
throw new Error('获取token失败')
|
||||
}
|
||||
})
|
||||
const { token } = data?.data || {}
|
||||
if (!token) {
|
||||
return
|
||||
downloadFile(token)
|
||||
} catch (error: any) {
|
||||
toast.error(error?.data?.message || error?.message || error)
|
||||
} finally {
|
||||
queryClient.invalidateQueries({ queryKey: ['share', id] })
|
||||
}
|
||||
(window as any)?.open(`/api/download?token=${token}`)
|
||||
queryClient.invalidateQueries({ queryKey: ['share', id] })
|
||||
}
|
||||
|
||||
const expireSeconds = computed(() => {
|
||||
return dayjs(props?.data?.expire_at * 10e2).unix() - dayjs().unix()
|
||||
})
|
||||
|
||||
const { remaining, start} = useCountdown(expireSeconds.value)
|
||||
const { remaining, start } = useCountdown(expireSeconds.value)
|
||||
|
||||
onMounted(() => {
|
||||
start()
|
||||
@@ -49,7 +54,10 @@ onMounted(() => {
|
||||
const fileShareInfo = computed(() => {
|
||||
return [
|
||||
{ label: '需要密码', value: props?.data?.has_password ?? false },
|
||||
{ label: '过期时间', value: dayjs.duration(remaining.value, 'seconds').format(`D天 HH:mm:ss`) },
|
||||
{
|
||||
label: '过期时间',
|
||||
value: dayjs.duration(remaining.value, 'seconds').format(`D天 HH:mm:ss`),
|
||||
},
|
||||
{ label: '剩余下载次数', value: props?.data?.download_nums ?? 0 },
|
||||
]
|
||||
})
|
||||
@@ -70,4 +78,4 @@ const fileShareInfo = computed(() => {
|
||||
<AsyncButton @click="handleDownload" class="w-full">下载</AsyncButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import dayjs from 'dayjs';
|
||||
import dayjs from 'dayjs'
|
||||
import AsyncButton from '@/components/ui/button/AsyncButton.vue'
|
||||
import duration from 'dayjs/plugin/duration';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import { isBoolean } from 'lodash-es';
|
||||
import { LucideCheck, LucideX } from 'lucide-vue-next';
|
||||
import { cx } from 'class-variance-authority';
|
||||
import { toast } from 'vue-sonner';
|
||||
import duration from 'dayjs/plugin/duration'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { isBoolean } from 'lodash-es'
|
||||
import { LucideCheck, LucideX } from 'lucide-vue-next'
|
||||
import { cx } from 'class-variance-authority'
|
||||
import { toast } from 'vue-sonner'
|
||||
import MarkdownRender from '@/components/MarkdownRender.vue'
|
||||
import { Button } from '@/components/ui/button'
|
||||
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)
|
||||
|
||||
@@ -15,12 +21,16 @@ const props = defineProps<{
|
||||
data: any
|
||||
}>()
|
||||
|
||||
const { getShareToken } = useMyAppShare()
|
||||
|
||||
const expireSeconds = computed(() => {
|
||||
return dayjs(props?.data?.expire_at * 10e2).unix() - dayjs().unix()
|
||||
})
|
||||
|
||||
const { remaining, start } = useCountdown(expireSeconds.value)
|
||||
|
||||
const { copy } = useClipboard()
|
||||
|
||||
onMounted(() => {
|
||||
start()
|
||||
})
|
||||
@@ -28,7 +38,10 @@ onMounted(() => {
|
||||
const fileShareInfo = computed(() => {
|
||||
return [
|
||||
{ label: '需要密码', value: props?.data?.has_password ?? false },
|
||||
{ label: '过期时间', value: dayjs.duration(remaining.value, 'seconds').format(`D天 HH:mm:ss`) },
|
||||
{
|
||||
label: '过期时间',
|
||||
value: dayjs.duration(remaining.value, 'seconds').format(`D天 HH:mm:ss`),
|
||||
},
|
||||
{ label: '剩余浏览次数', value: props?.data?.download_nums ?? 0 },
|
||||
]
|
||||
})
|
||||
@@ -36,21 +49,13 @@ const previewText = ref<string | null>(null)
|
||||
|
||||
const handlePreview = async () => {
|
||||
try {
|
||||
const { id } = props?.data || {}
|
||||
const data = await $fetch<{
|
||||
code: number
|
||||
data: {
|
||||
token?: string
|
||||
}
|
||||
}>(`/api/download`, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
share_id: id
|
||||
}
|
||||
})
|
||||
const { token } = data?.data || {}
|
||||
if (!token) {
|
||||
return
|
||||
let token = null
|
||||
if (props?.data?.has_password) {
|
||||
token = await showDrawer({
|
||||
render: ({ ...rest }) => h(PasswallShareDrawer, { ...rest, share_id: props?.data?.id }),
|
||||
})
|
||||
} else {
|
||||
token = await getShareToken(props?.data?.id)
|
||||
}
|
||||
const r = await $fetch<{
|
||||
code: number
|
||||
@@ -59,18 +64,32 @@ const handlePreview = async () => {
|
||||
}
|
||||
}>(`/api/download?token=${token}`)
|
||||
previewText.value = r?.data?.data
|
||||
} catch (error) {
|
||||
toast.error(error?.data?.message || '获取失败')
|
||||
} catch (error: any) {
|
||||
toast.error(error?.data?.message || error?.message || error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div :class="cx('flex flex-col max-h-full', !!previewText ? 'gap-3' : 'gap-16 items-center')">
|
||||
<h1 class="text-xl">查看文本</h1>
|
||||
<div :class="cx('flex flex-row w-full', !!previewText ? 'justify-between' : 'justify-center')">
|
||||
<h1 class="text-xl">查看文本</h1>
|
||||
<Button
|
||||
v-if="!!previewText"
|
||||
variant="outline"
|
||||
size="icon"
|
||||
@click="
|
||||
() => {
|
||||
copy(previewText as string)
|
||||
toast.success('复制成功')
|
||||
}
|
||||
"
|
||||
>
|
||||
<LucideCopy />
|
||||
</Button>
|
||||
</div>
|
||||
<template v-if="!previewText">
|
||||
<div class="flex flex-col gap-2 md:flex-row w-full">
|
||||
<div class="flex flex-row md:flex-col md:gap-1 justify-between items-center md:flex-1"
|
||||
v-for="item in fileShareInfo">
|
||||
<div class="flex flex-row md:flex-col md:gap-1 justify-between items-center md:flex-1" v-for="item in fileShareInfo">
|
||||
<div class="text-xs opacity-75">{{ item?.label }}</div>
|
||||
<component v-if="isBoolean(item?.value)" :is="item?.value ? LucideCheck : LucideX" class="size-6" />
|
||||
<div v-else class="md:text-xl">{{ item?.value }}</div>
|
||||
@@ -84,4 +103,4 @@ const handlePreview = async () => {
|
||||
<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,6 +0,0 @@
|
||||
const useAppConfig = () => {
|
||||
const { data } = useFetch('/config')
|
||||
return data
|
||||
}
|
||||
|
||||
export default useAppConfig
|
||||
6
front/composables/useMyAppConfig.ts
Normal file
6
front/composables/useMyAppConfig.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
const useMyAppConfig = () => {
|
||||
const { data } = useFetch("/config");
|
||||
return data;
|
||||
};
|
||||
|
||||
export default useMyAppConfig;
|
||||
109
front/composables/useMyAppShare.ts
Normal file
109
front/composables/useMyAppShare.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import { toast } from 'vue-sonner'
|
||||
declare const window: any
|
||||
let shareIdTokenMap: WeakMap<{ share_id: string }, string>
|
||||
|
||||
const getShareToken = async (
|
||||
share_id: string,
|
||||
options?: {
|
||||
password?: string
|
||||
}
|
||||
): Promise<string | undefined> => {
|
||||
if (!shareIdTokenMap) {
|
||||
shareIdTokenMap = new WeakMap()
|
||||
}
|
||||
let token = shareIdTokenMap.get({ share_id })
|
||||
const { password } = options || {}
|
||||
if (!token) {
|
||||
const data = await $fetch<{
|
||||
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)
|
||||
}
|
||||
return token
|
||||
}
|
||||
|
||||
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) => {
|
||||
return await $fetch<{
|
||||
code: number
|
||||
data: {
|
||||
id?: string
|
||||
download_nums?: number
|
||||
expire_at?: number
|
||||
file_name?: string
|
||||
pickup_code?: string
|
||||
}
|
||||
}>(`/api/share`, {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
})
|
||||
}
|
||||
|
||||
const createFileShare = async (data: {
|
||||
file_id: string
|
||||
config: {
|
||||
download_nums: number
|
||||
expire_time: number
|
||||
has_pickup_code?: boolean
|
||||
has_password?: boolean
|
||||
pickup_code?: string
|
||||
password?: string
|
||||
notify_email?: string
|
||||
}
|
||||
file_name: string
|
||||
}) => {
|
||||
const { file_id, config, file_name } = data || {}
|
||||
return await createShare({
|
||||
type: 'file',
|
||||
data: file_id,
|
||||
config,
|
||||
file_name,
|
||||
})
|
||||
}
|
||||
|
||||
const createTextShare = async (data: { text: string; config: any }) => {
|
||||
const { text, config } = data || {}
|
||||
return await createShare({
|
||||
type: 'text',
|
||||
data: text,
|
||||
config,
|
||||
})
|
||||
}
|
||||
|
||||
const useMyAppShare = () => {
|
||||
return {
|
||||
downloadFile,
|
||||
downloadFileByShareId,
|
||||
createShare,
|
||||
createFileShare,
|
||||
createTextShare,
|
||||
getShareToken,
|
||||
}
|
||||
}
|
||||
|
||||
export default useMyAppShare
|
||||
@@ -4,23 +4,45 @@ type UseSeoProps = {
|
||||
}
|
||||
const useSeo = async (props: UseSeoProps = {}) => {
|
||||
const { head, seo } = props || {}
|
||||
const { data } = await useFetch<any>('/config')
|
||||
const seoMeta = computed(() => data.value?.data)
|
||||
const { title } = head || {}
|
||||
useHead({
|
||||
...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: seoMeta?.value?.site_url,
|
||||
// twitterCard: 'summary_large_image',
|
||||
})
|
||||
const seoMeta = ref<any>()
|
||||
if (import.meta.server) {
|
||||
const { SITE_TITLE, SITE_DESC, SITE_URL } = process.env || {}
|
||||
seoMeta.value = {
|
||||
site_title: SITE_TITLE,
|
||||
site_desc: SITE_DESC,
|
||||
site_url: SITE_URL,
|
||||
}
|
||||
const { title } = head || {}
|
||||
useHead({
|
||||
link: [
|
||||
{ rel: 'icon', href: '/logo.png', sizes: 'any' },
|
||||
// { rel: 'icon', href: '/favicon.svg', sizes: 'any', type: 'image/svg+xml' },
|
||||
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/logo.png' },
|
||||
],
|
||||
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
|
||||
}
|
||||
|
||||
export default useSeo
|
||||
export default useSeo
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
const downloadFile = async (share_id: string) => {
|
||||
const data = await $fetch<{
|
||||
code: number;
|
||||
data: {
|
||||
token?: string;
|
||||
};
|
||||
}>(`/api/download`, {
|
||||
method: "POST",
|
||||
body: {
|
||||
share_id,
|
||||
},
|
||||
});
|
||||
const { token } = data?.data || {};
|
||||
if (!token) {
|
||||
return;
|
||||
}
|
||||
(window as any)?.open(`/api/download?token=${token}`);
|
||||
};
|
||||
|
||||
const createShare = async (data: any) => {
|
||||
return await $fetch<{
|
||||
code: number;
|
||||
data: {
|
||||
id?: string;
|
||||
};
|
||||
}>(`/api/share`, {
|
||||
method: "POST",
|
||||
body: data,
|
||||
});
|
||||
};
|
||||
|
||||
const createFileShare = async (data: {
|
||||
file_id: string;
|
||||
config: {
|
||||
download_nums: number;
|
||||
expire_time: number;
|
||||
has_pickup_code?: boolean;
|
||||
has_password?: boolean;
|
||||
pickup_code?: string;
|
||||
password?: string;
|
||||
notify_email?: string;
|
||||
};
|
||||
file_name: string;
|
||||
}) => {
|
||||
const { file_id, config, file_name } = data || {};
|
||||
return await createShare({
|
||||
type: "file",
|
||||
data: file_id,
|
||||
config,
|
||||
file_name,
|
||||
});
|
||||
};
|
||||
|
||||
const createTextShare = async (data: { text: string; config: any }) => {
|
||||
const { text, config } = data || {};
|
||||
return await createShare({
|
||||
type: "text",
|
||||
data: text,
|
||||
config,
|
||||
});
|
||||
};
|
||||
|
||||
const useAppShare = () => {
|
||||
return {
|
||||
downloadFile,
|
||||
createShare,
|
||||
createFileShare,
|
||||
createTextShare,
|
||||
};
|
||||
};
|
||||
|
||||
export default useAppShare;
|
||||
@@ -1,35 +1,34 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { cloneDeep, get, isEmpty, isUndefined, set,isString } from 'lodash-es'
|
||||
import { cloneDeep, get, isEmpty, isUndefined, set, isString } from 'lodash-es'
|
||||
|
||||
type StoreType = Record<string, any>
|
||||
|
||||
const initState: StoreType = {}
|
||||
// 做了一点小小的改进,可以传入key,会自动初始化,如果不初始化的话容易导致不存在值而丢失响应式
|
||||
const useStore = (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 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)
|
||||
},
|
||||
},
|
||||
})()
|
||||
if (!isEmpty(key) && isString(key) && isUndefined(store?._get(key))) {
|
||||
// console.log('reset', key, store?._get(key))
|
||||
store?._set(key, null)
|
||||
}
|
||||
return store
|
||||
}
|
||||
|
||||
export default useStore
|
||||
|
||||
24
front/error.vue
Normal file
24
front/error.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import type { NuxtError } from "#app";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps({
|
||||
error: Object as () => NuxtError,
|
||||
});
|
||||
|
||||
const handleError = () => clearError({ redirect: "/" });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NuxtLayout>
|
||||
<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"
|
||||
>
|
||||
<div class="font-bold text-5xl">{{ error?.statusCode }}</div>
|
||||
<Button @click="handleError">{{ t("btn.backToHome") }}</Button>
|
||||
</div>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
@@ -10,7 +10,8 @@
|
||||
"desc": "015 is a temporary file sharing platform project, supporting temporary large file slicing upload, temporary text upload, download and share"
|
||||
},
|
||||
"btn": {
|
||||
"submit": "Submit"
|
||||
"submit": "Submit",
|
||||
"backToHome": "Back to Home"
|
||||
},
|
||||
"file": {
|
||||
"uploadFile": "Upload File",
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"desc": "015 是一个开源的临时文件分享平台项目,支持临时大文件切片上传,临时文本上传、下载、分享"
|
||||
},
|
||||
"btn": {
|
||||
"submit": "提交"
|
||||
"submit": "提交",
|
||||
"backToHome": "返回首页"
|
||||
},
|
||||
"file": {
|
||||
"uploadFile": "上传文件",
|
||||
|
||||
@@ -8,7 +8,7 @@ await useSeo();
|
||||
<Toaster position="top-center" richColors closeButton />
|
||||
<img
|
||||
class="w-full h-full object-cover absolute inset-0 -z-[1]"
|
||||
src="https://fuwari.vercel.app/_astro/demo-banner.DFyx781H_Z1gN7UP.webp"
|
||||
src="https://img.fudaoyuan.icu/api/1/random/?scale_min=1.5&webp=true&md=false&format=302"
|
||||
/>
|
||||
<div
|
||||
class="h-full w-full flex flex-col items-center lg:p-10 p-5 overflow-y-auto"
|
||||
|
||||
14
front/lib/asyncWorker.ts
Normal file
14
front/lib/asyncWorker.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
const asyncWorker = (w: new () => Worker, opts: { data: any }) => {
|
||||
const { data } = opts || {}
|
||||
return new Promise<MessageEvent>((resolve, reject) => {
|
||||
const worker = new w()
|
||||
worker.postMessage(data || {})
|
||||
worker.onmessage = (e: MessageEvent) => {
|
||||
resolve(e)
|
||||
}
|
||||
worker.onerror = (e: ErrorEvent) => {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
export default asyncWorker
|
||||
@@ -1,44 +1,47 @@
|
||||
import SparkMD5 from 'spark-md5';
|
||||
import { noop } from 'lodash-es';
|
||||
import { noop } from 'lodash-es'
|
||||
import { md5 } from 'js-md5'
|
||||
|
||||
interface CalcFileHashProps {
|
||||
file: File;
|
||||
onProgress?: (current: number) => void;
|
||||
chunkSize?: number;
|
||||
file: File
|
||||
onProgress?: (current: number) => void
|
||||
chunkSize?: number
|
||||
}
|
||||
|
||||
const calcFileHash = async (props: CalcFileHashProps) => {
|
||||
const { file, onProgress = noop, chunkSize = 100 } = props || {};
|
||||
const finalChunkSize = chunkSize * 1024 * 1024;
|
||||
const chunks = Math.ceil(file.size / finalChunkSize);
|
||||
const spark = new SparkMD5.ArrayBuffer(); // 使用 SparkMD5 增量计算哈希
|
||||
const fileReader = new FileReader();
|
||||
const { file, onProgress = noop, chunkSize = 100 } = props || {}
|
||||
const blob = await file.arrayBuffer()
|
||||
const hash = md5(blob)
|
||||
return hash
|
||||
// const finalChunkSize = chunkSize * 1024 * 1024;
|
||||
// const chunks = Math.ceil(file.size / finalChunkSize);
|
||||
// const spark = new SparkMD5.ArrayBuffer(); // 使用 SparkMD5 增量计算哈希
|
||||
// const fileReader = new FileReader();
|
||||
|
||||
const readChunk = (start: number): Promise<ArrayBuffer> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunk = file.slice(start, start + finalChunkSize);
|
||||
fileReader.onload = (e) => resolve(e.target?.result as ArrayBuffer);
|
||||
fileReader.onerror = reject;
|
||||
fileReader.readAsArrayBuffer(chunk);
|
||||
});
|
||||
};
|
||||
// const readChunk = (start: number): Promise<ArrayBuffer> => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const chunk = file.slice(start, Math.min(start + finalChunkSize, file.size));
|
||||
// fileReader.onload = (e) => resolve(e.target?.result as ArrayBuffer);
|
||||
// fileReader.onerror = reject;
|
||||
// fileReader.readAsArrayBuffer(chunk);
|
||||
// });
|
||||
// };
|
||||
|
||||
try {
|
||||
const progressCallback = (current: number) => {
|
||||
const percentage = Math.round((current / chunks) * 100);
|
||||
onProgress(percentage);
|
||||
};
|
||||
// try {
|
||||
// const progressCallback = (current: number) => {
|
||||
// const percentage = Math.round((current / chunks) * 100);
|
||||
// onProgress(percentage);
|
||||
// };
|
||||
|
||||
for (let i = 0; i < chunks; i++) {
|
||||
const chunk = await readChunk(i * chunkSize);
|
||||
spark.append(chunk);
|
||||
progressCallback(i + 1);
|
||||
}
|
||||
// for (let i = 0; i < chunks; i++) {
|
||||
// const chunk = await readChunk(i * chunkSize);
|
||||
// spark.append(chunk);
|
||||
// progressCallback(i + 1);
|
||||
// }
|
||||
|
||||
return spark.end();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
// return spark.end();
|
||||
// } catch (error) {
|
||||
// throw error;
|
||||
// }
|
||||
}
|
||||
|
||||
export default calcFileHash;
|
||||
export default calcFileHash
|
||||
|
||||
8
front/lib/calcFileHashWorker.ts
Normal file
8
front/lib/calcFileHashWorker.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import calcFileHash from './calcFileHash'
|
||||
|
||||
// 监听主线程消息
|
||||
self.onmessage = async (e: MessageEvent<{ file: File }>) => {
|
||||
const { file } = e.data || {}
|
||||
const hash = await calcFileHash({ file })
|
||||
self.postMessage({ hash })
|
||||
}
|
||||
@@ -1,11 +1,21 @@
|
||||
interface DrawerProps {
|
||||
render: (props: { hide: () => void }) => Component
|
||||
render: (props: { hide: () => void }) => Component
|
||||
}
|
||||
|
||||
const showDrawer = (props: DrawerProps) => {
|
||||
const { render } = props || {}
|
||||
const store = useStore()
|
||||
store?._set('drawer', [...(store?._get('drawer')?.value || []), { render }])
|
||||
const key = Math.random().toString(36).slice(2, 8)
|
||||
return new Promise<void>((res) => {
|
||||
const { render } = props || {}
|
||||
const onClose = (data?: any) => {
|
||||
store._set(
|
||||
'drawer',
|
||||
(store._get('drawer')?.value ?? [])?.filter((item: any) => item.key !== key)
|
||||
)
|
||||
res(data)
|
||||
}
|
||||
const store = useStore()
|
||||
store._set('drawer', [...(store._get('drawer')?.value || []), { render, onClose, key }])
|
||||
})
|
||||
}
|
||||
|
||||
export default showDrawer
|
||||
|
||||
@@ -3,7 +3,7 @@ import tailwindcss from "@tailwindcss/vite";
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: "2024-04-03",
|
||||
devtools: { enabled: true },
|
||||
css: ["~/assets/css/main.css"],
|
||||
css: ["@/assets/css/main.css"],
|
||||
modules: [
|
||||
// '@serwist/nuxt',
|
||||
"@vueuse/nuxt",
|
||||
@@ -35,7 +35,6 @@ export default defineNuxtConfig({
|
||||
},
|
||||
},
|
||||
devServer: {
|
||||
port: parseInt(process.env.PORT || "5000"),
|
||||
host: process.env.HOST || "0.0.0.0",
|
||||
port: 5000,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,71 +1,71 @@
|
||||
{
|
||||
"name": "015-front",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxt/image": "1.10.0",
|
||||
"@nuxtjs/i18n": "9.5.5",
|
||||
"@pinia/nuxt": "^0.11.0",
|
||||
"@tailwindcss/postcss": "^4.1.3",
|
||||
"@tailwindcss/vite": "^4.1.3",
|
||||
"@tanstack/vue-query": "^5.76.0",
|
||||
"@tiptap/extension-blockquote": "^2.11.7",
|
||||
"@tiptap/extension-bold": "^2.11.7",
|
||||
"@tiptap/extension-heading": "^2.11.7",
|
||||
"@tiptap/extension-italic": "^2.11.7",
|
||||
"@tiptap/extension-paragraph": "^2.11.7",
|
||||
"@tiptap/extension-placeholder": "^2.11.7",
|
||||
"@tiptap/extension-strike": "^2.11.7",
|
||||
"@tiptap/extension-text": "^2.11.7",
|
||||
"@tiptap/pm": "^2.11.7",
|
||||
"@tiptap/starter-kit": "^2.11.7",
|
||||
"@tiptap/vue-3": "^2.11.7",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/spark-md5": "^3.0.5",
|
||||
"@unovis/ts": "^1.5.1",
|
||||
"@unovis/vue": "^1.5.1",
|
||||
"@vee-validate/nuxt": "^4.15.0",
|
||||
"@vee-validate/rules": "^4.15.0",
|
||||
"axios": "^1.8.4",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"dayjs": "^1.11.13",
|
||||
"filesize": "^10.1.6",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lucide-vue-next": "^0.487.0",
|
||||
"markdown-it": "^14.1.0",
|
||||
"motion-v": "1.0.0-beta.2",
|
||||
"nuxt": "^3.16.0",
|
||||
"nuxt-lucide-icons": "1.0.5",
|
||||
"reka-ui": "^2.2.0",
|
||||
"shadcn-nuxt": "2.0.1",
|
||||
"spark-md5": "^3.0.2",
|
||||
"tailwind-merge": "^3.2.0",
|
||||
"tailwindcss": "^4.1.3",
|
||||
"tiptap-markdown": "^0.8.10",
|
||||
"tw-animate-css": "^1.2.5",
|
||||
"vaul-vue": "^0.4.1",
|
||||
"vue": "latest",
|
||||
"vue-router": "latest",
|
||||
"vue-sonner": "^1.3.2"
|
||||
},
|
||||
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
|
||||
"devDependencies": {
|
||||
"@nuxtjs/tailwindcss": "^6.13.2",
|
||||
"@serwist/build": "^9.0.12",
|
||||
"@serwist/nuxt": "^9.0.12",
|
||||
"@serwist/vite": "^9.0.12",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"@vueuse/core": "^13.0.0",
|
||||
"@vueuse/nuxt": "^13.0.0",
|
||||
"serwist": "^9.0.12"
|
||||
}
|
||||
"name": "015-front",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxt/image": "1.10.0",
|
||||
"@nuxtjs/i18n": "9.5.5",
|
||||
"@pinia/nuxt": "^0.11.0",
|
||||
"@tailwindcss/postcss": "^4.1.3",
|
||||
"@tailwindcss/vite": "^4.1.3",
|
||||
"@tanstack/vue-query": "^5.76.0",
|
||||
"@tiptap/extension-blockquote": "^2.11.7",
|
||||
"@tiptap/extension-bold": "^2.11.7",
|
||||
"@tiptap/extension-heading": "^2.11.7",
|
||||
"@tiptap/extension-italic": "^2.11.7",
|
||||
"@tiptap/extension-paragraph": "^2.11.7",
|
||||
"@tiptap/extension-placeholder": "^2.11.7",
|
||||
"@tiptap/extension-strike": "^2.11.7",
|
||||
"@tiptap/extension-text": "^2.11.7",
|
||||
"@tiptap/pm": "^2.11.7",
|
||||
"@tiptap/starter-kit": "^2.11.7",
|
||||
"@tiptap/vue-3": "^2.11.7",
|
||||
"@unovis/ts": "^1.5.1",
|
||||
"@unovis/vue": "^1.5.1",
|
||||
"@vee-validate/nuxt": "^4.15.0",
|
||||
"@vee-validate/rules": "^4.15.0",
|
||||
"axios": "^1.8.4",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"dayjs": "^1.11.13",
|
||||
"filesize": "^10.1.6",
|
||||
"js-md5": "^0.8.3",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lucide-vue-next": "^0.487.0",
|
||||
"markdown-it": "^14.1.0",
|
||||
"motion-v": "1.0.0-beta.2",
|
||||
"nuxt": "^3.17.4",
|
||||
"nuxt-lucide-icons": "1.0.5",
|
||||
"pinia": "^3.0.2",
|
||||
"qrcode": "^1.5.4",
|
||||
"reka-ui": "^2.2.0",
|
||||
"shadcn-nuxt": "2.0.1",
|
||||
"spark-md5": "^3.0.2",
|
||||
"tailwind-merge": "^3.2.0",
|
||||
"tailwindcss": "^4.1.3",
|
||||
"tiptap-markdown": "^0.8.10",
|
||||
"tw-animate-css": "^1.2.5",
|
||||
"vaul-vue": "^0.4.1",
|
||||
"vue": "^3.5.16",
|
||||
"vue-router": "^4.5.1",
|
||||
"vue-sonner": "^1.3.2"
|
||||
},
|
||||
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
|
||||
"devDependencies": {
|
||||
"@nuxtjs/tailwindcss": "^6.13.2",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"@types/qrcode": "^1.5.5",
|
||||
"@types/spark-md5": "^3.0.5",
|
||||
"@vueuse/core": "^13.0.0",
|
||||
"@vueuse/nuxt": "^13.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,239 +1,213 @@
|
||||
<script setup lang="ts">
|
||||
import { CurveType } from "@unovis/ts";
|
||||
import { AreaChart } from "@/components/ui/chart-area";
|
||||
import { cx } from "class-variance-authority";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import AboutChartTooltip from "@/components/AboutChartTooltip.vue";
|
||||
import { filesize } from "filesize";
|
||||
import SparkMD5 from "spark-md5";
|
||||
import { CurveType } from '@unovis/ts'
|
||||
import { AreaChart } from '@/components/ui/chart-area'
|
||||
import { cx } from 'class-variance-authority'
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import AboutChartTooltip from '@/components/AboutChartTooltip.vue'
|
||||
import { filesize } from 'filesize'
|
||||
import SparkMD5 from 'spark-md5'
|
||||
import useMyAppConfig from '@/composables/useMyAppConfig'
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import Progress from '~/components/ui/progress/Progress.vue'
|
||||
|
||||
const appConfig = useAppConfig();
|
||||
const { site_title, site_desc } = appConfig.value || {};
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
const appConfig = useMyAppConfig()
|
||||
const { site_title, site_desc } = appConfig.value || {}
|
||||
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ["stat"],
|
||||
queryFn: async () => {
|
||||
const data = await $fetch<{ data: any }>("/api/stat");
|
||||
return data.data;
|
||||
},
|
||||
});
|
||||
queryKey: ['stat'],
|
||||
queryFn: async () => {
|
||||
const data = await $fetch<{ data: any }>('/api/stat')
|
||||
return data.data
|
||||
},
|
||||
})
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t } = useI18n()
|
||||
|
||||
const chartTabs = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: t("about.file"),
|
||||
value: "storage",
|
||||
total:
|
||||
data.value?.chart?.storage?.reduce(
|
||||
(acc: number, curr: { file_size: number; file_num: number }) =>
|
||||
acc + curr.file_num,
|
||||
0,
|
||||
) ?? 0,
|
||||
},
|
||||
{
|
||||
label: t("about.task"),
|
||||
value: "queue",
|
||||
total:
|
||||
data.value?.chart?.queue?.reduce(
|
||||
(acc: number, curr: { processed: number; failed: number }) =>
|
||||
acc + curr.processed + curr.failed,
|
||||
0,
|
||||
) ?? 0,
|
||||
},
|
||||
];
|
||||
});
|
||||
return [
|
||||
{
|
||||
label: t('about.file'),
|
||||
value: 'storage',
|
||||
total: data.value?.chart?.storage?.reduce((acc: number, curr: { file_size: number; file_num: number }) => acc + curr.file_num, 0) ?? 0,
|
||||
},
|
||||
{
|
||||
label: t('about.task'),
|
||||
value: 'queue',
|
||||
total:
|
||||
data.value?.chart?.queue?.reduce(
|
||||
(acc: number, curr: { processed: number; failed: number }) => acc + curr.processed + curr.failed,
|
||||
0
|
||||
) ?? 0,
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const currentFileSize = computed(() => {
|
||||
return (
|
||||
data.value?.chart?.storage?.reduce(
|
||||
(acc: number, curr: { file_size: number; file_num: number }) =>
|
||||
acc + curr.file_size,
|
||||
0,
|
||||
) ?? 0
|
||||
);
|
||||
});
|
||||
return data.value?.chart?.storage?.reduce((acc: number, curr: { file_size: number; file_num: number }) => acc + curr.file_size, 0) ?? 0
|
||||
})
|
||||
|
||||
const currentChartTab = ref<"storage" | "queue">("storage");
|
||||
const currentChartTab = ref<'storage' | 'queue'>('storage')
|
||||
const currentChartData = computed(() => {
|
||||
const { storage, queue } = data.value?.chart || {};
|
||||
if (currentChartTab.value === "storage") {
|
||||
const { storage, queue } = data.value?.chart || {}
|
||||
if (currentChartTab.value === 'storage') {
|
||||
return {
|
||||
data: storage,
|
||||
index: 'date',
|
||||
categories: ['file_size', 'file_num'],
|
||||
colors: ['#22d3ee', '#c084fc'],
|
||||
}
|
||||
}
|
||||
return {
|
||||
data: storage,
|
||||
index: "date",
|
||||
categories: ["file_size", "file_num"],
|
||||
colors: ["#22d3ee", "#c084fc"],
|
||||
};
|
||||
}
|
||||
return {
|
||||
data: queue,
|
||||
index: "date",
|
||||
categories: ["processed", "failed"],
|
||||
colors: ["#4ade80", "#f87171"],
|
||||
};
|
||||
});
|
||||
data: queue,
|
||||
index: 'date',
|
||||
categories: ['processed', 'failed'],
|
||||
colors: ['#4ade80', '#f87171'],
|
||||
}
|
||||
})
|
||||
|
||||
const genUserAvatar = ({ email }: { email: string }) => {
|
||||
if (!email) {
|
||||
return "/logo.png";
|
||||
}
|
||||
return `https://www.gravatar.com/avatar/${SparkMD5.hash(email)}?d=retro`;
|
||||
};
|
||||
if (!email) {
|
||||
return '/logo.png'
|
||||
}
|
||||
return `https://www.gravatar.com/avatar/${SparkMD5.hash(email)}?d=retro`
|
||||
}
|
||||
|
||||
const handleUserClick = ({ url, email }: { url: string; email: string }) => {
|
||||
if (url) {
|
||||
return navigateTo(url, { external: true });
|
||||
}
|
||||
if (email) {
|
||||
return navigateTo(`mailto:${email}`, { external: true });
|
||||
}
|
||||
return null;
|
||||
};
|
||||
if (url) {
|
||||
return navigateTo(url, { external: true })
|
||||
}
|
||||
if (email) {
|
||||
return navigateTo(`mailto:${email}`, { external: true })
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const users = computed(() => {
|
||||
const { email, name, url } = data.value?.admin || {};
|
||||
return [
|
||||
...(!!name
|
||||
? [
|
||||
{
|
||||
title: t("about.admin"),
|
||||
email,
|
||||
name,
|
||||
url: url ?? (email ? `mailto:${email}` : null),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
title: t("about.author"),
|
||||
name: "keven1024",
|
||||
email: "keven@fudaoyuan.icu",
|
||||
url: "https://github.com/keven1024",
|
||||
},
|
||||
];
|
||||
});
|
||||
const { email, name, url } = data.value?.admin || {}
|
||||
return [
|
||||
...(!!name
|
||||
? [
|
||||
{
|
||||
title: t('about.admin'),
|
||||
email,
|
||||
name,
|
||||
url: url ?? (email ? `mailto:${email}` : null),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
title: t('about.author'),
|
||||
name: 'keven1024',
|
||||
email: 'keven@fudaoyuan.icu',
|
||||
url: 'https://github.com/keven1024',
|
||||
},
|
||||
]
|
||||
})
|
||||
</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"
|
||||
>
|
||||
<div class="text-xl font-normal">{{ t("about.title") }}</div>
|
||||
<div class="flex flex-col gap-2 items-center">
|
||||
<NuxtImg src="/logo.png" class="size-20 rounded-xl" />
|
||||
<div class="text-xl">{{ site_title ?? "015" }}</div>
|
||||
<div class="text-sm opacity-75 text-center px-5">
|
||||
{{ site_desc ?? t("seo.desc") }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="font-semibold">{{ t("about.systemInfo") }}</div>
|
||||
<template v-if="isLoading">
|
||||
<div class="flex flex-row gap-2">
|
||||
<Skeleton class="w-full h-20 rounded-xl" v-for="i in 2" :key="i" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="rounded-xl bg-white/50 flex-1 flex flex-col p-3">
|
||||
<div class="opacity-75 text-xs">{{ t("about.systemVersion") }}</div>
|
||||
<div class="text-xl font-semibold">
|
||||
{{ data?.version ?? "dev" }}
|
||||
</div>
|
||||
</div>
|
||||
<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="text-right flex flex-row items-baseline">
|
||||
<span class="text-lg font-semibold">{{
|
||||
filesize(currentFileSize ?? 0)
|
||||
}}</span>
|
||||
<span class="text-md opacity-75"
|
||||
>/ {{ filesize(data?.max_limit?.file_size ?? 0) }}</span
|
||||
>
|
||||
</div>
|
||||
<div class="rounded-full w-full h-1 bg-black/10">
|
||||
<div
|
||||
class="rounded-full h-full bg-blue-500"
|
||||
:style="{
|
||||
width: `${(currentFileSize / (data?.max_limit?.file_size ?? 0)) * 100}%`,
|
||||
}"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="font-semibold">{{ t("about.analysis") }}</div>
|
||||
<template v-if="isLoading">
|
||||
<div class="flex flex-row gap-2">
|
||||
<Skeleton class="w-full h-96 rounded-xl" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="flex flex-col gap-2 bg-white/50 w-full rounded-xl py-5">
|
||||
<div class="flex flex-row gap-2 px-5">
|
||||
<div
|
||||
:class="
|
||||
cx(
|
||||
'rounded-md min-w-30 flex flex-col px-3 py-1.5 cursor-pointer',
|
||||
currentChartTab === tab.value && 'bg-black/10',
|
||||
)
|
||||
"
|
||||
v-for="tab in chartTabs"
|
||||
:key="tab.value"
|
||||
@click="
|
||||
() => {
|
||||
currentChartTab = tab.value as 'storage' | 'queue';
|
||||
}
|
||||
"
|
||||
>
|
||||
<div class="opacity-75 text-xs">{{ tab.label }}</div>
|
||||
<div class="text-lg font-semibold">{{ tab.total }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<AreaChart
|
||||
v-if="currentChartData"
|
||||
class="h-64 w-full"
|
||||
:key="currentChartTab"
|
||||
:index="currentChartData.index"
|
||||
:data="currentChartData.data"
|
||||
:categories="currentChartData.categories"
|
||||
:show-grid-line="false"
|
||||
:show-legend="false"
|
||||
:show-y-axis="true"
|
||||
:show-x-axis="true"
|
||||
:colors="currentChartData.colors"
|
||||
:custom-tooltip="AboutChartTooltip"
|
||||
:curve-type="CurveType.CatmullRom"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="isLoading">
|
||||
<div class="flex flex-row gap-2">
|
||||
<Skeleton class="w-full h-20 rounded-xl" v-for="i in 2" :key="i" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<div class="flex flex-col gap-3" v-for="user in users" :key="user.name">
|
||||
<div class="font-semibold">{{ user.title }}</div>
|
||||
<div
|
||||
class="rounded-xl bg-white/50 hover:bg-white/40 flex-1 flex flex-row items-center gap-2 p-3 cursor-pointer"
|
||||
@click="
|
||||
() => {
|
||||
handleUserClick(user);
|
||||
}
|
||||
"
|
||||
>
|
||||
<div class="size-10 rounded-full bg-white/50">
|
||||
<NuxtImg
|
||||
:src="genUserAvatar(user)"
|
||||
class="size-full rounded-full"
|
||||
/>
|
||||
<div class="rounded-xl p-5 bg-white/50 backdrop-blur-xl w-full lg:w-200 my-5 flex flex-col gap-5">
|
||||
<div class="text-xl font-normal">{{ t('about.title') }}</div>
|
||||
<div class="flex flex-col gap-2 items-center">
|
||||
<NuxtImg src="/logo.png" class="size-20 rounded-xl" />
|
||||
<div class="text-xl">{{ site_title ?? '015' }}</div>
|
||||
<div class="text-sm opacity-75 text-center px-5">
|
||||
{{ site_desc ?? t('seo.desc') }}
|
||||
</div>
|
||||
<div class="text-md font-semibold">{{ user.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="font-semibold">{{ t('about.systemInfo') }}</div>
|
||||
<template v-if="isLoading">
|
||||
<div class="flex flex-row gap-2">
|
||||
<Skeleton class="w-full h-20 rounded-xl" v-for="i in 2" :key="i" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="rounded-xl bg-white/50 flex-1 flex flex-col p-3">
|
||||
<div class="opacity-75 text-xs">{{ t('about.systemVersion') }}</div>
|
||||
<div class="text-xl font-semibold flex items-center gap-1">
|
||||
{{ data?.version ?? 'dev' }}
|
||||
<span class="text-xs px-2 py-0.5 rounded bg-primary/20 text-primary">{{ dayjs(data?.build_time * 1000).fromNow() }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<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="text-right flex flex-row items-baseline">
|
||||
<span class="text-lg font-semibold">{{ filesize(currentFileSize ?? 0) }}</span>
|
||||
<span class="text-md opacity-75">/ {{ filesize(data?.max_limit?.file_size ?? 0) }}</span>
|
||||
</div>
|
||||
<Progress class="h-1" :model-value="(currentFileSize / (data?.max_limit?.file_size ?? 0)) * 100" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="font-semibold">{{ t('about.analysis') }}</div>
|
||||
<template v-if="isLoading">
|
||||
<div class="flex flex-row gap-2">
|
||||
<Skeleton class="w-full h-96 rounded-xl" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="flex flex-col gap-2 bg-white/50 w-full rounded-xl py-5">
|
||||
<div class="flex flex-row gap-2 px-5">
|
||||
<div
|
||||
:class="cx('rounded-md min-w-30 flex flex-col px-3 py-1.5 cursor-pointer', currentChartTab === tab.value && 'bg-black/10')"
|
||||
v-for="tab in chartTabs"
|
||||
:key="tab.value"
|
||||
@click="
|
||||
() => {
|
||||
currentChartTab = tab.value as 'storage' | 'queue'
|
||||
}
|
||||
"
|
||||
>
|
||||
<div class="opacity-75 text-xs">{{ tab.label }}</div>
|
||||
<div class="text-lg font-semibold">{{ tab.total }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<AreaChart
|
||||
v-if="currentChartData"
|
||||
class="h-64 w-full"
|
||||
:key="currentChartTab"
|
||||
:index="currentChartData.index"
|
||||
:data="currentChartData.data"
|
||||
:categories="currentChartData.categories"
|
||||
:show-grid-line="false"
|
||||
:show-legend="false"
|
||||
:show-y-axis="true"
|
||||
:show-x-axis="true"
|
||||
:colors="currentChartData.colors"
|
||||
:custom-tooltip="AboutChartTooltip"
|
||||
:curve-type="CurveType.CatmullRom"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="isLoading">
|
||||
<div class="flex flex-row gap-2">
|
||||
<Skeleton class="w-full h-20 rounded-xl" v-for="i in 2" :key="i" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<div class="flex flex-col gap-3" v-for="user in users" :key="user.name">
|
||||
<div class="font-semibold">{{ user.title }}</div>
|
||||
<div
|
||||
class="rounded-xl bg-white/50 hover:bg-white/40 flex-1 flex flex-row items-center gap-2 p-3 cursor-pointer"
|
||||
@click="
|
||||
() => {
|
||||
handleUserClick(user)
|
||||
}
|
||||
"
|
||||
>
|
||||
<div class="size-10 rounded-full bg-white/50">
|
||||
<NuxtImg :src="genUserAvatar(user)" class="size-full rounded-full" />
|
||||
</div>
|
||||
<div class="text-md font-semibold">{{ user.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
@@ -9,7 +9,6 @@
|
||||
"dev:backend": "cd backend && air",
|
||||
"dev:worker": "cd worker && air",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"postinstall": "npx husky init",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"workspaces": [
|
||||
|
||||
4457
pnpm-lock.yaml
generated
4457
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user