mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
fix(usage): treat usage_script credentials as explicit overrides (#4654)
* fix(usage): treat usage_script credentials as explicit overrides * fix: treat usage script credentials as explicit overrides
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
useDeleteProviderMutation,
|
||||
useSwitchProviderMutation,
|
||||
} from "@/lib/query";
|
||||
import { usageKeys } from "@/lib/query/usage";
|
||||
import { extractErrorMessage } from "@/utils/errorUtils";
|
||||
import { openclawKeys } from "@/hooks/useOpenClaw";
|
||||
import {
|
||||
@@ -309,7 +310,7 @@ export function useProviderActions(
|
||||
// 🔧 保存用量脚本后,也应该失效该 provider 的用量查询缓存
|
||||
// 这样主页列表会使用新配置重新查询,而不是使用测试时的缓存
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["usage", provider.id, activeApp],
|
||||
queryKey: usageKeys.script(provider.id, activeApp),
|
||||
});
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["subscription", "quota", activeApp],
|
||||
|
||||
@@ -9,6 +9,7 @@ import { extractErrorMessage } from "@/utils/errorUtils";
|
||||
import { generateUUID } from "@/utils/uuid";
|
||||
import { openclawKeys } from "@/hooks/useOpenClaw";
|
||||
import { invalidateHermesProviderCaches } from "@/hooks/useHermes";
|
||||
import { usageKeys } from "@/lib/query/usage";
|
||||
|
||||
export const useAddProviderMutation = (appId: AppId) => {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -141,8 +142,16 @@ export const useUpdateProviderMutation = (appId: AppId) => {
|
||||
await providersApi.update(provider, appId, originalId);
|
||||
return provider;
|
||||
},
|
||||
onSuccess: async () => {
|
||||
onSuccess: async (provider, variables) => {
|
||||
await queryClient.invalidateQueries({ queryKey: ["providers", appId] });
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: usageKeys.script(provider.id, appId),
|
||||
});
|
||||
if (variables.originalId && variables.originalId !== provider.id) {
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: usageKeys.script(variables.originalId, appId),
|
||||
});
|
||||
}
|
||||
if (appId === "openclaw") {
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: openclawKeys.health,
|
||||
|
||||
Reference in New Issue
Block a user