mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-06 16:31:12 +08:00
feat: add Chinese localization and new assets for CCW documentation
- Created LICENSE.txt for JavaScript assets including NProgress and React libraries. - Added runtime JavaScript file for main functionality. - Introduced new favicon and logo SVG assets for branding. - Added comprehensive FAQ section in Chinese, covering CCW features, installation, workflows, AI model support, and troubleshooting.
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
crossCliCopy,
|
||||
type McpServer,
|
||||
type McpServersResponse,
|
||||
type McpProjectConfigType,
|
||||
type McpTemplate,
|
||||
type McpTemplateInstallRequest,
|
||||
type AllProjectsResponse,
|
||||
@@ -124,70 +125,75 @@ export function useMcpServers(options: UseMcpServersOptions = {}): UseMcpServers
|
||||
// ========== Mutations ==========
|
||||
|
||||
export interface UseUpdateMcpServerReturn {
|
||||
updateServer: (serverName: string, config: Partial<McpServer>) => Promise<McpServer>;
|
||||
updateServer: (serverName: string, config: Partial<McpServer>, configType?: McpProjectConfigType) => Promise<McpServer>;
|
||||
isUpdating: boolean;
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
export function useUpdateMcpServer(): UseUpdateMcpServerReturn {
|
||||
const queryClient = useQueryClient();
|
||||
const projectPath = useWorkflowStore(selectProjectPath);
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: ({ serverName, config }: { serverName: string; config: Partial<McpServer> }) =>
|
||||
updateMcpServer(serverName, config),
|
||||
mutationFn: ({ serverName, config, configType }: { serverName: string; config: Partial<McpServer>; configType?: McpProjectConfigType }) =>
|
||||
updateMcpServer(serverName, config, { projectPath: projectPath ?? undefined, configType }),
|
||||
onSettled: () => {
|
||||
queryClient.invalidateQueries({ queryKey: mcpServersKeys.all });
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
updateServer: (serverName, config) => mutation.mutateAsync({ serverName, config }),
|
||||
updateServer: (serverName, config, configType) => mutation.mutateAsync({ serverName, config, configType }),
|
||||
isUpdating: mutation.isPending,
|
||||
error: mutation.error,
|
||||
};
|
||||
}
|
||||
|
||||
export interface UseCreateMcpServerReturn {
|
||||
createServer: (server: Omit<McpServer, 'name'>) => Promise<McpServer>;
|
||||
createServer: (server: McpServer, configType?: McpProjectConfigType) => Promise<McpServer>;
|
||||
isCreating: boolean;
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
export function useCreateMcpServer(): UseCreateMcpServerReturn {
|
||||
const queryClient = useQueryClient();
|
||||
const projectPath = useWorkflowStore(selectProjectPath);
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: (server: Omit<McpServer, 'name'>) => createMcpServer(server),
|
||||
mutationFn: ({ server, configType }: { server: McpServer; configType?: McpProjectConfigType }) =>
|
||||
createMcpServer(server, { projectPath: projectPath ?? undefined, configType }),
|
||||
onSettled: () => {
|
||||
queryClient.invalidateQueries({ queryKey: mcpServersKeys.all });
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
createServer: mutation.mutateAsync,
|
||||
createServer: (server, configType) => mutation.mutateAsync({ server, configType }),
|
||||
isCreating: mutation.isPending,
|
||||
error: mutation.error,
|
||||
};
|
||||
}
|
||||
|
||||
export interface UseDeleteMcpServerReturn {
|
||||
deleteServer: (serverName: string) => Promise<void>;
|
||||
deleteServer: (serverName: string, scope: 'project' | 'global') => Promise<void>;
|
||||
isDeleting: boolean;
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
export function useDeleteMcpServer(): UseDeleteMcpServerReturn {
|
||||
const queryClient = useQueryClient();
|
||||
const projectPath = useWorkflowStore(selectProjectPath);
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: (serverName: string) => deleteMcpServer(serverName),
|
||||
mutationFn: ({ serverName, scope }: { serverName: string; scope: 'project' | 'global' }) =>
|
||||
deleteMcpServer(serverName, scope, { projectPath: projectPath ?? undefined }),
|
||||
onSettled: () => {
|
||||
queryClient.invalidateQueries({ queryKey: mcpServersKeys.all });
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
deleteServer: mutation.mutateAsync,
|
||||
deleteServer: (serverName, scope) => mutation.mutateAsync({ serverName, scope }),
|
||||
isDeleting: mutation.isPending,
|
||||
error: mutation.error,
|
||||
};
|
||||
@@ -201,10 +207,11 @@ export interface UseToggleMcpServerReturn {
|
||||
|
||||
export function useToggleMcpServer(): UseToggleMcpServerReturn {
|
||||
const queryClient = useQueryClient();
|
||||
const projectPath = useWorkflowStore(selectProjectPath);
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: ({ serverName, enabled }: { serverName: string; enabled: boolean }) =>
|
||||
toggleMcpServer(serverName, enabled),
|
||||
toggleMcpServer(serverName, enabled, { projectPath: projectPath ?? undefined }),
|
||||
onMutate: async ({ serverName, enabled }) => {
|
||||
await queryClient.cancelQueries({ queryKey: mcpServersKeys.all });
|
||||
const previousServers = queryClient.getQueryData<McpServersResponse>(mcpServersKeys.list());
|
||||
|
||||
84
ccw/frontend/src/hooks/useNativeSession.ts
Normal file
84
ccw/frontend/src/hooks/useNativeSession.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
// ========================================
|
||||
// useNativeSession Hook
|
||||
// ========================================
|
||||
// TanStack Query hook for native CLI session content
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import {
|
||||
fetchNativeSession,
|
||||
type NativeSession,
|
||||
} from '../lib/api';
|
||||
import { useWorkflowStore, selectProjectPath } from '@/stores/workflowStore';
|
||||
|
||||
// ========== Query Keys ==========
|
||||
|
||||
export const nativeSessionKeys = {
|
||||
all: ['nativeSession'] as const,
|
||||
details: () => [...nativeSessionKeys.all, 'detail'] as const,
|
||||
detail: (id: string | null) => [...nativeSessionKeys.details(), id] as const,
|
||||
};
|
||||
|
||||
// ========== Constants ==========
|
||||
|
||||
const STALE_TIME = 5 * 60 * 1000;
|
||||
const GC_TIME = 10 * 60 * 1000;
|
||||
|
||||
// ========== Types ==========
|
||||
|
||||
export interface UseNativeSessionOptions {
|
||||
staleTime?: number;
|
||||
gcTime?: number;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export interface UseNativeSessionReturn {
|
||||
data: NativeSession | undefined;
|
||||
isLoading: boolean;
|
||||
isFetching: boolean;
|
||||
error: Error | null;
|
||||
refetch: () => Promise<void>;
|
||||
}
|
||||
|
||||
// ========== Hook ==========
|
||||
|
||||
/**
|
||||
* Hook for fetching native CLI session content
|
||||
*
|
||||
* @param executionId - The CCW execution ID to fetch native session for
|
||||
* @param options - Query options
|
||||
*/
|
||||
export function useNativeSession(
|
||||
executionId: string | null,
|
||||
options: UseNativeSessionOptions = {}
|
||||
): UseNativeSessionReturn {
|
||||
const { staleTime = STALE_TIME, gcTime = GC_TIME, enabled = true } = options;
|
||||
const projectPath = useWorkflowStore(selectProjectPath);
|
||||
|
||||
const query = useQuery<NativeSession>({
|
||||
queryKey: nativeSessionKeys.detail(executionId),
|
||||
queryFn: () => {
|
||||
if (!executionId) throw new Error('executionId is required');
|
||||
return fetchNativeSession(executionId, projectPath);
|
||||
},
|
||||
enabled: !!executionId && enabled,
|
||||
staleTime,
|
||||
gcTime,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnMount: false,
|
||||
refetchOnReconnect: false,
|
||||
retry: 2,
|
||||
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000),
|
||||
});
|
||||
|
||||
const refetch = async () => {
|
||||
await query.refetch();
|
||||
};
|
||||
|
||||
return {
|
||||
data: query.data,
|
||||
isLoading: query.isLoading,
|
||||
isFetching: query.isFetching,
|
||||
error: query.error,
|
||||
refetch,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user