refactor: centralize llm backend configuration
This commit is contained in:
@@ -29,6 +29,29 @@
|
||||
<iframe ref="monitorFrame" src="{{ src_url }}" frameborder="0"></iframe>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card class="workspace-card" shadow="hover">
|
||||
<div slot="header" class="workspace-header">
|
||||
<div>
|
||||
<h3>全局配置</h3>
|
||||
<p>集中维护 `config.yaml`,其中 `llm.backends` 用于统一管理所有模型后端。</p>
|
||||
</div>
|
||||
<div class="page-hero-actions">
|
||||
<el-button size="mini" plain @click="loadSystemConfig">刷新配置</el-button>
|
||||
<el-button size="mini" type="success" @click="saveSystemConfig">保存配置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-meta" v-if="configPath">
|
||||
<span>配置文件:{% raw %}{{ configPath }}{% endraw %}</span>
|
||||
<span v-if="llmBackends.length">LLM 后端:{% raw %}{{ llmBackends.join(', ') }}{% endraw %}</span>
|
||||
</div>
|
||||
<el-input
|
||||
type="textarea"
|
||||
v-model="systemConfigText"
|
||||
:rows="18"
|
||||
placeholder="请输入 YAML 格式的全局配置">
|
||||
</el-input>
|
||||
</el-card>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -42,11 +65,15 @@
|
||||
currentView: '14',
|
||||
showTimeRangeSelector: false,
|
||||
frameUrl: '{{ src_url }}',
|
||||
restarting: false
|
||||
restarting: false,
|
||||
systemConfigText: '',
|
||||
configPath: '',
|
||||
llmBackends: []
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.currentView = '14';
|
||||
this.loadSystemConfig();
|
||||
},
|
||||
methods: {
|
||||
reloadIframe() {
|
||||
@@ -81,6 +108,35 @@
|
||||
} finally {
|
||||
this.restarting = false;
|
||||
}
|
||||
},
|
||||
async loadSystemConfig() {
|
||||
try {
|
||||
const response = await axios.get('/api/system/config/raw');
|
||||
if (response.data.success) {
|
||||
this.systemConfigText = response.data.data || '';
|
||||
this.configPath = response.data.path || '';
|
||||
this.llmBackends = response.data.llm_backends || [];
|
||||
} else {
|
||||
this.$message.error(response.data.message || '读取全局配置失败');
|
||||
}
|
||||
} catch (error) {
|
||||
this.$message.error(error.response?.data?.message || '读取全局配置失败');
|
||||
}
|
||||
},
|
||||
async saveSystemConfig() {
|
||||
try {
|
||||
const response = await axios.post('/api/system/config/update', {
|
||||
config_text: this.systemConfigText
|
||||
});
|
||||
if (response.data.success) {
|
||||
this.$message.success(response.data.message || '保存成功');
|
||||
this.loadSystemConfig();
|
||||
} else {
|
||||
this.$message.error(response.data.message || '保存失败');
|
||||
}
|
||||
} catch (error) {
|
||||
this.$message.error(error.response?.data?.message || '保存失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -108,5 +164,7 @@
|
||||
.iframe-shell-card .el-card__body { height: calc(100% - 73px); }
|
||||
.iframe-shell { height: 100%; border-radius: 18px; overflow: hidden; border: 1px solid rgba(148,163,184,0.12); background: rgba(248,250,252,0.82); }
|
||||
.iframe-shell iframe { width: 100%; height: 100%; border: none; display: block; background: #fff; }
|
||||
.workspace-card .el-card__body { display: flex; flex-direction: column; gap: 12px; }
|
||||
.config-meta { display: flex; justify-content: space-between; gap: 12px; color: #64748b; font-size: 12px; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user