+
@@ -98,7 +104,7 @@ onMounted(async () => {
}
}
})
-const mouseup = (e: any) => {
+const mouseup = (e: MouseEvent) => {
e.preventDefault()
// setTimeout(() => {
isDrag = false
@@ -185,34 +191,34 @@ const dragStart = async (e: MouseEvent, { id, width, height, cover }: TGetCompLi
}
}
- const selectItem = async (item: any) => {
- if (isDrag) {
- return
- }
- store.commit('setShowMoveable', false) // 清理掉上一次的选择
- tempDetail = tempDetail || (await getCompDetail({ id: item.id, type: 1 }))
- // let group = JSON.parse(tempDetail.data)
- const group: any = await getComponentsData(tempDetail.data)
- let parent: any = { x: 0, y: 0 }
- const { width: pW, height: pH } = store.getters.dPage
+const selectItem = async (item: TGetCompListResult) => {
+ if (isDrag) {
+ return
+ }
+ store.commit('setShowMoveable', false) // 清理掉上一次的选择
+ tempDetail = tempDetail || (await getCompDetail({ id: item.id, type: 1 }))
+ // let group = JSON.parse(tempDetail.data)
+ const group: any = await getComponentsData(tempDetail.data)
+ let parent: Record = { x: 0, y: 0 }
+ const { width: pW, height: pH } = store.getters.dPage
- Array.isArray(group) &&
- group.forEach((element: any) => {
- element.type === 'w-group' && (parent = element)
- })
- if (parent.isContainer) {
- group.forEach((element: any) => {
- element.left += (pW - parent.width) / 2
- element.top += (pH - parent.height) / 2
- })
- store.dispatch('addGroup', group)
- } else {
- group.text && (group.text = decodeURIComponent(group.text))
- group.left = pW / 2 - group.fontSize * (group.text.length / 2)
- group.top = pH / 2 - group.fontSize / 2
- store.dispatch('addWidget', group)
- }
- }
+ Array.isArray(group) &&
+ group.forEach((element) => {
+ element.type === 'w-group' && (parent = element)
+ })
+ if (parent.isContainer) {
+ group.forEach((element: any) => {
+ element.left += (pW - parent.width) / 2
+ element.top += (pH - parent.height) / 2
+ })
+ store.dispatch('addGroup', group)
+ } else {
+ group.text && (group.text = decodeURIComponent(group.text))
+ group.left = pW / 2 - group.fontSize * (group.text.length / 2)
+ group.top = pH / 2 - group.fontSize / 2
+ store.dispatch('addWidget', group)
+ }
+}
function getCompDetail(params: TGetTempDetail): Promise {
// 有缓存则直接返回组件数据,否则请求获取数据