From 25e2e4afb82679839d5a4bc29a027f9f4d09c6d7 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 22 Feb 2024 14:11:08 +0800 Subject: [PATCH] =?UTF-8?q?pref(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E9=93=BE=E6=8E=A5=E5=AF=BC=E5=87=BA=E7=AD=89=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/editor/PreviewPublicLink.vue | 225 ++++++++++++++++++ .../canvas/customComponent/CircleShape.vue | 34 +++ .../canvas/customComponent/LineShape.vue | 14 ++ .../canvas/customComponent/TriangleShape.vue | 93 ++++++++ core/frontend/src/utils/CanvasUtils.js | 65 +++++ 5 files changed, 431 insertions(+) create mode 100644 core/frontend/src/components/canvas/components/editor/PreviewPublicLink.vue create mode 100644 core/frontend/src/components/canvas/customComponent/CircleShape.vue create mode 100644 core/frontend/src/components/canvas/customComponent/LineShape.vue create mode 100644 core/frontend/src/components/canvas/customComponent/TriangleShape.vue diff --git a/core/frontend/src/components/canvas/components/editor/PreviewPublicLink.vue b/core/frontend/src/components/canvas/components/editor/PreviewPublicLink.vue new file mode 100644 index 0000000000..0699b7c724 --- /dev/null +++ b/core/frontend/src/components/canvas/components/editor/PreviewPublicLink.vue @@ -0,0 +1,225 @@ + + + + + diff --git a/core/frontend/src/components/canvas/customComponent/CircleShape.vue b/core/frontend/src/components/canvas/customComponent/CircleShape.vue new file mode 100644 index 0000000000..48f2d6140f --- /dev/null +++ b/core/frontend/src/components/canvas/customComponent/CircleShape.vue @@ -0,0 +1,34 @@ + + + + + diff --git a/core/frontend/src/components/canvas/customComponent/LineShape.vue b/core/frontend/src/components/canvas/customComponent/LineShape.vue new file mode 100644 index 0000000000..91fdb26c04 --- /dev/null +++ b/core/frontend/src/components/canvas/customComponent/LineShape.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/core/frontend/src/components/canvas/customComponent/TriangleShape.vue b/core/frontend/src/components/canvas/customComponent/TriangleShape.vue new file mode 100644 index 0000000000..55c246f7c9 --- /dev/null +++ b/core/frontend/src/components/canvas/customComponent/TriangleShape.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/core/frontend/src/utils/CanvasUtils.js b/core/frontend/src/utils/CanvasUtils.js index 6c59e37048..02a0d8ac0d 100644 --- a/core/frontend/src/utils/CanvasUtils.js +++ b/core/frontend/src/utils/CanvasUtils.js @@ -1,4 +1,5 @@ import { toPng } from 'html-to-image' +import store from "@/store"; export function toPngUrl(refContainer, callBack) { toPng(refContainer) @@ -9,3 +10,67 @@ export function toPngUrl(refContainer, callBack) { console.error('oops, toPngUrl went wrong!', error) }) } + + +export function dataURLToBlobCheck(dataurl) { // ie 图片转格式 + const arr = dataurl.split(',') + const mime = arr[0].match(/:(.*?);/)[1] + const bstr = atob(arr[1]) + let n = bstr.length + const u8arr = new Uint8Array(n) + while (n--) { + u8arr[n] = bstr.charCodeAt(n) + } + return new Blob([u8arr], { type: mime }) +} + +export function colorReverseCheck(OldColorValue) { + OldColorValue = '0x' + OldColorValue.replace(/#/g, '') + const str = '000000' + (0xFFFFFF - OldColorValue).toString(16) + return '#' + str.substring(str.length - 6, str.length) +} + +export function imgUrlTransCheck(url) { + if (url && typeof url === 'string' && url.indexOf('static-resource') > -1) { + return process.env.VUE_APP_BASE_API + url.replace('/static-resource', 'static-resource') + } else { + return url + } +} + +export function getNowCanvasComponentDataCheck(canvasId, showPosition) { + if (showPosition && (showPosition.includes('email-task') || showPosition.includes('multiplexing'))) { + return store.state.previewComponentData.filter(item => item.canvasId === canvasId) + } else { + return store.state.componentData.filter(item => item.canvasId === canvasId) + } +} + +export function findCurComponentIndexCheck(componentData, curComponent) { + let curIndex = 0 + for (let index = 0; index < componentData.length; index++) { + const element = componentData[index] + if (element.id && element.id === curComponent.id) { + curIndex = index + break + } + } + return curIndex +} + +export function deleteTreeNodeCheck(nodeId, tree, nodeTarget) { + if (!nodeId || !tree || !tree.length) { + return + } + for (let i = 0, len = tree.length; i < len; i++) { + if (tree[i].id === nodeId) { + if (nodeTarget) { + nodeTarget['target'] = tree[i] + } + tree.splice(i, 1) + return + } else if (tree[i].children && tree[i].children.length) { + deleteTreeNode(nodeId, tree[i].children, nodeTarget) + } + } +}