mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 修改文件结构
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { toRefs } from 'vue'
|
||||
import { useThrottleFn } from '@vueuse/core'
|
||||
import { getChartEditStore } from './useStore.hook'
|
||||
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { DragKeyEnum } from '@/enums/editPageEnum'
|
||||
import { createComponent } from '@/packages'
|
||||
import { ConfigType } from '@/packages/index.d'
|
||||
|
||||
const chartEditStore = getChartEditStore()
|
||||
const { scale } = toRefs(chartEditStore.getEditCanvas)
|
||||
|
||||
// * 拖拽中
|
||||
export const handleDrop = async (e: DragEvent) => {
|
||||
e.preventDefault()
|
||||
const Loading = window['$loading']
|
||||
try {
|
||||
Loading.start()
|
||||
|
||||
const drayDataString = e!.dataTransfer!.getData(DragKeyEnum.DROG_KEY)
|
||||
|
||||
const dropData: Exclude<ConfigType, ['node', 'image']> = JSON.parse(
|
||||
drayDataString
|
||||
)
|
||||
|
||||
let newComponent= await createComponent(dropData)
|
||||
newComponent.setPosition(e.offsetX, e.offsetY)
|
||||
|
||||
chartEditStore.addComponentList(newComponent)
|
||||
|
||||
setTimeout(() => {
|
||||
Loading.finish()
|
||||
})
|
||||
} catch (error) {
|
||||
Loading.error()
|
||||
window['$message'].success(`图表正在研发中, 敬请期待...`)
|
||||
}
|
||||
}
|
||||
|
||||
// * 拖拽结束
|
||||
export const handleDragOver = (e: DragEvent) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy'
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { onUnmounted, onMounted } from 'vue'
|
||||
import { getChartEditStore } from './useStore.hook'
|
||||
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
|
||||
const chartEditStore = getChartEditStore()
|
||||
|
||||
export const useLayout = () => {
|
||||
onMounted(() => {
|
||||
// 设置 Dom 值(ref 不生效先用 document)
|
||||
chartEditStore.setEditCanvasItem(
|
||||
EditCanvasTypeEnum.EDIT_LAYOUT_DOM,
|
||||
document.getElementById('go-chart-edit-layout')
|
||||
)
|
||||
chartEditStore.setEditCanvasItem(
|
||||
EditCanvasTypeEnum.EDIT_CONTENT_DOM,
|
||||
document.getElementById('go-chart-edit-content')
|
||||
)
|
||||
|
||||
// 大小初始化
|
||||
chartEditStore.setPageSize()
|
||||
|
||||
// 监听初始化
|
||||
const removeScale = chartEditStore.listenerScale()
|
||||
|
||||
onUnmounted(() => {
|
||||
removeScale()
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
const chartEditStore = useChartEditStoreStore()
|
||||
|
||||
export const getChartEditStore = () => {
|
||||
return chartEditStore
|
||||
}
|
||||
export const getChartEditStoreEnum = () => {
|
||||
return EditCanvasTypeEnum
|
||||
}
|
||||
Reference in New Issue
Block a user