|
@@ -43,9 +43,15 @@ withDefaults(defineProps<{ width?: number; height?: number; pixelRation?: number
|
|
|
});
|
|
|
type Board = ReturnType<typeof createBoard>;
|
|
|
|
|
|
+const board = createBoard({ store: storeData });
|
|
|
+board.bound.autoBound(60);
|
|
|
+
|
|
|
+const activeEntity = shallowRef<EditPoi>();
|
|
|
+board.bus.on("activePoi", (entity) => (activeEntity.value = entity));
|
|
|
+
|
|
|
const drawing = shallowRef<ReturnType<EditWholeLine["createPolygon"]>>();
|
|
|
const drawHandler = () => {
|
|
|
- drawing.value = board.value.room.createPolygon();
|
|
|
+ drawing.value = board.room.createPolygon();
|
|
|
drawing.value.promise.then((result) => {
|
|
|
console.log(result);
|
|
|
drawing.value = null;
|
|
@@ -54,31 +60,19 @@ const drawHandler = () => {
|
|
|
|
|
|
const addPoiState = shallowRef<ReturnType<Board["addPoi"]>>();
|
|
|
const addPoiHandler = (type: string) => {
|
|
|
- addPoiState.value = board.value.addPoi(type);
|
|
|
+ addPoiState.value = board.addPoi(type);
|
|
|
addPoiState.value.promise.finally(() => {
|
|
|
addPoiState.value = null;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-const board = shallowRef<Board>();
|
|
|
const containerRef = shallowRef<HTMLDivElement>();
|
|
|
-const activeEntity = shallowRef<EditPoi>();
|
|
|
-
|
|
|
-watch(containerRef, (container, _, onClanup) => {
|
|
|
- if (container) {
|
|
|
- board.value = createBoard(container, storeData);
|
|
|
- board.value.bound.autoBound(60);
|
|
|
- board.value.getData();
|
|
|
- onClanup(() => board.value.destory);
|
|
|
-
|
|
|
- board.value.bus.on("activePoi", (entity) => {
|
|
|
- activeEntity.value = entity;
|
|
|
- });
|
|
|
- }
|
|
|
+watch(containerRef, (container, _) => {
|
|
|
+ container && board.mount(container);
|
|
|
});
|
|
|
|
|
|
const getData = () => {
|
|
|
- console.log(JSON.stringify(board.value?.getData(), null, 4));
|
|
|
+ console.log(JSON.stringify(board.getData(), null, 4));
|
|
|
};
|
|
|
</script>
|
|
|
|