feat:【ele】【mall】将 magic-cube-editor 迁移到 mall/promotion/components 中,聚焦一点

This commit is contained in:
YunaiV
2025-10-25 16:23:44 +08:00
parent d550ef626c
commit 1af1a9b2d4
22 changed files with 72 additions and 62 deletions

View File

@@ -16,11 +16,11 @@ import {
ElTooltip,
} from 'element-plus';
import { AppLinkInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import Draggable from '#/components/draggable/index.vue';
import UploadFile from '#/components/upload/file-upload.vue';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput } from '#/views/mall/promotion/components';
// 轮播图属性面板
defineOptions({ name: 'CarouselProperty' });

View File

@@ -10,9 +10,9 @@ import {
ElTooltip,
} from 'element-plus';
import { AppLinkInput } from '#/views/mall/promotion/components';
import Draggable from '#/components/draggable/index.vue';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput } from '#/views/mall/promotion/components';
// 弹窗广告属性面板
defineOptions({ name: 'PopoverProperty' });

View File

@@ -24,9 +24,9 @@ import {
} from 'element-plus';
import * as CouponTemplateApi from '#/api/mall/promotion/coupon/couponTemplate';
import { ColorInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import UploadImg from '#/components/upload/image-upload.vue';
import { ColorInput } from '#/views/mall/promotion/components';
// TODO: 添加组件
// import CouponSelect from '#/views/mall/promotion/coupon/components/coupon-select.vue';

View File

@@ -11,10 +11,12 @@ import {
ElSwitch,
} from 'element-plus';
import { AppLinkInput } from '#/views/mall/promotion/components';
import Draggable from '#/components/draggable/index.vue';
import { InputWithColor } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import {
AppLinkInput,
InputWithColor,
} from '#/views/mall/promotion/components';
// 悬浮按钮属性面板
defineOptions({ name: 'FloatingActionButtonProperty' });

View File

@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { ControlDot } from './controller';
import type { AppLink } from '#/views/mall/promotion/components/app-link-input/data';
import type { HotZoneItemProperty } from '#/components/diy-editor/components/mobile/HotZone/config';
import type { AppLink } from '#/views/mall/promotion/components/app-link-input/data';
import { ref } from 'vue';

View File

@@ -4,9 +4,9 @@ import type { ImageBarProperty } from './config';
import { useVModel } from '@vueuse/core';
import { ElForm, ElFormItem } from 'element-plus';
import { AppLinkInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput } from '#/views/mall/promotion/components';
// 图片展示属性面板
defineOptions({ name: 'ImageBarProperty' });

View File

@@ -6,10 +6,10 @@ import { ref } from 'vue';
import { useVModel } from '@vueuse/core';
import { ElForm, ElFormItem, ElSlider, ElText } from 'element-plus';
import { AppLinkInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import MagicCubeEditor from '#/components/magic-cube-editor/index.vue';
import { MagicCubeEditor } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput } from '#/views/mall/promotion/components';
/** 广告魔方属性面板 */
defineOptions({ name: 'MagicCubeProperty' });

View File

@@ -11,10 +11,10 @@ import {
ElSwitch,
} from 'element-plus';
import { AppLinkInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import Draggable from '#/components/draggable/index.vue';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput } from '#/views/mall/promotion/components';
import { EMPTY_MENU_GRID_ITEM_PROPERTY } from './config';

View File

@@ -4,11 +4,13 @@ import type { MenuListProperty } from './config';
import { useVModel } from '@vueuse/core';
import { ElForm, ElFormItem, ElText } from 'element-plus';
import { AppLinkInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import Draggable from '#/components/draggable/index.vue';
import { InputWithColor } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import {
AppLinkInput,
InputWithColor,
} from '#/views/mall/promotion/components';
import { EMPTY_MENU_LIST_ITEM_PROPERTY } from './config';

View File

@@ -13,11 +13,14 @@ import {
ElSwitch,
} from 'element-plus';
import { AppLinkInput, ColorInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import Draggable from '#/components/draggable/index.vue';
import { InputWithColor } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import {
AppLinkInput,
ColorInput,
InputWithColor,
} from '#/views/mall/promotion/components';
import { EMPTY_MENU_SWIPER_ITEM_PROPERTY } from './config';

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { NavigationBarCellProperty } from '../config';
import type { Rect } from '#/components/magic-cube-editor/util';
import type { Rect } from '#/views/mall/promotion/components/magic-cube-editor/util';
import { computed, ref } from 'vue';
@@ -15,9 +15,9 @@ import {
} from 'element-plus';
import appNavBarMp from '#/assets/imgs/diy/app-nav-bar-mp.png';
import { AppLinkInput, ColorInput } from '#/views/mall/promotion/components';
import MagicCubeEditor from '#/components/magic-cube-editor/index.vue';
import { MagicCubeEditor } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput, ColorInput } from '#/views/mall/promotion/components';
// 导航栏属性面板
defineOptions({ name: 'NavigationBarCellProperty' });

View File

@@ -4,10 +4,10 @@ import type { NoticeBarProperty } from './config';
import { useVModel } from '@vueuse/core';
import { ElCard, ElForm, ElFormItem, ElInput } from 'element-plus';
import { AppLinkInput, ColorInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import Draggable from '#/components/draggable/index.vue';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput, ColorInput } from '#/views/mall/promotion/components';
// 通知栏属性面板
defineOptions({ name: 'NoticeBarProperty' });

View File

@@ -4,8 +4,8 @@ import type { PageConfigProperty } from './config';
import { useVModel } from '@vueuse/core';
import { ElForm, ElFormItem, ElInput } from 'element-plus';
import { ColorInput } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import { ColorInput } from '#/views/mall/promotion/components';
// 导航栏属性面板
defineOptions({ name: 'PageConfigProperty' });

View File

@@ -17,8 +17,8 @@ import {
ElTooltip,
} from 'element-plus';
import { ColorInput } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import { ColorInput } from '#/views/mall/promotion/components';
// TODO: 添加组件
// import SpuShowcase from '#/views/mall/product/spu/components/spu-showcase.vue';

View File

@@ -16,8 +16,8 @@ import {
} from 'element-plus';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import { InputWithColor as ColorInput } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import { InputWithColor as ColorInput } from '#/views/mall/promotion/components';
// TODO: 添加组件
// import SpuShowcase from '#/views/mall/product/spu/components/spu-showcase.vue';

View File

@@ -20,9 +20,9 @@ import {
} from 'element-plus';
import * as CombinationActivityApi from '#/api/mall/promotion/combination/combinationActivity';
import { ColorInput } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import CombinationShowcase from '#/views/mall/promotion/combination/components/combination-showcase.vue';
import { ColorInput } from '#/views/mall/promotion/components';
// 拼团属性面板
defineOptions({ name: 'PromotionCombinationProperty' });

View File

@@ -22,8 +22,8 @@ import {
} from 'element-plus';
import * as SeckillActivityApi from '#/api/mall/promotion/seckill/seckillActivity';
import { ColorInput } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import { ColorInput } from '#/views/mall/promotion/components';
import SeckillShowcase from '#/views/mall/promotion/seckill/components/seckill-showcase.vue';
// 秒杀属性面板

View File

@@ -15,9 +15,9 @@ import {
ElText,
} from 'element-plus';
import { AppLinkInput, ColorInput } from '#/views/mall/promotion/components';
import Draggable from '#/components/draggable/index.vue';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput, ColorInput } from '#/views/mall/promotion/components';
import { component, THEME_LIST } from './config';
// 底部导航栏

View File

@@ -16,10 +16,12 @@ import {
ElTooltip,
} from 'element-plus';
import { AppLinkInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '#/components/diy-editor/components/component-container-property.vue';
import { InputWithColor } from '#/views/mall/promotion/components';
import UploadImg from '#/components/upload/image-upload.vue';
import {
AppLinkInput,
InputWithColor,
} from '#/views/mall/promotion/components';
// 导航栏属性面板
defineOptions({ name: 'TitleBarProperty' });

View File

@@ -1,4 +1,5 @@
export { default as AppLinkInput } from './app-link-input/index.vue';
export { default as ColorInput } from './color-input/index.vue';
export { default as InputWithColor } from './input-with-color/index.vue';
export { default as MagicCubeEditor } from './magic-cube-editor/index.vue';
export { default as VerticalButtonGroup } from './vertical-button-group/index.vue';

View File

@@ -1,5 +1,4 @@
<script lang="ts" setup>
// TODO @ diy-editor
import type { Point, Rect } from './util';
import { ref, watch } from 'vue';
@@ -8,6 +7,7 @@ import { IconifyIcon } from '@vben/icons';
import { createRect, isContains, isOverlap } from './util';
// TODO @AI:
//
//
// 1.
@@ -19,42 +19,38 @@ import { createRect, isContains, isOverlap } from './util';
// 2.
defineOptions({ name: 'MagicCubeEditor' });
//
/** 定义属性 */
const props = defineProps({
//
modelValue: {
type: Array as () => Rect[],
default: () => [],
},
// 4
}, //
rows: {
type: Number,
default: 4,
},
// 4
}, // 4
cols: {
type: Number,
default: 4,
},
// px75px
}, // 4
cubeSize: {
type: Number,
default: 75,
},
}, // px75px
});
//
const emit = defineEmits(['update:modelValue', 'hotAreaSelected']);
const emit = defineEmits(['update:modelValue', 'hotAreaSelected']); //
/**
* 方块
* @property active 是否激
*/
type Cube = Point & { active: boolean };
/** 方块 */
type Cube = {
active: boolean; //
} & Point;
//
const cubes = ref<Cube[][]>([]);
//
const cubes = ref<Cube[][]>([]); //
/** 监听行数、列数变化 */
watch(
() => [props.rows, props.cols],
() => {
@@ -73,19 +69,17 @@ watch(
{ immediate: true },
);
//
const hotAreas = ref<Rect[]>([]);
//
const hotAreas = ref<Rect[]>([]); //
/** 初始化热区 */
watch(
() => props.modelValue,
() => (hotAreas.value = props.modelValue || []),
{ immediate: true },
);
//
const hotAreaBeginCube = ref<Cube>();
//
const isHotAreaSelectMode = () => !!hotAreaBeginCube.value;
const hotAreaBeginCube = ref<Cube>(); //
const isHotAreaSelectMode = () => !!hotAreaBeginCube.value; //
/**
* 处理鼠标点击方块
*
@@ -94,7 +88,9 @@ const isHotAreaSelectMode = () => !!hotAreaBeginCube.value;
*/
const handleCubeClick = (currentRow: number, currentCol: number) => {
const currentCube = cubes.value[currentRow]?.[currentCol];
if (!currentCube) return;
if (!currentCube) {
return;
}
// 1
if (!isHotAreaSelectMode()) {
@@ -116,6 +112,7 @@ const handleCubeClick = (currentRow: number, currentCol: number) => {
//
emitUpdateModelValue();
};
/**
* 处理鼠标经过方块
*
@@ -124,11 +121,15 @@ const handleCubeClick = (currentRow: number, currentCol: number) => {
*/
const handleCellHover = (currentRow: number, currentCol: number) => {
//
if (!isHotAreaSelectMode()) return;
if (!isHotAreaSelectMode()) {
return;
}
//
const currentCube = cubes.value[currentRow]?.[currentCol];
if (!currentCube) return;
if (!currentCube) {
return;
}
const currentSelectedArea = createRect(hotAreaBeginCube.value!, currentCube);
//
@@ -147,24 +148,23 @@ const handleCellHover = (currentRow: number, currentCol: number) => {
cube.active = isContains(currentSelectedArea, cube);
});
};
/**
* 处理热区删除
*
* @param index 热区索引
*/
const handleDeleteHotArea = (index: number) => {
function handleDeleteHotArea(index: number) {
hotAreas.value.splice(index, 1);
//
exitHotAreaSelectMode();
//
emitUpdateModelValue();
};
}
//
const emitUpdateModelValue = () => emit('update:modelValue', hotAreas.value);
const emitUpdateModelValue = () => emit('update:modelValue', hotAreas.value); //
//
const selectedHotAreaIndex = ref(0);
const selectedHotAreaIndex = ref(0); //
const handleHotAreaSelected = (hotArea: Rect, index: number) => {
selectedHotAreaIndex.value = index;
emit('hotAreaSelected', hotArea, index);