mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-30 22:02:24 +00:00
perf: 优化 protocol setting
This commit is contained in:
parent
09dabb5d3f
commit
ddf9780f9c
@ -5,7 +5,7 @@
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
:show-confirm="false"
|
||||
:title="$tc('assets.PlatformProtocolConfig') + ':' + item.name"
|
||||
:title="$tc('assets.PlatformProtocolConfig') + ':' + protocol.name"
|
||||
class="setting-dialog"
|
||||
v-bind="$attrs"
|
||||
width="70%"
|
||||
@ -38,7 +38,7 @@ export default {
|
||||
AutoDataForm
|
||||
},
|
||||
props: {
|
||||
item: {
|
||||
protocol: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
@ -51,23 +51,13 @@ export default {
|
||||
const vm = this
|
||||
const platform = this.$route.query.platform
|
||||
return {
|
||||
baseAttrs: ['primary', 'required', 'default', 'public'], // 基础属性, 放到 setting 中处理了,处理完成后,还得返回回去
|
||||
defaultSetting: {
|
||||
sftp_enabled: true,
|
||||
sftp_home: '/tmp',
|
||||
username_selector: '#username',
|
||||
password_selector: '#password',
|
||||
submit_selector: '.btn-submit',
|
||||
security: 'any',
|
||||
console: false
|
||||
},
|
||||
loading: true,
|
||||
form: {},
|
||||
form: this.protocol,
|
||||
platformDetail: platform ? '#/console/assets/platforms/' + platform : '',
|
||||
config: {
|
||||
hasSaveContinue: false,
|
||||
hasButtons: !this.disabled,
|
||||
url: '/api/v1/assets/protocol-settings/?name=' + this.item.name,
|
||||
url: '/api/v1/assets/protocol-settings/?name=' + this.protocol.name,
|
||||
fields: [
|
||||
[vm.$t('common.Basic'), [
|
||||
'primary', 'required', 'default', 'public'
|
||||
@ -82,25 +72,11 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.form = this.item.setting
|
||||
if (!this.form || !this.item) {
|
||||
return
|
||||
}
|
||||
for (const i of this.baseAttrs) {
|
||||
this.form[i] = !!this.item[i]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSubmit(form) {
|
||||
for (const i of this.baseAttrs) {
|
||||
if (form.hasOwnProperty(i)) {
|
||||
this.item[i] = form[i]
|
||||
}
|
||||
}
|
||||
this.item.setting = form
|
||||
this.protocol = Object.assign(this.protocol, form)
|
||||
this.$emit('update:visible', false)
|
||||
this.$emit('confirm', this.item)
|
||||
this.$emit('confirm', this.protocol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@
|
||||
<ProtocolSettingDialog
|
||||
v-if="showDialog"
|
||||
:disabled="settingReadonly || readonly"
|
||||
:item="settingItem"
|
||||
:protocol="currentProtocol"
|
||||
:visible.sync="showDialog"
|
||||
@confirm="handleSettingConfirm"
|
||||
/>
|
||||
@ -108,7 +108,7 @@ export default {
|
||||
return {
|
||||
name: '',
|
||||
items: [],
|
||||
settingItem: {},
|
||||
currentProtocol: {},
|
||||
showDialog: false,
|
||||
loading: false
|
||||
}
|
||||
@ -167,20 +167,20 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
handleSettingConfirm() {
|
||||
if (this.settingItem.primary) {
|
||||
if (this.currentProtocol.primary) {
|
||||
const others = this.items
|
||||
.filter(item => item.name !== this.settingItem.name)
|
||||
.filter(item => item.name !== this.currentProtocol.name)
|
||||
.map(item => {
|
||||
item.primary = false
|
||||
return item
|
||||
})
|
||||
this.items = [this.settingItem, ...others]
|
||||
this.items = [this.currentProtocol, ...others]
|
||||
}
|
||||
if (this.settingItem.name === 'winrm') {
|
||||
if (this.settingItem.setting?.use_ssl) {
|
||||
this.settingItem.port = 5986
|
||||
if (this.currentProtocol.name === 'winrm') {
|
||||
if (this.currentProtocol.setting?.use_ssl) {
|
||||
this.currentProtocol.port = 5986
|
||||
} else {
|
||||
this.settingItem.port = 5985
|
||||
this.currentProtocol.port = 5985
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -271,7 +271,7 @@ export default {
|
||||
return protocols
|
||||
},
|
||||
onSettingClick(item) {
|
||||
this.settingItem = item
|
||||
this.currentProtocol = item
|
||||
this.showDialog = true
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user