feat(chat-sdk/chatitem): 消息支持导出图表图片

This commit is contained in:
pisces
2024-12-02 15:16:51 +08:00
parent 0fc29304a8
commit 5b45cfbad7
9 changed files with 274 additions and 124 deletions

View File

@@ -0,0 +1,25 @@
import { useCallback, useRef } from 'react';
export const useMethodRegister = (fallback?: (...args: any[]) => any) => {
const methodStore = useRef<Map<string, (...args: any[]) => any>>(new Map());
const register = useCallback<(key: string, method: (...args: any[]) => any) => any>(
(key, method) => {
methodStore.current.set(key, method);
},
[methodStore]
);
const call = useCallback<(key: string, ...args: any[]) => any>(
(key, ...args) => {
const method = methodStore.current.get(key);
if (method) {
return method(...args);
}
return fallback?.(...args);
},
[methodStore]
);
return { register, call };
};