Browse Source

fix: WebDav 端口去掉必填校验 (#3617)

pull/3618/head
ssongliu 10 months ago committed by GitHub
parent
commit
be6b58b0a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      backend/utils/cloud_storage/client/webdav.go
  2. 24
      frontend/src/views/setting/backup-account/webdav/index.vue

8
backend/utils/cloud_storage/client/webdav.go

@ -15,12 +15,16 @@ type webDAVClient struct {
func NewWebDAVClient(vars map[string]interface{}) (*webDAVClient, error) {
address := loadParamFromVars("address", true, vars)
port := loadParamFromVars("port", false, vars)
port := loadParamFromVars("port", true, vars)
password := loadParamFromVars("password", true, vars)
username := loadParamFromVars("username", true, vars)
bucket := loadParamFromVars("bucket", true, vars)
client := gowebdav.NewClient(fmt.Sprintf("%s:%s", address, port), username, password)
url := fmt.Sprintf("%s:%s", address, port)
if len(port) == 0 {
url = address
}
client := gowebdav.NewClient(url, username, password)
if err := client.Connect(); err != nil {
return nil, err
}

24
frontend/src/views/setting/backup-account/webdav/index.vue

@ -24,12 +24,8 @@
</template>
</el-input>
</el-form-item>
<el-form-item :label="$t('commons.table.port')" prop="varsJson.port" :rules="[Rules.port]">
<el-input-number
:min="0"
:max="65535"
v-model.number="webdavData.rowData!.varsJson['port']"
/>
<el-form-item :label="$t('commons.table.port')" prop="varsJson.port" :rules="[portRule]">
<el-input-number v-model.number="webdavData.rowData!.varsJson['port']" />
</el-form-item>
<el-form-item
:label="$t('commons.login.username')"
@ -71,7 +67,7 @@
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { reactive, ref } from 'vue';
import { Rules } from '@/global/form-rules';
import i18n from '@/lang';
import { ElForm } from 'element-plus';
@ -79,7 +75,7 @@ import { Backup } from '@/api/interface/backup';
import DrawerHeader from '@/components/drawer-header/index.vue';
import { addBackup, editBackup } from '@/api/modules/setting';
import { MsgSuccess } from '@/utils/message';
import { spliceHttp, splitHttp } from '@/utils/util';
import { checkPort, spliceHttp, splitHttp } from '@/utils/util';
const loading = ref(false);
type FormInstance = InstanceType<typeof ElForm>;
@ -97,6 +93,18 @@ const drawerVisible = ref(false);
const webdavData = ref<DialogProps>({
title: '',
});
const portRule = reactive({ validator: checkportRule, trigger: 'blur', type: 'number' });
function checkportRule(rule: any, value: any, callback: any) {
if (value !== undefined && value !== null) {
if (checkPort(value)) {
return callback(new Error(i18n.global.t('commons.rule.port')));
}
}
callback();
}
const acceptParams = (params: DialogProps): void => {
webdavData.value = params;
if (webdavData.value.title === 'edit') {

Loading…
Cancel
Save