2525import MarsDialog from " @mars/components/mars-work/mars-dialog.vue"
2626import { onUnmounted , nextTick , reactive , ref } from " vue"
2727import useLifecycle from " @mars/common/uses/use-lifecycle"
28+ import useClock from " @mars/common/uses/use-clock"
2829import * as mapWork from " ./map"
2930import { useWidget } from " @mars/common/store/widget"
3031
@@ -35,6 +36,7 @@ onUnmounted(() => {
3536})
3637
3738useLifecycle (mapWork )
39+ const clock = useClock ()
3840
3941const treeData = ref <any []>([])
4042
@@ -54,7 +56,6 @@ let lastWidget: any
5456const checkedChange = (keys : string [], e : any ) => {
5557 const layer = layersObj [e .node .id ]
5658 // console.log("点击的矢量图层", layer)
57-
5859 if (layer ) {
5960 if (! layer .isAdded ) {
6061 mapWork .addLayer (layer )
@@ -94,22 +95,31 @@ const checkedChange = (keys: string[], e: any) => {
9495 initLayerTree (layer )
9596 }
9697
97- // 处理图层的关联事件
98+ // 处理图层的关联事件 TODO: show-clock 封装为widget
9899 if (layer .options .onWidget ) {
99100 if (e .checked ) {
100- if (lastWidget ) {
101+ if (lastWidget === " show-clock" ) {
102+ clock .closeClock ()
103+ } else if (lastWidget ) {
101104 disable (lastWidget )
102105 }
103- activate ({
104- name: layer .options .onWidget
105- })
106+ if (layer .options .onWidget === " show-clock" ) {
107+ clock .showClock ()
108+ } else {
109+ activate ({
110+ name: layer .options .onWidget
111+ })
112+ }
106113 lastWidget = layer .options .onWidget
107114 } else {
108- disable (layer .options .onWidget )
115+ if (layer .options .onWidget === " show-clock" ) {
116+ // clock.closeClock()
117+ } else {
118+ disable (layer .options .onWidget )
119+ }
109120 }
110121 }
111122 }
112- }
113123
114124 // let show = true
115125 // keys.forEach((id: string) => {
0 commit comments