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

Refs #2610
This commit is contained in:
ssongliu 2023-10-21 22:46:48 +08:00 committed by GitHub
parent 8a7e61e9e5
commit e1cf68becc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View file

@ -1091,6 +1091,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:

View file

@ -1043,6 +1043,7 @@ const message = {
MINIO: 'MINIO',
SFTP: 'SFTP',
OneDrive: '微軟 OneDrive',
codeWarning: '當前授權碼格式錯誤請重新確認',
backupDir: '備份路徑',
isCN: '國內版',
code: '授權碼',

View file

@ -1044,6 +1044,7 @@ const message = {
MINIO: 'MINIO',
SFTP: 'SFTP',
OneDrive: '微软 OneDrive',
codeWarning: '当前授权码格式错误请重新确认',
backupDir: '备份路径',
isCN: '国内版',
code: '授权码',

View file

@ -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>
@ -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';
@ -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 }>();