Skip to content
Permalink
Browse files

update server setting

  • Loading branch information
EryouHao committed Feb 13, 2020
1 parent bf4aafc commit 49e78908e0e5294d92a2b785f00313c0300d7530
Showing with 57 additions and 13 deletions.
  1. +7 −7 src/assets/locales.ts
  2. +50 −6 src/views/setting/includes/BasicSetting.vue
@@ -53,7 +53,7 @@ const message = {
faviconSetting: '网页图标',
avatarSetting: '头像配置',
domain: '域 名',
repository: '仓 库',
repository: '仓库名称',
branch: '分 支',
username: '仓库用户名',
email: '邮 箱',
@@ -108,9 +108,9 @@ const message = {
words: '字 数',
readingTime: '阅读时间',
version: '版本',
token: '令牌',
token: '令 牌',
tokenUsername: '令牌用户名',
platform: '平台',
platform: '平 台',
},
zh_TW: {
preview: '預 覽',
@@ -167,7 +167,7 @@ const message = {
faviconSetting: '網頁圖標',
avatarSetting: '頭像配置',
domain: '域 名',
repository: '倉 庫',
repository: '倉庫名稱',
branch: '分 支',
username: '倉庫用戶名',
email: '郵 箱',
@@ -222,9 +222,9 @@ const message = {
words: '字 數',
readingTime: '閱讀時間',
version: '版本',
token: '令牌',
token: '令 牌',
tokenUsername: '令牌用户名',
platform: '平臺',
platform: '平 臺',
},
en: {
preview: 'Preview',
@@ -280,7 +280,7 @@ const message = {
faviconSetting: 'Favicon Setting',
avatarSetting: 'Avatar Setting',
domain: 'Domain',
repository: 'Repository',
repository: 'Repository Name',
branch: 'Branch',
username: 'Branch Username',
email: 'Email',
@@ -9,7 +9,13 @@
</a-radio-group>
</a-form-item>
<a-form-item :label="$t('domain')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-input v-model="form.domain" placeholder="http(s)://" />
<a-input-group compact>
<a-select v-model="protocol" style="width: 96px">
<a-select-option value="https://">https://</a-select-option>
<a-select-option value="http://">http://</a-select-option>
</a-select>
<a-input v-model="form.domain" placeholder="mydomain.com" style="width: calc(100% - 96px);" />
</a-input-group>
</a-form-item>
<template v-if="['github', 'coding'].includes(form.platform)">
<a-form-item :label="$t('repository')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
@@ -46,12 +52,18 @@
<a-form-item label="Username" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-input v-model="form.username" />
</a-form-item>
<a-form-item label="Password" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-form-item label="Connect Type" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-radio-group name="remoteType" v-model="remoteType">
<a-radio value="password">Password</a-radio>
<a-radio value="key">SSH Key</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="Password" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false" v-if="remoteType === 'password'">
<a-input v-model="form.password" :type="passVisible ? '' : 'password'">
<a-icon class="icon" slot="addonAfter" :type="passVisible ? 'eye-invisible' : 'eye'" @click="passVisible = !passVisible" />
</a-input>
</a-form-item>
<a-form-item label="Private Key" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false" :help="$t('privateKeyTip')">
<a-form-item label="Private Key Path" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false" :help="$t('privateKeyTip')" v-else>
<a-input v-model="form.privateKey" />
</a-form-item>
<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 {
wrapper: { span: 12 },
}
protocol = 'https://'
form: ISetting = {
platform: 'github',
domain: '',
@@ -110,6 +124,8 @@ export default class BasicSetting extends Vue {
remotePath: '',
}
remoteType = 'password'
get canSubmit() {
const { form } = this
const baseValid = form.domain
@@ -133,8 +149,20 @@ export default class BasicSetting extends Vue {
const { form, site: { setting } } = this
console.log('setting', setting)
Object.keys(form).forEach((key: string) => {
form[key] = setting[key]
if (key === 'domain') {
const protocolEndIndex = setting[key].indexOf('://')
if (protocolEndIndex !== -1) {
form[key] = setting[key].substring(protocolEndIndex + 3)
this.protocol = setting[key].substring(0, protocolEndIndex + 3)
}
} else {
form[key] = setting[key]
}
})
if (form.privateKey) {
this.remoteType = 'key'
}
}
/**
@@ -153,7 +181,18 @@ export default class BasicSetting extends Vue {
const formValid = this.checkFormValid()
if (!formValid) { return false }
ipcRenderer.send('setting-save', this.form)
const form = {
...this.form,
domain: `${this.protocol}${this.form.domain}`,
}
if (this.remoteType === 'password') {
form.privateKey = ''
} else {
form.password = ''
}
ipcRenderer.send('setting-save', form)
ipcRenderer.once('setting-saved', (event: IpcRendererEvent, result: any) => {
this.$bus.$emit('site-reload')
this.$message.success(this.$t('basicSettingSuccess'))
@@ -163,7 +202,12 @@ export default class BasicSetting extends Vue {
}
async remoteDetect() {
ipcRenderer.send('setting-save', this.form)
const form = {
...this.form,
domain: `${this.protocol}${this.form.domain}`,
}
ipcRenderer.send('setting-save', form)
ipcRenderer.once('setting-saved', () => {
ipcRenderer.send('app-site-reload')
ipcRenderer.once('app-site-loaded', () => {

0 comments on commit 49e7890

Please sign in to comment.
You can’t perform that action at this time.