Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OneDrive 授权码增加格式校验 #2614

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ const message = {
SFTP: 'SFTP',
OneDrive: 'Microsoft OneDrive',
backupDir: 'Backup dir',
codeWarning: 'The current authorization code format is incorrect, please confirm again!',
isCN: 'Domestic version',
code: 'Auth code',
codeHelper:
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ const message = {
MINIO: 'MINIO',
SFTP: 'SFTP',
OneDrive: '微軟 OneDrive',
codeWarning: '當前授權碼格式錯誤,請重新確認!',
backupDir: '備份路徑',
isCN: '國內版',
code: '授權碼',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ const message = {
MINIO: 'MINIO',
SFTP: 'SFTP',
OneDrive: '微软 OneDrive',
codeWarning: '当前授权码格式错误,请重新确认!',
backupDir: '备份路径',
isCN: '国内版',
code: '授权码',
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/views/setting/backup-account/operate/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
v-if="dialogData.rowData!.type === 'OneDrive'"
:label="$t('setting.code')"
prop="varsJson.code"
:rules="Rules.requiredInput"
:rules="rules.driveCode"
>
<el-input clearable v-model.trim="dialogData.rowData!.varsJson['code']">
<template #append>
Expand Down Expand Up @@ -247,7 +247,7 @@
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { reactive, ref } from 'vue';
import { Rules } from '@/global/form-rules';
import FileList from '@/components/file-list/index.vue';
import i18n from '@/lang';
Expand All @@ -265,6 +265,16 @@ const buckets = ref();
const errBuckets = ref();

const endpoints = ref('http');
const rules = reactive({
driveCode: [{ validator: checkDriveCode, required: true, trigger: 'blur' }],
});
function checkDriveCode(rule: any, value: any, callback: any) {
const reg = /^[A-Za-z0-9_.-]{32,60}$/;
if (!reg.test(value)) {
return callback(new Error(i18n.global.t('setting.codeWarning')));
}
callback();
}

const emit = defineEmits<{ (e: 'search'): void }>();

Expand Down
Loading