Show all system settings explicitly
This commit is contained in:
@@ -162,14 +162,8 @@ const nullableModelFields = [
|
|||||||
"remark",
|
"remark",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
const configForm = reactive({
|
|
||||||
configKey: "daily_chat_limit",
|
|
||||||
configValue: "100",
|
|
||||||
description: "默认每日聊天次数",
|
|
||||||
});
|
|
||||||
|
|
||||||
type SystemSettingValue = string | number | boolean;
|
type SystemSettingValue = string | number | boolean;
|
||||||
type SystemSettingType = "number" | "switch";
|
type SystemSettingType = "number" | "switch" | "text";
|
||||||
|
|
||||||
interface SystemSettingDefinition {
|
interface SystemSettingDefinition {
|
||||||
key: string;
|
key: string;
|
||||||
@@ -178,6 +172,7 @@ interface SystemSettingDefinition {
|
|||||||
defaultValue: SystemSettingValue;
|
defaultValue: SystemSettingValue;
|
||||||
min?: number;
|
min?: number;
|
||||||
max?: number;
|
max?: number;
|
||||||
|
placeholder?: string;
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +185,7 @@ interface SystemSettingSection {
|
|||||||
const systemSettingSections: SystemSettingSection[] = [
|
const systemSettingSections: SystemSettingSection[] = [
|
||||||
{
|
{
|
||||||
title: "用户与登录",
|
title: "用户与登录",
|
||||||
description: "控制学员准入后的默认额度和登录态有效时间。",
|
description: "控制学员准入、默认资料、验证码和登录态有效时间。",
|
||||||
settings: [
|
settings: [
|
||||||
{
|
{
|
||||||
key: "daily_chat_limit",
|
key: "daily_chat_limit",
|
||||||
@@ -202,13 +197,45 @@ const systemSettingSections: SystemSettingSection[] = [
|
|||||||
description: "新建或导入学员未单独填写额度时使用。",
|
description: "新建或导入学员未单独填写额度时使用。",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "login_token_expire_minutes",
|
key: "access_token_expire_minutes",
|
||||||
label: "登录有效期(分钟)",
|
label: "登录 Token 有效期(分钟)",
|
||||||
type: "number",
|
type: "number",
|
||||||
defaultValue: 10080,
|
defaultValue: 43200,
|
||||||
min: 5,
|
min: 5,
|
||||||
max: 43200,
|
max: 43200,
|
||||||
description: "用户端和管理端 Token 的建议有效期配置。",
|
description: "用户端和管理端登录后的 Token 有效期。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "sms_code_expire_minutes",
|
||||||
|
label: "验证码有效期(分钟)",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 5,
|
||||||
|
min: 1,
|
||||||
|
max: 60,
|
||||||
|
description: "短信验证码生成后的可使用时间。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mock_sms_enabled",
|
||||||
|
label: "使用 mock 短信",
|
||||||
|
type: "switch",
|
||||||
|
defaultValue: true,
|
||||||
|
description: "开发和演示环境可开启,生产环境应关闭并接入真实短信。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mock_sms_code",
|
||||||
|
label: "mock 短信验证码",
|
||||||
|
type: "text",
|
||||||
|
defaultValue: "123456",
|
||||||
|
placeholder: "例如 123456",
|
||||||
|
description: "mock 短信开启时使用的固定验证码。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "default_user_name_prefix",
|
||||||
|
label: "默认用户名前缀",
|
||||||
|
type: "text",
|
||||||
|
defaultValue: "用户",
|
||||||
|
placeholder: "例如 用户",
|
||||||
|
description: "系统需要生成默认名称时使用的前缀。",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -225,6 +252,20 @@ const systemSettingSections: SystemSettingSection[] = [
|
|||||||
max: 300,
|
max: 300,
|
||||||
description: "真实模型请求超过该时间应判定为超时。",
|
description: "真实模型请求超过该时间应判定为超时。",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "mock_rag_enabled",
|
||||||
|
label: "使用 mock RAG",
|
||||||
|
type: "switch",
|
||||||
|
defaultValue: true,
|
||||||
|
description: "开发和演示环境可开启,真实飞书检索验收前应关闭。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mock_model_enabled",
|
||||||
|
label: "使用 mock 大模型",
|
||||||
|
type: "switch",
|
||||||
|
defaultValue: true,
|
||||||
|
description: "开发和演示环境可开启,真实模型验收前应关闭。",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "chat_context_message_count",
|
key: "chat_context_message_count",
|
||||||
label: "上下文消息数",
|
label: "上下文消息数",
|
||||||
@@ -245,8 +286,25 @@ const systemSettingSections: SystemSettingSection[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "外部服务",
|
title: "外部服务",
|
||||||
description: "控制飞书检索和模型 mock 开关,方便开发、测试和灰度。",
|
description: "控制飞书检索服务的地址、超时、重试和 mock 开关。",
|
||||||
settings: [
|
settings: [
|
||||||
|
{
|
||||||
|
key: "feishu_search_url",
|
||||||
|
label: "飞书检索服务地址",
|
||||||
|
type: "text",
|
||||||
|
defaultValue: "",
|
||||||
|
placeholder: "例如 https://example.com/search",
|
||||||
|
description: "如使用独立飞书检索适配服务,在这里填写调用地址。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "feishu_timeout_seconds",
|
||||||
|
label: "飞书请求超时(秒)",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 20,
|
||||||
|
min: 1,
|
||||||
|
max: 120,
|
||||||
|
description: "飞书相关接口调用超过该时间应判定为超时。",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "feishu_retry_count",
|
key: "feishu_retry_count",
|
||||||
label: "飞书检索重试次数",
|
label: "飞书检索重试次数",
|
||||||
@@ -257,18 +315,38 @@ const systemSettingSections: SystemSettingSection[] = [
|
|||||||
description: "飞书检索失败时的最大重试次数。",
|
description: "飞书检索失败时的最大重试次数。",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "use_mock_feishu",
|
key: "feishu_mock_enabled",
|
||||||
label: "使用 mock 飞书检索",
|
label: "使用 mock 飞书检索",
|
||||||
type: "switch",
|
type: "switch",
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
description: "开发和演示环境可开启,生产环境应关闭。",
|
description: "开发和演示环境可开启,生产环境应关闭。",
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "use_mock_model",
|
title: "系统开关",
|
||||||
label: "使用 mock 大模型",
|
description: "控制系统级展示和运行策略,不包含密钥类配置。",
|
||||||
|
settings: [
|
||||||
|
{
|
||||||
|
key: "show_operation_log_detail",
|
||||||
|
label: "展示操作日志详情",
|
||||||
type: "switch",
|
type: "switch",
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
description: "开发和演示环境可开启,真实验收前应关闭。",
|
description: "开启后后台审计页可展示更完整的操作上下文。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "chat_export_enabled",
|
||||||
|
label: "允许导出聊天记录",
|
||||||
|
type: "switch",
|
||||||
|
defaultValue: true,
|
||||||
|
description: "关闭后后台不应提供聊天记录导出能力。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "maintenance_mode",
|
||||||
|
label: "维护模式",
|
||||||
|
type: "switch",
|
||||||
|
defaultValue: false,
|
||||||
|
description: "预留给后续停机维护提示和访问控制使用。",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -694,12 +772,6 @@ function validateModelForm() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveConfig() {
|
|
||||||
await api.saveConfig({ ...configForm });
|
|
||||||
ElMessage.success("配置已保存");
|
|
||||||
await loadCurrentMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveSystemSettings() {
|
async function saveSystemSettings() {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
systemSettingDefinitions.map((setting) =>
|
systemSettingDefinitions.map((setting) =>
|
||||||
@@ -729,6 +801,9 @@ function normalizeSystemSettingValue(setting: (typeof systemSettingDefinitions)[
|
|||||||
if (setting.type === "switch") {
|
if (setting.type === "switch") {
|
||||||
return ["1", "true", "yes", "on", "启用"].includes(rawValue.toLowerCase());
|
return ["1", "true", "yes", "on", "启用"].includes(rawValue.toLowerCase());
|
||||||
}
|
}
|
||||||
|
if (setting.type === "text") {
|
||||||
|
return rawValue;
|
||||||
|
}
|
||||||
const parsed = Number(rawValue);
|
const parsed = Number(rawValue);
|
||||||
if (Number.isFinite(parsed)) {
|
if (Number.isFinite(parsed)) {
|
||||||
return parsed;
|
return parsed;
|
||||||
@@ -1236,29 +1311,17 @@ function buildChatQuery() {
|
|||||||
:min="setting.min"
|
:min="setting.min"
|
||||||
:max="setting.max"
|
:max="setting.max"
|
||||||
/>
|
/>
|
||||||
|
<el-input
|
||||||
|
v-else-if="setting.type === 'text'"
|
||||||
|
v-model="systemSettingValues[setting.key]"
|
||||||
|
:placeholder="setting.placeholder"
|
||||||
|
/>
|
||||||
<el-switch v-else v-model="systemSettingValues[setting.key]" />
|
<el-switch v-else v-model="systemSettingValues[setting.key]" />
|
||||||
<small>{{ setting.description }}</small>
|
<small>{{ setting.description }}</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<div class="advanced-config-panel">
|
|
||||||
<div class="advanced-config-head">
|
|
||||||
<h3>高级配置</h3>
|
|
||||||
<p>用于排查或临时增加未展示在分组表单里的配置项。</p>
|
|
||||||
</div>
|
|
||||||
<el-form class="inline-form" :model="configForm">
|
|
||||||
<el-input v-model="configForm.configKey" placeholder="配置 Key" />
|
|
||||||
<el-input v-model="configForm.configValue" placeholder="配置值" />
|
|
||||||
<el-input v-model="configForm.description" placeholder="说明" />
|
|
||||||
<el-button type="primary" @click="saveConfig">保存</el-button>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
<el-table :data="configs" stripe>
|
|
||||||
<el-table-column prop="configKey" label="Key" />
|
|
||||||
<el-table-column prop="configValue" label="Value" />
|
|
||||||
<el-table-column prop="description" label="说明" />
|
|
||||||
</el-table>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="activeMenu === 'records'">
|
<template v-if="activeMenu === 'records'">
|
||||||
|
|||||||
@@ -529,22 +529,19 @@ textarea {
|
|||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-section,
|
.settings-section {
|
||||||
.advanced-config-panel {
|
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
border: 1px solid #dfe8e5;
|
border: 1px solid #dfe8e5;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-section-head h3,
|
.settings-section-head h3 {
|
||||||
.advanced-config-head h3 {
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-section-head p,
|
.settings-section-head p {
|
||||||
.advanced-config-head p {
|
|
||||||
margin: 6px 0 0;
|
margin: 6px 0 0;
|
||||||
color: #667a73;
|
color: #667a73;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@@ -572,18 +569,11 @@ textarea {
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.setting-field .el-input-number {
|
.setting-field .el-input-number,
|
||||||
|
.setting-field .el-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.advanced-config-panel {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.advanced-config-head {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-drawer .el-date-editor.el-input {
|
.el-drawer .el-date-editor.el-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user