mirror of
https://github.com/vastsa/FileCodeBox.git
synced 2026-11-24 08:07:01 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3344f471e3 | ||
|
|
c8ac6bb76b | ||
|
|
e66e668616 | ||
|
|
c3022bff78 | ||
|
|
f070bdcece | ||
|
|
58e8407e7d | ||
|
|
5462584188 | ||
|
|
143d4794bc | ||
|
|
58c1d3d44b | ||
|
|
757e8ec16a | ||
|
|
2fc95ebc7e | ||
|
|
64f476e6db | ||
|
|
0d5e26f752 | ||
|
|
b33671a018 | ||
|
|
56cf08ccd1 | ||
|
|
f4089877ed | ||
|
|
248e6b8292 | ||
|
|
ab3971f911 | ||
|
|
6c07f9a5ab | ||
|
|
f94a918253 | ||
|
|
eec2ec6354 | ||
|
|
330b34953d | ||
|
|
0433507a9c | ||
|
|
63105579f7 | ||
|
|
255a2149b0 | ||
|
|
0b12aad4eb | ||
|
|
7767ade2f3 | ||
|
|
c15bf9563c | ||
|
|
99529b69ee | ||
|
|
d6029e4899 | ||
|
|
14b6f0e9a7 |
No files matched your search
+1
-4
@@ -16,11 +16,8 @@ async def admin_required(pwd: Union[str, None] = Header(default=None), request:
|
|||||||
|
|
||||||
|
|
||||||
class IPRateLimit:
|
class IPRateLimit:
|
||||||
ips = {}
|
|
||||||
count = 0
|
|
||||||
minutes = 0
|
|
||||||
|
|
||||||
def __init__(self, count, minutes):
|
def __init__(self, count, minutes):
|
||||||
|
self.ips = {}
|
||||||
self.count = count
|
self.count = count
|
||||||
self.minutes = minutes
|
self.minutes = minutes
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
@@ -41,8 +41,8 @@ index_html = open('templates/index.html', 'r', encoding='utf-8').read() \
|
|||||||
.replace('{{title}}', settings.TITLE) \
|
.replace('{{title}}', settings.TITLE) \
|
||||||
.replace('{{description}}', settings.DESCRIPTION) \
|
.replace('{{description}}', settings.DESCRIPTION) \
|
||||||
.replace('{{keywords}}', settings.KEYWORDS) \
|
.replace('{{keywords}}', settings.KEYWORDS) \
|
||||||
.replace("'{{fileSizeLimit}}'", str(settings.FILE_SIZE_LIMIT))
|
.replace("'{{fileSizeLimit}}'", str(settings.FILE_SIZE_LIMIT)) \
|
||||||
# 管理页面
|
# 管理页面
|
||||||
admin_html = open('templates/admin.html', 'r', encoding='utf-8').read() \
|
admin_html = open('templates/admin.html', 'r', encoding='utf-8').read() \
|
||||||
.replace('{{title}}', settings.TITLE) \
|
.replace('{{title}}', settings.TITLE) \
|
||||||
.replace('{{description}}', settings.DESCRIPTION) \
|
.replace('{{description}}', settings.DESCRIPTION) \
|
||||||
@@ -98,7 +98,7 @@ async def admin_delete(code: str, s: AsyncSession = Depends(get_session)):
|
|||||||
async def config(s: AsyncSession = Depends(get_session)):
|
async def config(s: AsyncSession = Depends(get_session)):
|
||||||
# 从数据库获取系统配置
|
# 从数据库获取系统配置
|
||||||
data = (await s.execute(select(Values).filter(Values.key == 'config'))).scalar_one_or_none()
|
data = (await s.execute(select(Values).filter(Values.key == 'config'))).scalar_one_or_none()
|
||||||
return {'detail': '获取成功', 'data': data.value}
|
return {'detail': '获取成功', 'data': data.value if data else {}}
|
||||||
|
|
||||||
|
|
||||||
@app.get('/')
|
@app.get('/')
|
||||||
@@ -107,7 +107,7 @@ async def index():
|
|||||||
|
|
||||||
|
|
||||||
@app.get('/banner')
|
@app.get('/banner')
|
||||||
async def banner(s: AsyncSession = Depends(get_session)):
|
async def banner(request: Request, s: AsyncSession = Depends(get_session)):
|
||||||
# 数据库查询config
|
# 数据库查询config
|
||||||
config = (await s.execute(select(Values).filter(Values.key == 'config'))).scalar_one_or_none()
|
config = (await s.execute(select(Values).filter(Values.key == 'config'))).scalar_one_or_none()
|
||||||
# 如果存在config,就返回config的value
|
# 如果存在config,就返回config的value
|
||||||
@@ -119,6 +119,7 @@ async def banner(s: AsyncSession = Depends(get_session)):
|
|||||||
# 如果不存在config,就返回默认的banner
|
# 如果不存在config,就返回默认的banner
|
||||||
return {
|
return {
|
||||||
'detail': 'banner',
|
'detail': 'banner',
|
||||||
|
'enable': request.headers.get('pwd', '') == settings.ADMIN_PASSWORD or settings.ENABLE_UPLOAD,
|
||||||
'data': [{
|
'data': [{
|
||||||
'text': 'FileCodeBox',
|
'text': 'FileCodeBox',
|
||||||
'url': 'https://github.com/vastsa/FileCodeBox',
|
'url': 'https://github.com/vastsa/FileCodeBox',
|
||||||
@@ -201,7 +202,7 @@ async def share(background_tasks: BackgroundTasks, text: str = Form(default=None
|
|||||||
upload_ip_limit.add_ip(ip)
|
upload_ip_limit.add_ip(ip)
|
||||||
return {
|
return {
|
||||||
'detail': '分享成功,请点击取件码按钮查看上传列表',
|
'detail': '分享成功,请点击取件码按钮查看上传列表',
|
||||||
'data': {'code': code, 'key': key, 'name': name, 'text': _text}
|
'data': {'code': code, 'key': key, 'name': name}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,36 @@
|
|||||||
- [x] 管理面板:查看所有文件,删除文件
|
- [x] 管理面板:查看所有文件,删除文件
|
||||||
- [x] 一键部署:docker一键部署
|
- [x] 一键部署:docker一键部署
|
||||||
|
|
||||||
## 未来规划
|
## 部署方式
|
||||||
|
|
||||||
|
### Docker一键部署
|
||||||
|
|
||||||
|
#### AMD
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
#### ARM
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:arm
|
||||||
|
```
|
||||||
|
|
||||||
|
### 更新方式
|
||||||
|
|
||||||
|
```bash
|
||||||
|
// 停止容器并删除
|
||||||
|
docker stop filecodebox && docker rm filecodebox
|
||||||
|
// 重新运行容器
|
||||||
|
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### 其他方式
|
||||||
|
|
||||||
|
仅供参考,历史版本->[部署文档](https://www.yuque.com/lxyo/work/zd0kvzy7fofx6w7v)
|
||||||
|
|
||||||
|
## 项目规划
|
||||||
|
|
||||||
2022年12月14日
|
2022年12月14日
|
||||||
|
|
||||||
@@ -39,6 +68,22 @@
|
|||||||
|
|
||||||
[https://share.lanol.cn](https://share.lanol.cn)
|
[https://share.lanol.cn](https://share.lanol.cn)
|
||||||
|
|
||||||
|
### 暗黑模式
|
||||||
|
|
||||||
|
<table style="width:100%">
|
||||||
|
|
||||||
|
<tr style="width: 100%">
|
||||||
|
<td style="width: 50%">
|
||||||
|
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_10.png" alt="寄文件">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td style="width: 50%">
|
||||||
|
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_11.png" alt="寄文件">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
### 寄件
|
### 寄件
|
||||||
|
|
||||||
<table style="width: 100%">
|
<table style="width: 100%">
|
||||||
@@ -79,18 +124,6 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 部署方式
|
|
||||||
|
|
||||||
### Docker一键部署
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
### 其他方式
|
|
||||||
|
|
||||||
仅供参考,历史版本->[部署文档](https://www.yuque.com/lxyo/work/zd0kvzy7fofx6w7v)
|
|
||||||
|
|
||||||
## 配置文件
|
## 配置文件
|
||||||
|
|
||||||
如果需要修改配置,可以将该文件放在`/opt/FileCodeBox/`目录下,并命名为`.env`,然后重启容器即可。
|
如果需要修改配置,可以将该文件放在`/opt/FileCodeBox/`目录下,并命名为`.env`,然后重启容器即可。
|
||||||
@@ -137,6 +170,10 @@ STORAGE_ENGINE=filesystem
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Star History
|
||||||
|
|
||||||
|
[](https://star-history.com/#vastsa/FileCodeBox&Date)
|
||||||
|
|
||||||
## 赞赏
|
## 赞赏
|
||||||
|
|
||||||
<table style="width: 100%">
|
<table style="width: 100%">
|
||||||
@@ -152,6 +189,14 @@ STORAGE_ENGINE=filesystem
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
1. 413 Request Entity Too Large
|
||||||
|
Nginx限制:
|
||||||
|
找到自己主机的nginx.conf配置文件,打开
|
||||||
|
在http{}中加入 client_max_body_size 10m;
|
||||||
|
然后重启nginx
|
||||||
|
|
||||||
## 免责声明
|
## 免责声明
|
||||||
|
|
||||||
本项目开源仅供学习使用,不得用于任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。
|
本项目开源仅供学习使用,不得用于任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。
|
||||||
+52
-13
@@ -20,7 +20,38 @@
|
|||||||
- [x] management Panel: View all files and delete them
|
- [x] management Panel: View all files and delete them
|
||||||
- [x] one-click deployment: docker one-click deployment
|
- [x] one-click deployment: docker one-click deployment
|
||||||
|
|
||||||
## Future Plan
|
## Deployment method
|
||||||
|
|
||||||
|
### One-click Docker deployment
|
||||||
|
|
||||||
|
#### AMD
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
#### ARM
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d --restart=always -p 12345:12345 -v /Users/lan/soft/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:arm
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update
|
||||||
|
|
||||||
|
```bash
|
||||||
|
// 找到容器ID
|
||||||
|
docker ps -a
|
||||||
|
// 停止容器并删除
|
||||||
|
docker stop 容器ID && docker rm 容器ID
|
||||||
|
// 重新运行容器
|
||||||
|
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### Other methods
|
||||||
|
|
||||||
|
For reference only, historical version->[部署文档](https://www.yuque.com/lxyo/work/zd0kvzy7fofx6w7v)
|
||||||
|
|
||||||
|
## Project Plan
|
||||||
|
|
||||||
December 14, 2022
|
December 14, 2022
|
||||||
This project is mainly light-weight, mainly single-user, offline environment, so there is no need to add too many
|
This project is mainly light-weight, mainly single-user, offline environment, so there is no need to add too many
|
||||||
@@ -43,6 +74,22 @@ If you have better ideas and suggestions, welcome to file an issue.
|
|||||||
|
|
||||||
[https://share.lanol.cn](https://share.lanol.cn)
|
[https://share.lanol.cn](https://share.lanol.cn)
|
||||||
|
|
||||||
|
### Dark Theme
|
||||||
|
|
||||||
|
<table style="width:100%">
|
||||||
|
|
||||||
|
<tr style="width: 100%">
|
||||||
|
<td style="width: 50%">
|
||||||
|
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_10.png" alt="寄文件">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td style="width: 50%">
|
||||||
|
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_11.png" alt="寄文件">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
### Send
|
### Send
|
||||||
|
|
||||||
<table style="width: 100%">
|
<table style="width: 100%">
|
||||||
@@ -83,18 +130,6 @@ If you have better ideas and suggestions, welcome to file an issue.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Deployment method
|
|
||||||
|
|
||||||
### One-click Docker deployment
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
### Other methods
|
|
||||||
|
|
||||||
For reference only, historical version->[部署文档](https://www.yuque.com/lxyo/work/zd0kvzy7fofx6w7v)
|
|
||||||
|
|
||||||
## Configuration file
|
## Configuration file
|
||||||
|
|
||||||
if you need to modify the configuration, you can put the file in `/opt/FileCodeBox/` directory and name it `.env` , and
|
if you need to modify the configuration, you can put the file in `/opt/FileCodeBox/` directory and name it `.env` , and
|
||||||
@@ -143,6 +178,10 @@ STORAGE_ENGINE=filesystem
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Star History
|
||||||
|
|
||||||
|
[](https://star-history.com/#vastsa/FileCodeBox&Date)
|
||||||
|
|
||||||
## Appreciate
|
## Appreciate
|
||||||
|
|
||||||
<table style="width: 100%">
|
<table style="width: 100%">
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ DATA_ROOT = './data/' + config('DATA_ROOT', cast=str, default=f"static")
|
|||||||
# 静态文件夹URL
|
# 静态文件夹URL
|
||||||
STATIC_URL = config('STATIC_URL', cast=str, default="/static")
|
STATIC_URL = config('STATIC_URL', cast=str, default="/static")
|
||||||
# 开启上传
|
# 开启上传
|
||||||
ENABLE_UPLOAD = config('ENABLE_UPLOAD', cast=bool, default=False)
|
ENABLE_UPLOAD = config('ENABLE_UPLOAD', cast=bool, default=True)
|
||||||
# 最长天数
|
# 最长天数
|
||||||
MAX_DAYS = config('MAX_DAYS', cast=int, default=7)
|
MAX_DAYS = config('MAX_DAYS', cast=int, default=7)
|
||||||
# 错误次数
|
# 错误次数
|
||||||
|
|||||||
+12
-1
@@ -49,12 +49,23 @@ class FileSystemStorage:
|
|||||||
|
|
||||||
async def delete_file(self, text: str):
|
async def delete_file(self, text: str):
|
||||||
filepath = await self.get_filepath(text)
|
filepath = await self.get_filepath(text)
|
||||||
await asyncio.to_thread(os.remove, filepath)
|
if filepath.exists():
|
||||||
|
await asyncio.to_thread(os.remove, filepath)
|
||||||
|
await asyncio.to_thread(self.judge_delete_folder, filepath)
|
||||||
|
|
||||||
async def delete_files(self, texts):
|
async def delete_files(self, texts):
|
||||||
tasks = [self.delete_file(text) for text in texts]
|
tasks = [self.delete_file(text) for text in texts]
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
|
|
||||||
|
def judge_delete_folder(self, filepath):
|
||||||
|
current = filepath.parent
|
||||||
|
while current != self.DATA_ROOT:
|
||||||
|
if not list(current.iterdir()):
|
||||||
|
os.rmdir(current)
|
||||||
|
current = current.parent
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
STORAGE_ENGINE = {
|
STORAGE_ENGINE = {
|
||||||
"filesystem": FileSystemStorage
|
"filesystem": FileSystemStorage
|
||||||
|
|||||||
+106
-52
@@ -29,6 +29,11 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.el-icon-circle-close::before {
|
||||||
|
font-size: 26px !important;
|
||||||
|
line-height: 128px;
|
||||||
|
}
|
||||||
|
|
||||||
.qu .el-input__inner {
|
.qu .el-input__inner {
|
||||||
height: 100px;
|
height: 100px;
|
||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
@@ -40,14 +45,43 @@
|
|||||||
.el-card {
|
.el-card {
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #18181c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-card, .el-textarea__inner, .el-upload-dragger {
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
|
box-shadow: 5px 5px 0 0 rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
color: #ccc !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-input-group__prepend, .el-input__inner, .el-input-group__append, .el-empty__description, .el-select-dropdown, .el-button {
|
||||||
|
border: 1px solid transparent;
|
||||||
|
background-color: rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-drawer, #el-drawer__title, .el-drawer__body, .el-drawer__wrapper {
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script src="/static/asserts/vue.min.js"></script>
|
<script src="/static/asserts/vue.min.js"></script>
|
||||||
<script src="/static/asserts/index.js"></script>
|
<script src="/static/asserts/index.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app" style="text-align: center">
|
<div id="app" style="text-align: center">
|
||||||
<el-row v-if="pageNum === 0" class="qu" style="width:400px;height: 596px;margin: 6vh auto 0 auto">
|
<el-row v-if="pageNum === 0" class="qu" style="max-width:400px;margin: 4rem auto 0 auto">
|
||||||
<el-card style="padding-bottom: 1rem">
|
<el-card class="glass" style="padding-bottom: 1rem">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-input round autofocus @change="changeInput" clearable v-model:value="code" maxlength="5"
|
<el-input round autofocus @change="changeInput" clearable v-model:value="code" maxlength="5"
|
||||||
:disabled="inputDisable" placeholder="请输入五位取件码">
|
:disabled="inputDisable" placeholder="请输入五位取件码">
|
||||||
@@ -95,7 +129,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row v-else style="width:400px;margin: 6vh auto 0 auto">
|
<el-row v-else style="max-width:400px;margin: 4rem auto 0 auto">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-card :body-style="{ padding: '0px 0px 20px 0px' }">
|
<el-card :body-style="{ padding: '0px 0px 20px 0px' }">
|
||||||
<div class="block" style="margin-bottom: 1rem">
|
<div class="block" style="margin-bottom: 1rem">
|
||||||
@@ -174,7 +208,7 @@
|
|||||||
:direction="direction"
|
:direction="direction"
|
||||||
size="50%"
|
size="50%"
|
||||||
>
|
>
|
||||||
<el-card v-for="(file,index) in files" :key="index" class="box-card">
|
<el-card v-for="(file,index) in quFiles" :key="index" class="box-card">
|
||||||
<div style="cursor: pointer;text-align: left;margin-left: 2rem">
|
<div style="cursor: pointer;text-align: left;margin-left: 2rem">
|
||||||
<div>取件码:${ file.code }</div>
|
<div>取件码:${ file.code }</div>
|
||||||
<div>文件名:${ file.name }</div>
|
<div>文件名:${ file.name }</div>
|
||||||
@@ -189,36 +223,34 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-empty v-if="files.length===0" description="请输入取件码,收取文件"></el-empty>
|
<el-empty v-if="quFiles.length===0" description="请输入取件码,收取文件"></el-empty>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<el-drawer
|
<el-drawer
|
||||||
title="文件箱"
|
title="文件箱"
|
||||||
:visible.sync="jiDrawer"
|
:visible.sync="jiDrawer"
|
||||||
:direction="direction"
|
:direction="direction"
|
||||||
size="50%">
|
size="50%">
|
||||||
<el-card>
|
<el-empty v-if="jiFiles.length===0" description="请上传文件"></el-empty>
|
||||||
<el-empty v-if="files.length===0" description="请上传文件"></el-empty>
|
<el-card style="margin-top: 0.2rem" v-for="(file,index) in jiFiles" :key="index">
|
||||||
<el-card style="margin-top: 0.2rem" v-for="(file,index) in files" :key="index">
|
<el-row>
|
||||||
<el-row>
|
<el-col :span="15">
|
||||||
<el-col :span="15">
|
<el-row>
|
||||||
<el-row>
|
<el-col :span="24" style="line-height: 45px">
|
||||||
<el-col :span="24" style="line-height: 45px">
|
${ file.name }
|
||||||
${ file.name }
|
</el-col>
|
||||||
</el-col>
|
<el-col :span="24">
|
||||||
<el-col :span="24">
|
取件码:
|
||||||
取件码:
|
<h1 @click="copyText(file.code,0)" style="margin: 0;display: inline;cursor: pointer">
|
||||||
<h1 @click="copyText(file.code,0)" style="margin: 0;display: inline;cursor: pointer">
|
${ file.code }
|
||||||
${ file.code }
|
</h1>
|
||||||
</h1>
|
</el-col>
|
||||||
</el-col>
|
</el-row>
|
||||||
</el-row>
|
</el-col>
|
||||||
</el-col>
|
<el-col :span="4">
|
||||||
<el-col :span="4">
|
<img style="width: 80px;height: 80px;"
|
||||||
<img style="width: 80px;height: 80px;"
|
:src="qrcodeUrl(file)" alt="二维码" :alt="file.code">
|
||||||
:src="qrcodeUrl(file)" alt="二维码" :alt="file.code">
|
</el-col>
|
||||||
</el-col>
|
</el-row>
|
||||||
</el-row>
|
|
||||||
</el-card>
|
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<div style="text-align: center; margin-top: 1rem;color: #606266">
|
<div style="text-align: center; margin-top: 1rem;color: #606266">
|
||||||
@@ -237,12 +269,14 @@
|
|||||||
quDrawer: false,
|
quDrawer: false,
|
||||||
jiDrawer: false,
|
jiDrawer: false,
|
||||||
direction: 'btt',
|
direction: 'btt',
|
||||||
files: [],
|
quFiles: [],
|
||||||
|
jiFiles: [],
|
||||||
pageNum: 0,
|
pageNum: 0,
|
||||||
inputDisable: false,
|
inputDisable: false,
|
||||||
fileSizeLimit: '{{fileSizeLimit}}',
|
fileSizeLimit: '{{fileSizeLimit}}',
|
||||||
pwd: localStorage.getItem('pwd') || '',
|
pwd: localStorage.getItem('pwd') || '',
|
||||||
banners: [],
|
banners: [],
|
||||||
|
enableUpload: false,
|
||||||
uploadData: {
|
uploadData: {
|
||||||
style: '2',
|
style: '2',
|
||||||
type: '1',
|
type: '1',
|
||||||
@@ -285,7 +319,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 获取Banner
|
// 获取Banner
|
||||||
axios.get('/banner').then(res => {
|
axios.get('/banner', {
|
||||||
|
headers: {
|
||||||
|
pwd: localStorage.getItem('pwd')
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
this.enableUpload = res.data.enable
|
||||||
this.banners = res.data.data
|
this.banners = res.data.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -321,7 +360,7 @@
|
|||||||
},
|
},
|
||||||
copyText: function (value, style = 1) {
|
copyText: function (value, style = 1) {
|
||||||
if (style === 0) {
|
if (style === 0) {
|
||||||
value = `我在分享了给你文件,取件码:${value},${window.location.href}?code=${value}`;
|
value = `我给你分享了文件,取件码:${value},${window.location.href}?code=${value}`;
|
||||||
}
|
}
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.setAttribute('readonly', 'readonly');
|
input.setAttribute('readonly', 'readonly');
|
||||||
@@ -341,13 +380,13 @@
|
|||||||
const that = this;
|
const that = this;
|
||||||
this.http('post', `?code=${that.code}`).then(res => {
|
this.http('post', `?code=${that.code}`).then(res => {
|
||||||
that.quDrawer = true;
|
that.quDrawer = true;
|
||||||
that.files.unshift(res.data);
|
that.quFiles.unshift(res.data);
|
||||||
})
|
})
|
||||||
that.code = '';
|
that.code = '';
|
||||||
that.input_disable = false
|
that.input_disable = false
|
||||||
},
|
},
|
||||||
qrcodeUrl(file) {
|
qrcodeUrl(file) {
|
||||||
return 'https://api.qrserver.com/v1/create-qr-code/?data=' + window.location.origin + '/?code=' + file.code
|
return 'https://api.qrserver.com/v1/create-qr-code/?data=' + window.location.href + '/?code=' + file.code
|
||||||
},
|
},
|
||||||
listenInput: function (value) {
|
listenInput: function (value) {
|
||||||
if (this.code.length < 5) {
|
if (this.code.length < 5) {
|
||||||
@@ -357,6 +396,25 @@
|
|||||||
changeInput: function (value) {
|
changeInput: function (value) {
|
||||||
this.code = value;
|
this.code = value;
|
||||||
},
|
},
|
||||||
|
checkFile: function (file) {
|
||||||
|
if (!this.enableUpload) {
|
||||||
|
this.$message({
|
||||||
|
message: '上传功能已关闭',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (file != null) {
|
||||||
|
if (file.size > this.fileSizeLimit) {
|
||||||
|
this.$message({
|
||||||
|
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
toUploadData: function () {
|
toUploadData: function () {
|
||||||
if (this.uploadData.text === '' && this.uploadData.file === null) {
|
if (this.uploadData.text === '' && this.uploadData.file === null) {
|
||||||
this.$message({
|
this.$message({
|
||||||
@@ -364,17 +422,19 @@
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.http('post', '/share', this.uploadData, {
|
if (this.checkFile(this.uploadData.file)) {
|
||||||
headers: {
|
this.http('post', '/share', this.uploadData, {
|
||||||
'Content-Type': 'multipart/form-data',
|
headers: {
|
||||||
'pwd': this.pwd
|
'Content-Type': 'multipart/form-data',
|
||||||
}
|
'pwd': this.pwd
|
||||||
}).then(res => {
|
}
|
||||||
this.files.unshift(res.data);
|
}).then(res => {
|
||||||
this.jiDrawer = true;
|
this.jiFiles.unshift(res.data);
|
||||||
this.uploadData.text = '';
|
this.jiDrawer = true;
|
||||||
this.uploadData.file = null;
|
this.uploadData.text = '';
|
||||||
});
|
this.uploadData.file = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
successUpload(response, file, fileList) {
|
successUpload(response, file, fileList) {
|
||||||
@@ -382,7 +442,7 @@
|
|||||||
message: response.detail,
|
message: response.detail,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
this.files.unshift(response.data);
|
this.jiFiles.unshift(response.data);
|
||||||
},
|
},
|
||||||
errorUpload(error, file, fileList) {
|
errorUpload(error, file, fileList) {
|
||||||
error = JSON.parse(error.message)
|
error = JSON.parse(error.message)
|
||||||
@@ -392,13 +452,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
beforeUpload: function (file) {
|
beforeUpload: function (file) {
|
||||||
if (file.size > this.fileSizeLimit) {
|
return this.checkFile(file);
|
||||||
this.$message({
|
|
||||||
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user