|
@@ -1,39 +1,37 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <v-image ref="pointRef" :config="getPointCurvConfig()" />
|
|
|
|
|
- <v-image ref="rectRef" :config="getRectCurConfig()" />
|
|
|
|
|
- <v-text :config="getTextConfig()" />
|
|
|
|
|
- <v-image :config="shineConfig()" />
|
|
|
|
|
|
|
+ <v-image ref="pointRef" :config="getPointCurvConfig(props.shop.posType, curvImage)" />
|
|
|
|
|
+ <v-image :config="getCirConfig(props.shop.posType, cirImage)" />
|
|
|
|
|
+ <v-image ref="rectRef" :config="getRectCurConfig(props.shop.posType, rectImage)" />
|
|
|
|
|
+ <v-text :config="getTextConfig(props.shop)" />
|
|
|
|
|
+ <v-image :config="shineConfig(props.shop.posType, shineImage)" />
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
- import { ref, onMounted, nextTick, computed, watch } from 'vue';
|
|
|
|
|
|
|
+ import { ref, onMounted, nextTick, watch } from 'vue';
|
|
|
import rectBlock from '@/assets/test/2-rect.svg';
|
|
import rectBlock from '@/assets/test/2-rect.svg';
|
|
|
import pointCurv from '@/assets/test/1-curv2.svg';
|
|
import pointCurv from '@/assets/test/1-curv2.svg';
|
|
|
- import shine from '@/assets/test/2-shine.svg';
|
|
|
|
|
|
|
+ import shine from '@/assets/test/2-shining.svg';
|
|
|
|
|
+ import circle from '@/assets/test/1-cir.svg';
|
|
|
import Konva from 'konva';
|
|
import Konva from 'konva';
|
|
|
- import { MapWorkShopInfoItem, LabelPositionEnum } from '../../stores/useMapEditor';
|
|
|
|
|
- // import { LabelPositionEnum, MapWorkShopInfoItem } from '../stores/useMapEditor';
|
|
|
|
|
|
|
+ import { MapWorkShopInfoItem } from '../../stores/useMapEditor';
|
|
|
|
|
+ import {
|
|
|
|
|
+ getRGBANum,
|
|
|
|
|
+ getPointCurvConfig,
|
|
|
|
|
+ getCirConfig,
|
|
|
|
|
+ getRectCurConfig,
|
|
|
|
|
+ getTextConfig,
|
|
|
|
|
+ shineConfig,
|
|
|
|
|
+ } from './labelConfig';
|
|
|
|
|
|
|
|
const props = defineProps<{ shop: MapWorkShopInfoItem }>();
|
|
const props = defineProps<{ shop: MapWorkShopInfoItem }>();
|
|
|
|
|
|
|
|
const curvImage = ref<HTMLImageElement>(new Image());
|
|
const curvImage = ref<HTMLImageElement>(new Image());
|
|
|
const rectImage = ref<HTMLImageElement>(new Image());
|
|
const rectImage = ref<HTMLImageElement>(new Image());
|
|
|
const shineImage = ref<HTMLImageElement>(new Image());
|
|
const shineImage = ref<HTMLImageElement>(new Image());
|
|
|
|
|
+ const cirImage = ref<HTMLImageElement>(new Image());
|
|
|
const rectRef = ref<Konva.Image>();
|
|
const rectRef = ref<Konva.Image>();
|
|
|
const pointRef = ref<Konva.Image>();
|
|
const pointRef = ref<Konva.Image>();
|
|
|
|
|
|
|
|
- const getRGBANum = (color: string) => {
|
|
|
|
|
- if (!color) return [0, 0, 0, 0];
|
|
|
|
|
- const pattern = /\((\d+),\s*(\d+),\s*(\d+),\s*(\d+(\.\d+)?)\)$/;
|
|
|
|
|
- const array = color.match(pattern);
|
|
|
|
|
- return [
|
|
|
|
|
- Number(array![1]) || 0,
|
|
|
|
|
- Number(array![2]) || 0,
|
|
|
|
|
- Number(array![3]) || 0,
|
|
|
|
|
- Number(array![4]) || 0,
|
|
|
|
|
- ];
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
const nodeUpdateFilter = (node: Konva.Node) => {
|
|
const nodeUpdateFilter = (node: Konva.Node) => {
|
|
|
node.cache();
|
|
node.cache();
|
|
|
const rgba = getRGBANum(props.shop.bgColor);
|
|
const rgba = getRGBANum(props.shop.bgColor);
|
|
@@ -43,188 +41,6 @@
|
|
|
node.alpha(rgba[3]);
|
|
node.alpha(rgba[3]);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // const getPointCurvConfig = () => {
|
|
|
|
|
- // return {
|
|
|
|
|
- // x: 65,
|
|
|
|
|
- // y: 35,
|
|
|
|
|
- // width: 32,
|
|
|
|
|
- // height: 39,
|
|
|
|
|
- // image: curvImage.value,
|
|
|
|
|
- // };
|
|
|
|
|
- // };
|
|
|
|
|
-
|
|
|
|
|
- const getPointCurvConfig = () => {
|
|
|
|
|
- if (props.shop.posType === LabelPositionEnum.LEFT) {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 0,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- width: 32,
|
|
|
|
|
- height: 39,
|
|
|
|
|
- image: curvImage.value,
|
|
|
|
|
- };
|
|
|
|
|
- } else if (props.shop.posType === LabelPositionEnum.RIGHT) {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 183,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- width: 32,
|
|
|
|
|
- height: 39,
|
|
|
|
|
- image: curvImage.value,
|
|
|
|
|
- };
|
|
|
|
|
- } else {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 65,
|
|
|
|
|
- y: 35,
|
|
|
|
|
- width: 32,
|
|
|
|
|
- height: 39,
|
|
|
|
|
- image: curvImage.value,
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // const getRectCurConfig = () => {
|
|
|
|
|
- // return {
|
|
|
|
|
- // x: 0,
|
|
|
|
|
- // y: 0,
|
|
|
|
|
- // width: 160,
|
|
|
|
|
- // height: 38,
|
|
|
|
|
- // image: rectImage.value,
|
|
|
|
|
- // };
|
|
|
|
|
- // };
|
|
|
|
|
-
|
|
|
|
|
- const getRectCurConfig = () => {
|
|
|
|
|
- if (props.shop.posType === LabelPositionEnum.LEFT) {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 53,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- width: 160,
|
|
|
|
|
- height: 38,
|
|
|
|
|
- image: rectImage.value,
|
|
|
|
|
- };
|
|
|
|
|
- } else if (props.shop.posType === LabelPositionEnum.RIGHT) {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 0,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- width: 160,
|
|
|
|
|
- height: 38,
|
|
|
|
|
- image: rectImage.value,
|
|
|
|
|
- };
|
|
|
|
|
- } else {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 0,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- width: 160,
|
|
|
|
|
- height: 38,
|
|
|
|
|
- image: rectImage.value,
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // const getTextConfig = () => {
|
|
|
|
|
- // return {
|
|
|
|
|
- // x: 0,
|
|
|
|
|
- // y: 0,
|
|
|
|
|
- // text: props.shop.name,
|
|
|
|
|
- // fontSize: props.shop.fontSize,
|
|
|
|
|
- // fontFamily: 'TRENDS',
|
|
|
|
|
- // fill: props.shop.fontColor,
|
|
|
|
|
- // width: 160,
|
|
|
|
|
- // height: 32,
|
|
|
|
|
- // align: 'center',
|
|
|
|
|
- // verticalAlign: 'middle',
|
|
|
|
|
- // };
|
|
|
|
|
- // };
|
|
|
|
|
-
|
|
|
|
|
- const getTextConfig = () => {
|
|
|
|
|
- if (props.shop.posType === LabelPositionEnum.LEFT) {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 53,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- text: props.shop.name,
|
|
|
|
|
- fontSize: props.shop.fontSize,
|
|
|
|
|
- fontFamily: 'TRENDS',
|
|
|
|
|
- fill: props.shop.fontColor,
|
|
|
|
|
- width: 160,
|
|
|
|
|
- height: 32,
|
|
|
|
|
- align: 'center',
|
|
|
|
|
- verticalAlign: 'middle',
|
|
|
|
|
- };
|
|
|
|
|
- } else if (props.shop.posType === LabelPositionEnum.RIGHT) {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 0,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- text: props.shop.name,
|
|
|
|
|
- fontSize: props.shop.fontSize,
|
|
|
|
|
- fontFamily: 'TRENDS',
|
|
|
|
|
- fill: props.shop.fontColor,
|
|
|
|
|
- width: 160,
|
|
|
|
|
- height: 32,
|
|
|
|
|
- align: 'center',
|
|
|
|
|
- verticalAlign: 'middle',
|
|
|
|
|
- };
|
|
|
|
|
- } else {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 0,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- text: props.shop.name,
|
|
|
|
|
- fontSize: props.shop.fontSize,
|
|
|
|
|
- fontFamily: 'TRENDS',
|
|
|
|
|
- fill: props.shop.fontColor,
|
|
|
|
|
- width: 160,
|
|
|
|
|
- height: 32,
|
|
|
|
|
- align: 'center',
|
|
|
|
|
- verticalAlign: 'middle',
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // const shineConfig = () => {
|
|
|
|
|
- // return {
|
|
|
|
|
- // x: 0,
|
|
|
|
|
- // y: 0,
|
|
|
|
|
- // width: 163,
|
|
|
|
|
- // height: 38,
|
|
|
|
|
- // image: shineImage.value,
|
|
|
|
|
- // };
|
|
|
|
|
- // };
|
|
|
|
|
-
|
|
|
|
|
- const shineConfig = () => {
|
|
|
|
|
- // if (props.shop.posType === LabelPositionEnum.LEFT) {
|
|
|
|
|
- return {
|
|
|
|
|
- x: 0,
|
|
|
|
|
- y: 0,
|
|
|
|
|
- width: 213,
|
|
|
|
|
- height: 38,
|
|
|
|
|
- image: shineImage.value,
|
|
|
|
|
- };
|
|
|
|
|
- // } else if (props.shop.posType === LabelPositionEnum.RIGHT) {
|
|
|
|
|
- // return {
|
|
|
|
|
- // x: 0,
|
|
|
|
|
- // y: 0,
|
|
|
|
|
- // width: 213,
|
|
|
|
|
- // height: 38,
|
|
|
|
|
- // image: shineImage.value,
|
|
|
|
|
- // };
|
|
|
|
|
- // } else {
|
|
|
|
|
- // return {
|
|
|
|
|
- // x: 0,
|
|
|
|
|
- // y: 0,
|
|
|
|
|
- // width: 213,
|
|
|
|
|
- // height: 38,
|
|
|
|
|
- // image: shineImage.value,
|
|
|
|
|
- // };
|
|
|
|
|
- // }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // const shineConfig = computed(() => {
|
|
|
|
|
- // return {
|
|
|
|
|
- // x: 0,
|
|
|
|
|
- // y: 0,
|
|
|
|
|
- // width: 213,
|
|
|
|
|
- // height: 38,
|
|
|
|
|
- // image: shineImage.value,
|
|
|
|
|
- // };
|
|
|
|
|
- // });
|
|
|
|
|
-
|
|
|
|
|
watch(
|
|
watch(
|
|
|
() => props.shop,
|
|
() => props.shop,
|
|
|
() => {
|
|
() => {
|
|
@@ -261,6 +77,12 @@
|
|
|
};
|
|
};
|
|
|
shineImg.src = shine;
|
|
shineImg.src = shine;
|
|
|
|
|
|
|
|
|
|
+ const cirImg = new Image();
|
|
|
|
|
+ cirImg.onload = () => {
|
|
|
|
|
+ cirImage.value = cirImg;
|
|
|
|
|
+ };
|
|
|
|
|
+ cirImg.src = circle;
|
|
|
|
|
+
|
|
|
rectRef.value?.getNode().filters([Konva.Filters.RGBA]);
|
|
rectRef.value?.getNode().filters([Konva.Filters.RGBA]);
|
|
|
pointRef.value?.getNode().filters([Konva.Filters.RGBA]);
|
|
pointRef.value?.getNode().filters([Konva.Filters.RGBA]);
|
|
|
});
|
|
});
|