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 @@