2025-11-12 10:47:34 +08:00
|
|
|
import type { ProviderCategory } from "@/types";
|
|
|
|
|
|
2025-11-12 22:41:26 +08:00
|
|
|
/**
|
|
|
|
|
* Gemini 预设供应商的视觉主题配置
|
|
|
|
|
*/
|
|
|
|
|
export interface GeminiPresetTheme {
|
|
|
|
|
/** 图标类型:'gemini' | 'generic' */
|
|
|
|
|
icon?: "gemini" | "generic";
|
|
|
|
|
/** 背景色(选中状态),支持 hex 颜色 */
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
/** 文字色(选中状态),支持 hex 颜色 */
|
|
|
|
|
textColor?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-12 10:47:34 +08:00
|
|
|
export interface GeminiProviderPreset {
|
|
|
|
|
name: string;
|
|
|
|
|
websiteUrl: string;
|
|
|
|
|
apiKeyUrl?: string;
|
|
|
|
|
settingsConfig: object;
|
|
|
|
|
baseURL?: string;
|
|
|
|
|
model?: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
category?: ProviderCategory;
|
|
|
|
|
isPartner?: boolean;
|
|
|
|
|
partnerPromotionKey?: string;
|
|
|
|
|
endpointCandidates?: string[];
|
2025-11-12 22:41:26 +08:00
|
|
|
theme?: GeminiPresetTheme;
|
2025-11-12 10:47:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const geminiProviderPresets: GeminiProviderPreset[] = [
|
|
|
|
|
{
|
2025-11-12 22:41:26 +08:00
|
|
|
name: "Google Official",
|
2025-11-12 10:47:34 +08:00
|
|
|
websiteUrl: "https://ai.google.dev/",
|
|
|
|
|
apiKeyUrl: "https://aistudio.google.com/apikey",
|
|
|
|
|
settingsConfig: {
|
2025-11-19 10:53:33 +08:00
|
|
|
env: {},
|
2025-11-12 10:47:34 +08:00
|
|
|
},
|
|
|
|
|
description: "Google 官方 Gemini API (OAuth)",
|
|
|
|
|
category: "official",
|
|
|
|
|
partnerPromotionKey: "google-official",
|
2025-11-12 22:41:26 +08:00
|
|
|
theme: {
|
|
|
|
|
icon: "gemini",
|
|
|
|
|
backgroundColor: "#4285F4",
|
|
|
|
|
textColor: "#FFFFFF",
|
|
|
|
|
},
|
2025-11-12 10:47:34 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "PackyCode",
|
|
|
|
|
websiteUrl: "https://www.packyapi.com",
|
|
|
|
|
apiKeyUrl: "https://www.packyapi.com/register?aff=cc-switch",
|
|
|
|
|
settingsConfig: {
|
|
|
|
|
env: {
|
|
|
|
|
GOOGLE_GEMINI_BASE_URL: "https://www.packyapi.com",
|
2025-11-19 10:53:33 +08:00
|
|
|
GEMINI_MODEL: "gemini-3-pro-preview",
|
2025-11-12 10:47:34 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
baseURL: "https://www.packyapi.com",
|
2025-11-19 10:53:33 +08:00
|
|
|
model: "gemini-3-pro-preview",
|
2025-11-12 10:47:34 +08:00
|
|
|
description: "PackyCode",
|
|
|
|
|
category: "third_party",
|
|
|
|
|
isPartner: true,
|
|
|
|
|
partnerPromotionKey: "packycode",
|
|
|
|
|
endpointCandidates: [
|
|
|
|
|
"https://api-slb.packyapi.com",
|
|
|
|
|
"https://www.packyapi.com",
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "自定义",
|
|
|
|
|
websiteUrl: "",
|
|
|
|
|
settingsConfig: {
|
|
|
|
|
env: {
|
|
|
|
|
GOOGLE_GEMINI_BASE_URL: "",
|
2025-11-19 10:53:33 +08:00
|
|
|
GEMINI_MODEL: "gemini-3-pro-preview",
|
2025-11-12 10:47:34 +08:00
|
|
|
},
|
|
|
|
|
},
|
2025-11-19 10:53:33 +08:00
|
|
|
model: "gemini-3-pro-preview",
|
2025-11-12 10:47:34 +08:00
|
|
|
description: "自定义 Gemini API 端点",
|
|
|
|
|
category: "custom",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function getGeminiPresetByName(
|
|
|
|
|
name: string,
|
|
|
|
|
): GeminiProviderPreset | undefined {
|
|
|
|
|
return geminiProviderPresets.find((preset) => preset.name === name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getGeminiPresetByUrl(
|
|
|
|
|
url: string,
|
|
|
|
|
): GeminiProviderPreset | undefined {
|
|
|
|
|
if (!url) return undefined;
|
|
|
|
|
return geminiProviderPresets.find(
|
|
|
|
|
(preset) =>
|
|
|
|
|
preset.baseURL &&
|
|
|
|
|
url.toLowerCase().includes(preset.baseURL.toLowerCase()),
|
|
|
|
|
);
|
|
|
|
|
}
|