Skip to content

Commit 2b3c524

Browse files
committed
fix: 阻止按日期授权时剩余次数无限减少
1 parent 7998607 commit 2b3c524

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

apps/base/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ async def get_code_file(code: str, ip: str = Depends(error_ip_limit)):
102102
return APIResponse(code=404, detail=file_code)
103103
# 更新文件的使用次数和过期次数
104104
file_code.used_count += 1
105-
file_code.expired_count -= 1
105+
if file_code.expired_count > 0:
106+
file_code.expired_count -= 1
106107
# 保存文件
107108
await file_code.save()
108109
# 返回文件响应
@@ -122,7 +123,8 @@ async def select_file(data: SelectFileModel, ip: str = Depends(error_ip_limit)):
122123
return APIResponse(code=404, detail=file_code)
123124
# 更新文件的使用次数和过期次数
124125
file_code.used_count += 1
125-
file_code.expired_count -= 1
126+
if file_code.expired_count > 0:
127+
file_code.expired_count -= 1
126128
# 保存文件
127129
await file_code.save()
128130
# 返回API响应

fcb-fronted/src/views/Admin/FileView.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
</template>
1111
</el-table-column>
1212
<el-table-column prop="used_count" :label="t('admin.fileView.used_count')" />
13-
<el-table-column prop="expired_count" :label="t('admin.fileView.expired_count')" />
13+
<el-table-column prop="expired_count" :label="t('admin.fileView.expired_count')">
14+
<template #default="scope">
15+
<span>{{ scope.row.expired_count > -1 ? scope.row.expired_count : '不限次数' }}</span>
16+
</template>
17+
</el-table-column>
1418
<el-table-column prop="size" :label="t('admin.fileView.size')">
1519
<template #default="scope">
1620
<span>{{ Math.round(scope.row.size/1024/1024*100)/100 }}MB</span>

0 commit comments

Comments
 (0)