mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-03 11:01:22 +08:00
feat(openclaw): add additive mode frontend support
- Add getOpenClawLiveProviderIds() API for querying live config - Update ProviderList to query OpenClaw live IDs - Rename isOpenCodeMode to isAdditiveMode (covers OpenCode + OpenClaw) - Update ProviderCard shouldAutoQuery and isActiveProvider logic - Update App.tsx onRemoveFromConfig and invalidateQueries for OpenClaw
This commit is contained in:
@@ -84,12 +84,25 @@ export function ProviderList({
|
||||
enabled: appId === "opencode",
|
||||
});
|
||||
|
||||
// OpenClaw: 查询 live 配置中的供应商 ID 列表,用于判断 isInConfig
|
||||
const { data: openclawLiveIds } = useQuery({
|
||||
queryKey: ["openclawLiveProviderIds"],
|
||||
queryFn: () => providersApi.getOpenClawLiveProviderIds(),
|
||||
enabled: appId === "openclaw",
|
||||
});
|
||||
|
||||
// 判断供应商是否已添加到配置(累加模式应用:OpenCode/OpenClaw)
|
||||
const isProviderInConfig = useCallback(
|
||||
(providerId: string): boolean => {
|
||||
if (appId !== "opencode") return true; // 非 OpenCode 应用始终返回 true
|
||||
return opencodeLiveIds?.includes(providerId) ?? false;
|
||||
if (appId === "opencode") {
|
||||
return opencodeLiveIds?.includes(providerId) ?? false;
|
||||
}
|
||||
if (appId === "openclaw") {
|
||||
return openclawLiveIds?.includes(providerId) ?? false;
|
||||
}
|
||||
return true; // 其他应用始终返回 true
|
||||
},
|
||||
[appId, opencodeLiveIds],
|
||||
[appId, opencodeLiveIds, openclawLiveIds],
|
||||
);
|
||||
|
||||
const { data: isAutoFailoverEnabled } = useAutoFailoverEnabled(appId);
|
||||
|
||||
Reference in New Issue
Block a user