暂存,修改navigate和添加图片
This commit is contained in:
@@ -22,12 +22,14 @@ export const clearBlank = (newStyle: any) => {
|
||||
return change;
|
||||
};
|
||||
export const useListener = (id?: string, opts?: any) => {
|
||||
const { refresh } = opts || {};
|
||||
const { refresh, cids = [] } = opts || {};
|
||||
const connected = useStore((state) => state.connected);
|
||||
// 监听服务器的消息
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
if (!connected) return;
|
||||
if (cids.length === 0) return;
|
||||
console.log('cids', cids);
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
type: 'subscribe',
|
||||
@@ -35,7 +37,7 @@ export const useListener = (id?: string, opts?: any) => {
|
||||
type: 'pageEdit',
|
||||
data: {
|
||||
pid: id,
|
||||
cids: ['170c0b55-8c13-4d6e-bf35-3f935d979a0d'],
|
||||
cids: cids,
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -46,7 +48,7 @@ export const useListener = (id?: string, opts?: any) => {
|
||||
if (!connected) return;
|
||||
ws.removeEventListener('message', listener);
|
||||
};
|
||||
}, [id, connected]);
|
||||
}, [id, connected, cids]);
|
||||
const listener = (event) => {
|
||||
const parseIfJson = (data: string) => {
|
||||
try {
|
||||
@@ -66,17 +68,6 @@ export const useListener = (id?: string, opts?: any) => {
|
||||
}
|
||||
};
|
||||
};
|
||||
const getParent = (data: { children?: string[]; [key: string]: any }[], id: string, list: string[]) => {
|
||||
for (let item of data) {
|
||||
if (item.children?.includes(id)) {
|
||||
// 找到了当前的父亲节点
|
||||
list.unshift(item.id);
|
||||
getParent(data, item.id, list);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
export const Deck = () => {
|
||||
const params = useParams<{ id: string }>();
|
||||
@@ -86,6 +77,7 @@ export const Deck = () => {
|
||||
const deckPageStore = useDeckPageStore();
|
||||
const { code, setCode } = deckPageStore;
|
||||
const { selected, setSelected } = deckPageStore;
|
||||
const { cids } = deckPageStore;
|
||||
const aiStore = useAiStore(
|
||||
useShallow((state) => {
|
||||
return {
|
||||
@@ -129,6 +121,7 @@ export const Deck = () => {
|
||||
const result = getContainerData({ page, containerList });
|
||||
console.log('result', result);
|
||||
deckPageStore.setPageData(result);
|
||||
deckPageStore.setCids();
|
||||
init(result);
|
||||
}
|
||||
};
|
||||
@@ -149,12 +142,12 @@ export const Deck = () => {
|
||||
});
|
||||
// container.reRender();
|
||||
containerList.forEach((item) => {
|
||||
container.hotReload(item.id);
|
||||
container.renderId(item.id);
|
||||
});
|
||||
// @ts-ignore
|
||||
window.c = container;
|
||||
};
|
||||
useListener(id, { refresh });
|
||||
useListener(id, { refresh, cids });
|
||||
const onContainer = (e) => {
|
||||
const { data } = e;
|
||||
const types = ['position', 'resize'];
|
||||
|
||||
Reference in New Issue
Block a user