mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-14 01:34:47 +08:00
fix: WebDav 端口去掉必填校验 (#3617)
This commit is contained in:
parent
33910f7993
commit
be6b58b0a1
@ -15,12 +15,16 @@ type webDAVClient struct {
|
|||||||
|
|
||||||
func NewWebDAVClient(vars map[string]interface{}) (*webDAVClient, error) {
|
func NewWebDAVClient(vars map[string]interface{}) (*webDAVClient, error) {
|
||||||
address := loadParamFromVars("address", true, vars)
|
address := loadParamFromVars("address", true, vars)
|
||||||
port := loadParamFromVars("port", false, vars)
|
port := loadParamFromVars("port", true, vars)
|
||||||
password := loadParamFromVars("password", true, vars)
|
password := loadParamFromVars("password", true, vars)
|
||||||
username := loadParamFromVars("username", true, vars)
|
username := loadParamFromVars("username", true, vars)
|
||||||
bucket := loadParamFromVars("bucket", 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 {
|
if err := client.Connect(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,8 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('commons.table.port')" prop="varsJson.port" :rules="[Rules.port]">
|
<el-form-item :label="$t('commons.table.port')" prop="varsJson.port" :rules="[portRule]">
|
||||||
<el-input-number
|
<el-input-number v-model.number="webdavData.rowData!.varsJson['port']" />
|
||||||
:min="0"
|
|
||||||
:max="65535"
|
|
||||||
v-model.number="webdavData.rowData!.varsJson['port']"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
:label="$t('commons.login.username')"
|
:label="$t('commons.login.username')"
|
||||||
@ -71,7 +67,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 i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { ElForm } from 'element-plus';
|
import { ElForm } from 'element-plus';
|
||||||
@ -79,7 +75,7 @@ import { Backup } from '@/api/interface/backup';
|
|||||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||||
import { addBackup, editBackup } from '@/api/modules/setting';
|
import { addBackup, editBackup } from '@/api/modules/setting';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
import { spliceHttp, splitHttp } from '@/utils/util';
|
import { checkPort, spliceHttp, splitHttp } from '@/utils/util';
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
type FormInstance = InstanceType<typeof ElForm>;
|
type FormInstance = InstanceType<typeof ElForm>;
|
||||||
@ -97,6 +93,18 @@ const drawerVisible = ref(false);
|
|||||||
const webdavData = ref<DialogProps>({
|
const webdavData = ref<DialogProps>({
|
||||||
title: '',
|
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 => {
|
const acceptParams = (params: DialogProps): void => {
|
||||||
webdavData.value = params;
|
webdavData.value = params;
|
||||||
if (webdavData.value.title === 'edit') {
|
if (webdavData.value.title === 'edit') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user