界面改进和代码重构:设置窗口最小尺寸并抽象预设供应商配置

- 设置窗口最小尺寸为600x400,防止界面缩放问题
- 将预设供应商配置提取到独立文件providerPresets.ts
- 便于管理和维护预设供应商列表

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
farion1231
2025-08-08 12:12:28 +08:00
parent 6021ad8b22
commit fe71373e7d
3 changed files with 56 additions and 32 deletions

View File

@@ -20,6 +20,8 @@ function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
minWidth: 600,
minHeight: 400,
webPreferences: {
preload: path.join(__dirname, "../main/preload.js"),
contextIsolation: true,

View File

@@ -1,6 +1,7 @@
import React, { useState } from "react";
import { Provider } from "../../shared/types";
import { updateCoAuthoredSetting, checkCoAuthoredSetting, extractWebsiteUrl } from "../utils/providerConfigUtils";
import { providerPresets } from "../config/providerPresets";
import "./AddProviderModal.css";
interface AddProviderModalProps {
@@ -21,38 +22,7 @@ const AddProviderModal: React.FC<AddProviderModalProps> = ({
const [disableCoAuthored, setDisableCoAuthored] = useState(false);
// 预设的供应商配置模板
const presets = [
{
name: "Anthropic 官方",
websiteUrl: "https://console.anthropic.com",
settingsConfig: {
"env": {
"ANTHROPIC_BASE_URL": "https://api.anthropic.com",
"ANTHROPIC_AUTH_TOKEN": "sk-your-api-key-here"
}
}
},
{
name: "PackyCode",
websiteUrl: "https://www.packycode.com",
settingsConfig: {
"env": {
"ANTHROPIC_BASE_URL": "https://api.packycode.com",
"ANTHROPIC_AUTH_TOKEN": "sk-your-api-key-here"
}
}
},
{
name: "YesCode",
websiteUrl: "https://yes.vg",
settingsConfig: {
"env": {
"ANTHROPIC_BASE_URL": "https://co.yes.vg",
"ANTHROPIC_AUTH_TOKEN": "cr-your-api-key-here"
}
}
}
];
const presets = providerPresets;
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();

View File

@@ -0,0 +1,52 @@
/**
* 预设供应商配置模板
*/
export interface ProviderPreset {
name: string;
websiteUrl: string;
settingsConfig: object;
}
export const providerPresets: ProviderPreset[] = [
{
name: "智谱GLM",
websiteUrl: "https://open.bigmodel.cn",
settingsConfig: {
env: {
ANTHROPIC_BASE_URL: "https://open.bigmodel.cn/api/anthropic",
ANTHROPIC_AUTH_TOKEN: "sk-your-api-key-here",
},
},
},
{
name: "千问Qwen-Coder",
websiteUrl: "https://bailian.console.aliyun.com",
settingsConfig: {
env: {
ANTHROPIC_BASE_URL:
"https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy",
ANTHROPIC_AUTH_TOKEN: "sk-your-api-key-here",
},
},
},
{
name: "PackyCode",
websiteUrl: "https://www.packycode.com",
settingsConfig: {
env: {
ANTHROPIC_BASE_URL: "https://api.packycode.com",
ANTHROPIC_AUTH_TOKEN: "sk-your-api-key-here",
},
},
},
{
name: "AnyRouter",
websiteUrl: "https://anyrouter.top",
settingsConfig: {
env: {
ANTHROPIC_BASE_URL: "https://anyrouter.top",
ANTHROPIC_AUTH_TOKEN: "sk-your-api-key-here",
},
},
},
];