1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 22:18:07 +08:00

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

Refs #2610
This commit is contained in:
ssongliu 2023-10-21 22:46:48 +08:00 committed by wanghe-fit2cloud
parent a2bfa5acaa
commit 0ed5ae71c5
4 changed files with 15 additions and 2 deletions

View File

@ -1065,6 +1065,7 @@ const message = {
SFTP: 'SFTP', SFTP: 'SFTP',
OneDrive: 'Microsoft OneDrive', OneDrive: 'Microsoft OneDrive',
backupDir: 'Backup dir', backupDir: 'Backup dir',
codeWarning: 'The current authorization code format is incorrect, please confirm again!',
isCN: 'Domestic version', isCN: 'Domestic version',
code: 'Auth code', code: 'Auth code',
codeHelper: codeHelper:

View File

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

View File

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

View File

@ -52,7 +52,7 @@
v-if="dialogData.rowData!.type === 'OneDrive'" v-if="dialogData.rowData!.type === 'OneDrive'"
:label="$t('setting.code')" :label="$t('setting.code')"
prop="varsJson.code" prop="varsJson.code"
:rules="Rules.requiredInput" :rules="rules.driveCode"
> >
<el-input clearable v-model.trim="dialogData.rowData!.varsJson['code']"> <el-input clearable v-model.trim="dialogData.rowData!.varsJson['code']">
<template #append> <template #append>
@ -247,7 +247,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { reactive, ref } from 'vue';
import { Rules } from '@/global/form-rules'; import { Rules } from '@/global/form-rules';
import FileList from '@/components/file-list/index.vue'; import FileList from '@/components/file-list/index.vue';
import i18n from '@/lang'; import i18n from '@/lang';
@ -265,6 +265,16 @@ const buckets = ref();
const errBuckets = ref(); const errBuckets = ref();
const endpoints = ref('http'); 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 }>(); const emit = defineEmits<{ (e: 'search'): void }>();