feat(设置): 添加 CCH 服务地址配置功能
- 新增服务地址输入框,支持自定义 CCH 服务 URL - 服务地址与 API Key 一起保存到用户设置 - 页面加载时自动填充已保存的服务地址
This commit is contained in:
parent
d6dc77f63a
commit
92ab731c62
@ -50,6 +50,7 @@ export default function SettingsPage() {
|
|||||||
const { tools, loading: toolsLoading } = useTools();
|
const { tools, loading: toolsLoading } = useTools();
|
||||||
|
|
||||||
// CCH 配置状态
|
// CCH 配置状态
|
||||||
|
const [cchUrl, setCchUrl] = useState('');
|
||||||
const [cchApiKey, setCchApiKey] = useState('');
|
const [cchApiKey, setCchApiKey] = useState('');
|
||||||
const [showApiKey, setShowApiKey] = useState(false);
|
const [showApiKey, setShowApiKey] = useState(false);
|
||||||
const [saveStatus, setSaveStatus] = useState<'idle' | 'saving' | 'saved' | 'error'>('idle');
|
const [saveStatus, setSaveStatus] = useState<'idle' | 'saving' | 'saved' | 'error'>('idle');
|
||||||
@ -68,6 +69,7 @@ export default function SettingsPage() {
|
|||||||
// 当设置加载完成后,更新本地状态
|
// 当设置加载完成后,更新本地状态
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (settings) {
|
if (settings) {
|
||||||
|
setCchUrl(settings.cchUrl || '');
|
||||||
setSystemPrompt(settings.systemPrompt || '');
|
setSystemPrompt(settings.systemPrompt || '');
|
||||||
setTemperature(settings.temperature || '0.7');
|
setTemperature(settings.temperature || '0.7');
|
||||||
}
|
}
|
||||||
@ -77,8 +79,12 @@ export default function SettingsPage() {
|
|||||||
const handleSaveCchConfig = async () => {
|
const handleSaveCchConfig = async () => {
|
||||||
setSaveStatus('saving');
|
setSaveStatus('saving');
|
||||||
try {
|
try {
|
||||||
if (cchApiKey) {
|
const updates: Record<string, string> = {};
|
||||||
await updateSettings({ cchApiKey });
|
if (cchUrl) updates.cchUrl = cchUrl;
|
||||||
|
if (cchApiKey) updates.cchApiKey = cchApiKey;
|
||||||
|
|
||||||
|
if (Object.keys(updates).length > 0) {
|
||||||
|
await updateSettings(updates);
|
||||||
}
|
}
|
||||||
setSaveStatus('saved');
|
setSaveStatus('saved');
|
||||||
setCchApiKey(''); // 清除输入的 API Key
|
setCchApiKey(''); // 清除输入的 API Key
|
||||||
@ -313,6 +319,20 @@ export default function SettingsPage() {
|
|||||||
title="CCH 服务配置"
|
title="CCH 服务配置"
|
||||||
description="配置 Claude Code Hub 服务连接"
|
description="配置 Claude Code Hub 服务连接"
|
||||||
>
|
>
|
||||||
|
{/* 服务地址配置 */}
|
||||||
|
<SettingsItem
|
||||||
|
label="服务地址"
|
||||||
|
description="配置 CCH 服务的访问地址"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="settings-input w-80"
|
||||||
|
value={cchUrl}
|
||||||
|
onChange={(e) => setCchUrl(e.target.value)}
|
||||||
|
placeholder="https://claude.leocoder.cn/"
|
||||||
|
/>
|
||||||
|
</SettingsItem>
|
||||||
|
|
||||||
<SettingsItem
|
<SettingsItem
|
||||||
label="API Key"
|
label="API Key"
|
||||||
description={
|
description={
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user