chore: post-deployment cleanup and docs update
- Make AI routing rules DB-driven (read from system_configs, removed from config.py) - Add translation quota tracking to LLM translation (OpenAIProvider) - Add Alibaba MT ECS RAM role support (STS token, no AccessKey needed) - Fix admin sidebar link for AI模型配置 page - Fix Quota.vue API path (quotas → translation-quotas) - Fix login auto-redirect to dashboard - Add provider dropdown selects to AI routing config UI - Clean up stale ai_provider_* system_configs records - Remove OpencodeGo, Spark providers (code + DB) - Update deploy config: nginx port 8000, systemd cwd
This commit is contained in:
@@ -7,7 +7,24 @@
|
||||
<el-tag size="small" v-if="cfg.description">{{ cfg.description }}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="typeof cfg.value === 'object' && !Array.isArray(cfg.value)">
|
||||
<div v-if="cfg.key === 'ai_routing'">
|
||||
<div v-for="(taskVal, taskKey) in cfg.value" :key="taskKey" class="cfg-nested-group">
|
||||
<div class="cfg-group-title">{{ fieldLabelsMap.ai_routing?.[taskKey] || taskKey }}</div>
|
||||
<div class="cfg-field">
|
||||
<span class="cfg-label">主选</span>
|
||||
<el-select v-model="edits[cfg.key][taskKey].primary" size="small" style="width:300px" filterable>
|
||||
<el-option v-for="p in providers" :key="p.provider_type" :value="p.provider_type" :label="p.name + ' — ' + p.model_name" />
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="cfg-field">
|
||||
<span class="cfg-label">备用</span>
|
||||
<el-select v-model="edits[cfg.key][taskKey].fallback" size="small" style="width:400px" multiple filterable collapse-tags>
|
||||
<el-option v-for="p in providers" :key="p.provider_type" :value="p.provider_type" :label="p.name + ' — ' + p.model_name" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="typeof cfg.value === 'object' && !Array.isArray(cfg.value)">
|
||||
<div class="cfg-field" v-for="(v, k) in cfg.value" :key="k">
|
||||
<span class="cfg-label">{{ fieldLabel(cfg.key, k) }}</span>
|
||||
<el-input v-if="typeof v === 'string'" v-model="edits[cfg.key][k]" size="small" style="width:300px" />
|
||||
@@ -34,12 +51,33 @@
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { listConfig, updateConfig } from '@/api'
|
||||
import http from '@/api'
|
||||
|
||||
const configs = ref([])
|
||||
const edits = reactive({})
|
||||
const configLabels = { system_maintenance: '系统维护', feature_flags: '功能开关', translation_providers: '翻译服务', ai_model_config: 'AI模型', cache_ttl: '缓存时间' }
|
||||
const fieldLabelsMap = { system_maintenance: { maintenance_mode: '维护模式', maintenance_message: '维护消息' }, feature_flags: { feature_wechat_login: '微信登录', feature_export: '数据导出' }, translation_providers: { primary: '首选服务', fallback: '备用服务' }, ai_model_config: { default_model: '默认模型', max_tokens: '最大Token' } }
|
||||
function fieldLabel(key, k) { return fieldLabelsMap[key]?.[k] || k }
|
||||
const providers = ref([])
|
||||
const configLabels = { system_maintenance: '系统维护', feature_flags: '功能开关', translation_providers: '翻译服务', ai_model_config: 'AI模型', cache_ttl: '缓存时间', ai_routing: 'AI路由规则' }
|
||||
const fieldLabelsMap = { system_maintenance: { maintenance_mode: '维护模式', maintenance_message: '维护消息' }, feature_flags: { feature_wechat_login: '微信登录', feature_export: '数据导出' }, translation_providers: { primary: '首选服务', fallback: '备用服务' }, ai_model_config: { default_model: '默认模型', max_tokens: '最大Token' }, ai_routing: { translate: '翻译', reply: '回复建议', marketing: '营销文案', extract: '信息提取', quotation: '报价单', chat: 'AI助手' } }
|
||||
const taskFieldLabels = { primary: '主选', fallback: '备用' }
|
||||
function fieldLabel(key, k) {
|
||||
if (key === 'ai_routing') return configLabels[key] + ' > ' + (taskFieldLabels[k] || k)
|
||||
return fieldLabelsMap[key]?.[k] || k
|
||||
}
|
||||
function taskFieldLabel(cfgKey, taskKey, subKey) {
|
||||
if (cfgKey === 'ai_routing') {
|
||||
const taskLabel = fieldLabelsMap.ai_routing?.[taskKey] || taskKey
|
||||
const subLabel = taskFieldLabels[subKey] || subKey
|
||||
return taskLabel + ' > ' + subLabel
|
||||
}
|
||||
return subKey || taskKey
|
||||
}
|
||||
|
||||
async function loadProviders() {
|
||||
try {
|
||||
const res = await http.get('/admin/ai-providers')
|
||||
providers.value = (res.items || []).filter(p => p.enabled)
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
@@ -48,13 +86,14 @@ async function load() {
|
||||
for (const cfg of configs.value) {
|
||||
edits[cfg.key] = JSON.parse(JSON.stringify(cfg.value))
|
||||
}
|
||||
await loadProviders()
|
||||
} catch (e) { console.error(e) }
|
||||
}
|
||||
|
||||
async function save(key) {
|
||||
try {
|
||||
await updateConfig(key, edits[key])
|
||||
ElMessage.success('已保存')
|
||||
ElMessage.success('已保存,AI 路由器已重载')
|
||||
} catch (e) { ElMessage.error(e?.detail || '保存失败') }
|
||||
}
|
||||
|
||||
@@ -66,5 +105,7 @@ onMounted(load)
|
||||
.cfg-header { display: flex; align-items: center; gap: 12px; font-weight: 600; }
|
||||
.cfg-field { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
|
||||
.cfg-label { width: 160px; font-size: 13px; color: #666; flex-shrink: 0; }
|
||||
.cfg-nested-group { margin-bottom: 12px; padding: 8px 12px; background: #f9fafb; border-radius: 6px; }
|
||||
.cfg-group-title { font-weight: 600; font-size: 13px; color: #333; margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid #e5e7eb; }
|
||||
.cfg-actions { margin-top: 12px; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user