Browse Source

feat: support update application.yaml.

pull/59/head
ruibaby 5 years ago
parent
commit
d58b1f022f
  1. 25
      src/api/admin.js
  2. 12
      src/views/system/developer/DeveloperOptions.vue
  3. 95
      src/views/system/developer/tabs/ApplicationConfig.vue
  4. 8
      src/views/system/developer/tabs/OptionsList.vue

25
src/api/admin.js

@ -82,4 +82,29 @@ adminApi.updateAdminAssets = () => {
timeout: 600 * 1000
})
}
adminApi.getApplicationConfig = () => {
return service({
url: `${baseUrl}/spring/application.yaml`,
method: 'get'
})
}
adminApi.updateApplicationConfig = content => {
return service({
url: `${baseUrl}/spring/application.yaml/update`,
params: {
content: content
},
method: 'put'
})
}
adminApi.restartApplication = () => {
return service({
url: `${baseUrl}/spring/restart`,
method: 'post'
})
}
export default adminApi

12
src/views/system/developer/DeveloperOptions.vue

@ -21,10 +21,16 @@
</a-tab-pane>
<a-tab-pane key="optionsList">
<span slot="tab">
<a-icon type="code" />系统变量
<a-icon type="table" />系统变量
</span>
<OptionsList />
</a-tab-pane>
<a-tab-pane key="applicationConfig">
<span slot="tab">
<a-icon type="file-protect" />配置文件
</span>
<ApplicationConfig />
</a-tab-pane>
<a-tab-pane key="settings">
<span slot="tab">
<a-icon type="setting" />设置
@ -50,12 +56,14 @@ import Environment from './tabs/Environment'
import RuntimeLogs from './tabs/RuntimeLogs'
import SettingsForm from './tabs/SettingsForm'
import OptionsList from './tabs/OptionsList'
import ApplicationConfig from './tabs/ApplicationConfig'
export default {
components: {
Environment,
RuntimeLogs,
SettingsForm,
OptionsList
OptionsList,
ApplicationConfig
},
computed: {
...mapGetters(['options'])

95
src/views/system/developer/tabs/ApplicationConfig.vue

@ -0,0 +1,95 @@
<template>
<div>
<a-alert
message="注意:配置文件严格要求代码格式,上下文必须对齐,属性与值之间必须以英文引号和空格隔开。如格式有误,将无法启动。"
banner
closable
/>
<a-form layout="vertical">
<a-form-item>
<a-skeleton
active
:loading="loading"
:paragraph="{rows: 12}"
>
<codemirror
v-model="content"
:options="codemirrorOptions"
></codemirror>
</a-skeleton>
</a-form-item>
<a-form-item>
<a-popconfirm
:title="'修改配置文件之后需重启才能生效,是否继续?'"
okText="确定"
cancelText="取消"
@confirm="handleUpdateConfig()"
>
<a-button
type="primary"
style="margin-right: 8px;"
>保存</a-button>
</a-popconfirm>
<a-button
type="danger"
@click="handleRestartApplication()"
>重启</a-button>
</a-form-item>
</a-form>
</div>
</template>
<script>
import { codemirror } from 'vue-codemirror-lite'
import 'codemirror/mode/yaml/yaml.js'
import adminApi from '@/api/admin'
export default {
name: 'ApplicationConfig',
components: {
codemirror
},
data() {
return {
codemirrorOptions: {
tabSize: 4,
mode: 'text/x-yaml',
lineNumbers: true,
line: true
},
content: '',
loading: true
}
},
created() {
this.loadConfig()
},
methods: {
loadConfig() {
this.loading = true
adminApi.getApplicationConfig().then(response => {
this.content = response.data.data
this.loading = false
})
},
handleUpdateConfig() {
adminApi.updateApplicationConfig(this.content).then(response => {
this.$message.success(`配置保存成功!`)
this.loadConfig()
})
},
handleRestartApplication() {
adminApi.restartApplication().then(response => {
this.$message.success(`重启中...`)
})
}
}
}
</script>
<style lang="less">
.CodeMirror {
height: 560px;
}
.CodeMirror-gutters {
border-right: 1px solid #fff3f3;
background-color: #ffffff;
}
</style>

8
src/views/system/developer/tabs/OptionsList.vue

@ -170,7 +170,11 @@
<a-input v-model="optionToStage.key" />
</a-form-item>
<a-form-item label="Value:">
<a-input v-model="optionToStage.value" />
<a-input
type="textarea"
:autosize="{ minRows: 5 }"
v-model="optionToStage.value"
/>
</a-form-item>
</a-form>
</a-modal>
@ -211,7 +215,7 @@ const columns = [
{
title: '操作',
dataIndex: 'action',
width: '180px',
width: '120px',
scopedSlots: { customRender: 'action' }
}
]

Loading…
Cancel
Save