From 452640f8355c2dad7219d677e7c686da6ba10564 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <44583944+putianyi889@users.noreply.github.com> Date: Sat, 29 Jun 2024 17:11:16 +0100 Subject: [PATCH 1/6] Rename pl to pl.ts --- front_end/src/i18n/locales/{pl => pl.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename front_end/src/i18n/locales/{pl => pl.ts} (100%) diff --git a/front_end/src/i18n/locales/pl b/front_end/src/i18n/locales/pl.ts similarity index 100% rename from front_end/src/i18n/locales/pl rename to front_end/src/i18n/locales/pl.ts From 7413ece2541e27b4ed0bb49b3779dab692748cc1 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Sat, 29 Jun 2024 17:20:50 +0100 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B3=A2=E5=85=B0=E8=AF=AD=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=8C=96=E5=AE=9E=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front_end/src/components/LanguagePicker.vue | 1 + front_end/src/i18n/index.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/front_end/src/components/LanguagePicker.vue b/front_end/src/components/LanguagePicker.vue index a46d405c..8c7dcd78 100644 --- a/front_end/src/components/LanguagePicker.vue +++ b/front_end/src/components/LanguagePicker.vue @@ -24,6 +24,7 @@ const options = [ { lang: "zh-cn", text: "简体中文" }, { lang: "en", text: "English" }, { lang: "de", text: "name" }, + { lang: "pl", text: "polski"}, { lang: "dev", text: "dev" }, ]; diff --git a/front_end/src/i18n/index.ts b/front_end/src/i18n/index.ts index 9d43e31a..54686d00 100644 --- a/front_end/src/i18n/index.ts +++ b/front_end/src/i18n/index.ts @@ -3,6 +3,7 @@ import { dev } from '@/i18n/locales/dev' import { zhCn } from '@/i18n/locales/zh-cn' import { de } from '@/i18n/locales/de' import { en } from './locales/en' +import { pl } from './locales/pl' /** * 获取所有语言 @@ -13,6 +14,7 @@ function getMessages (): Record { messages[zhCn.local] = zhCn messages[de.local] = de messages[en.local] = en + messages[pl.local] = pl return messages } From 58034df820a9376a23a0155118b196e8c759128d Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Sun, 30 Jun 2024 11:47:49 +0100 Subject: [PATCH 3/6] update en.ts and config.ts --- front_end/src/i18n/config.ts | 76 +++++++++++++++++++++++++++++--- front_end/src/i18n/locales/en.ts | 33 ++++++++++++++ 2 files changed, 103 insertions(+), 6 deletions(-) diff --git a/front_end/src/i18n/config.ts b/front_end/src/i18n/config.ts index 227566af..57c20fb4 100644 --- a/front_end/src/i18n/config.ts +++ b/front_end/src/i18n/config.ts @@ -10,25 +10,70 @@ export type LocaleConfig = LocaleMessage & { // 嵌套配置示例 TODO 删除嵌套配置示例 name: string, common: { + action: { + getSoftware: string, + getUserProfile: string, + setUserProfile: string, + uploadFile: string, + videoQuery: string, + }, + hide: string, level: { b: string, i: string, e: string, }, mode: { - standard: string, - noFlag: string, - noGuess: string, - recursive: string + std: string, + nf: string, + ng: string, + dg: string, } + msg: { + actionFail: string, + actionSuccess: string, + agreeTAC: string, + confirmPasswordFail: string, + connectionFail: string, + emailCodeSent: string, + emptyEmail: string, + emptyEmailCode: string, + emptyPassword: string, + emptyUsername: string, + fileTooLarge: string, + invalidEmail: string, + invalidEmailCode: string, + invalidPassword: string, + invalidUsername: string, + logoutFail: string, + logoutSuccess: string, + realNameRequired: string, + }, prop: { action: string, designator: string, fileName: string, + is: string, + op: string, level: string, + realName: string, + sex: string, status: string, time: string, + timems: string, + upload_time: string, } + response: { + OK: '', + BadRequest: string, + Forbidden: string, + InternalServerError: string, + NotFound: string, + PayloadTooLarge: string, + UnsupportedMediaType: string, + }, + show: string, + toDo: string, }, forgetPassword: { title: string, @@ -38,7 +83,8 @@ export type LocaleConfig = LocaleMessage & { emailCode: string, password: string, confirmPassword: string, - confirm: string + confirm: string, + success: string, }, login: { title: string, @@ -60,6 +106,7 @@ export type LocaleConfig = LocaleMessage & { login: string, logout: string, register: string, + setting: string, downloads: string, links: string, team: string @@ -74,6 +121,13 @@ export type LocaleConfig = LocaleMessage & { confirmChange: string, cancelChange: string, designator: string, + msg: { + avatarChange: string, + avatarFormat: string, + avatarFilesize: string, + realnameChange: string, + signatureChange: string, + }, records: { title: string, modeRecord: string @@ -110,6 +164,16 @@ export type LocaleConfig = LocaleMessage & { confirmPassword: string, agreeTo: string, termsAndConditions: string, - confirm: string + confirm: string, + }, + setting: { + appearance: string, + darkMode: string, + languageSwitch: string, + menuFontSize: string, + menuHeight: string, + menuLayout: string, + menuLayoutAbstract: string, + menuLayoutDefault: string, }, } diff --git a/front_end/src/i18n/locales/en.ts b/front_end/src/i18n/locales/en.ts index ba53fb1b..2ef6bac6 100644 --- a/front_end/src/i18n/locales/en.ts +++ b/front_end/src/i18n/locales/en.ts @@ -2,6 +2,13 @@ export const en = { local: 'en', name: 'English', common: { + action: { + getSoftware: 'fetch video data', + getUserProfile: 'fetch user data', + setUserProfile: 'modify user data', + uploadFile: 'upload file', + videoQuery: 'fetch video data', + }, hide: 'Hide', level: { b: 'Beginner', @@ -15,6 +22,8 @@ export const en = { dg: 'Recursive Chord' }, msg: { + actionFail: 'Failed to {0}', + actionSuccess: 'Succeed to {0}', agreeTAC: 'Please agree to Terms and Conditions!', confirmPasswordFail: 'Passwords do not match!', connectionFail: 'Connection Fails!', @@ -23,12 +32,14 @@ export const en = { emptyEmailCode: 'Please enter 6-char email code!', emptyPassword: 'Please enter your password!', emptyUsername: 'Please enter your username!', + fileTooLarge: 'Maximum file size is {0}', invalidEmail: 'Invalid email!', invalidEmailCode: 'Email code is invalid! Please re-sent your email code.', invalidPassword: 'The length of password should be from 6 to 20!。', invalidUsername: 'The length of username cannot exceed 20!', logoutFail: 'Failed to log out!', logoutSuccess: 'Log out success!', + realNameRequired: 'Real name required', }, prop: { action: 'Action', @@ -42,6 +53,15 @@ export const en = { timems: 'Time', upload_time: 'Upload time', }, + response: { + OK: '', + BadRequest: 'Unrecognised request', + Forbidden: 'Permission denied', + InternalServerError: 'Internal server error', + NotFound: 'Data not found', + PayloadTooLarge: 'Payload too large', + UnsupportedMediaType: 'Unsupported file type', + }, show: 'Show', toDo: 'TODO', }, @@ -115,6 +135,19 @@ export const en = { } } }, + register: { + title: 'Register', + username: 'username', + email: 'email', + captcha: 'captcha', + getEmailCode: 'Send email code', + emailCode: 'email code', + password: 'password', + confirmPassword: 'confirm password', + agreeTo: 'Agree to ', + termsAndConditions: 'Terms & Conditions', + confirm: 'Register', + }, setting: { appearance: 'Appearance', darkMode: 'Dark Mode', From 25696a0088e25bf58cef6f79ea3d0abe3d348c8d Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Sun, 30 Jun 2024 11:55:00 +0100 Subject: [PATCH 4/6] Update en.ts --- front_end/src/i18n/locales/en.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/front_end/src/i18n/locales/en.ts b/front_end/src/i18n/locales/en.ts index 2ef6bac6..273a0bae 100644 --- a/front_end/src/i18n/locales/en.ts +++ b/front_end/src/i18n/locales/en.ts @@ -1,3 +1,5 @@ +import { LocaleConfig } from '@/i18n/config' + export const en = { local: 'en', name: 'English', @@ -43,6 +45,8 @@ export const en = { }, prop: { action: 'Action', + designator: 'Designator', + fileName: 'File name', is: 'Island', level: 'Level', op: 'Opening', @@ -67,13 +71,14 @@ export const en = { }, forgetPassword: { title: 'Reset password', - email: 'email', captcha: 'captcha', - getEmailCode: 'Send one-time password', + confirm: 'Reset', + confirmPassword: 'confirm password', + email: 'email', emailCode: 'one-time password', + getEmailCode: 'Send one-time password', password: 'new password', - confirmPassword: 'confirm password', - confirm: 'Reset' + success: 'Password reset complete!' }, login: { title: 'Login', @@ -110,6 +115,13 @@ export const en = { confirmChange: 'Confirm', cancelChange: 'Cancel', designator: 'My designators: ', + msg: { + avatarChange: 'Avatar change complete! {0} times left', + avatarFormat: 'Avatar file has to be in JPG or PNG format!', + avatarFilesize: 'Maximum file size is 50MB!', + realnameChange: 'Real name change complete! {0} times left', + signatureChange: 'Signature change complete! {0} times left', + }, records: { title: 'Personal Records', modeRecord: ' mode record: ' From c1442b4a5e1f690c908b5b9f733b3154a434f5ea Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Sun, 30 Jun 2024 12:32:10 +0100 Subject: [PATCH 5/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=9B=BE=E6=A0=87=E5=8F=AF=E8=83=BD=E7=9C=8B?= =?UTF-8?q?=E4=B8=8D=E8=A7=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front_end/src/components/LanguagePicker.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/front_end/src/components/LanguagePicker.vue b/front_end/src/components/LanguagePicker.vue index 8c7dcd78..e6568e08 100644 --- a/front_end/src/components/LanguagePicker.vue +++ b/front_end/src/components/LanguagePicker.vue @@ -40,8 +40,9 @@ const changeLanguage = (value: any) => { \ No newline at end of file From 04da0d2ec7ab99bd8b5b2066debb37ba89f83769 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Sun, 30 Jun 2024 13:30:38 +0100 Subject: [PATCH 6/6] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=BF=87=E4=BA=8E?= =?UTF-8?q?=E9=A2=91=E7=B9=81=E7=9A=84=E5=BC=82=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/saolei/settings.py | 2 +- back_end/saolei/utils/response.py | 4 ++++ front_end/src/i18n/config.ts | 1 + front_end/src/i18n/locales/en.ts | 1 + front_end/src/i18n/locales/zh-cn.ts | 1 + front_end/src/utils/system/status.ts | 1 + 6 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 back_end/saolei/utils/response.py diff --git a/back_end/saolei/saolei/settings.py b/back_end/saolei/saolei/settings.py index 3e13cc5e..64c71fa7 100644 --- a/back_end/saolei/saolei/settings.py +++ b/back_end/saolei/saolei/settings.py @@ -74,7 +74,7 @@ ROOT_URLCONF = "saolei.urls" -RATELIMIT_VIEW = "utils.ratelimited" +RATELIMIT_VIEW = "utils.response.ratelimited_error" TEMPLATES = [ { diff --git a/back_end/saolei/utils/response.py b/back_end/saolei/utils/response.py new file mode 100644 index 00000000..c1ae90c4 --- /dev/null +++ b/back_end/saolei/utils/response.py @@ -0,0 +1,4 @@ +from django.http import HttpResponse + +def ratelimited_error(request, exception): + return HttpResponse(status=429) \ No newline at end of file diff --git a/front_end/src/i18n/config.ts b/front_end/src/i18n/config.ts index 57c20fb4..66ef79d3 100644 --- a/front_end/src/i18n/config.ts +++ b/front_end/src/i18n/config.ts @@ -70,6 +70,7 @@ export type LocaleConfig = LocaleMessage & { InternalServerError: string, NotFound: string, PayloadTooLarge: string, + TooManyRequests: string, UnsupportedMediaType: string, }, show: string, diff --git a/front_end/src/i18n/locales/en.ts b/front_end/src/i18n/locales/en.ts index 273a0bae..b1e684aa 100644 --- a/front_end/src/i18n/locales/en.ts +++ b/front_end/src/i18n/locales/en.ts @@ -64,6 +64,7 @@ export const en = { InternalServerError: 'Internal server error', NotFound: 'Data not found', PayloadTooLarge: 'Payload too large', + TooManyRequests: 'Too many requests', UnsupportedMediaType: 'Unsupported file type', }, show: 'Show', diff --git a/front_end/src/i18n/locales/zh-cn.ts b/front_end/src/i18n/locales/zh-cn.ts index 0f4a75b2..1d72de3a 100644 --- a/front_end/src/i18n/locales/zh-cn.ts +++ b/front_end/src/i18n/locales/zh-cn.ts @@ -64,6 +64,7 @@ export const zhCn = { InternalServerError: '后端发生错误', NotFound: '找不到数据', PayloadTooLarge: '文件过大', + TooManyRequests: '请求过于频繁', UnsupportedMediaType: '不支持的文件类型', }, show: '显示', diff --git a/front_end/src/utils/system/status.ts b/front_end/src/utils/system/status.ts index 34068f78..06cc6455 100644 --- a/front_end/src/utils/system/status.ts +++ b/front_end/src/utils/system/status.ts @@ -11,6 +11,7 @@ const notificationMessage: { [code: number]: string} = { 404: 'common.response.NotFound', 413: 'common.response.PayloadTooLarge', 415: 'common.response.UnsupportedMediaType', + 429: 'common.response.TooManyRequests', 500: 'common.response.InternalServerError', };