feat: preset config dropdown with auto-fill default values
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 7s
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 7s
This commit is contained in:
parent
f5882c8ee6
commit
6d2921e3e0
@ -1,6 +1,6 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { Table, Switch, Button, Typography, App, Modal, Input, Tabs, Space, Tooltip, Alert } from 'antd'
|
import { Table, Switch, Button, Typography, App, Modal, Input, Select, Tabs, Space, Tooltip, Alert } from 'antd'
|
||||||
import { ReloadOutlined, PlusOutlined, DeleteOutlined, EditOutlined, QuestionCircleOutlined } from '@ant-design/icons'
|
import { ReloadOutlined, PlusOutlined, DeleteOutlined, EditOutlined, QuestionCircleOutlined } from '@ant-design/icons'
|
||||||
import { getConfig, setConfig, updateConfig, deleteConfig, toggleFlag, getChangeLog } from '@/services/config-api'
|
import { getConfig, setConfig, updateConfig, deleteConfig, toggleFlag, getChangeLog } from '@/services/config-api'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
@ -8,6 +8,12 @@ import dayjs from 'dayjs'
|
|||||||
const { Title, Text, Paragraph } = Typography
|
const { Title, Text, Paragraph } = Typography
|
||||||
|
|
||||||
// Config documentation
|
// Config documentation
|
||||||
|
const PRESET_CONFIGS = [
|
||||||
|
{ key: 'ai.temperature', value: '0.7', desc: 'AI 回复随机性 (0=确定, 1=最随机)' },
|
||||||
|
{ key: 'ai.max_tokens', value: '4096', desc: 'AI 单次回复最大长度 (1 token ≈ 0.7 中文)' },
|
||||||
|
{ key: 'hermes.api_url', value: 'http://10.2.0.7:8642', desc: 'Hermes Agent 服务地址' },
|
||||||
|
]
|
||||||
|
|
||||||
const CONFIG_DOCS: Record<string, { desc: string; example: string; note: string }> = {
|
const CONFIG_DOCS: Record<string, { desc: string; example: string; note: string }> = {
|
||||||
'ai.temperature': { desc: 'AI 回复的随机性/创造力', example: '0.7', note: '0=确定, 1=最随机, 推荐 0.5~0.7' },
|
'ai.temperature': { desc: 'AI 回复的随机性/创造力', example: '0.7', note: '0=确定, 1=最随机, 推荐 0.5~0.7' },
|
||||||
'ai.max_tokens': { desc: 'AI 单次回复最大长度', example: '4096', note: '1 token ≈ 0.7 个中文字, 4096≈2800字' },
|
'ai.max_tokens': { desc: 'AI 单次回复最大长度', example: '4096', note: '1 token ≈ 0.7 个中文字, 4096≈2800字' },
|
||||||
@ -133,7 +139,27 @@ function ConfigPage() {
|
|||||||
<Tabs items={items} />
|
<Tabs items={items} />
|
||||||
|
|
||||||
<Modal title={editKey ? '编辑配置' : '新增配置'} open={addOpen} onOk={handleSave} onCancel={() => setAddOpen(false)} okText="保存">
|
<Modal title={editKey ? '编辑配置' : '新增配置'} open={addOpen} onOk={handleSave} onCancel={() => setAddOpen(false)} okText="保存">
|
||||||
<Input placeholder="Key" value={newKey} onChange={e => setNewKey(e.target.value)} disabled={!!editKey} style={{ marginBottom: 12 }} />
|
{editKey ? (
|
||||||
|
<Input value={newKey} disabled style={{ marginBottom: 12 }} />
|
||||||
|
) : (
|
||||||
|
<Select
|
||||||
|
showSearch
|
||||||
|
placeholder="选择参数"
|
||||||
|
value={newKey || undefined}
|
||||||
|
onChange={(val, opt: any) => { setNewKey(val); setNewValue(opt?.defaultValue || '') }}
|
||||||
|
options={PRESET_CONFIGS.map(p => ({ label: `${p.key} — ${p.desc}`, value: p.key, defaultValue: p.value }))}
|
||||||
|
style={{ width: '100%', marginBottom: 12 }}
|
||||||
|
notFoundContent="无匹配参数,可手动输入 Key"
|
||||||
|
dropdownRender={menu => (
|
||||||
|
<>
|
||||||
|
{menu}
|
||||||
|
<div style={{ padding: '8px 12px', borderTop: '1px solid #f0f0f0', fontSize: 12, color: '#999' }}>
|
||||||
|
选择预设参数,Value 自动填入默认值
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Input.TextArea placeholder="Value" value={newValue} onChange={e => setNewValue(e.target.value)} rows={3} />
|
<Input.TextArea placeholder="Value" value={newValue} onChange={e => setNewValue(e.target.value)} rows={3} />
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user