From b9c7c631f5bb8f0faaa4c0f5fab4922e3624c395 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 08:36:30 +0100
Subject: [PATCH 01/18] =?UTF-8?q?=E5=88=AB=E7=9E=8E=E7=8E=A9=E6=94=B9?=
=?UTF-8?q?=E6=88=90405NotAllowed?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
back_end/saolei/videomanager/views.py | 39 +++++++++------------------
1 file changed, 12 insertions(+), 27 deletions(-)
diff --git a/back_end/saolei/videomanager/views.py b/back_end/saolei/videomanager/views.py
index 5177b79b..68687d4e 100644
--- a/back_end/saolei/videomanager/views.py
+++ b/back_end/saolei/videomanager/views.py
@@ -6,7 +6,7 @@
from .models import VideoModel, ExpandVideoModel
from .view_utils import update_personal_record, update_personal_record_stock, video_all_fields
from userprofile.models import UserProfile
-from django.http import HttpResponse, JsonResponse, FileResponse
+from django.http import HttpResponse, JsonResponse, FileResponse, HttpResponseForbidden, HttpResponseBadRequest, HttpResponseNotAllowed, HttpResponseNotFound
import json, urllib
from utils import ComplexEncoder
from django.core.paginator import Paginator
@@ -108,7 +108,7 @@ def video_upload(request):
elif request.method == 'GET':
return HttpResponse("别瞎玩")
else:
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
# 根据id向后台请求软件类型(适配flop播放器用)
def get_software(request):
@@ -127,7 +127,7 @@ def get_software(request):
@ratelimit(key='ip', rate='20/m')
def video_preview(request):
if request.method != 'GET':
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
# 这里性能可能有问题
try:
video = VideoModel.objects.get(id=int(request.GET["id"][:-4]))
@@ -151,7 +151,7 @@ def video_preview(request):
@ratelimit(key='ip', rate='20/m')
def video_download(request):
if request.method != 'GET':
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
try:
video = VideoModel.objects.get(id=request.GET["id"])
response =FileResponse(open(video.file.path, 'rb'))
@@ -211,7 +211,7 @@ def video_query(request):
elif request.method == 'POST':
return HttpResponse("别瞎玩")
else:
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
# 按id查询这个用户的所有录像
@@ -225,22 +225,7 @@ def video_query_by_id(request):
return JsonResponse(json.dumps({"videos": list(videos)}, cls=ComplexEncoder), safe=False)
else:
- return HttpResponse("别瞎玩")
-
-
-# {
-# "1": "{\"time\": \"2023-12-16 14:52:40\", \"player\": \"\\u5b9e\\u540d\", \"level\": \"b\", \"mode\": \"00\", \"timems\": \"4770\", \"bv\": 23, \"bvs\": 4.821802935010482}",
-# "3": "{\"time\": \"2023-12-16 14:52:52\", \"player\": \"\\u5b9e\\u540d\", \"level\": \"i\", \"mode\": \"00\", \"timems\": \"20390\", \"bv\": 71, \"bvs\": 3.4330554193231975}",
-# "4": "{\"time\": \"2023-12-16 15:17:58\", \"player\": \"\\u5b9e\\u540d\", \"level\": \"b\", \"mode\": \"12\", \"timems\": \"1530\", \"bv\": 4, \"bvs\": 2.6143790849673203}",
-# "8": "{\"time\": \"2023-12-16 15:26:22\", \"player\": \"www333\", \"level\": \"e\", \"mode\": \"00\", \"timems\": \"51940\", \"bv\": 149, \"bvs\": 2.849441663457836}",
-# "9": "{\"time\": \"2023-12-16 15:26:26\", \"player\": \"www333\", \"level\": \"b\", \"mode\": \"00\", \"timems\": \"3250\", \"bv\": 18, \"bvs\": 5.538461538461538}",
-# "10": "{\"time\": \"2023-12-16 15:26:30\", \"player\": \"www333\", \"level\": \"i\", \"mode\": \"00\", \"timems\": \"20110\", \"bv\": 69, \"bvs\": 3.431128791645947}",
-# "7": "{\"time\": \"2023-12-16 15:24:07\", \"player\": \"\\u5b9e\\u540d\", \"level\": \"i\", \"mode\": \"00\", \"timems\": \"15280\", \"bv\": 31, \"bvs\": 2.0287958115183247}",
-# "6": "{\"time\": \"2023-12-16 15:24:02\", \"player\": \"\\u5b9e\\u540d\", \"level\": \"e\", \"mode\": \"00\", \"timems\": \"59450\", \"bv\": 193, \"bvs\": 3.2127838519764507}",
-# "2": "{\"time\": \"2023-12-16 14:52:48\", \"player\": \"\\u5b9e\\u540d\", \"level\": \"e\", \"mode\": \"00\", \"timems\": \"61710\", \"bv\": 193, \"bvs\": 3.0789175174201913}",
-# "5": "{\"time\": \"2023-12-16 15:23:59\", \"player\": \"\\u5b9e\\u540d\", \"level\": \"b\", \"mode\": \"12\", \"timems\": \"1580\", \"bv\": 6, \"bvs\": 3.7974683544303796}"
-# }
-
+ return HttpResponseNotAllowed()
# 上传的录像进入数据库后,更新用户的录像数目
def update_video_num(video: VideoModel, add = True):
@@ -291,7 +276,7 @@ def review_queue(request):
review_video_ids.update({str(key, encoding="utf-8"): review_video_ids.pop(key)})
return JsonResponse(review_video_ids, encoder=ComplexEncoder)
else:
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
# 获取最新录像
# http://127.0.0.1:8000/video/newest_queue
@@ -302,7 +287,7 @@ def newest_queue(request):
newest_queue_ids.update({str(key, encoding="utf-8"): newest_queue_ids.pop(key)})
return JsonResponse(newest_queue_ids, encoder=ComplexEncoder)
else:
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
# 获取谁破纪录的消息
@@ -312,7 +297,7 @@ def news_queue(request):
news_queue = cache.lrange("news_queue", 0, -1)
return JsonResponse(news_queue, encoder=ComplexEncoder, safe=False)
else:
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
# 获取全网被冻结的录像
@@ -324,7 +309,7 @@ def freeze_queue(request):
freeze_queue_ids.update({str(key, encoding="utf-8"): freeze_queue_ids.pop(key)})
return JsonResponse(freeze_queue_ids, encoder=ComplexEncoder)
else:
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
# 【管理员】审核通过队列里的录像,未审核或冻结状态的录像可以审核通过
@@ -365,7 +350,7 @@ def approve(request):
# logger.info(f'{request.user.id} approve {json.dumps(ids)} response {json.dumps(res)}')
return JsonResponse(res, safe=False)
else:
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
# 【管理员】冻结队列里的录像,未审核或审核通过的录像可以冻结
# 两种用法,冻结指定的录像id,或冻结某用户的所有录像
@@ -424,7 +409,7 @@ def freeze(request):
logger.info(f'{request.user.id} freeze {json.dumps(ids)} response {json.dumps(res)}')
return JsonResponse(json.dumps(res), safe=False)
else:
- return HttpResponse("别瞎玩")
+ return HttpResponseNotAllowed()
From 577fada9d06defb6113d8506affab04a9050a141 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 08:37:26 +0100
Subject: [PATCH 02/18] Update views.py
---
back_end/saolei/videomanager/views.py | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/back_end/saolei/videomanager/views.py b/back_end/saolei/videomanager/views.py
index 68687d4e..a5f3d4d2 100644
--- a/back_end/saolei/videomanager/views.py
+++ b/back_end/saolei/videomanager/views.py
@@ -104,9 +104,7 @@ def video_upload(request):
return JsonResponse({"status": 100, "msg": None})
else:
# print(video_form.errors)
- return JsonResponse({"status": 666, "msg": "小型网站,请勿攻击!"})
- elif request.method == 'GET':
- return HttpResponse("别瞎玩")
+ return HttpResponseBadRequest()
else:
return HttpResponseNotAllowed()
@@ -207,9 +205,6 @@ def video_query(request):
# t=json.dumps(response, cls=ComplexEncoder)
# print(t)
return JsonResponse(json.dumps(response, cls=ComplexEncoder), safe=False)
-
- elif request.method == 'POST':
- return HttpResponse("别瞎玩")
else:
return HttpResponseNotAllowed()
From 095cc03616ccf60f7d96ab1092991963a1aa40dd Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 08:38:11 +0100
Subject: [PATCH 03/18] =?UTF-8?q?=E7=A6=81=E7=94=A8i18n=E7=9A=84html?=
=?UTF-8?q?=E8=AD=A6=E5=91=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front_end/src/i18n/index.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/front_end/src/i18n/index.ts b/front_end/src/i18n/index.ts
index 372191bc..9d43e31a 100644
--- a/front_end/src/i18n/index.ts
+++ b/front_end/src/i18n/index.ts
@@ -31,6 +31,7 @@ export default createI18n({
fallbackLocale: dev.local,
fallbackWarn: false,
missingWarn: false,
+ warnHtmlMessage: false,
locale: getDefaultLocale(),
messages: getMessages(),
})
From 92bd6a449bf4d2b9054660b0b3d5b159ad3f6d51 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 08:38:35 +0100
Subject: [PATCH 04/18] =?UTF-8?q?=E8=8B=A5=E5=B9=B2=E6=9C=AC=E5=9C=B0?=
=?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front_end/src/i18n/locales/en.ts | 13 ++++++++++++-
front_end/src/i18n/locales/zh-cn.ts | 17 ++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/front_end/src/i18n/locales/en.ts b/front_end/src/i18n/locales/en.ts
index f30153b1..ba53fb1b 100644
--- a/front_end/src/i18n/locales/en.ts
+++ b/front_end/src/i18n/locales/en.ts
@@ -75,6 +75,7 @@ export const en = {
login: 'Login',
logout: 'Logout',
register: 'Register',
+ setting: 'Settings',
downloads: 'Downloads',
links: 'Links',
team: 'Team'
@@ -99,7 +100,7 @@ export const en = {
dragOrClick: `Drag files here or click here to select`,
uploadAll: 'Upload All ({0})',
cancelAll: 'Clear All',
- constraintNote: '*File size maximum is 5MB. File count maximum is 99.',
+ constraintNote: '*File size maximum is 5MB.',
error: {
collision: 'Video already exist',
custom: 'Custom level is currently not supported',
@@ -114,4 +115,14 @@ export const en = {
}
}
},
+ setting: {
+ appearance: 'Appearance',
+ darkMode: 'Dark Mode',
+ languageSwitch: 'Language Switch',
+ menuFontSize: 'Menu Font Size',
+ menuHeight: 'Menu Height',
+ menuLayout: 'Menu Layout',
+ menuLayoutAbstract: 'Abstract',
+ menuLayoutDefault: 'Default',
+ },
}
\ No newline at end of file
diff --git a/front_end/src/i18n/locales/zh-cn.ts b/front_end/src/i18n/locales/zh-cn.ts
index 69857fd1..5aa05fee 100644
--- a/front_end/src/i18n/locales/zh-cn.ts
+++ b/front_end/src/i18n/locales/zh-cn.ts
@@ -7,6 +7,7 @@ export const zhCn = {
action: {
getUserProfile: '查询用户',
setUserProfile: '修改用户',
+ uploadFile: '上传文件',
},
hide: '隐藏',
level: {
@@ -31,12 +32,14 @@ export const zhCn = {
emptyEmailCode: '请输入6位邮箱验证码!',
emptyPassword: '请输入密码!',
emptyUsername: '请输入用户名!',
+ fileTooLarge: '文件大小不能超过{0}',
invalidEmail: '邮箱格式不正确!',
invalidEmailCode: '邮箱验证码格式不正确!请点击邮箱验证码并打开邮箱查收。',
invalidPassword: '密码格式不正确!长度应该为6-20位。',
invalidUsername: '用户名格式不正确!长度不超过20位。',
logoutFail: '退出失败!',
logoutSuccess: '退出成功!',
+ realNameRequired: '请修改为实名',
},
prop: {
action: '操作',
@@ -58,6 +61,8 @@ export const zhCn = {
Forbidden: '权限不足',
InternalServerError: '后端发生错误',
NotFound: '找不到数据',
+ PayloadTooLarge: '文件过大',
+ UnsupportedMediaType: '不支持的文件类型',
},
show: '显示',
toDo: '敬请期待',
@@ -125,7 +130,7 @@ export const zhCn = {
dragOrClick: `将录像拉到此处或 点击此处选择`,
uploadAll: '一键上传({0}个)',
cancelAll: '全部清空',
- constraintNote: '*单个文件大小不能超过5M,文件数量不能超过99',
+ constraintNote: '*单个文件大小不能超过5MB',
error: {
collision: '录像已存在',
custom: '暂不支持自定义级别',
@@ -153,4 +158,14 @@ export const zhCn = {
termsAndConditions: '元扫雷网用户协议',
confirm: '注册',
},
+ setting: {
+ appearance: '外观设置',
+ darkMode: '深色模式',
+ languageSwitch: '语言切换',
+ menuFontSize: '菜单字号',
+ menuHeight: '菜单高度',
+ menuLayout: '菜单排版',
+ menuLayoutAbstract: '抽象',
+ menuLayoutDefault: '默认',
+ },
}
From afbc593820596982a77754d028a679f85499fad2 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 08:39:24 +0100
Subject: [PATCH 05/18] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=94=99=E8=AF=AF?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81413PayloadTooLarge=E5=92=8C415UnsupportedMedi?=
=?UTF-8?q?aType?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front_end/src/utils/system/status.ts | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/front_end/src/utils/system/status.ts b/front_end/src/utils/system/status.ts
index e26177e6..34068f78 100644
--- a/front_end/src/utils/system/status.ts
+++ b/front_end/src/utils/system/status.ts
@@ -9,6 +9,8 @@ const notificationMessage: { [code: number]: string} = {
400: 'common.response.BadRequest',
403: 'common.response.Forbidden',
404: 'common.response.NotFound',
+ 413: 'common.response.PayloadTooLarge',
+ 415: 'common.response.UnsupportedMediaType',
500: 'common.response.InternalServerError',
};
@@ -20,4 +22,4 @@ export function generalNotification(t: any, status: number, action: string) {
type: notificationType[type],
duration: local.notification_duration,
})
-}
\ No newline at end of file
+}
From aa7540a986f684004a0357eafcfa46ff77a4f211 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 08:41:29 +0100
Subject: [PATCH 06/18] =?UTF-8?q?=E8=8B=A5=E5=B9=B2=E6=9C=AC=E5=9C=B0?=
=?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front_end/src/views/SettingView.vue | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/front_end/src/views/SettingView.vue b/front_end/src/views/SettingView.vue
index 7212091c..26ea7183 100644
--- a/front_end/src/views/SettingView.vue
+++ b/front_end/src/views/SettingView.vue
@@ -1,13 +1,17 @@
-
-
-
-
-
+
-
+
+
+
+
+
+
通知自动关闭的时间,单位毫秒。
值为0则不会自动关闭。
From e69bf2cc10913587bbb778002b50fd8bcd54b019 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 08:45:05 +0100
Subject: [PATCH 07/18] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=BD=95=E5=83=8F?=
=?UTF-8?q?=E9=99=90=E5=88=B6=E7=A7=BB=E5=88=B0=E5=90=91=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E5=99=A8=E4=B8=8A=E4=BC=A0=E6=97=B6=EF=BC=8C=E5=AE=9E=E5=90=8D?=
=?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=BA=E2=80=9C=E5=8C=BF=E5=90=8D=E2=80=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
back_end/saolei/userprofile/models.py | 2 +-
front_end/src/views/UploadView.vue | 32 +++++----------------------
2 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/back_end/saolei/userprofile/models.py b/back_end/saolei/userprofile/models.py
index 160e13b7..53bc3357 100644
--- a/back_end/saolei/userprofile/models.py
+++ b/back_end/saolei/userprofile/models.py
@@ -47,7 +47,7 @@ class UserProfile(AbstractUser):
},)
realname = models.CharField(
- max_length=10, unique=False, blank=True, default='请修改为实名', null=False)
+ max_length=10, unique=False, blank=True, default='匿名', null=False)
# 头像
avatar = RestrictedImageField(upload_to='avatar/%Y%m%d/', max_length=100,
max_upload_size=MaxSizes.avatar, blank=True, null=True)
diff --git a/front_end/src/views/UploadView.vue b/front_end/src/views/UploadView.vue
index 35c5de8e..27cd3403 100644
--- a/front_end/src/views/UploadView.vue
+++ b/front_end/src/views/UploadView.vue
@@ -1,10 +1,10 @@
-
+
-
+
@@ -249,26 +249,6 @@ const push_video_msg = async (uploadFile: UploadFile | UploadRawFile) => {
})
}
-const handleExceed: UploadProps['onExceed'] = async (files) => {
- elmsg_handles.push(ElMessage.error({ message: '单次最多上传99个录像!', offset: 68 }));
- const left_num = 99 - video_msgs.value.length;
- files.splice(left_num);
-
- for (let file of files) {
- const f = file as UploadRawFile;
- f.uid = genFileId();
- allow_upload.value = false; // 暂时屏蔽onChange回调
- upload.value!.handleStart(f);
- allow_upload.value = true;
- await push_video_msg(f);
- // 修改id。最后一个协程才是真正起作用的。
- for (let i = 0; i < video_msgs.value.length; i++) {
- video_msgs.value[i].id = i;
- }
- }
-
-}
-
// 清空待上传列表
const cancel_all = () => {
upload.value!.clearFiles();
@@ -284,8 +264,8 @@ const submitUpload = async () => {
// 先锁死,不让进变化回调
allow_upload.value = false;
let i = 0;
- let count = 0; // 防止无限循环bug
- while (count < 100) {
+ let count = 0; // 最多上传99个
+ while (count < 99) {
if (i >= video_msgs.value.length) break;
if (video_msgs.value[i].status === "pass") {
await forceUpload(i);
From 635ff7233d49f1ed364e739f465a2eabaed8dcf7 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 08:46:26 +0100
Subject: [PATCH 08/18] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E7=94=A8?=
=?UTF-8?q?=E7=9A=84=E8=AD=A6=E5=91=8A=E4=B8=8Eimport?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front_end/src/views/UploadView.vue | 31 +-----------------------------
1 file changed, 1 insertion(+), 30 deletions(-)
diff --git a/front_end/src/views/UploadView.vue b/front_end/src/views/UploadView.vue
index 27cd3403..f412e8fb 100644
--- a/front_end/src/views/UploadView.vue
+++ b/front_end/src/views/UploadView.vue
@@ -63,16 +63,13 @@
\ No newline at end of file
From 3acc50c02a0596d69c17eaafd9aa8e33f4c154b7 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 11:40:35 +0100
Subject: [PATCH 13/18] Update package.json
---
front_end/package.json | 2 ++
1 file changed, 2 insertions(+)
diff --git a/front_end/package.json b/front_end/package.json
index 289f01a3..929c9c41 100644
--- a/front_end/package.json
+++ b/front_end/package.json
@@ -17,6 +17,8 @@
"@types/js-cookie": "^3.0.3",
"@types/lowdb": "^1.0.11",
"@types/node": "^20.5.1",
+ "@vueuse/components": "^10.11.0",
+ "@vueuse/core": "^10.11.0",
"axios": "^1.7.2",
"echarts": "^5.5.0",
"element-plus": "^2.7.0",
From bc9e1311ddbc21773d22817e3f5c0a60ef6d666a Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 12:18:23 +0100
Subject: [PATCH 14/18] =?UTF-8?q?`get=5Fsoftware`=E7=9A=84=E5=BC=82?=
=?UTF-8?q?=E5=B8=B8=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
back_end/saolei/videomanager/views.py | 11 ++++-------
front_end/src/components/PreviewNumber.vue | 16 ++++++----------
front_end/src/i18n/locales/zh-cn.ts | 1 +
3 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/back_end/saolei/videomanager/views.py b/back_end/saolei/videomanager/views.py
index ee496963..e691b036 100644
--- a/back_end/saolei/videomanager/views.py
+++ b/back_end/saolei/videomanager/views.py
@@ -111,13 +111,10 @@ def video_upload(request):
# 根据id向后台请求软件类型(适配flop播放器用)
def get_software(request):
if request.method != 'GET':
- return HttpResponse("别瞎玩")
- try:
- video = VideoModel.objects.get(id=request.GET["id"])
- # print({"status": 100, "msg": video.software})
- return JsonResponse({"status": 100, "msg": video.software})
- except Exception:
- return JsonResponse({"status": 104, "msg": "file not exist!"})
+ return HttpResponseNotAllowed()
+ video = VideoModel.objects.get(id=request.GET["id"])
+ # print({"status": 100, "msg": video.software})
+ return JsonResponse({"msg": video.software})
# 给预览用的接口,区别是结尾是文件后缀
# 坑:如果做成必须登录才能下载,由于Django的某种特性,会重定向资源,
diff --git a/front_end/src/components/PreviewNumber.vue b/front_end/src/components/PreviewNumber.vue
index 8d5c76bf..d8755801 100644
--- a/front_end/src/components/PreviewNumber.vue
+++ b/front_end/src/components/PreviewNumber.vue
@@ -15,8 +15,11 @@
// 某个数字或字符串,点击后预览
import { onMounted, watch, ref, toRefs } from "vue";
import useCurrentInstance from "@/utils/common/useCurrentInstance";
+import { generalNotification } from "@/utils/system/status";
+import { useI18n } from "vue-i18n";
const { proxy } = useCurrentInstance();
const preview_visible = ref(false);
+const t = useI18n();
const data = defineProps({
id: {
@@ -60,12 +63,9 @@ const preview = (id: Number | undefined) => {
}
}
- }).catch(
- (res) => {
- // console.log("报错");
- // console.log(res);
- }
- )
+ }).catch((error: any) => {
+ generalNotification(t, error.response.status, t.t('common.action.getSoftware'))
+ })
}
const playVideo = function (uri: string) {
@@ -87,10 +87,6 @@ const playVideo = function (uri: string) {
});
}
-onMounted(() => {
-
-});
-
diff --git a/front_end/src/i18n/locales/zh-cn.ts b/front_end/src/i18n/locales/zh-cn.ts
index 5aa05fee..557f2b5a 100644
--- a/front_end/src/i18n/locales/zh-cn.ts
+++ b/front_end/src/i18n/locales/zh-cn.ts
@@ -5,6 +5,7 @@ export const zhCn = {
name: '简体中文',
common: {
action: {
+ getSoftware: '获取录像信息',
getUserProfile: '查询用户',
setUserProfile: '修改用户',
uploadFile: '上传文件',
From d66b32592735a8fa8857f8c4c2e99122da040cb3 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 12:24:53 +0100
Subject: [PATCH 15/18] Update views.py
---
back_end/saolei/videomanager/views.py | 28 ++++++++++++---------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/back_end/saolei/videomanager/views.py b/back_end/saolei/videomanager/views.py
index e691b036..dc62beb8 100644
--- a/back_end/saolei/videomanager/views.py
+++ b/back_end/saolei/videomanager/views.py
@@ -124,22 +124,18 @@ def video_preview(request):
if request.method != 'GET':
return HttpResponseNotAllowed()
# 这里性能可能有问题
- try:
- video = VideoModel.objects.get(id=int(request.GET["id"][:-4]))
- # video.file.name是相对路径(含upload_to),video.file.path是绝对路径
- # print(settings.MEDIA_ROOT / "assets" / video.file.name)
- file_path = settings.MEDIA_ROOT / video.file.name
- response =FileResponse(open(file_path, 'rb'))
- response['Content-Type']='application/octet-stream'
- # response['Content-Disposition']=f'attachment;filename="{video.file.name.split("/")[2]}"'
- file_name = video.file.name.split("/")[2]
- file_name_uri = urllib.parse.quote(file_name)
- response['Content-Disposition'] = f'attachment; filename="{file_name_uri}"'
- response['Access-Control-Expose-Headers']='Content-Disposition'
-
- return response
- except Exception:
- return JsonResponse({"status": 104, "msg": "file not exist!"})
+ video = VideoModel.objects.get(id=int(request.GET["id"][:-4]))
+ # video.file.name是相对路径(含upload_to),video.file.path是绝对路径
+ # print(settings.MEDIA_ROOT / "assets" / video.file.name)
+ file_path = settings.MEDIA_ROOT / video.file.name
+ response =FileResponse(open(file_path, 'rb'))
+ response['Content-Type']='application/octet-stream'
+ # response['Content-Disposition']=f'attachment;filename="{video.file.name.split("/")[2]}"'
+ file_name = video.file.name.split("/")[2]
+ file_name_uri = urllib.parse.quote(file_name)
+ response['Content-Disposition'] = f'attachment; filename="{file_name_uri}"'
+ response['Access-Control-Expose-Headers']='Content-Disposition'
+ return response
# 给下载用的接口,区别是结尾没有文件后缀
# @login_required(login_url='/')
From 7a1756c2df20c6553ae09031bc241cf7493cd245 Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 12:39:06 +0100
Subject: [PATCH 16/18] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=BC=82=E5=B8=B8?=
=?UTF-8?q?=E5=A4=84=E7=90=86=E6=94=B9=E4=B8=BA=E6=A0=87=E5=87=86HttpReque?=
=?UTF-8?q?st?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
back_end/saolei/videomanager/views.py | 14 +++-----------
front_end/src/components/VideoList.vue | 13 +++++++------
front_end/src/i18n/locales/zh-cn.ts | 1 +
front_end/src/utils/index.ts | 1 +
4 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/back_end/saolei/videomanager/views.py b/back_end/saolei/videomanager/views.py
index dc62beb8..4cec20d0 100644
--- a/back_end/saolei/videomanager/views.py
+++ b/back_end/saolei/videomanager/views.py
@@ -150,15 +150,7 @@ def video_download(request):
response['Content-Disposition']=f'attachment;filename="{video.file.name.split("/")[2]}"'
return response
except VideoModel.DoesNotExist:
- return JsonResponse({"status": 104, "msg": "录像不存在!"})
- # try:
- # video = VideoModel.objects.get(id=request.GET["id"])
- # response =FileResponse(open(video.file.path, 'rb'))
- # response['Content-Type']='application/octet-stream'
- # response['Content-Disposition']=f'attachment;filename="{video.file.name.split("/")[2]}"'
- # return response
- # except Exception:
- # return JsonResponse({"status": 104, "msg": "file not exist!"})
+ return HttpResponseNotFound()
# 录像查询(无需登录)
# 按任何基础指标+难度+模式,排序,分页
@@ -310,7 +302,7 @@ def approve(request):
res = []
for _id in ids:
if not isinstance(_id, int):
- return HttpResponse("审核录像的id应为正整数。")
+ return HttpResponseNotFound() # id应为正整数
video_i = VideoModel.objects.filter(id=_id)
if not video_i:
res.append("Null")
@@ -365,7 +357,7 @@ def freeze(request):
res = []
for _id in ids:
if not isinstance(_id, int) or _id < 1:
- return HttpResponse("冻结录像的id应为正整数。")
+ return HttpResponseNotFound() # id应为正整数
video_i = VideoModel.objects.filter(id=_id)
if not video_i:
res.append("Null")
diff --git a/front_end/src/components/VideoList.vue b/front_end/src/components/VideoList.vue
index 81243524..f5ecc51e 100644
--- a/front_end/src/components/VideoList.vue
+++ b/front_end/src/components/VideoList.vue
@@ -51,8 +51,12 @@ import { useUserStore } from '@/store';
const store = useUserStore()
import { ms_to_s, approve, freeze, simple_formatter } from '@/utils';
+import { generalNotification } from '@/utils/system/status';
+import { useI18n } from 'vue-i18n';
const { proxy } = useCurrentInstance();
+const t = useI18n();
+
const data = defineProps({
videos: {
type: Array,
@@ -142,12 +146,9 @@ const preview = (row: any, column: any, event: Event) => {
},
}
}
- }).catch(
- (res) => {
- // console.log("报错");
- // console.log(res);
- }
- )
+ }).catch((error: any) => {
+ generalNotification(t, error.response.status, t.t('common.action.getSoftware'));
+ })
}
diff --git a/front_end/src/i18n/locales/zh-cn.ts b/front_end/src/i18n/locales/zh-cn.ts
index 557f2b5a..0f4a75b2 100644
--- a/front_end/src/i18n/locales/zh-cn.ts
+++ b/front_end/src/i18n/locales/zh-cn.ts
@@ -9,6 +9,7 @@ export const zhCn = {
getUserProfile: '查询用户',
setUserProfile: '修改用户',
uploadFile: '上传文件',
+ videoQuery: '查询录像',
},
hide: '隐藏',
level: {
diff --git a/front_end/src/utils/index.ts b/front_end/src/utils/index.ts
index df6c5d85..50393f87 100644
--- a/front_end/src/utils/index.ts
+++ b/front_end/src/utils/index.ts
@@ -22,6 +22,7 @@ export function simple_formatter(f: Function): Function{
}
import { ComponentCustomProperties } from "vue";
+import { generalNotification } from "./system/status";
export async function approve(proxy: ComponentCustomProperties & Record, id: number) {
var status;
await proxy.$axios.get('video/approve?ids=[' + id + ']').then(function (response) {
From 491c132d00fd07d0c38180d759c2b21ea5dd785c Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 12:41:02 +0100
Subject: [PATCH 17/18] fix
---
front_end/src/components/PreviewNumber.vue | 9 +++------
front_end/src/main.ts | 1 +
front_end/src/store/index.ts | 1 +
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/front_end/src/components/PreviewNumber.vue b/front_end/src/components/PreviewNumber.vue
index d8755801..6c26057e 100644
--- a/front_end/src/components/PreviewNumber.vue
+++ b/front_end/src/components/PreviewNumber.vue
@@ -3,8 +3,8 @@
-
+
{{ data.text }}
@@ -62,7 +62,6 @@ const preview = (id: Number | undefined) => {
},
}
}
-
}).catch((error: any) => {
generalNotification(t, error.response.status, t.t('common.action.getSoftware'))
})
@@ -90,6 +89,4 @@ const playVideo = function (uri: string) {
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/front_end/src/main.ts b/front_end/src/main.ts
index 3ae21db3..8e804c51 100644
--- a/front_end/src/main.ts
+++ b/front_end/src/main.ts
@@ -14,6 +14,7 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
// 全局挂载axios
import 'highlight.js/styles/stackoverflow-light.css'
+import 'element-plus/theme-chalk/dark/css-vars.css'
const app = createApp(App)
diff --git a/front_end/src/store/index.ts b/front_end/src/store/index.ts
index 47bd1291..8535a639 100644
--- a/front_end/src/store/index.ts
+++ b/front_end/src/store/index.ts
@@ -31,6 +31,7 @@ export const useUserStore = defineStore('user', {
export const useLocalStore = defineStore('local', {
state: () => ({
+ darkmode: false,
language: "zh-cn",
language_show: true,
menu_font_size: 18,
From 4744ef2a30051cfc7209d7084d8bbe5d2523203c Mon Sep 17 00:00:00 2001
From: Tianyi Pu <912396513@qq.com>
Date: Sat, 29 Jun 2024 12:42:46 +0100
Subject: [PATCH 18/18] Update UploadView.vue
---
front_end/src/views/UploadView.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/front_end/src/views/UploadView.vue b/front_end/src/views/UploadView.vue
index 35a49c06..9526eede 100644
--- a/front_end/src/views/UploadView.vue
+++ b/front_end/src/views/UploadView.vue
@@ -45,7 +45,7 @@
{{ $t('profile.upload.error.' + props.row.status) }}
-
+