feat: add official preset orange theme and disabled API input

- Add Anthropic orange theme styling for official preset buttons
- Auto-disable API Key input field when official preset is selected
- Add isOfficial field for precise official preset identification
- Enhance UX: official login requires no manual API Key input
This commit is contained in:
Jason
2025-08-29 09:03:11 +08:00
parent 9c17be1b59
commit fa2d64b692
3 changed files with 50 additions and 13 deletions

View File

@@ -133,6 +133,18 @@
color: white; color: white;
} }
/* 官方按钮橙色主题Anthropic 风格) */
.preset-btn.official {
border: 1px solid #d97706;
color: #d97706;
}
.preset-btn.official:hover,
.preset-btn.official.selected {
background: #d97706;
color: white;
}
.form-group { .form-group {
margin-bottom: 1.25rem; margin-bottom: 1.25rem;
} }

View File

@@ -170,6 +170,10 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
const showApiKey = const showApiKey =
selectedPreset !== null || hasApiKeyField(formData.settingsConfig); selectedPreset !== null || hasApiKeyField(formData.settingsConfig);
// 判断当前选中的预设是否是官方
const isOfficialPreset = selectedPreset !== null &&
providerPresets[selectedPreset]?.isOfficial === true;
// 初始时从配置中同步 API Key编辑模式 // 初始时从配置中同步 API Key编辑模式
useEffect(() => { useEffect(() => {
if (initialData) { if (initialData) {
@@ -225,18 +229,20 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
<div className="presets"> <div className="presets">
<label> key</label> <label> key</label>
<div className="preset-buttons"> <div className="preset-buttons">
{providerPresets.map((preset, index) => ( {providerPresets.map((preset, index) => {
<button return (
key={index} <button
type="button" key={index}
className={`preset-btn ${ type="button"
selectedPreset === index ? "selected" : "" className={`preset-btn ${
}`} selectedPreset === index ? "selected" : ""
onClick={() => applyPreset(preset, index)} } ${preset.isOfficial ? "official" : ""}`}
> onClick={() => applyPreset(preset, index)}
{preset.name} >
</button> {preset.name}
))} </button>
);
})}
</div> </div>
</div> </div>
)} )}
@@ -264,8 +270,17 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
id="apiKey" id="apiKey"
value={apiKey} value={apiKey}
onChange={(e) => handleApiKeyChange(e.target.value)} onChange={(e) => handleApiKeyChange(e.target.value)}
placeholder="只需要填这里,下方配置会自动填充" placeholder={isOfficialPreset
? "官方登录无需填写 API Key直接保存即可"
: "只需要填这里,下方配置会自动填充"
}
disabled={isOfficialPreset}
autoComplete="off" autoComplete="off"
style={isOfficialPreset ? {
backgroundColor: '#f5f5f5',
cursor: 'not-allowed',
color: '#999'
} : {}}
/> />
</div> </div>

View File

@@ -5,9 +5,19 @@ export interface ProviderPreset {
name: string; name: string;
websiteUrl: string; websiteUrl: string;
settingsConfig: object; settingsConfig: object;
isOfficial?: boolean; // 标识是否为官方预设
} }
export const providerPresets: ProviderPreset[] = [ export const providerPresets: ProviderPreset[] = [
{
name: "Claude官方登录",
websiteUrl: "https://www.anthropic.com/claude-code",
settingsConfig: {
env: {
},
},
isOfficial: true, // 明确标识为官方预设
},
{ {
name: "DeepSeek v3.1", name: "DeepSeek v3.1",
websiteUrl: "https://platform.deepseek.com", websiteUrl: "https://platform.deepseek.com",