feat: 增加DeepWiki页面和侧边栏导航支持,更新Hook管理功能以支持作用域和索引

This commit is contained in:
catlog22
2026-03-05 18:53:24 +08:00
parent fb4f6e718e
commit bc7a556985
9 changed files with 78 additions and 22 deletions

View File

@@ -514,23 +514,33 @@ export function useToggleHook() {
export function useDeleteHook() {
const queryClient = useQueryClient();
const projectPath = useWorkflowStore(selectProjectPath);
const mutation = useMutation({
mutationFn: (hookName: string) => deleteHook(hookName),
onMutate: async (hookName) => {
mutationFn: (hook: { name: string; scope?: 'global' | 'project'; trigger: string; index?: number }) => {
const scope = hook.scope || 'project';
const hookIndex = hook.index ?? 0;
return deleteHook({
projectPath: projectPath || undefined,
scope,
event: hook.trigger,
hookIndex,
});
},
onMutate: async (hook) => {
await queryClient.cancelQueries({ queryKey: hooksKeys.all });
const previousHooks = queryClient.getQueryData<HooksResponse>(hooksKeys.lists());
queryClient.setQueryData<HooksResponse>(hooksKeys.lists(), (old) => {
if (!old) return old;
return {
hooks: old.hooks.filter((h) => h.name !== hookName),
hooks: old.hooks.filter((h) => h.name !== hook.name),
};
});
return { previousHooks };
},
onError: (_error, _hookName, context) => {
onError: (_error, _hook, context) => {
if (context?.previousHooks) {
queryClient.setQueryData(hooksKeys.lists(), context.previousHooks);
}