99 </a-radio-group >
1010 </a-form-item >
1111 <a-form-item :label =" $t('domain')" :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" >
12- <a-input v-model =" form.domain" placeholder =" http(s)://" />
12+ <a-input-group compact >
13+ <a-select v-model =" protocol" style =" width : 96px " >
14+ <a-select-option value =" https://" >https://</a-select-option >
15+ <a-select-option value =" http://" >http://</a-select-option >
16+ </a-select >
17+ <a-input v-model =" form.domain" placeholder =" mydomain.com" style =" width : calc (100% - 96px );" />
18+ </a-input-group >
1319 </a-form-item >
1420 <template v-if =" [' github' , ' coding' ].includes (form .platform ) " >
1521 <a-form-item :label =" $t('repository')" :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" >
4652 <a-form-item label =" Username" :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" >
4753 <a-input v-model =" form.username" />
4854 </a-form-item >
49- <a-form-item label =" Password" :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" >
55+ <a-form-item label =" Connect Type" :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" >
56+ <a-radio-group name =" remoteType" v-model =" remoteType" >
57+ <a-radio value =" password" >Password</a-radio >
58+ <a-radio value =" key" >SSH Key</a-radio >
59+ </a-radio-group >
60+ </a-form-item >
61+ <a-form-item label =" Password" :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" v-if =" remoteType === 'password'" >
5062 <a-input v-model =" form.password" :type =" passVisible ? '' : 'password'" >
5163 <a-icon class =" icon" slot =" addonAfter" :type =" passVisible ? 'eye-invisible' : 'eye'" @click =" passVisible = !passVisible" />
5264 </a-input >
5365 </a-form-item >
54- <a-form-item label =" Private Key" :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" :help =" $t('privateKeyTip')" >
66+ <a-form-item label =" Private Key Path " :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" :help =" $t('privateKeyTip')" v-else >
5567 <a-input v-model =" form.privateKey" />
5668 </a-form-item >
5769 <a-form-item label =" Remote Path" :labelCol =" formLayout.label" :wrapperCol =" formLayout.wrapper" :colon =" false" :help =" $t('remotePathTip')" >
@@ -93,6 +105,8 @@ export default class BasicSetting extends Vue {
93105 wrapper: { span: 12 },
94106 }
95107
108+ protocol = ' https://'
109+
96110 form: ISetting = {
97111 platform: ' github' ,
98112 domain: ' ' ,
@@ -110,6 +124,8 @@ export default class BasicSetting extends Vue {
110124 remotePath: ' ' ,
111125 }
112126
127+ remoteType = ' password'
128+
113129 get canSubmit() {
114130 const { form } = this
115131 const baseValid = form .domain
@@ -133,8 +149,20 @@ export default class BasicSetting extends Vue {
133149 const { form, site : { setting } } = this
134150 console .log (' setting' , setting )
135151 Object .keys (form ).forEach ((key : string ) => {
136- form [key ] = setting [key ]
152+ if (key === ' domain' ) {
153+ const protocolEndIndex = setting [key ].indexOf (' ://' )
154+ if (protocolEndIndex !== - 1 ) {
155+ form [key ] = setting [key ].substring (protocolEndIndex + 3 )
156+ this .protocol = setting [key ].substring (0 , protocolEndIndex + 3 )
157+ }
158+ } else {
159+ form [key ] = setting [key ]
160+ }
137161 })
162+
163+ if (form .privateKey ) {
164+ this .remoteType = ' key'
165+ }
138166 }
139167
140168 /**
@@ -153,7 +181,18 @@ export default class BasicSetting extends Vue {
153181 const formValid = this .checkFormValid ()
154182 if (! formValid ) { return false }
155183
156- ipcRenderer .send (' setting-save' , this .form )
184+ const form = {
185+ ... this .form ,
186+ domain: ` ${this .protocol }${this .form .domain } ` ,
187+ }
188+
189+ if (this .remoteType === ' password' ) {
190+ form .privateKey = ' '
191+ } else {
192+ form .password = ' '
193+ }
194+
195+ ipcRenderer .send (' setting-save' , form )
157196 ipcRenderer .once (' setting-saved' , (event : IpcRendererEvent , result : any ) => {
158197 this .$bus .$emit (' site-reload' )
159198 this .$message .success (this .$t (' basicSettingSuccess' ))
@@ -163,7 +202,12 @@ export default class BasicSetting extends Vue {
163202 }
164203
165204 async remoteDetect() {
166- ipcRenderer .send (' setting-save' , this .form )
205+ const form = {
206+ ... this .form ,
207+ domain: ` ${this .protocol }${this .form .domain } ` ,
208+ }
209+
210+ ipcRenderer .send (' setting-save' , form )
167211 ipcRenderer .once (' setting-saved' , () => {
168212 ipcRenderer .send (' app-site-reload' )
169213 ipcRenderer .once (' app-site-loaded' , () => {
0 commit comments