Files
Genarrative/src/components/image-editor/ImageCanvasActionsContext.ts
T
k88936 7f9984d12d
Project CI / Backend tests (pull_request) Failing after 11s
Project CI / Repository checks (pull_request) Failing after 11s
Project CI / Frontend tests (pull_request) Successful in 2m46s
Project CI / Native shell tests (pull_request) Failing after 9m17s
fix 修正画布资源定位结果与失败反馈
抽取并透传画布操作结构化结果
区分画布资源不存在与其他定位失败提示
明确重复资源仅定位首个图层并补充文档与测试
2026-07-31 16:47:28 +08:00

25 lines
636 B
TypeScript

import { createContext, useContext } from 'react';
export interface ImageCanvasActionResult {
successed: boolean;
reason?: 'not-found-on-canva' | 'other';
}
export type ImageCanvasActions = {
focusResource: (resourceId: string) => ImageCanvasActionResult;
refreshCanvas: () => void;
};
export const ImageCanvasActionsContext =
createContext<ImageCanvasActions | null>(null);
export function useImageCanvasActions() {
const actions = useContext(ImageCanvasActionsContext);
if (!actions) {
throw new Error(
'useImageCanvasActions must be used within ImageCanvasActionsProvider',
);
}
return actions;
}