mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 修改右键判定区域,新增历史记录store
This commit is contained in:
@@ -58,17 +58,17 @@ const select = computed(() => {
|
||||
}
|
||||
|
||||
.shape-modal-select {
|
||||
opacity: 0.2;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
opacity: 0.1;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
&.active {
|
||||
background-color: v-bind('themeColor');
|
||||
}
|
||||
}
|
||||
.shape-modal-change {
|
||||
border: 1px solid rgba(0, 0, 0, 0);
|
||||
border: 2px solid rgba(0, 0, 0, 0);
|
||||
&.active {
|
||||
border: 1px solid v-bind('themeColor');
|
||||
border: 2px solid v-bind('themeColor');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ interface AttrType {
|
||||
|
||||
export const useComponentStyle = (attr: AttrType, index: number) => {
|
||||
const componentStyle = {
|
||||
zIndex: index,
|
||||
zIndex: index + 1,
|
||||
left: `${attr.x}px`,
|
||||
top: `${attr.y}px`,
|
||||
}
|
||||
|
||||
@@ -13,18 +13,6 @@
|
||||
<div id="go-chart-edit-content">
|
||||
<!-- 展示 -->
|
||||
<EditRange ref="editRangeRef">
|
||||
<!-- 右键 -->
|
||||
<n-dropdown
|
||||
placement="bottom-start"
|
||||
trigger="manual"
|
||||
size="small"
|
||||
:x="mousePosition.x"
|
||||
:y="mousePosition.y"
|
||||
:options="menuOptions"
|
||||
:show="showDropdownRef"
|
||||
:on-clickoutside="onClickoutside"
|
||||
@select="handleMenuSelect"
|
||||
/>
|
||||
<!-- 图表 -->
|
||||
<ShapeBox
|
||||
v-for="(item, index) in chartEditStore.getComponentList"
|
||||
@@ -63,22 +51,14 @@ import { ShapeBox } from './components/ShapeBox/index'
|
||||
|
||||
import { useLayout } from './hooks/useLayout.hook'
|
||||
import { handleDrop, handleDragOver, useMouseHandle } from './hooks/useDrop.hook'
|
||||
import { useContextMenu } from './hooks/useContextMenu.hook'
|
||||
import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
|
||||
import { getChartEditStore } from './hooks/useStore.hook'
|
||||
import { useComponentStyle, useSizeStyle } from './hooks/useStyle.hook'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
|
||||
const chartEditStore = getChartEditStore()
|
||||
|
||||
// 右键
|
||||
const {
|
||||
showDropdownRef,
|
||||
menuOptions,
|
||||
onClickoutside,
|
||||
mousePosition,
|
||||
handleContextMenu,
|
||||
handleMenuSelect
|
||||
} = useContextMenu()
|
||||
const { handleContextMenu } = useContextMenu()
|
||||
|
||||
// 布局处理
|
||||
useLayout()
|
||||
|
||||
+6
-8
@@ -1,15 +1,14 @@
|
||||
import { reactive, ref, nextTick } from 'vue'
|
||||
import { getChartEditStore } from './useStore.hook'
|
||||
import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { loadingError } from '@/utils'
|
||||
|
||||
const chartEditStore = getChartEditStore()
|
||||
const chartEditStore = useChartEditStoreStore()
|
||||
|
||||
enum MenuEnum {
|
||||
DELETE = 'delete'
|
||||
}
|
||||
|
||||
export const useContextMenu = () => {
|
||||
const showDropdownRef = ref(false)
|
||||
const targetIndex = ref<number>(0)
|
||||
|
||||
// * 右键选项
|
||||
@@ -29,21 +28,21 @@ export const useContextMenu = () => {
|
||||
while (target instanceof SVGElement) {
|
||||
target = target.parentNode
|
||||
}
|
||||
showDropdownRef.value = false
|
||||
chartEditStore.setRightMenuShow(false)
|
||||
nextTick().then(() => {
|
||||
chartEditStore.setMousePosition(e.clientX, e.clientY)
|
||||
showDropdownRef.value = true
|
||||
chartEditStore.setRightMenuShow(true)
|
||||
})
|
||||
}
|
||||
|
||||
// * 失焦
|
||||
const onClickoutside = (e: MouseEvent) => {
|
||||
showDropdownRef.value = false
|
||||
chartEditStore.setRightMenuShow(false)
|
||||
}
|
||||
|
||||
// * 事件处理
|
||||
const handleMenuSelect = (key: string) => {
|
||||
showDropdownRef.value = false
|
||||
chartEditStore.setRightMenuShow(false)
|
||||
switch (key) {
|
||||
case MenuEnum.DELETE:
|
||||
chartEditStore.removeComponentList(targetIndex.value)
|
||||
@@ -53,7 +52,6 @@ export const useContextMenu = () => {
|
||||
}
|
||||
|
||||
return {
|
||||
showDropdownRef,
|
||||
menuOptions,
|
||||
handleContextMenu,
|
||||
onClickoutside,
|
||||
@@ -20,11 +20,26 @@
|
||||
</n-layout-content>
|
||||
</n-layout>
|
||||
</div>
|
||||
<!-- 右键 -->
|
||||
<n-dropdown
|
||||
placement="bottom-start"
|
||||
trigger="manual"
|
||||
size="small"
|
||||
:x="mousePosition.x"
|
||||
:y="mousePosition.y"
|
||||
:options="menuOptions"
|
||||
:show="chartEditStore.getRightMenuShow"
|
||||
:on-clickoutside="onClickoutside"
|
||||
@select="handleMenuSelect"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { loadAsyncComponent } from '@/utils'
|
||||
import { HeaderPro } from '@/layout/components/HeaderPro'
|
||||
import { useContextMenu } from './hooks/useContextMenu.hook'
|
||||
import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
const chartEditStore = useChartEditStoreStore()
|
||||
|
||||
const HeaderLeftBtn = loadAsyncComponent(() =>
|
||||
import('./HeaderLeftBtn/index.vue')
|
||||
@@ -44,6 +59,15 @@ const ContentCharts = loadAsyncComponent(() =>
|
||||
const ContentDetails = loadAsyncComponent(() =>
|
||||
import('./ContentDetails/index.vue')
|
||||
)
|
||||
|
||||
// 右键
|
||||
const {
|
||||
menuOptions,
|
||||
onClickoutside,
|
||||
mousePosition,
|
||||
handleContextMenu,
|
||||
handleMenuSelect
|
||||
} = useContextMenu()
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user