From 73b71d578f55a77256af95f635a651575e8cebf9 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 14 Jul 2022 09:55:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=20topology=20?= =?UTF-8?q?=E6=BA=90=E7=A0=81=20=E5=88=A0=E9=99=A4=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=9A=84=E8=8A=82=E7=82=B9=E4=BB=A5=E5=8F=8A=E7=BB=99=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=88=9B=E5=BB=BA=E7=9A=84=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/assets/css/font/iconfont.js | 2 +- .../chart/chart/chartAutotopology.vue | 11 +- .../src/components/chart/chart/chartBar.vue | 2 +- .../src/components/chart/chartMixin.js | 1 - .../src/components/chart/panelChart.vue | 4 +- .../@topology/activity-diagram/index.js | 12 +- .../activity-diagram/src/final/final.js | 18 +- .../activity-diagram/src/final/final.rect.js | 18 +- .../activity-diagram/src/final/index.js | 6 +- .../activity-diagram/src/fork/fork.anchor.js | 52 +- .../activity-diagram/src/fork/fork.js | 48 +- .../activity-diagram/src/fork/fork.rect.js | 14 +- .../activity-diagram/src/fork/index.js | 8 +- .../activity-diagram/src/register.js | 24 +- .../activity-diagram/src/swimlaneH/index.js | 6 +- .../src/swimlaneH/swimlaneH.js | 52 +- .../src/swimlaneH/swimlaneH.rect.js | 14 +- .../activity-diagram/src/swimlaneV/index.js | 6 +- .../src/swimlaneV/swimlaneV.js | 52 +- .../src/swimlaneV/swimlaneV.rect.js | 14 +- .../common/@topology/chart-diagram/index.js | 6 +- .../chart-diagram/src/echarts/index.js | 84 +- .../@topology/chart-diagram/src/register.js | 18 +- .../common/@topology/class-diagram/index.js | 6 +- .../class-diagram/src/class/class.js | 108 +- .../class-diagram/src/class/class.rect.js | 24 +- .../class-diagram/src/class/index.js | 6 +- .../@topology/class-diagram/src/register.js | 12 +- .../components/common/@topology/core/index.js | 12 +- .../common/@topology/core/src/activeLayer.js | 1408 ++++++++--------- .../common/@topology/core/src/animateLayer.js | 502 +++--- .../common/@topology/core/src/canvas.js | 181 ++- .../common/@topology/core/src/core.js | 35 +- .../common/@topology/core/src/divLayer.js | 1005 ++++++------ .../common/@topology/core/src/hoverLayer.js | 402 ++--- .../common/@topology/core/src/layer.js | 39 +- .../core/src/middles/arrows/circle.js | 43 +- .../core/src/middles/arrows/diamond.js | 59 +- .../@topology/core/src/middles/arrows/line.js | 76 +- .../core/src/middles/arrows/triangle.js | 53 +- .../core/src/middles/default.anchor.js | 16 +- .../@topology/core/src/middles/default.js | 480 +++--- .../core/src/middles/default.rect.js | 32 +- .../@topology/core/src/middles/index.js | 8 +- .../@topology/core/src/middles/lines/curve.js | 220 ++- .../@topology/core/src/middles/lines/line.js | 18 +- .../@topology/core/src/middles/lines/mind.js | 58 +- .../core/src/middles/lines/polyline.js | 540 +++---- .../core/src/middles/nodes/arrow.anchor.js | 12 +- .../@topology/core/src/middles/nodes/arrow.js | 84 +- .../core/src/middles/nodes/arrow.rect.js | 34 +- .../core/src/middles/nodes/circle.anchor.js | 32 +- .../core/src/middles/nodes/circle.js | 12 +- .../core/src/middles/nodes/circle.rect.js | 49 +- .../core/src/middles/nodes/cloud.anchor.js | 16 +- .../@topology/core/src/middles/nodes/cloud.js | 20 +- .../core/src/middles/nodes/cloud.rect.js | 14 +- .../core/src/middles/nodes/cube.anchor.js | 18 +- .../@topology/core/src/middles/nodes/cube.js | 8 +- .../core/src/middles/nodes/cube.model.js | 123 +- .../core/src/middles/nodes/cube.rect.js | 18 +- .../core/src/middles/nodes/diamond.js | 20 +- .../core/src/middles/nodes/diamond.rect.js | 49 +- .../@topology/core/src/middles/nodes/file.js | 30 +- .../core/src/middles/nodes/graffiti.anchor.js | 33 +- .../core/src/middles/nodes/graffiti.js | 26 +- .../core/src/middles/nodes/hexagon.anchor.js | 40 +- .../core/src/middles/nodes/hexagon.js | 26 +- .../core/src/middles/nodes/hexagon.rect.js | 24 +- .../core/src/middles/nodes/image.anchor.js | 33 +- .../core/src/middles/nodes/image.rect.js | 46 +- .../core/src/middles/nodes/line.anchor.js | 26 +- .../@topology/core/src/middles/nodes/line.js | 14 +- .../core/src/middles/nodes/line.rect.js | 14 +- .../@topology/core/src/middles/nodes/lines.js | 48 +- .../core/src/middles/nodes/message.anchor.js | 16 +- .../core/src/middles/nodes/message.js | 26 +- .../core/src/middles/nodes/message.rect.js | 16 +- .../core/src/middles/nodes/mindLine.anchor.js | 10 +- .../core/src/middles/nodes/mindLine.js | 14 +- .../core/src/middles/nodes/mindNode.anchor.js | 172 +- .../core/src/middles/nodes/pentagon.anchor.js | 18 +- .../core/src/middles/nodes/pentagon.js | 22 +- .../core/src/middles/nodes/pentagon.rect.js | 41 +- .../src/middles/nodes/pentagram.anchor.js | 18 +- .../core/src/middles/nodes/pentagram.js | 20 +- .../core/src/middles/nodes/pentagram.rect.js | 18 +- .../core/src/middles/nodes/people.js | 32 +- .../core/src/middles/nodes/people.rect.js | 14 +- .../core/src/middles/nodes/rectangle.js | 48 +- .../core/src/middles/nodes/rectangle.rect.js | 18 +- .../@topology/core/src/middles/nodes/text.js | 495 +++--- .../core/src/middles/nodes/triangle.anchor.js | 16 +- .../core/src/middles/nodes/triangle.js | 18 +- .../core/src/middles/nodes/triangle.rect.js | 41 +- .../common/@topology/core/src/models/data.js | 123 +- .../@topology/core/src/models/direction.js | 14 +- .../common/@topology/core/src/models/event.js | 34 +- .../common/@topology/core/src/models/index.js | 20 +- .../common/@topology/core/src/models/line.js | 1049 ++++++------ .../common/@topology/core/src/models/point.js | 102 +- .../common/@topology/core/src/models/rect.js | 182 +-- .../@topology/core/src/models/status.js | 20 +- .../common/@topology/core/src/mqtt.js | 52 +- .../common/@topology/core/src/offscreen.js | 105 +- .../common/@topology/core/src/options.js | 80 +- .../common/@topology/core/src/renderLayer.js | 265 ++-- .../common/@topology/core/src/socket.js | 46 +- .../@topology/core/src/utils/browser.js | 6 +- .../@topology/core/src/utils/cacheDB.js | 200 +-- .../common/@topology/core/src/utils/canvas.js | 207 ++- .../common/@topology/core/src/utils/clone.js | 40 +- .../common/@topology/core/src/utils/dom.js | 84 +- .../common/@topology/core/src/utils/index.js | 18 +- .../common/@topology/core/src/utils/math.js | 123 +- .../@topology/core/src/utils/padding.js | 42 +- .../common/@topology/core/src/utils/rect.js | 157 +- .../common/@topology/core/src/utils/uuid.js | 18 +- .../common/@topology/flow-diagram/index.js | 26 +- .../src/comment/comment.anchor.js | 8 +- .../flow-diagram/src/comment/comment.js | 18 +- .../flow-diagram/src/comment/index.js | 6 +- .../flow-diagram/src/data/data.anchor.js | 14 +- .../@topology/flow-diagram/src/data/data.js | 22 +- .../flow-diagram/src/data/data.rect.js | 14 +- .../@topology/flow-diagram/src/data/index.js | 8 +- .../@topology/flow-diagram/src/db/db.js | 26 +- .../@topology/flow-diagram/src/db/db.rect.js | 14 +- .../@topology/flow-diagram/src/db/index.js | 6 +- .../src/display/display.anchor.js | 14 +- .../flow-diagram/src/display/display.js | 24 +- .../flow-diagram/src/display/display.rect.js | 14 +- .../flow-diagram/src/display/index.js | 8 +- .../src/document/document.anchor.js | 14 +- .../flow-diagram/src/document/document.js | 28 +- .../src/document/document.rect.js | 14 +- .../flow-diagram/src/document/index.js | 8 +- .../src/externStorage/externStorage.anchor.js | 14 +- .../src/externStorage/externStorage.js | 22 +- .../src/externStorage/externStorage.rect.js | 14 +- .../flow-diagram/src/externStorage/index.js | 8 +- .../flow-diagram/src/internalStorage/index.js | 6 +- .../src/internalStorage/internalStorage.js | 30 +- .../internalStorage/internalStorage.rect.js | 16 +- .../flow-diagram/src/manually/index.js | 8 +- .../src/manually/manually.anchor.js | 14 +- .../flow-diagram/src/manually/manually.js | 22 +- .../src/manually/manually.rect.js | 14 +- .../flow-diagram/src/parallel/index.js | 6 +- .../src/parallel/parallel.anchor.js | 10 +- .../flow-diagram/src/parallel/parallel.js | 16 +- .../@topology/flow-diagram/src/queue/index.js | 6 +- .../@topology/flow-diagram/src/queue/queue.js | 16 +- .../flow-diagram/src/queue/queue.rect.js | 18 +- .../@topology/flow-diagram/src/register.js | 50 +- .../flow-diagram/src/subprocess/index.js | 6 +- .../flow-diagram/src/subprocess/subprocess.js | 30 +- .../src/subprocess/subprocess.rect.js | 14 +- .../common/@topology/layout/index.js | 6 +- .../common/@topology/layout/src/align.js | 116 +- .../common/@topology/layout/src/layout.js | 94 +- .../@topology/sequence-diagram/index.js | 8 +- .../src/focus/focus.anchor.js | 28 +- .../sequence-diagram/src/focus/focus.js | 23 +- .../sequence-diagram/src/focus/focus.rect.js | 14 +- .../sequence-diagram/src/focus/index.js | 8 +- .../sequence-diagram/src/lifeline/index.js | 8 +- .../src/lifeline/lifeline.anchor.js | 16 +- .../sequence-diagram/src/lifeline/lifeline.js | 68 +- .../src/lifeline/lifeline.rect.js | 14 +- .../sequence-diagram/src/register.js | 14 +- .../common/ChartDiagram/diagram.vue | 2 +- .../bottomBox/tabs/alertMessageTabNew.vue | 2 +- .../common/bottomBox/tabs/panelTabNew.vue | 2 +- .../list/endpoint/endpointDetail.vue | 2 +- .../detailView/view/detailViewRight.vue | 2 +- .../src/components/common/js/tools.js | 76 +- .../components/common/mixin/subDataList.js | 2 +- .../common/project/popData/assetTable.vue | 2 +- .../components/common/project/topologyL5.vue | 92 +- .../common/rightBox/chart/chartTypeShow.js | 2 +- .../common/table/asset/assetTable.vue | 2 +- .../src/components/layout/header.vue | 2 +- .../src/components/page/dashboard/panel.vue | 2 +- nezha-fronted/src/store/user.js | 1 - nezha-fronted/static/config.json | 2 +- 186 files changed, 5955 insertions(+), 6025 deletions(-) diff --git a/nezha-fronted/src/assets/css/font/iconfont.js b/nezha-fronted/src/assets/css/font/iconfont.js index 1b70a6d66..accb8a1dd 100644 --- a/nezha-fronted/src/assets/css/font/iconfont.js +++ b/nezha-fronted/src/assets/css/font/iconfont.js @@ -1 +1 @@ -!function(a){var h,c,l,z,o,i='',v=(v=document.getElementsByTagName("script"))[v.length-1].getAttribute("data-injectcss"),t=function(a,h){h.parentNode.insertBefore(a,h)};if(v&&!a.__iconfont__svg__cssinject__){a.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}function m(){o||(o=!0,l())}function p(){try{z.documentElement.doScroll("left")}catch(a){return void setTimeout(p,50)}m()}h=function(){var a,h=document.createElement("div");h.innerHTML=i,i=null,(h=h.getElementsByTagName("svg")[0])&&(h.setAttribute("aria-hidden","true"),h.style.position="absolute",h.style.width=0,h.style.height=0,h.style.overflow="hidden",h=h,(a=document.body).firstChild?t(h,a.firstChild):a.appendChild(h))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(h,0):(c=function(){document.removeEventListener("DOMContentLoaded",c,!1),h()},document.addEventListener("DOMContentLoaded",c,!1)):document.attachEvent&&(l=h,z=a.document,o=!1,p(),z.onreadystatechange=function(){"complete"==z.readyState&&(z.onreadystatechange=null,m())})}(window); \ No newline at end of file +!(function (a) { let h; let c; let l; let z; let o; let i = ''; var v = (v = document.getElementsByTagName('script'))[v.length - 1].getAttribute('data-injectcss'); const t = function (a, h) { h.parentNode.insertBefore(a, h) }; if (v && !a.__iconfont__svg__cssinject__) { a.__iconfont__svg__cssinject__ = !0; try { document.write('') } catch (a) { console && console.log(a) } } function m () { o || (o = !0, l()) } function p () { try { z.documentElement.doScroll('left') } catch (a) { return void setTimeout(p, 50) }m() }h = function () { let a; let h = document.createElement('div'); h.innerHTML = i, i = null, (h = h.getElementsByTagName('svg')[0]) && (h.setAttribute('aria-hidden', 'true'), h.style.position = 'absolute', h.style.width = 0, h.style.height = 0, h.style.overflow = 'hidden', h = h, (a = document.body).firstChild ? t(h, a.firstChild) : a.appendChild(h)) }, document.addEventListener ? ~['complete', 'loaded', 'interactive'].indexOf(document.readyState) ? setTimeout(h, 0) : (c = function () { document.removeEventListener('DOMContentLoaded', c, !1), h() }, document.addEventListener('DOMContentLoaded', c, !1)) : document.attachEvent && (l = h, z = a.document, o = !1, p(), z.onreadystatechange = function () { z.readyState == 'complete' && (z.onreadystatechange = null, m()) }) }(window)) diff --git a/nezha-fronted/src/components/chart/chart/chartAutotopology.vue b/nezha-fronted/src/components/chart/chart/chartAutotopology.vue index 90161acc4..c156e941a 100644 --- a/nezha-fronted/src/components/chart/chart/chartAutotopology.vue +++ b/nezha-fronted/src/components/chart/chart/chartAutotopology.vue @@ -60,10 +60,10 @@ export default { if (res2.length == 0) { this.topologyLoading = false } - // res2.forEach(item => { - // temp.push(item) - // }) - temp.push(res2[2]) + res2.forEach(item => { + temp.push(item) + }) + // temp.push(res2[2]) this.allProject = JSON.parse(JSON.stringify(temp)) temp = null axiosAll = null @@ -101,6 +101,9 @@ export default { }, mounted () { this.queryAllProjectData() + }, + beforeDestroy () { + this.allProject = [] } } diff --git a/nezha-fronted/src/components/chart/chart/chartBar.vue b/nezha-fronted/src/components/chart/chart/chartBar.vue index faba90b60..2abebcc85 100644 --- a/nezha-fronted/src/components/chart/chart/chartBar.vue +++ b/nezha-fronted/src/components/chart/chart/chartBar.vue @@ -28,7 +28,7 @@ import { formatScientificNotation, getMetricTypeValue } from '@/components/commo import chartDataFormat from '@/components/chart/chartDataFormat' import { initColor } from '@/components/chart/chart/tools' import lodash from 'lodash' -import bus from "@/libs/bus"; +import bus from '@/libs/bus' export default { name: 'chart-bar', diff --git a/nezha-fronted/src/components/chart/chartMixin.js b/nezha-fronted/src/components/chart/chartMixin.js index dab16c545..652f2e75f 100644 --- a/nezha-fronted/src/components/chart/chartMixin.js +++ b/nezha-fronted/src/components/chart/chartMixin.js @@ -293,7 +293,6 @@ export default { } }, mounted () { - this.chartId = `${this.chartInfo.id}${this.isFullscreen ? '-fullscreen' : ''}` }, beforeDestroy () { diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index aaaaef59b..aaef3cee1 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -496,7 +496,7 @@ export default { xhr.responseType = '' // 创建一个 post 请求,采用异步 xhr.open('get', 'http://192.168.44.100/' + nowUrl, true) - xhr.setRequestHeader('Authorization', localStorage.getItem('nz-token')); + xhr.setRequestHeader('Authorization', localStorage.getItem('nz-token')) // 注册相关事件回调处理函数 xhr.onload = function (e) { if (this.status == 200 || this.status == 304) { @@ -504,7 +504,7 @@ export default { resolve(JSON.parse(this.responseText)) } } - xhr.onerror = function(e) { console.log(e) }; + xhr.onerror = function (e) { console.log(e) } // 发送数据 xhr.send() }) diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/index.js b/nezha-fronted/src/components/common/@topology/activity-diagram/index.js index 93b5c05df..65d21e838 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/index.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/index.js @@ -1,6 +1,6 @@ -export * from './src/final'; -export * from './src/fork'; -export * from './src/swimlaneH'; -export * from './src/swimlaneV'; -export * from './src/register'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './src/final' +export * from './src/fork' +export * from './src/swimlaneH' +export * from './src/swimlaneV' +export * from './src/register' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/final.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/final.js index 19e0f1268..bbc9e8174 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/final.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/final.js @@ -1,10 +1,10 @@ -export function activityFinal(ctx, node) { - ctx.beginPath(); - ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2); - ctx.stroke(); - ctx.beginPath(); - ctx.fillStyle = ctx.strokeStyle; - ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 4, node.rect.height / 4, 0, 0, Math.PI * 2); - ctx.fill(); +export function activityFinal (ctx, node) { + ctx.beginPath() + ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2) + ctx.stroke() + ctx.beginPath() + ctx.fillStyle = ctx.strokeStyle + ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 4, node.rect.height / 4, 0, 0, Math.PI * 2) + ctx.fill() } -//# sourceMappingURL=final.js.map \ No newline at end of file +// # sourceMappingURL=final.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/final.rect.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/final.rect.js index a5f08d68b..f8944efb5 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/final.rect.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/final.rect.js @@ -1,11 +1,11 @@ -import { Rect } from '@topology/core'; -export function activityFinalIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function activityFinalIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function activityFinalTextRect(node) { - var w = (node.rect.width * 5) / 7; - var h = (node.rect.height * 5) / 7; - node.textRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h); - node.fullTextRect = node.textRect; +export function activityFinalTextRect (node) { + const w = (node.rect.width * 5) / 7 + const h = (node.rect.height * 5) / 7 + node.textRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h) + node.fullTextRect = node.textRect } -//# sourceMappingURL=final.rect.js.map \ No newline at end of file +// # sourceMappingURL=final.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/index.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/index.js index 55512438e..4aece1e96 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/index.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/final/index.js @@ -1,3 +1,3 @@ -export * from './final'; -export * from './final.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './final' +export * from './final.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.anchor.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.anchor.js index fdc19756d..85f5bfd36 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.anchor.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.anchor.js @@ -1,28 +1,28 @@ -import { Point, Direction } from '@topology/core'; -export function forkHAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.ex, node.rect.y + node.rect.height / 2, Direction.Right)); - var dis = 5; - for (var i = dis; node.rect.x + i < node.rect.ex; i = i + dis) { - var pt1 = new Point(node.rect.x + i, node.rect.y, Direction.Up); - var pt2 = new Point(node.rect.x + i, node.rect.ey, Direction.Bottom); - pt1.hidden = true; - pt2.hidden = true; - node.anchors.push(pt1); - node.anchors.push(pt2); - } +import { Point, Direction } from '@topology/core' +export function forkHAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.ex, node.rect.y + node.rect.height / 2, Direction.Right)) + const dis = 5 + for (let i = dis; node.rect.x + i < node.rect.ex; i = i + dis) { + const pt1 = new Point(node.rect.x + i, node.rect.y, Direction.Up) + const pt2 = new Point(node.rect.x + i, node.rect.ey, Direction.Bottom) + pt1.hidden = true + pt2.hidden = true + node.anchors.push(pt1) + node.anchors.push(pt2) + } } -export function forkVAnchors(node) { - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom)); - var dis = 5; - for (var i = dis; node.rect.y + i < node.rect.ey; i = i + dis) { - var pt1 = new Point(node.rect.x, node.rect.y + i, Direction.Left); - var pt2 = new Point(node.rect.ex, node.rect.y + i, Direction.Right); - pt1.hidden = true; - pt2.hidden = true; - node.anchors.push(pt1); - node.anchors.push(pt2); - } +export function forkVAnchors (node) { + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom)) + const dis = 5 + for (let i = dis; node.rect.y + i < node.rect.ey; i = i + dis) { + const pt1 = new Point(node.rect.x, node.rect.y + i, Direction.Left) + const pt2 = new Point(node.rect.ex, node.rect.y + i, Direction.Right) + pt1.hidden = true + pt2.hidden = true + node.anchors.push(pt1) + node.anchors.push(pt2) + } } -//# sourceMappingURL=fork.anchor.js.map \ No newline at end of file +// # sourceMappingURL=fork.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.js index ed389fc0e..071c32b5a 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.js @@ -1,25 +1,25 @@ -export function fork(ctx, node) { - var wr = node.borderRadius; - var hr = node.borderRadius; - if (node.borderRadius < 1) { - wr = node.rect.width * node.borderRadius; - hr = node.rect.height * node.borderRadius; - } - var r = wr < hr ? wr : hr; - if (node.rect.width < 2 * r) { - r = node.rect.width / 2; - } - if (node.rect.height < 2 * r) { - r = node.rect.height / 2; - } - ctx.beginPath(); - ctx.moveTo(node.rect.x + r, node.rect.y); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r); - ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function fork (ctx, node) { + let wr = node.borderRadius + let hr = node.borderRadius + if (node.borderRadius < 1) { + wr = node.rect.width * node.borderRadius + hr = node.rect.height * node.borderRadius + } + let r = wr < hr ? wr : hr + if (node.rect.width < 2 * r) { + r = node.rect.width / 2 + } + if (node.rect.height < 2 * r) { + r = node.rect.height / 2 + } + ctx.beginPath() + ctx.moveTo(node.rect.x + r, node.rect.y) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r) + ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=fork.js.map \ No newline at end of file +// # sourceMappingURL=fork.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.rect.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.rect.js index b00a0083f..457f8ec0e 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.rect.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/fork.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function forkIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function forkIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function forkTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, node.rect.height); - node.fullTextRect = node.textRect; +export function forkTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, node.rect.height) + node.fullTextRect = node.textRect } -//# sourceMappingURL=fork.rect.js.map \ No newline at end of file +// # sourceMappingURL=fork.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/index.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/index.js index d602e3900..ac78c9d77 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/index.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/fork/index.js @@ -1,4 +1,4 @@ -export * from './fork'; -export * from './fork.rect'; -export * from './fork.anchor'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './fork' +export * from './fork.rect' +export * from './fork.anchor' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/register.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/register.js index 97ad85f88..959b1884b 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/register.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/register.js @@ -1,13 +1,13 @@ -import { registerNode } from '@topology/core'; -import { activityFinal, activityFinalIconRect, activityFinalTextRect } from './final'; -import { fork, forkHAnchors, forkVAnchors, forkIconRect, forkTextRect } from './fork'; -import { swimlaneH, swimlaneHIconRect, swimlaneHTextRect } from './swimlaneH'; -import { swimlaneV, swimlaneVIconRect, swimlaneVTextRect } from './swimlaneV'; -export function register() { - registerNode('activityFinal', activityFinal, null, activityFinalIconRect, activityFinalTextRect); - registerNode('swimlaneV', swimlaneV, null, swimlaneVIconRect, swimlaneVTextRect); - registerNode('swimlaneH', swimlaneH, null, swimlaneHIconRect, swimlaneHTextRect); - registerNode('forkH', fork, forkHAnchors, forkIconRect, forkTextRect); - registerNode('forkV', fork, forkVAnchors, forkIconRect, forkTextRect); +import { registerNode } from '@topology/core' +import { activityFinal, activityFinalIconRect, activityFinalTextRect } from './final' +import { fork, forkHAnchors, forkVAnchors, forkIconRect, forkTextRect } from './fork' +import { swimlaneH, swimlaneHIconRect, swimlaneHTextRect } from './swimlaneH' +import { swimlaneV, swimlaneVIconRect, swimlaneVTextRect } from './swimlaneV' +export function register () { + registerNode('activityFinal', activityFinal, null, activityFinalIconRect, activityFinalTextRect) + registerNode('swimlaneV', swimlaneV, null, swimlaneVIconRect, swimlaneVTextRect) + registerNode('swimlaneH', swimlaneH, null, swimlaneHIconRect, swimlaneHTextRect) + registerNode('forkH', fork, forkHAnchors, forkIconRect, forkTextRect) + registerNode('forkV', fork, forkVAnchors, forkIconRect, forkTextRect) } -//# sourceMappingURL=register.js.map \ No newline at end of file +// # sourceMappingURL=register.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/index.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/index.js index 36680fce0..d85646311 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/index.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/index.js @@ -1,3 +1,3 @@ -export * from './swimlaneH'; -export * from './swimlaneH.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './swimlaneH' +export * from './swimlaneH.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/swimlaneH.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/swimlaneH.js index 32ce0484e..1d107c7bf 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/swimlaneH.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/swimlaneH.js @@ -1,27 +1,27 @@ -export function swimlaneH(ctx, node) { - var wr = node.borderRadius; - var hr = node.borderRadius; - if (node.borderRadius < 1) { - wr = node.rect.width * node.borderRadius; - hr = node.rect.height * node.borderRadius; - } - var r = wr < hr ? wr : hr; - if (node.rect.width < 2 * r) { - r = node.rect.width / 2; - } - if (node.rect.height < 2 * r) { - r = node.rect.height / 2; - } - ctx.beginPath(); - ctx.moveTo(node.rect.x + r, node.rect.y); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r); - ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r); - ctx.closePath(); - ctx.moveTo(node.rect.x + 40, node.rect.y); - ctx.lineTo(node.rect.x + 40, node.rect.ey); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function swimlaneH (ctx, node) { + let wr = node.borderRadius + let hr = node.borderRadius + if (node.borderRadius < 1) { + wr = node.rect.width * node.borderRadius + hr = node.rect.height * node.borderRadius + } + let r = wr < hr ? wr : hr + if (node.rect.width < 2 * r) { + r = node.rect.width / 2 + } + if (node.rect.height < 2 * r) { + r = node.rect.height / 2 + } + ctx.beginPath() + ctx.moveTo(node.rect.x + r, node.rect.y) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r) + ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r) + ctx.closePath() + ctx.moveTo(node.rect.x + 40, node.rect.y) + ctx.lineTo(node.rect.x + 40, node.rect.ey); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=swimlaneH.js.map \ No newline at end of file +// # sourceMappingURL=swimlaneH.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/swimlaneH.rect.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/swimlaneH.rect.js index b357ee22a..e369ba05c 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/swimlaneH.rect.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneH/swimlaneH.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function swimlaneHIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function swimlaneHIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function swimlaneHTextRect(node) { - node.textRect = new Rect(node.rect.x + 10, node.rect.y, 20, node.rect.height); - node.fullTextRect = node.textRect; +export function swimlaneHTextRect (node) { + node.textRect = new Rect(node.rect.x + 10, node.rect.y, 20, node.rect.height) + node.fullTextRect = node.textRect } -//# sourceMappingURL=swimlaneH.rect.js.map \ No newline at end of file +// # sourceMappingURL=swimlaneH.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/index.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/index.js index 26157c9aa..9b88f7826 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/index.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/index.js @@ -1,3 +1,3 @@ -export * from './swimlaneV'; -export * from './swimlaneV.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './swimlaneV' +export * from './swimlaneV.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/swimlaneV.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/swimlaneV.js index a29721980..61c476be1 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/swimlaneV.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/swimlaneV.js @@ -1,27 +1,27 @@ -export function swimlaneV(ctx, node) { - var wr = node.borderRadius; - var hr = node.borderRadius; - if (node.borderRadius < 1) { - wr = node.rect.width * node.borderRadius; - hr = node.rect.height * node.borderRadius; - } - var r = wr < hr ? wr : hr; - if (node.rect.width < 2 * r) { - r = node.rect.width / 2; - } - if (node.rect.height < 2 * r) { - r = node.rect.height / 2; - } - ctx.beginPath(); - ctx.moveTo(node.rect.x + r, node.rect.y); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r); - ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r); - ctx.closePath(); - ctx.moveTo(node.rect.x, node.rect.y + 40); - ctx.lineTo(node.rect.ex, node.rect.y + 40); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function swimlaneV (ctx, node) { + let wr = node.borderRadius + let hr = node.borderRadius + if (node.borderRadius < 1) { + wr = node.rect.width * node.borderRadius + hr = node.rect.height * node.borderRadius + } + let r = wr < hr ? wr : hr + if (node.rect.width < 2 * r) { + r = node.rect.width / 2 + } + if (node.rect.height < 2 * r) { + r = node.rect.height / 2 + } + ctx.beginPath() + ctx.moveTo(node.rect.x + r, node.rect.y) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r) + ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r) + ctx.closePath() + ctx.moveTo(node.rect.x, node.rect.y + 40) + ctx.lineTo(node.rect.ex, node.rect.y + 40); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=swimlaneV.js.map \ No newline at end of file +// # sourceMappingURL=swimlaneV.js.map diff --git a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/swimlaneV.rect.js b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/swimlaneV.rect.js index d53b7436a..4fed56e36 100644 --- a/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/swimlaneV.rect.js +++ b/nezha-fronted/src/components/common/@topology/activity-diagram/src/swimlaneV/swimlaneV.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function swimlaneVIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function swimlaneVIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function swimlaneVTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40); - node.fullTextRect = node.textRect; +export function swimlaneVTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40) + node.fullTextRect = node.textRect } -//# sourceMappingURL=swimlaneV.rect.js.map \ No newline at end of file +// # sourceMappingURL=swimlaneV.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/chart-diagram/index.js b/nezha-fronted/src/components/common/@topology/chart-diagram/index.js index 6986612a0..ce0c9323f 100644 --- a/nezha-fronted/src/components/common/@topology/chart-diagram/index.js +++ b/nezha-fronted/src/components/common/@topology/chart-diagram/index.js @@ -1,3 +1,3 @@ -export * from './src/echarts'; -export * from './src/register'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './src/echarts' +export * from './src/register' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/chart-diagram/src/echarts/index.js b/nezha-fronted/src/components/common/@topology/chart-diagram/src/echarts/index.js index 244f32aad..c52ed5c0c 100644 --- a/nezha-fronted/src/components/common/@topology/chart-diagram/src/echarts/index.js +++ b/nezha-fronted/src/components/common/@topology/chart-diagram/src/echarts/index.js @@ -1,44 +1,44 @@ -import { s8, createDiv, rectangle } from '@topology/core'; -export var echartsObjs = {}; -export function echarts(ctx, node) { - // 绘制一个底图,类似于占位符。 - rectangle(ctx, node); - // tslint:disable-next-line:no-shadowed-variable - var echarts = echartsObjs.echarts || window.echarts; - if (!node.data || !echarts) { - return; - } - if (typeof node.data === 'string') { - node.data = JSON.parse(node.data); - } - if (!node.data.echarts) { - return; - } - if (!node.elementId) { - node.elementId = s8(); - } - if (!node.elementLoaded) { - echartsObjs[node.id] = { - div: createDiv(node), - }; - node.elementLoaded = true; - document.body.appendChild(echartsObjs[node.id].div); - // 添加当前节点到div层 - node.addToDiv(); - echartsObjs[node.id].chart = echarts.init(echartsObjs[node.id].div, node.data.echarts.theme); - node.elementRendered = false; - // 等待父div先渲染完成,避免初始图表控件太大 - setTimeout(function () { - echartsObjs[node.id].chart.resize(); - }); - } - if (!node.elementRendered) { - // 初始化时,等待父div先渲染完成,避免初始图表控件太大。 - setTimeout(function () { - echartsObjs[node.id].chart.setOption(node.data.echarts.option); - echartsObjs[node.id].chart.resize(); - node.elementRendered = true; - }); +import { s8, createDiv, rectangle } from '@topology/core' +export var echartsObjs = {} +export function echarts (ctx, node) { + // 绘制一个底图,类似于占位符。 + rectangle(ctx, node) + // tslint:disable-next-line:no-shadowed-variable + const echarts = echartsObjs.echarts || window.echarts + if (!node.data || !echarts) { + return + } + if (typeof node.data === 'string') { + node.data = JSON.parse(node.data) + } + if (!node.data.echarts) { + return + } + if (!node.elementId) { + node.elementId = s8() + } + if (!node.elementLoaded) { + echartsObjs[node.id] = { + div: createDiv(node) } + node.elementLoaded = true + document.body.appendChild(echartsObjs[node.id].div) + // 添加当前节点到div层 + node.addToDiv() + echartsObjs[node.id].chart = echarts.init(echartsObjs[node.id].div, node.data.echarts.theme) + node.elementRendered = false + // 等待父div先渲染完成,避免初始图表控件太大 + setTimeout(function () { + echartsObjs[node.id].chart.resize() + }) + } + if (!node.elementRendered) { + // 初始化时,等待父div先渲染完成,避免初始图表控件太大。 + setTimeout(function () { + echartsObjs[node.id].chart.setOption(node.data.echarts.option) + echartsObjs[node.id].chart.resize() + node.elementRendered = true + }) + } } -//# sourceMappingURL=index.js.map \ No newline at end of file +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/chart-diagram/src/register.js b/nezha-fronted/src/components/common/@topology/chart-diagram/src/register.js index 0a31149cf..dbda365c6 100644 --- a/nezha-fronted/src/components/common/@topology/chart-diagram/src/register.js +++ b/nezha-fronted/src/components/common/@topology/chart-diagram/src/register.js @@ -1,10 +1,10 @@ -import { registerNode, loadJS } from '@topology/core'; -import { echarts, echartsObjs } from './echarts'; -export function register(_echarts) { - echartsObjs.echarts = _echarts; - if (!echartsObjs.echarts && !window.echarts) { - loadJS('https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js', null, true); - } - registerNode('echarts', echarts, null, null, null); +import { registerNode, loadJS } from '@topology/core' +import { echarts, echartsObjs } from './echarts' +export function register (_echarts) { + echartsObjs.echarts = _echarts + if (!echartsObjs.echarts && !window.echarts) { + loadJS('https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js', null, true) + } + registerNode('echarts', echarts, null, null, null) } -//# sourceMappingURL=register.js.map \ No newline at end of file +// # sourceMappingURL=register.js.map diff --git a/nezha-fronted/src/components/common/@topology/class-diagram/index.js b/nezha-fronted/src/components/common/@topology/class-diagram/index.js index b1c532976..2d0c5b9d5 100644 --- a/nezha-fronted/src/components/common/@topology/class-diagram/index.js +++ b/nezha-fronted/src/components/common/@topology/class-diagram/index.js @@ -1,3 +1,3 @@ -export * from './src/class'; -export * from './src/register'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './src/class' +export * from './src/register' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/class-diagram/src/class/class.js b/nezha-fronted/src/components/common/@topology/class-diagram/src/class/class.js index 20eb982a7..9604c76ff 100644 --- a/nezha-fronted/src/components/common/@topology/class-diagram/src/class/class.js +++ b/nezha-fronted/src/components/common/@topology/class-diagram/src/class/class.js @@ -1,56 +1,56 @@ -export function simpleClass(ctx, node) { - var wr = node.borderRadius; - var hr = node.borderRadius; - if (node.borderRadius < 1) { - wr = node.rect.width * node.borderRadius; - hr = node.rect.height * node.borderRadius; - } - var r = wr < hr ? wr : hr; - if (node.rect.width < 2 * r) { - r = node.rect.width / 2; - } - if (node.rect.height < 2 * r) { - r = node.rect.height / 2; - } - ctx.beginPath(); - ctx.moveTo(node.rect.x + r, node.rect.y); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r); - ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r); - ctx.closePath(); - ctx.moveTo(node.rect.x, node.rect.y + 40); - ctx.lineTo(node.rect.ex, node.rect.y + 40); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function simpleClass (ctx, node) { + let wr = node.borderRadius + let hr = node.borderRadius + if (node.borderRadius < 1) { + wr = node.rect.width * node.borderRadius + hr = node.rect.height * node.borderRadius + } + let r = wr < hr ? wr : hr + if (node.rect.width < 2 * r) { + r = node.rect.width / 2 + } + if (node.rect.height < 2 * r) { + r = node.rect.height / 2 + } + ctx.beginPath() + ctx.moveTo(node.rect.x + r, node.rect.y) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r) + ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r) + ctx.closePath() + ctx.moveTo(node.rect.x, node.rect.y + 40) + ctx.lineTo(node.rect.ex, node.rect.y + 40); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -export function interfaceClass(ctx, node) { - var wr = node.borderRadius; - var hr = node.borderRadius; - if (node.borderRadius < 1) { - wr = node.rect.width * node.borderRadius; - hr = node.rect.height * node.borderRadius; - } - var r = wr < hr ? wr : hr; - if (node.rect.width < 2 * r) { - r = node.rect.width / 2; - } - if (node.rect.height < 2 * r) { - r = node.rect.height / 2; - } - ctx.beginPath(); - ctx.moveTo(node.rect.x + r, node.rect.y); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r); - ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r); - ctx.closePath(); - ctx.moveTo(node.rect.x, node.rect.y + 40); - ctx.lineTo(node.rect.ex, node.rect.y + 40); - var height = node.rect.y + 20 + node.rect.height / 2; - ctx.moveTo(node.rect.x, height); - ctx.lineTo(node.rect.ex, height); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function interfaceClass (ctx, node) { + let wr = node.borderRadius + let hr = node.borderRadius + if (node.borderRadius < 1) { + wr = node.rect.width * node.borderRadius + hr = node.rect.height * node.borderRadius + } + let r = wr < hr ? wr : hr + if (node.rect.width < 2 * r) { + r = node.rect.width / 2 + } + if (node.rect.height < 2 * r) { + r = node.rect.height / 2 + } + ctx.beginPath() + ctx.moveTo(node.rect.x + r, node.rect.y) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r) + ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r) + ctx.closePath() + ctx.moveTo(node.rect.x, node.rect.y + 40) + ctx.lineTo(node.rect.ex, node.rect.y + 40) + const height = node.rect.y + 20 + node.rect.height / 2 + ctx.moveTo(node.rect.x, height) + ctx.lineTo(node.rect.ex, height); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=class.js.map \ No newline at end of file +// # sourceMappingURL=class.js.map diff --git a/nezha-fronted/src/components/common/@topology/class-diagram/src/class/class.rect.js b/nezha-fronted/src/components/common/@topology/class-diagram/src/class/class.rect.js index 30f01d7c1..7390b41f6 100644 --- a/nezha-fronted/src/components/common/@topology/class-diagram/src/class/class.rect.js +++ b/nezha-fronted/src/components/common/@topology/class-diagram/src/class/class.rect.js @@ -1,16 +1,16 @@ -import { Rect } from '@topology/core'; -export function simpleClassIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function simpleClassIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function simpleClassTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40); - node.fullTextRect = node.textRect; +export function simpleClassTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40) + node.fullTextRect = node.textRect } -export function interfaceClassIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +export function interfaceClassIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function interfaceClassTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40); - node.fullTextRect = node.textRect; +export function interfaceClassTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40) + node.fullTextRect = node.textRect } -//# sourceMappingURL=class.rect.js.map \ No newline at end of file +// # sourceMappingURL=class.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/class-diagram/src/class/index.js b/nezha-fronted/src/components/common/@topology/class-diagram/src/class/index.js index bf42da6d8..6b4f15d6e 100644 --- a/nezha-fronted/src/components/common/@topology/class-diagram/src/class/index.js +++ b/nezha-fronted/src/components/common/@topology/class-diagram/src/class/index.js @@ -1,3 +1,3 @@ -export * from './class'; -export * from './class.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './class' +export * from './class.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/class-diagram/src/register.js b/nezha-fronted/src/components/common/@topology/class-diagram/src/register.js index 2cf4fda55..1801d39fa 100644 --- a/nezha-fronted/src/components/common/@topology/class-diagram/src/register.js +++ b/nezha-fronted/src/components/common/@topology/class-diagram/src/register.js @@ -1,7 +1,7 @@ -import { registerNode } from '@topology/core'; -import { simpleClass, simpleClassIconRect, simpleClassTextRect, interfaceClass, interfaceClassIconRect, interfaceClassTextRect } from './class'; -export function register() { - registerNode('simpleClass', simpleClass, null, simpleClassIconRect, simpleClassTextRect); - registerNode('interfaceClass', interfaceClass, null, interfaceClassIconRect, interfaceClassTextRect); +import { registerNode } from '@topology/core' +import { simpleClass, simpleClassIconRect, simpleClassTextRect, interfaceClass, interfaceClassIconRect, interfaceClassTextRect } from './class' +export function register () { + registerNode('simpleClass', simpleClass, null, simpleClassIconRect, simpleClassTextRect) + registerNode('interfaceClass', interfaceClass, null, interfaceClassIconRect, interfaceClassTextRect) } -//# sourceMappingURL=register.js.map \ No newline at end of file +// # sourceMappingURL=register.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/index.js b/nezha-fronted/src/components/common/@topology/core/index.js index 2a5442982..91e1ba983 100644 --- a/nezha-fronted/src/components/common/@topology/core/index.js +++ b/nezha-fronted/src/components/common/@topology/core/index.js @@ -1,6 +1,6 @@ -export * from './src/core'; -export * from './src/options'; -export * from './src/utils'; -export * from './src/models'; -export * from './src/middles'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './src/core' +export * from './src/options' +export * from './src/utils' +export * from './src/models' +export * from './src/middles' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/activeLayer.js b/nezha-fronted/src/components/common/@topology/core/src/activeLayer.js index f1d2c6fc3..bbb273789 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/activeLayer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/activeLayer.js @@ -1,743 +1,735 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -import { Store } from 'le5le-store'; -import { PenType } from './models/pen'; -import { Node } from './models/node'; -import { Line } from './models/line'; -import { Rect } from './models/rect'; -import { Point } from './models/point'; -import { Lock } from './models/status'; -import { drawLineFns } from './middles'; -import { getBezierPoint } from './middles/lines/curve'; -import { Layer } from './layer'; -import { find, flatNodes, getBboxOfPoints, rgba, deepClone, getRect } from './utils'; -var ActiveLayer = /** @class */ (function (_super) { - __extends(ActiveLayer, _super); - function ActiveLayer(options, TID) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, TID) || this; - _this.options = options; - _this.rotateCPs = []; - _this.sizeCPs = []; - _this.pens = []; - _this.rotate = 0; - _this.lastOffsetX = 0; - _this.lastOffsetY = 0; - // 备份初始位置,方便移动事件处理 - _this.initialSizeCPs = []; - _this.nodeRects = []; - _this.childrenRects = {}; - _this.childrenRotate = {}; - // nodes移动时,停靠点的参考位置 - _this.dockWatchers = []; - _this.rotating = false; - Store.set(_this.generateStoreKey('LT:ActiveLayer'), _this); - return _this; +import { Store } from 'le5le-store' +import { PenType } from './models/pen' +import { Node } from './models/node' +import { Line } from './models/line' +import { Rect } from './models/rect' +import { Point } from './models/point' +import { Lock } from './models/status' +import { drawLineFns } from './middles' +import { getBezierPoint } from './middles/lines/curve' +import { Layer } from './layer' +import { find, flatNodes, getBboxOfPoints, rgba, deepClone, getRect } from './utils' +const __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) || + function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] } + return extendStatics(d, b) + } + return function (d, b) { + extendStatics(d, b) + function __ () { this.constructor = d } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()) + } +})() +const ActiveLayer = /** @class */ (function (_super) { + __extends(ActiveLayer, _super) + function ActiveLayer (options, TID) { + if (options === void 0) { options = {} } + const _this = _super.call(this, TID) || this + _this.options = options + _this.rotateCPs = [] + _this.sizeCPs = [] + _this.pens = [] + _this.rotate = 0 + _this.lastOffsetX = 0 + _this.lastOffsetY = 0 + // 备份初始位置,方便移动事件处理 + _this.initialSizeCPs = [] + _this.nodeRects = [] + _this.childrenRects = {} + _this.childrenRotate = {} + // nodes移动时,停靠点的参考位置 + _this.dockWatchers = [] + _this.rotating = false + Store.set(_this.generateStoreKey('LT:ActiveLayer'), _this) + // return _this + } + ActiveLayer.prototype.calcControlPoints = function () { + if (this.pens.length === 1 && this.pens[0] instanceof Node) { + this.rect = this.pens[0].rect + this.sizeCPs = this.pens[0].rect.toPoints() + this.rotateCPs = [ + new Point(this.pens[0].rect.x + this.pens[0].rect.width / 2, this.pens[0].rect.y - 35), + new Point(this.pens[0].rect.x + this.pens[0].rect.width / 2, this.pens[0].rect.y) + ] + if (this.rotate || this.pens[0].rotate) { + for (let _i = 0, _a = this.sizeCPs; _i < _a.length; _i++) { + var pt = _a[_i] + if (this.pens[0].rotate) { + pt.rotate(this.pens[0].rotate, this.pens[0].rect.center) + } + if (this.rotate) { + pt.rotate(this.rotate, this.rect.center) + } + } + for (let _b = 0, _c = this.rotateCPs; _b < _c.length; _b++) { + var pt = _c[_b] + if (this.pens[0].rotate) { + pt.rotate(this.pens[0].rotate, this.pens[0].rect.center) + } + if (this.rotate) { + pt.rotate(this.rotate, this.rect.center) + } + } + } + if (this.options.hideRotateCP || this.pens[0].hideRotateCP) { + this.rotateCPs = [new Point(-1000, -1000), new Point(-1000, -1000)] + } + return } - ActiveLayer.prototype.calcControlPoints = function () { - if (this.pens.length === 1 && this.pens[0] instanceof Node) { - this.rect = this.pens[0].rect; - this.sizeCPs = this.pens[0].rect.toPoints(); - this.rotateCPs = [ - new Point(this.pens[0].rect.x + this.pens[0].rect.width / 2, this.pens[0].rect.y - 35), - new Point(this.pens[0].rect.x + this.pens[0].rect.width / 2, this.pens[0].rect.y), - ]; - if (this.rotate || this.pens[0].rotate) { - for (var _i = 0, _a = this.sizeCPs; _i < _a.length; _i++) { - var pt = _a[_i]; - if (this.pens[0].rotate) { - pt.rotate(this.pens[0].rotate, this.pens[0].rect.center); - } - if (this.rotate) { - pt.rotate(this.rotate, this.rect.center); - } - } - for (var _b = 0, _c = this.rotateCPs; _b < _c.length; _b++) { - var pt = _c[_b]; - if (this.pens[0].rotate) { - pt.rotate(this.pens[0].rotate, this.pens[0].rect.center); - } - if (this.rotate) { - pt.rotate(this.rotate, this.rect.center); - } - } + const _d = getBboxOfPoints(this.getPoints()); const x1 = _d.x1; const y1 = _d.y1; const x2 = _d.x2; const y2 = _d.y2 + this.rect = new Rect(x1, y1, x2 - x1, y2 - y1) + this.sizeCPs = [ + new Point(x1, y1), + new Point(x2, y1), + new Point(x2, y2), + new Point(x1, y2) + ] + this.rotateCPs = [ + new Point(x1 + (x2 - x1) / 2, y1 - 35), + new Point(x1 + (x2 - x1) / 2, y1) + ] + if (this.options.hideRotateCP) { + this.rotateCPs = [new Point(-1000, -1000), new Point(-1000, -1000)] + } + } + ActiveLayer.prototype.locked = function () { + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (!item.locked) { + return false + } + } + return true + } + ActiveLayer.prototype.getPoints = function () { + const points = [] + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (item.type === PenType.Node) { + const pts = item.rect.toPoints() + if (item.rotate) { + for (let _b = 0, pts_1 = pts; _b < pts_1.length; _b++) { + const pt = pts_1[_b] + pt.rotate(item.rotate, item.rect.center) + } + } + points.push.apply(points, pts) + } else if (item instanceof Line) { + if (item.children) { + item.children.forEach(function (child) { + points.push(child.from) + points.push(child.to) + if (child.name === 'curve') { + for (let i = 0.01; i < 1; i += 0.02) { + points.push(getBezierPoint(i, child.from, child.controlPoints[0], child.controlPoints[1], child.to)) + } } - if (this.options.hideRotateCP || this.pens[0].hideRotateCP) { - this.rotateCPs = [new Point(-1000, -1000), new Point(-1000, -1000)]; + }) + } else if (item.from) { + points.push(item.from) + points.push(item.to) + if (item.name === 'curve') { + for (let i = 0.01; i < 1; i += 0.02) { + points.push(getBezierPoint(i, item.from, item.controlPoints[0], item.controlPoints[1], item.to)) } - return; + } } - var _d = getBboxOfPoints(this.getPoints()), x1 = _d.x1, y1 = _d.y1, x2 = _d.x2, y2 = _d.y2; - this.rect = new Rect(x1, y1, x2 - x1, y2 - y1); - this.sizeCPs = [ - new Point(x1, y1), - new Point(x2, y1), - new Point(x2, y2), - new Point(x1, y2), - ]; - this.rotateCPs = [ - new Point(x1 + (x2 - x1) / 2, y1 - 35), - new Point(x1 + (x2 - x1) / 2, y1), - ]; - if (this.options.hideRotateCP) { - this.rotateCPs = [new Point(-1000, -1000), new Point(-1000, -1000)]; + } + } + return points + } + ActiveLayer.prototype.clear = function () { + this.pens = [] + this.sizeCPs = [] + this.rotateCPs = [] + Store.set(this.generateStoreKey('LT:activeNode'), undefined) + } + // 即将缩放选中的nodes,备份nodes最初大小,方便缩放比例计算 + ActiveLayer.prototype.saveNodeRects = function () { + this.nodeRects = [] + this.childrenRects = {} + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + var item = _a[_i] + if (item.type && item.from) { + this.nodeRects.push(new Rect(item.from.x, item.from.y, item.rect.width, item.rect.height)) + } else { + this.nodeRects.push(new Rect(item.rect.x, item.rect.y, item.rect.width, item.rect.height)) + } + this.saveChildrenRects(item) + } + this.initialSizeCPs = [] + for (let _b = 0, _c = this.sizeCPs; _b < _c.length; _b++) { + var item = _c[_b] + this.initialSizeCPs.push(item.clone()) + } + this.getDockWatchers() + } + ActiveLayer.prototype.saveChildrenRects = function (node) { + if (node.type || !node.children) { + return + } + for (let _i = 0, _a = node.children; _i < _a.length; _i++) { + const item = _a[_i] + this.childrenRects[item.id] = new Rect(item.rect.x, item.rect.y, item.rect.width, item.rect.height) + this.childrenRotate[item.id] = item.rotate + this.saveChildrenRects(item) + } + } + // pt1 - the point of mouse down. + // pt2 - the point of mouse move. + ActiveLayer.prototype.resize = function (type, pt1, pt2) { + const p1 = new Point(pt1.x, pt1.y) + const p2 = new Point(pt2.x, pt2.y) + if (this.pens.length === 1 && this.pens[0].rotate % 360) { + p1.rotate(-this.pens[0].rotate, this.nodeRects[0].center) + p2.rotate(-this.pens[0].rotate, this.nodeRects[0].center) + } + const x = p2.x - p1.x + const y = p2.y - p1.y + let offsetX = x - this.lastOffsetX + let offsetY = y - this.lastOffsetY + this.lastOffsetX = x + this.lastOffsetY = y + const w = this.activeRect.width + const h = this.activeRect.height + if (pt2.shiftKey) { + offsetY = (offsetX * h) / w + } + // const lines: Line[] = []; + switch (type) { + case 0: + if (this.activeRect.width - offsetX < 5 || this.activeRect.height - offsetY < 5) { + return } - }; - ActiveLayer.prototype.locked = function () { - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (!item.locked) { - return false; - } + if (!pt2.shiftKey) { + // offsetX = -offsetX; + // offsetY = -offsetY; + this.activeRect.x += offsetX + this.activeRect.y += offsetY + this.activeRect.width -= offsetX + this.activeRect.height -= offsetY + } else { + offsetX = -offsetX + offsetY = -offsetY + this.activeRect.ex += offsetX + this.activeRect.ey += offsetY + this.activeRect.width += offsetX + this.activeRect.height += offsetY } - return true; - }; - ActiveLayer.prototype.getPoints = function () { - var points = []; - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (item.type === PenType.Node) { - var pts = item.rect.toPoints(); - if (item.rotate) { - for (var _b = 0, pts_1 = pts; _b < pts_1.length; _b++) { - var pt = pts_1[_b]; - pt.rotate(item.rotate, item.rect.center); - } - } - points.push.apply(points, pts); - } - else if (item instanceof Line) { - if (item.children) { - item.children.forEach(function (child) { - points.push(child.from); - points.push(child.to); - if (child.name === 'curve') { - for (var i = 0.01; i < 1; i += 0.02) { - points.push(getBezierPoint(i, child.from, child.controlPoints[0], child.controlPoints[1], child.to)); - } - } - }); - } - else if (item.from) { - points.push(item.from); - points.push(item.to); - if (item.name === 'curve') { - for (var i = 0.01; i < 1; i += 0.02) { - points.push(getBezierPoint(i, item.from, item.controlPoints[0], item.controlPoints[1], item.to)); - } - } - } - } + break + case 1: + // offsetY = -offsetY; + if (this.activeRect.width + offsetX < 5 || this.activeRect.height - offsetY < 5) { + return } - return points; - }; - ActiveLayer.prototype.clear = function () { - this.pens = []; - this.sizeCPs = []; - this.rotateCPs = []; - Store.set(this.generateStoreKey('LT:activeNode'), undefined); - }; - // 即将缩放选中的nodes,备份nodes最初大小,方便缩放比例计算 - ActiveLayer.prototype.saveNodeRects = function () { - this.nodeRects = []; - this.childrenRects = {}; - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (item.type && item.from) { - this.nodeRects.push(new Rect(item.from.x, item.from.y, item.rect.width, item.rect.height)); - } - else { - this.nodeRects.push(new Rect(item.rect.x, item.rect.y, item.rect.width, item.rect.height)); - } - this.saveChildrenRects(item); + if (!pt2.shiftKey) { + this.activeRect.ex += offsetX + this.activeRect.y += offsetY + this.activeRect.width += offsetX + this.activeRect.height -= offsetY + } else { + // offsetX = -offsetX; + // offsetY = -offsetY; + this.activeRect.ex += offsetX + this.activeRect.ey += offsetY + this.activeRect.width += offsetX + this.activeRect.height += offsetY } - this.initialSizeCPs = []; - for (var _b = 0, _c = this.sizeCPs; _b < _c.length; _b++) { - var item = _c[_b]; - this.initialSizeCPs.push(item.clone()); + break + case 2: + if (this.activeRect.width + offsetX < 5 || this.activeRect.height + offsetY < 5) { + return } - this.getDockWatchers(); - }; - ActiveLayer.prototype.saveChildrenRects = function (node) { - if (node.type || !node.children) { - return; + this.activeRect.ex += offsetX + this.activeRect.ey += offsetY + this.activeRect.width += offsetX + this.activeRect.height += offsetY + break + case 3: + // offsetX = -offsetX; + if (this.activeRect.width - offsetX < 5 || this.activeRect.height + offsetY < 5) { + return } - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var item = _a[_i]; - this.childrenRects[item.id] = new Rect(item.rect.x, item.rect.y, item.rect.width, item.rect.height); - this.childrenRotate[item.id] = item.rotate; - this.saveChildrenRects(item); + if (!pt2.shiftKey) { + this.activeRect.x += offsetX + this.activeRect.ey += offsetY + this.activeRect.width -= offsetX + this.activeRect.height += offsetY + } else { + offsetX = -offsetX + offsetY = -offsetY + this.activeRect.ex += offsetX + this.activeRect.ey += offsetY + this.activeRect.width += offsetX + this.activeRect.height += offsetY } - }; - // pt1 - the point of mouse down. - // pt2 - the point of mouse move. - ActiveLayer.prototype.resize = function (type, pt1, pt2) { - var p1 = new Point(pt1.x, pt1.y); - var p2 = new Point(pt2.x, pt2.y); - if (this.pens.length === 1 && this.pens[0].rotate % 360) { - p1.rotate(-this.pens[0].rotate, this.nodeRects[0].center); - p2.rotate(-this.pens[0].rotate, this.nodeRects[0].center); - } - var x = p2.x - p1.x; - var y = p2.y - p1.y; - var offsetX = x - this.lastOffsetX; - var offsetY = y - this.lastOffsetY; - this.lastOffsetX = x; - this.lastOffsetY = y; - var w = this.activeRect.width; - var h = this.activeRect.height; - if (pt2.shiftKey) { - offsetY = (offsetX * h) / w; - } - // const lines: Line[] = []; - switch (type) { - case 0: - if (this.activeRect.width - offsetX < 5 || this.activeRect.height - offsetY < 5) { - return; - } - if (!pt2.shiftKey) { - // offsetX = -offsetX; - // offsetY = -offsetY; - this.activeRect.x += offsetX; - this.activeRect.y += offsetY; - this.activeRect.width -= offsetX; - this.activeRect.height -= offsetY; - } - else { - offsetX = -offsetX; - offsetY = -offsetY; - this.activeRect.ex += offsetX; - this.activeRect.ey += offsetY; - this.activeRect.width += offsetX; - this.activeRect.height += offsetY; - } - break; - case 1: - // offsetY = -offsetY; - if (this.activeRect.width + offsetX < 5 || this.activeRect.height - offsetY < 5) { - return; - } - if (!pt2.shiftKey) { - this.activeRect.ex += offsetX; - this.activeRect.y += offsetY; - this.activeRect.width += offsetX; - this.activeRect.height -= offsetY; - } - else { - // offsetX = -offsetX; - // offsetY = -offsetY; - this.activeRect.ex += offsetX; - this.activeRect.ey += offsetY; - this.activeRect.width += offsetX; - this.activeRect.height += offsetY; - } - break; - case 2: - if (this.activeRect.width + offsetX < 5 || this.activeRect.height + offsetY < 5) { - return; - } - this.activeRect.ex += offsetX; - this.activeRect.ey += offsetY; - this.activeRect.width += offsetX; - this.activeRect.height += offsetY; - break; - case 3: - // offsetX = -offsetX; - if (this.activeRect.width - offsetX < 5 || this.activeRect.height + offsetY < 5) { - return; - } - if (!pt2.shiftKey) { - this.activeRect.x += offsetX; - this.activeRect.ey += offsetY; - this.activeRect.width -= offsetX; - this.activeRect.height += offsetY; - } - else { - offsetX = -offsetX; - offsetY = -offsetY; - this.activeRect.ex += offsetX; - this.activeRect.ey += offsetY; - this.activeRect.width += offsetX; - this.activeRect.height += offsetY; - } - break; - } - var scaleX = this.activeRect.width / w; - var scaleY = this.activeRect.height / h; - // let i = 0; - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (item.locked) { - continue; - } - switch (item.type) { - case PenType.Line: - break; - default: - item['oldRect'] = item.rect.clone(); - if (!this.options.disableSizeX && + break + } + const scaleX = this.activeRect.width / w + const scaleY = this.activeRect.height / h + // let i = 0; + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (item.locked) { + continue + } + switch (item.type) { + case PenType.Line: + break + default: + item.oldRect = item.rect.clone() + if (!this.options.disableSizeX && !pt2.ctrlKey && !item.disableSizeX) { - // item.rect.width = this.nodeRects[i].width + offsetX; - item.rect.width *= scaleX; - if (item.imageWidth) { - item.imageWidth *= scaleX; - } - } - if (!this.options.disableSizeY && + // item.rect.width = this.nodeRects[i].width + offsetX; + item.rect.width *= scaleX + if (item.imageWidth) { + item.imageWidth *= scaleX + } + } + if (!this.options.disableSizeY && !pt2.altKey && !item.disableSizeY) { - // item.rect.height = this.nodeRects[i].height + offsetY; - item.rect.height *= scaleY; - if (item.imageHeight) { - item.imageHeight *= scaleY; - } - } - if ((!this.options.disableSizeX && + // item.rect.height = this.nodeRects[i].height + offsetY; + item.rect.height *= scaleY + if (item.imageHeight) { + item.imageHeight *= scaleY + } + } + if ((!this.options.disableSizeX && pt2.shiftKey && !item.disableSizeX) || (!this.options.disableSizeY && pt2.shiftKey && !item.disableSizeY)) { - // item.rect.width = this.nodeRects[i].width + offsetX; - // item.rect.height = this.nodeRects[i].height + offsetY; - item.rect.width *= scaleX; - item.rect.height *= scaleY; - if (item.imageWidth) { - item.imageWidth *= scaleX; - } - if (item.imageHeight) { - item.imageHeight *= scaleY; - } - } - switch (type) { - case 0: - item.rect.x = item.rect.ex - item.rect.width; - item.rect.y = item.rect.ey - item.rect.height; - break; - case 1: - item.rect.ex = item.rect.x + item.rect.width; - item.rect.y = item.rect.ey - item.rect.height; - break; - case 2: - item.rect.ex = item.rect.x + item.rect.width; - item.rect.ey = item.rect.y + item.rect.height; - break; - case 3: - item.rect.x = item.rect.ex - item.rect.width; - item.rect.ey = item.rect.y + item.rect.height; - break; - } - item.scalePoints(); - item.rect.calcCenter(); - item.init(); - item.calcChildrenRect(); - break; + // item.rect.width = this.nodeRects[i].width + offsetX; + // item.rect.height = this.nodeRects[i].height + offsetY; + item.rect.width *= scaleX + item.rect.height *= scaleY + if (item.imageWidth) { + item.imageWidth *= scaleX } - if (item.parentId) { - var parent_1 = void 0; - for (var _b = 0, _c = this.data.pens; _b < _c.length; _b++) { - var n = _c[_b]; - if (n.id === item.parentId) { - parent_1 = n; - item.calcRectInParent(parent_1); - break; - } - } + if (item.imageHeight) { + item.imageHeight *= scaleY } - // ++i; + } + switch (type) { + case 0: + item.rect.x = item.rect.ex - item.rect.width + item.rect.y = item.rect.ey - item.rect.height + break + case 1: + item.rect.ex = item.rect.x + item.rect.width + item.rect.y = item.rect.ey - item.rect.height + break + case 2: + item.rect.ex = item.rect.x + item.rect.width + item.rect.ey = item.rect.y + item.rect.height + break + case 3: + item.rect.x = item.rect.ex - item.rect.width + item.rect.ey = item.rect.y + item.rect.height + break + } + item.scalePoints() + item.rect.calcCenter() + item.init() + item.calcChildrenRect() + break + } + if (item.parentId) { + let parent_1 = void 0 + for (let _b = 0, _c = this.data.pens; _b < _c.length; _b++) { + const n = _c[_b] + if (n.id === item.parentId) { + parent_1 = n + item.calcRectInParent(parent_1) + break + } } - this.updateLines(); - }; - ActiveLayer.prototype.move = function (x, y) { - if (this.nodeRects.length !== this.pens.length) { - return; + } + // ++i; + } + this.updateLines() + } + ActiveLayer.prototype.move = function (x, y) { + if (this.nodeRects.length !== this.pens.length) { + return + } + let i = 0 + const _loop_1 = function (item) { + if (item.locked) { + return 'continue' + } + if (item instanceof Node) { + const offsetX = this_1.nodeRects[i].x + x - item.rect.x + const offsetY = this_1.nodeRects[i].y + y - item.rect.y + item.translate(offsetX, offsetY) + const lines = this_1.getLinesOfNode(item) + for (let _i = 0, lines_1 = lines; _i < lines_1.length; _i++) { + const line = lines_1[_i] + line.translate(offsetX, offsetY) } - var i = 0; - var _loop_1 = function (item) { - if (item.locked) { - return "continue"; + item.calcChildrenRect() + if (item.parentId && !item.locked) { + let parent_2 = void 0 + for (let _a = 0, _b = this_1.data.pens; _a < _b.length; _a++) { + const n = _b[_a] + if (n.id === item.parentId) { + parent_2 = n + item.calcRectInParent(parent_2) + break } - if (item instanceof Node) { - var offsetX = this_1.nodeRects[i].x + x - item.rect.x; - var offsetY = this_1.nodeRects[i].y + y - item.rect.y; - item.translate(offsetX, offsetY); - var lines = this_1.getLinesOfNode(item); - for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) { - var line = lines_1[_i]; - line.translate(offsetX, offsetY); - } - item.calcChildrenRect(); - if (item.parentId && !item.locked) { - var parent_2 = void 0; - for (var _a = 0, _b = this_1.data.pens; _a < _b.length; _a++) { - var n = _b[_a]; - if (n.id === item.parentId) { - parent_2 = n; - item.calcRectInParent(parent_2); - break; - } - } - } + } + } + } + if (item instanceof Line && item.from) { + const offsetX_1 = this_1.nodeRects[i].x + x - item.from.x + const offsetY_1 = this_1.nodeRects[i].y + y - item.from.y + if (item.parentId) { + const items = find(item.parentId, this_1.data.pens) + items.forEach(function (l) { + l.translate(offsetX_1, offsetY_1) + }) + } else { + item.translate(offsetX_1, offsetY_1) + } + } + ++i + } + var this_1 = this + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + const item = _a[_i] + _loop_1(item) + } + this.updateLines() + this.topology.dispatch('move', this.pens) + } + ActiveLayer.prototype.getLinesOfNode = function (node) { + const result = [] + const nodesLines = flatNodes([node]) + for (let _i = 0, _a = this.data.pens; _i < _a.length; _i++) { + const pen = _a[_i] + if (!(pen instanceof Line)) { + continue + } + const line = pen + let fromIn = false + let toIn = false + for (let _b = 0, _c = nodesLines.nodes; _b < _c.length; _b++) { + const item = _c[_b] + if (line.from && line.from.id === item.id) { + fromIn = true + } + if (line.to && line.to.id === item.id) { + toIn = true + } + } + if (fromIn && toIn) { + result.push(line) + } + } + return result + } + ActiveLayer.prototype.updateLines = function (pens) { + if (!pens) { + pens = this.pens + } + const allPens = flatNodes(this.data.pens) + const allLines = allPens.lines + let nodes = allPens.nodes + if (!this.options.autoAnchor) { // 非自动瞄点,只要活动层的 nodes + nodes = flatNodes(pens).nodes + } + const lines = [] + for (let _i = 0, allLines_1 = allLines; _i < allLines_1.length; _i++) { + const line = allLines_1[_i] + for (let _a = 0, nodes_1 = nodes; _a < nodes_1.length; _a++) { + const item = nodes_1[_a] + let cnt = 0 + if (line.from && line.from.id === item.id) { + if (line.from.autoAnchor) { + var autoAnchor = item.nearestAnchor(line.to) + if (autoAnchor.index > -1) { + line.from.anchorIndex = autoAnchor.index + line.from.direction = autoAnchor.direction } - if (item instanceof Line && item.from) { - var offsetX_1 = this_1.nodeRects[i].x + x - item.from.x; - var offsetY_1 = this_1.nodeRects[i].y + y - item.from.y; - if (item.parentId) { - var items = find(item.parentId, this_1.data.pens); - items.forEach(function (l) { - l.translate(offsetX_1, offsetY_1); - }); - } - else { - item.translate(offsetX_1, offsetY_1); - } + } + if (line.from.anchorIndex >= 0) { + line.from.x = item.rotatedAnchors[line.from.anchorIndex].x + line.from.y = item.rotatedAnchors[line.from.anchorIndex].y + ++cnt + } + } + if (line.to && line.to.id === item.id) { + if (line.to.autoAnchor) { + var autoAnchor = item.nearestAnchor(line.from) + if (autoAnchor.index > -1) { + line.to.anchorIndex = autoAnchor.index + line.to.direction = autoAnchor.direction } - ++i; - }; - var this_1 = this; - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - _loop_1(item); + } + if (line.to.anchorIndex >= 0) { + line.to.x = item.rotatedAnchors[line.to.anchorIndex].x + line.to.y = item.rotatedAnchors[line.to.anchorIndex].y + ++cnt + } } - this.updateLines(); - this.topology.dispatch('move', this.pens); - }; - ActiveLayer.prototype.getLinesOfNode = function (node) { - var result = []; - var nodesLines = flatNodes([node]); - for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) { - var pen = _a[_i]; - if (!(pen instanceof Line)) { - continue; - } - var line = pen; - var fromIn = false; - var toIn = false; - for (var _b = 0, _c = nodesLines.nodes; _b < _c.length; _b++) { - var item = _c[_b]; - if (line.from && line.from.id === item.id) { - fromIn = true; - } - if (line.to && line.to.id === item.id) { - toIn = true; - } - } - if (fromIn && toIn) { - result.push(line); - } + if (cnt && !this.data.manualCps) { + line.calcControlPoints() } - return result; - }; - ActiveLayer.prototype.updateLines = function (pens) { - if (!pens) { - pens = this.pens; + line.textRect = undefined + Store.set(this.generateStoreKey('pts-') + line.id, undefined) + lines.push(line) + } + } + Store.set(this.generateStoreKey('LT:updateLines'), lines) + } + ActiveLayer.prototype.offsetRotate = function (angle) { + this.rotating = true + let i = 0 + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (!(item instanceof Node)) { + continue + } + const center = this.nodeRects[i].center.clone() + if (this.pens.length > 1) { + center.rotate(angle, this.rect.center) + } + item.rect.x = center.x - item.rect.width / 2 + item.rect.y = center.y - item.rect.height / 2 + item.rect.ex = item.rect.x + item.rect.width + item.rect.ey = item.rect.y + item.rect.height + item.rect.calcCenter() + item.init() + item.offsetRotate = angle + item.calcRotateAnchors(item.rotate + item.offsetRotate) + this.rotateChildren(item) + ++i + } + this.rotate = angle + this.topology.dispatch('rotated', this.pens) + } + ActiveLayer.prototype.rotateChildren = function (node) { + if (node.type !== PenType.Node || !node.children) { + return + } + for (let _i = 0, _a = node.children; _i < _a.length; _i++) { + const item = _a[_i] + if (item.type !== PenType.Node) { + continue + } + const oldCenter = this.childrenRects[item.id].center.clone() + const newCenter = this.childrenRects[item.id].center + .clone() + .rotate(this.rotate, this.rect.center) + const rect = this.childrenRects[item.id].clone() + rect.translate(newCenter.x - oldCenter.x, newCenter.y - oldCenter.y) + item.rect = rect + item.rotate = this.childrenRotate[item.id] + this.rotate + item.init() + this.rotateChildren(item) + } + } + ActiveLayer.prototype.updateRotate = function () { + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + const item = _a[_i] + item.rotate += item.offsetRotate + if (item.type === PenType.Node && item.rectInParent) { + item.rectInParent.rotate += item.offsetRotate + } + item.offsetRotate = 0 + } + this.rotate = 0 + this.rotating = false + } + ActiveLayer.prototype.add = function (pen) { + if (this.has(pen)) { + return + } + this.pens.push(pen) + if (pen instanceof Node) { + Store.set(this.generateStoreKey('LT:activeNode'), pen) + } + } + ActiveLayer.prototype.setPens = function (pens) { + this.pens = pens + if (this.pens.length === 1 && this.pens[0] instanceof Node) { + Store.set(this.generateStoreKey('LT:activeNode'), this.pens[0]) + } + } + ActiveLayer.prototype.has = function (pen) { + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (item.id === pen.id) { + return true + } + } + return false + } + ActiveLayer.prototype.hasInAll = function (pen, pens) { + if (!pens) { + pens = this.pens + } + for (let _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { + const item = pens_1[_i] + if (item.id === pen.id) { + return true + } + if (item.children) { + const has = this.hasInAll(pen, item.children) + if (has) { + return true } - var allPens = flatNodes(this.data.pens); - var allLines = allPens.lines; - var nodes = allPens.nodes; - if (!this.options.autoAnchor) { // 非自动瞄点,只要活动层的 nodes - nodes = flatNodes(pens).nodes; - } - var lines = []; - for (var _i = 0, allLines_1 = allLines; _i < allLines_1.length; _i++) { - var line = allLines_1[_i]; - for (var _a = 0, nodes_1 = nodes; _a < nodes_1.length; _a++) { - var item = nodes_1[_a]; - var cnt = 0; - if (line.from && line.from.id === item.id) { - if (line.from.autoAnchor) { - var autoAnchor = item.nearestAnchor(line.to); - if (autoAnchor.index > -1) { - line.from.anchorIndex = autoAnchor.index; - line.from.direction = autoAnchor.direction; - } - } - if (line.from.anchorIndex >= 0) { - line.from.x = item.rotatedAnchors[line.from.anchorIndex].x; - line.from.y = item.rotatedAnchors[line.from.anchorIndex].y; - ++cnt; - } - } - if (line.to && line.to.id === item.id) { - if (line.to.autoAnchor) { - var autoAnchor = item.nearestAnchor(line.from); - if (autoAnchor.index > -1) { - line.to.anchorIndex = autoAnchor.index; - line.to.direction = autoAnchor.direction; - } - } - if (line.to.anchorIndex >= 0) { - line.to.x = item.rotatedAnchors[line.to.anchorIndex].x; - line.to.y = item.rotatedAnchors[line.to.anchorIndex].y; - ++cnt; - } - } - if (cnt && !this.data.manualCps) { - line.calcControlPoints(); - } - line.textRect = undefined; - Store.set(this.generateStoreKey('pts-') + line.id, undefined); - lines.push(line); - } - } - Store.set(this.generateStoreKey('LT:updateLines'), lines); - }; - ActiveLayer.prototype.offsetRotate = function (angle) { - this.rotating = true; - var i = 0; - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (!(item instanceof Node)) { - continue; - } - var center = this.nodeRects[i].center.clone(); - if (this.pens.length > 1) { - center.rotate(angle, this.rect.center); - } - item.rect.x = center.x - item.rect.width / 2; - item.rect.y = center.y - item.rect.height / 2; - item.rect.ex = item.rect.x + item.rect.width; - item.rect.ey = item.rect.y + item.rect.height; - item.rect.calcCenter(); - item.init(); - item.offsetRotate = angle; - item.calcRotateAnchors(item.rotate + item.offsetRotate); - this.rotateChildren(item); - ++i; - } - this.rotate = angle; - this.topology.dispatch('rotated', this.pens); - }; - ActiveLayer.prototype.rotateChildren = function (node) { - if (node.type !== PenType.Node || !node.children) { - return; - } - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var item = _a[_i]; - if (item.type !== PenType.Node) { - continue; - } - var oldCenter = this.childrenRects[item.id].center.clone(); - var newCenter = this.childrenRects[item.id].center - .clone() - .rotate(this.rotate, this.rect.center); - var rect = this.childrenRects[item.id].clone(); - rect.translate(newCenter.x - oldCenter.x, newCenter.y - oldCenter.y); - item.rect = rect; - item.rotate = this.childrenRotate[item.id] + this.rotate; - item.init(); - this.rotateChildren(item); - } - }; - ActiveLayer.prototype.updateRotate = function () { - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - item.rotate += item.offsetRotate; - if (item.type === PenType.Node && item.rectInParent) { - item.rectInParent.rotate += item.offsetRotate; - } - item.offsetRotate = 0; - } - this.rotate = 0; - this.rotating = false; - }; - ActiveLayer.prototype.add = function (pen) { - if (this.has(pen)) { - return; - } - this.pens.push(pen); - if (pen instanceof Node) { - Store.set(this.generateStoreKey('LT:activeNode'), pen); - } - }; - ActiveLayer.prototype.setPens = function (pens) { - this.pens = pens; - if (this.pens.length === 1 && this.pens[0] instanceof Node) { - Store.set(this.generateStoreKey('LT:activeNode'), this.pens[0]); - } - }; - ActiveLayer.prototype.has = function (pen) { - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (item.id === pen.id) { - return true; - } - } - return false; - }; - ActiveLayer.prototype.hasInAll = function (pen, pens) { - if (!pens) { - pens = this.pens; - } - for (var _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { - var item = pens_1[_i]; - if (item.id === pen.id) { - return true; - } - if (item.children) { - var has = this.hasInAll(pen, item.children); - if (has) { - return true; - } - } - } - return false; - }; - ActiveLayer.prototype.render = function (ctx) { - var _this = this; - if (this.data.locked > Lock.Readonly || + } + } + return false + } + ActiveLayer.prototype.render = function (ctx) { + const _this = this + if (this.data.locked > Lock.Readonly || this.options.activeColor === 'transparent') { - return; + return + } + if (!this.pens.length) { + return + } + this.pens.forEach(function (pen) { + if (!pen.getTID()) { + pen.setTID(_this.TID) + } + }) + if (this.pens.length === 1 || !this.rotating) { + this.calcControlPoints() + } + ctx.save() + ctx.strokeStyle = this.options.activeColor + ctx.fillStyle = '#fff' + ctx.lineWidth = 1 + const TID = this.TID + const scale = Store.get(this.generateStoreKey('LT:scale')) || 1 + for (let _i = 0, _a = this.pens; _i < _a.length; _i++) { + var item = _a[_i] + if (this.data.locked && item instanceof Node) { + var tmp = new Node(item) + tmp.setTID(TID) + tmp.data = undefined + tmp.fillStyle = undefined + tmp.bkType = 0 + tmp.icon = '' + tmp.image = '' + tmp.text = '' + if (tmp.strokeStyle !== 'transparent') { + tmp.strokeStyle = '#ffffff' + tmp.lineWidth += 2 + tmp.render(ctx) + tmp.strokeStyle = this.options.activeColor + tmp.lineWidth -= 2 } - if (!this.pens.length) { - return; + tmp.render(ctx) + } + if (item instanceof Line) { + var tmp = new Line(item) + tmp.lineWidth *= 2 + tmp.toArrowSize = + (tmp.toArrowSize * scale - 1.5 * tmp.lineWidth) / scale + tmp.fromArrowSize = + (tmp.fromArrowSize * scale - 1.5 * tmp.lineWidth) / scale + tmp.setTID(TID) + tmp.strokeStyle = rgba(0.2, this.options.activeColor) + tmp.borderWidth = 4 + tmp.borderColor = rgba(0.1, this.options.activeColor) + tmp.fromArrowColor = this.options.activeColor + tmp.toArrowColor = this.options.activeColor + tmp.render(ctx) + if (!this.data.locked && !item.locked) { + drawLineFns[item.name] && + drawLineFns[item.name].drawControlPointsFn(ctx, item) } - this.pens.forEach(function (pen) { - if (!pen.getTID()) { - pen.setTID(_this.TID); - } - }); - if (this.pens.length === 1 || !this.rotating) { - this.calcControlPoints(); - } - ctx.save(); - ctx.strokeStyle = this.options.activeColor; - ctx.fillStyle = '#fff'; - ctx.lineWidth = 1; - var TID = this.TID; - var scale = Store.get(this.generateStoreKey('LT:scale')) || 1; - for (var _i = 0, _a = this.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (this.data.locked && item instanceof Node) { - var tmp = new Node(item); - tmp.setTID(TID); - tmp.data = undefined; - tmp.fillStyle = undefined; - tmp.bkType = 0; - tmp.icon = ''; - tmp.image = ''; - tmp.text = ''; - if (tmp.strokeStyle !== 'transparent') { - tmp.strokeStyle = '#ffffff'; - tmp.lineWidth += 2; - tmp.render(ctx); - tmp.strokeStyle = this.options.activeColor; - tmp.lineWidth -= 2; - } - tmp.render(ctx); - } - if (item instanceof Line) { - var tmp = new Line(item); - tmp.lineWidth *= 2; - tmp.toArrowSize = - (tmp.toArrowSize * scale - 1.5 * tmp.lineWidth) / scale; - tmp.fromArrowSize = - (tmp.fromArrowSize * scale - 1.5 * tmp.lineWidth) / scale; - tmp.setTID(TID); - tmp.strokeStyle = rgba(0.2, this.options.activeColor); - tmp.borderWidth = 4; - tmp.borderColor = rgba(0.1, this.options.activeColor); - tmp.fromArrowColor = this.options.activeColor; - tmp.toArrowColor = this.options.activeColor; - tmp.render(ctx); - if (!this.data.locked && !item.locked) { - drawLineFns[item.name] && - drawLineFns[item.name].drawControlPointsFn(ctx, item); - } - } - } - if (this.pens.length === 1 && this.pens[0].type === PenType.Line) { - ctx.restore(); // 对应前面的 save() , 保持状态一致 - return; - } - // This is diffence between single node and more. - if (this.rotate && this.pens.length > 1) { - ctx.translate(this.rect.center.x, this.rect.center.y); - ctx.rotate((this.rotate * Math.PI) / 180); - ctx.translate(-this.rect.center.x, -this.rect.center.y); - } - if (this.data.locked || this.locked()) { - ctx.restore(); - return; - } - // Occupied territory. - ctx.save(); - ctx.globalAlpha = 0.3; - ctx.translate(0.5, 0.5); - ctx.beginPath(); - ctx.moveTo(this.sizeCPs[0].x, this.sizeCPs[0].y); - ctx.lineTo(this.sizeCPs[1].x, this.sizeCPs[1].y); - ctx.lineTo(this.sizeCPs[2].x, this.sizeCPs[2].y); - ctx.lineTo(this.sizeCPs[3].x, this.sizeCPs[3].y); - ctx.closePath(); - ctx.stroke(); - ctx.restore(); - // Draw rotate control point. - ctx.beginPath(); - ctx.moveTo(this.rotateCPs[0].x, this.rotateCPs[0].y); - ctx.lineTo(this.rotateCPs[1].x, this.rotateCPs[1].y); - ctx.stroke(); - ctx.beginPath(); - ctx.arc(this.rotateCPs[0].x, this.rotateCPs[0].y, 5, 0, Math.PI * 2); - ctx.fill(); - ctx.stroke(); - // Draw size control points. - if (!this.options.hideSizeCP && + } + } + if (this.pens.length === 1 && this.pens[0].type === PenType.Line) { + ctx.restore() // 对应前面的 save() , 保持状态一致 + return + } + // This is diffence between single node and more. + if (this.rotate && this.pens.length > 1) { + ctx.translate(this.rect.center.x, this.rect.center.y) + ctx.rotate((this.rotate * Math.PI) / 180) + ctx.translate(-this.rect.center.x, -this.rect.center.y) + } + if (this.data.locked || this.locked()) { + ctx.restore() + return + } + // Occupied territory. + ctx.save() + ctx.globalAlpha = 0.3 + ctx.translate(0.5, 0.5) + ctx.beginPath() + ctx.moveTo(this.sizeCPs[0].x, this.sizeCPs[0].y) + ctx.lineTo(this.sizeCPs[1].x, this.sizeCPs[1].y) + ctx.lineTo(this.sizeCPs[2].x, this.sizeCPs[2].y) + ctx.lineTo(this.sizeCPs[3].x, this.sizeCPs[3].y) + ctx.closePath() + ctx.stroke() + ctx.restore() + // Draw rotate control point. + ctx.beginPath() + ctx.moveTo(this.rotateCPs[0].x, this.rotateCPs[0].y) + ctx.lineTo(this.rotateCPs[1].x, this.rotateCPs[1].y) + ctx.stroke() + ctx.beginPath() + ctx.arc(this.rotateCPs[0].x, this.rotateCPs[0].y, 5, 0, Math.PI * 2) + ctx.fill() + ctx.stroke() + // Draw size control points. + if (!this.options.hideSizeCP && (this.pens.length > 1 || !this.pens[0].hideSizeCP)) { - ctx.lineWidth = 1; - for (var _b = 0, _c = this.sizeCPs; _b < _c.length; _b++) { - var item = _c[_b]; - ctx.save(); - ctx.beginPath(); - if (this.pens.length === 1 && (this.pens[0].rotate || this.rotate)) { - ctx.translate(item.x, item.y); - ctx.rotate(((this.pens[0].rotate + this.rotate) * Math.PI) / 180); - ctx.translate(-item.x, -item.y); - } - ctx.fillRect(item.x - 4.5, item.y - 4.5, 8, 8); - ctx.strokeRect(item.x - 5.5, item.y - 5.5, 10, 10); - ctx.restore(); - } + ctx.lineWidth = 1 + for (let _b = 0, _c = this.sizeCPs; _b < _c.length; _b++) { + var item = _c[_b] + ctx.save() + ctx.beginPath() + if (this.pens.length === 1 && (this.pens[0].rotate || this.rotate)) { + ctx.translate(item.x, item.y) + ctx.rotate(((this.pens[0].rotate + this.rotate) * Math.PI) / 180) + ctx.translate(-item.x, -item.y) } - ctx.restore(); - }; - ActiveLayer.prototype.calcActiveRect = function () { - if (this.pens.length === 1) { - if (this.pens[0].rect.height === 0) { - // 处理直线这种高度为0的情况 - this.pens[0].rect.height = 1; - } - this.activeRect = deepClone(this.pens[0].rect); - } - else { - this.activeRect = getRect(this.pens); - } - }; - ActiveLayer.prototype.getDockWatchers = function () { - if (this.pens.length === 1) { - this.dockWatchers = this.nodeRects[0].toPoints(); - this.dockWatchers.unshift(this.nodeRects[0].center); - return; - } - if (!this.rect) { - return; - } - this.dockWatchers = this.rect.toPoints(); - this.dockWatchers.unshift(this.rect.center); - }; - return ActiveLayer; -}(Layer)); -export { ActiveLayer }; -//# sourceMappingURL=activeLayer.js.map \ No newline at end of file + ctx.fillRect(item.x - 4.5, item.y - 4.5, 8, 8) + ctx.strokeRect(item.x - 5.5, item.y - 5.5, 10, 10) + ctx.restore() + } + } + ctx.restore() + } + ActiveLayer.prototype.calcActiveRect = function () { + if (this.pens.length === 1) { + if (this.pens[0].rect.height === 0) { + // 处理直线这种高度为0的情况 + this.pens[0].rect.height = 1 + } + this.activeRect = deepClone(this.pens[0].rect) + } else { + this.activeRect = getRect(this.pens) + } + } + ActiveLayer.prototype.getDockWatchers = function () { + if (this.pens.length === 1) { + this.dockWatchers = this.nodeRects[0].toPoints() + this.dockWatchers.unshift(this.nodeRects[0].center) + return + } + if (!this.rect) { + return + } + this.dockWatchers = this.rect.toPoints() + this.dockWatchers.unshift(this.rect.center) + } + return ActiveLayer +}(Layer)) +export { ActiveLayer } +// # sourceMappingURL=activeLayer.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/animateLayer.js b/nezha-fronted/src/components/common/@topology/core/src/animateLayer.js index 898622cd4..9b7d43520 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/animateLayer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/animateLayer.js @@ -1,264 +1,256 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -import { Store } from 'le5le-store'; -import { PenType } from './models/pen'; -import { Node } from './models/node'; -import { Line } from './models/line'; -import { Layer } from './layer'; -import { s8 } from './utils/uuid'; -import { find } from './utils/canvas'; -var AnimateLayer = /** @class */ (function (_super) { - __extends(AnimateLayer, _super); - function AnimateLayer(options, TID) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, TID) || this; - _this.options = options; - _this.pens = new Map(); - _this.lastNow = 0; - Store.set(_this.generateStoreKey('LT:AnimateLayer'), _this); - if (!_this.options.animateColor) { - _this.options.animateColor = '#ff6600'; - } - _this.subscribeUpdate = Store.subscribe(_this.generateStoreKey('LT:updateLines'), function (lines) { - _this.updateLines(lines); - }); - _this.subscribePlay = Store.subscribe(_this.generateStoreKey('LT:AnimatePlay'), function (params) { - if (params.stop) { - if (params.tag) { - var pens = find(params.tag, _this.data.pens); - pens.forEach(function (item) { - if (_this.pens.has(item.id)) { - _this.pens.get(item.id).animateStart = 0; - } - }); - } - if (params.pen && _this.pens.has(params.pen.id)) { - _this.pens.get(params.pen.id).animateStart = 0; - } - } - else { - if (params.pen) { - if (_this.pens.has(params.pen.id)) { - _this.pens.get(params.pen.id).animateStart = Date.now(); - } - else { - if (params.pen.type) { - _this.pens.set(params.pen.id, _this.getAnimateLine(params.pen)); - } - else { - _this.pens.set(params.pen.id, params.pen); - } - } - } - if (params.tag) { - _this.readyPlay(params.tag, false); - } - } - _this.animate(); - }); - return _this; +import { Store } from 'le5le-store' +import { PenType } from './models/pen' +import { Node } from './models/node' +import { Line } from './models/line' +import { Layer } from './layer' +import { s8 } from './utils/uuid' +import { find } from './utils/canvas' +const __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) || + function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] } + return extendStatics(d, b) + } + return function (d, b) { + extendStatics(d, b) + function __ () { this.constructor = d } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()) + } +})() +const AnimateLayer = /** @class */ (function (_super) { + __extends(AnimateLayer, _super) + function AnimateLayer (options, TID) { + if (options === void 0) { options = {} } + const _this = _super.call(this, TID) || this + _this.options = options + _this.pens = new Map() + _this.lastNow = 0 + Store.set(_this.generateStoreKey('LT:AnimateLayer'), _this) + if (!_this.options.animateColor) { + _this.options.animateColor = '#ff6600' } - AnimateLayer.prototype.getAnimateLine = function (item) { - var l = new Line(item); - l.data = l.id; - l.id = s8(); - l.setTID(this.TID); - l.isAnimate = true; - l.toArrow = ''; - if (l.fromArrow && l.fromArrow.indexOf('line') < 0) { - l.animateFromSize = l.fromArrowSize + l.lineWidth * 5; + _this.subscribeUpdate = Store.subscribe(_this.generateStoreKey('LT:updateLines'), function (lines) { + _this.updateLines(lines) + }) + _this.subscribePlay = Store.subscribe(_this.generateStoreKey('LT:AnimatePlay'), function (params) { + if (params.stop) { + if (params.tag) { + const pens = find(params.tag, _this.data.pens) + pens.forEach(function (item) { + if (_this.pens.has(item.id)) { + _this.pens.get(item.id).animateStart = 0 + } + }) } - if (l.toArrow && l.toArrow.indexOf('line') < 0) { - l.animateToSize = l.toArrowSize + l.lineWidth * 5; + if (params.pen && _this.pens.has(params.pen.id)) { + _this.pens.get(params.pen.id).animateStart = 0 } - l.animateStart = item.animateStart; - l.lineCap = 'round'; - l.fillStyle = '#fff'; - l.strokeStyle = l.animateColor || this.options.animateColor; - l.length = l.getLen(); - if (!l.fromArrowColor) { - l.fromArrowColor = l.strokeStyle || Store.get(this.generateStoreKey('LT:color')); + } else { + if (params.pen) { + if (_this.pens.has(params.pen.id)) { + _this.pens.get(params.pen.id).animateStart = Date.now() + } else { + if (params.pen.type) { + _this.pens.set(params.pen.id, _this.getAnimateLine(params.pen)) + } else { + _this.pens.set(params.pen.id, params.pen) + } + } } - if (!l.toArrowColor) { - l.toArrowColor = l.strokeStyle || Store.get(this.generateStoreKey('LT:color')); + if (params.tag) { + _this.readyPlay(params.tag, false) } - return l; - }; - AnimateLayer.prototype.findLine = function (pen) { - for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (item.id === pen.data) { - return item; - } + } + _this.animate() + }) + return _this + } + AnimateLayer.prototype.getAnimateLine = function (item) { + const l = new Line(item) + l.data = l.id + l.id = s8() + l.setTID(this.TID) + l.isAnimate = true + l.toArrow = '' + if (l.fromArrow && l.fromArrow.indexOf('line') < 0) { + l.animateFromSize = l.fromArrowSize + l.lineWidth * 5 + } + if (l.toArrow && l.toArrow.indexOf('line') < 0) { + l.animateToSize = l.toArrowSize + l.lineWidth * 5 + } + l.animateStart = item.animateStart + l.lineCap = 'round' + l.fillStyle = '#fff' + l.strokeStyle = l.animateColor || this.options.animateColor + l.length = l.getLen() + if (!l.fromArrowColor) { + l.fromArrowColor = l.strokeStyle || Store.get(this.generateStoreKey('LT:color')) + } + if (!l.toArrowColor) { + l.toArrowColor = l.strokeStyle || Store.get(this.generateStoreKey('LT:color')) + } + return l + } + AnimateLayer.prototype.findLine = function (pen) { + for (let _i = 0, _a = this.data.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (item.id === pen.data) { + return item + } + } + } + AnimateLayer.prototype.readyPlay = function (tag, auto, pens) { + const _this = this + const readyPens = new Map() + if (!pens) { + pens = this.data.pens + } + pens.forEach(function (pen) { + pen.setTID(_this.TID) + if (!pen.visible || readyPens.get(pen.id)) { + return + } + if ((auto && pen.animatePlay) || (tag && pen.tags.indexOf(tag) > -1)) { + if (!pen.animateStart || pen.animateStart < 1) { + pen.animateStart = Date.now() } - }; - AnimateLayer.prototype.readyPlay = function (tag, auto, pens) { - var _this = this; - var readyPens = new Map(); - if (!pens) { - pens = this.data.pens; + } + if (pen instanceof Node) { + if (pen.animateStart > 0) { + if (!pen.animateReady) { + pen.initAnimate() + } + readyPens.set(pen.id, pen) } - pens.forEach(function (pen) { - pen.setTID(_this.TID); - if (!pen.visible || readyPens.get(pen.id)) { - return; - } - if ((auto && pen.animatePlay) || (tag && pen.tags.indexOf(tag) > -1)) { - if (!pen.animateStart || pen.animateStart < 1) { - pen.animateStart = Date.now(); - } - } - if (pen instanceof Node) { - if (pen.animateStart > 0) { - if (!pen.animateReady) { - pen.initAnimate(); - } - readyPens.set(pen.id, pen); - } - if (pen.children && pen.children.length) { - _this.readyPlay(tag, auto, pen.children); - } - } - else { - if (pen.animateStart > 0) { - readyPens.set(pen.id, _this.getAnimateLine(pen)); - } - else if (_this.pens.has(pen.id)) { - _this.pens.get(pen.id).animateStart = 0; - } - } - }); - readyPens.forEach(function (pen) { - if (pen.type) { - _this.pens.set(pen.data, pen); - } - else { - _this.pens.set(pen.id, pen); - } - }); - }; - AnimateLayer.prototype.animate = function () { - var _this = this; - if (this.timer) { - cancelAnimationFrame(this.timer); + if (pen.children && pen.children.length) { + _this.readyPlay(tag, auto, pen.children) } - this.timer = requestAnimationFrame(function () { - var now = Date.now(); - if (now - _this.lastNow < _this.options.refresh) { - _this.animate(); - return; - } - _this.lastNow = now; - var animated = false; - _this.pens.forEach(function (pen) { - if (!pen.animateStart || pen.animateStart < 1) { - if (pen.type) { - _this.pens.delete(pen.data); - var line = _this.findLine(pen); - if (line) { - line.animateStart = 0; - line.animatePos = pen.animatePos; - } - } - else { - _this.pens.delete(pen.id); - } - return; - } - if (pen.animateStart > now) { - return; - } - if (pen.animateFn) { - if (typeof pen.animateFn === 'function') { - pen.animateFn(); - } - else if (window && window[pen.animateFn]) { - window[pen.animateFn](); - } - else { - // pen.render(); - } - } - else { - pen.animate(now); - } - if (pen.animateStart < 1) { - if (pen.type) { - _this.pens.delete(pen.data); - } - else { - _this.pens.delete(pen.id); - } - if (pen.type === PenType.Line) { - var line = _this.findLine(pen); - if (line) { - line.animateStart = 0; - line.animatePos = pen.animatePos; - } - } - if (pen.nextAnimate) { - _this.readyPlay(pen.nextAnimate, false); - } - } - animated = true; - }); - if (animated) { - Store.set(_this.generateStoreKey('LT:render'), true); - _this.animate(); - } - }); - }; - AnimateLayer.prototype.updateLines = function (lines) { - this.pens.forEach(function (line, key) { - if (!(line instanceof Line)) { - return; - } - for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) { - var item = lines_1[_i]; - if (line.data === item.id) { - line.from = item.from; - line.to = item.to; - line.controlPoints = item.controlPoints; - line.length = line.getLen(); - } - } - }); - }; - AnimateLayer.prototype.render = function (ctx) { - var _this = this; - this.pens.forEach(function (line, key) { - if (line.visible && line instanceof Line) { - if (!line.getTID()) { - line.setTID(_this.TID); - } - line.render(ctx); - } - }); - }; - AnimateLayer.prototype.stop = function () { - this.pens.clear(); - if (this.timer) { - cancelAnimationFrame(this.timer); - this.timer = null; + } else { + if (pen.animateStart > 0) { + readyPens.set(pen.id, _this.getAnimateLine(pen)) + } else if (_this.pens.has(pen.id)) { + _this.pens.get(pen.id).animateStart = 0 } - }; - AnimateLayer.prototype.destroy = function () { - this.stop(); - this.subscribeUpdate.unsubscribe(); - this.subscribePlay.unsubscribe(); - }; - return AnimateLayer; -}(Layer)); -export { AnimateLayer }; -//# sourceMappingURL=animateLayer.js.map \ No newline at end of file + } + }) + readyPens.forEach(function (pen) { + if (pen.type) { + _this.pens.set(pen.data, pen) + } else { + _this.pens.set(pen.id, pen) + } + }) + } + AnimateLayer.prototype.animate = function () { + const _this = this + if (this.timer) { + cancelAnimationFrame(this.timer) + } + this.timer = requestAnimationFrame(function () { + const now = Date.now() + if (now - _this.lastNow < _this.options.refresh) { + _this.animate() + return + } + _this.lastNow = now + let animated = false + _this.pens.forEach(function (pen) { + if (!pen.animateStart || pen.animateStart < 1) { + if (pen.type) { + _this.pens.delete(pen.data) + var line = _this.findLine(pen) + if (line) { + line.animateStart = 0 + line.animatePos = pen.animatePos + } + } else { + _this.pens.delete(pen.id) + } + return + } + if (pen.animateStart > now) { + return + } + if (pen.animateFn) { + if (typeof pen.animateFn === 'function') { + pen.animateFn() + } else if (window && window[pen.animateFn]) { + window[pen.animateFn]() + } else { + // pen.render(); + } + } else { + pen.animate(now) + } + if (pen.animateStart < 1) { + if (pen.type) { + _this.pens.delete(pen.data) + } else { + _this.pens.delete(pen.id) + } + if (pen.type === PenType.Line) { + var line = _this.findLine(pen) + if (line) { + line.animateStart = 0 + line.animatePos = pen.animatePos + } + } + if (pen.nextAnimate) { + _this.readyPlay(pen.nextAnimate, false) + } + } + animated = true + }) + if (animated) { + Store.set(_this.generateStoreKey('LT:render'), true) + _this.animate() + } + }) + } + AnimateLayer.prototype.updateLines = function (lines) { + this.pens.forEach(function (line, key) { + if (!(line instanceof Line)) { + return + } + for (let _i = 0, lines_1 = lines; _i < lines_1.length; _i++) { + const item = lines_1[_i] + if (line.data === item.id) { + line.from = item.from + line.to = item.to + line.controlPoints = item.controlPoints + line.length = line.getLen() + } + } + }) + } + AnimateLayer.prototype.render = function (ctx) { + const _this = this + this.pens.forEach(function (line, key) { + if (line.visible && line instanceof Line) { + if (!line.getTID()) { + line.setTID(_this.TID) + } + line.render(ctx) + } + }) + } + AnimateLayer.prototype.stop = function () { + this.pens.clear() + if (this.timer) { + cancelAnimationFrame(this.timer) + this.timer = null + } + } + AnimateLayer.prototype.destroy = function () { + this.stop() + this.subscribeUpdate.unsubscribe() + this.subscribePlay.unsubscribe() + this.subscribeUpdate = null + this.subscribePlay = null + this.pens = null + } + return AnimateLayer +}(Layer)) +export { AnimateLayer } +// # sourceMappingURL=animateLayer.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/canvas.js b/nezha-fronted/src/components/common/@topology/core/src/canvas.js index e1d5c78cd..d8d9f3fd0 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/canvas.js +++ b/nezha-fronted/src/components/common/@topology/core/src/canvas.js @@ -1,89 +1,96 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -import { Store } from 'le5le-store'; -import { Layer } from './layer'; -var Canvas = /** @class */ (function (_super) { - __extends(Canvas, _super); - function Canvas(parentElem, options, TID) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, TID) || this; - _this.parentElem = parentElem; - _this.options = options; - _this.canvas = document.createElement('canvas'); - _this.width = 0; - _this.height = 0; - _this.subcribe = Store.subscribe(_this.generateStoreKey('topology-data'), function (val) { - _this.data = val; - }); - _this.canvas.style.position = 'absolute'; - _this.canvas.style.left = '0'; - _this.canvas.style.top = '0'; - _this.canvas.style.outline = 'none'; - if (!Canvas.dpiRatio) { - if (!options.extDpiRatio && options.extDpiRatio !== 0) { - if (window && window.devicePixelRatio > 1) { - options.extDpiRatio = 0.25; - } - else { - options.extDpiRatio = 0; - } - } - Canvas.dpiRatio = (window ? window.devicePixelRatio : 0) + options.extDpiRatio; - if (Canvas.dpiRatio < 1) { - Canvas.dpiRatio = 1; - } +import { Store } from 'le5le-store' +import { Layer } from './layer' +const __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) || + function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] } + return extendStatics(d, b) + } + return function (d, b) { + extendStatics(d, b) + function __ () { this.constructor = d } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()) + } +})() +const Canvas = /** @class */ (function (_super) { + __extends(Canvas, _super) + function Canvas (parentElem, options, TID) { + if (options === void 0) { options = {} } + const _this = _super.call(this, TID) || this + _this.parentElem = parentElem + _this.options = options + _this.canvas = document.createElement('canvas') + _this.width = 0 + _this.height = 0 + _this.subcribe = Store.subscribe(_this.generateStoreKey('topology-data'), function (val) { + _this.data = val + }) + _this.canvas.style.position = 'absolute' + _this.canvas.style.left = '0' + _this.canvas.style.top = '0' + _this.canvas.style.outline = 'none' + if (!Canvas.dpiRatio) { + if (!options.extDpiRatio && options.extDpiRatio !== 0) { + if (window && window.devicePixelRatio > 1) { + options.extDpiRatio = 0.25 + } else { + options.extDpiRatio = 0 } - return _this; + } + Canvas.dpiRatio = (window ? window.devicePixelRatio : 0) + options.extDpiRatio + if (Canvas.dpiRatio < 1) { + Canvas.dpiRatio = 1 + } } - Canvas.prototype.resize = function (size) { - if (size) { - this.width = size.width | 0; - this.height = size.height | 0; - } - else { - if (this.options.width && this.options.width !== 'auto') { - this.width = +this.options.width; - } - else { - this.width = this.parentElem.clientWidth; - } - if (this.options.height && this.options.height !== 'auto') { - this.height = +this.options.height; - } - else { - this.height = this.parentElem.clientHeight; - } - } - this.canvas.style.width = this.width + 'px'; - this.canvas.style.height = this.height + 'px'; - this.canvas.width = (this.width * Canvas.dpiRatio) | 0; - this.canvas.height = (this.height * Canvas.dpiRatio) | 0; - this.canvas.getContext('2d').scale(Canvas.dpiRatio, Canvas.dpiRatio); - Store.set(this.generateStoreKey('LT:size'), { width: this.canvas.width, height: this.canvas.height }); - }; - Canvas.prototype.render = function () { - var ctx = this.canvas.getContext('2d'); - ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); - }; - Canvas.prototype.getDpiRatio = function () { - return Canvas.dpiRatio; - }; - Canvas.prototype.destroy = function () { - this.subcribe.unsubscribe(); - }; - Canvas.dpiRatio = 0; - return Canvas; -}(Layer)); -export { Canvas }; -//# sourceMappingURL=canvas.js.map \ No newline at end of file + return _this + } + Canvas.prototype.resize = function (size) { + if (size) { + this.width = size.width | 0 + this.height = size.height | 0 + } else { + if (this.options.width && this.options.width !== 'auto') { + this.width = +this.options.width + } else { + this.width = this.parentElem.clientWidth + } + if (this.options.height && this.options.height !== 'auto') { + this.height = +this.options.height + } else { + this.height = this.parentElem.clientHeight + } + } + this.canvas.style.width = this.width + 'px' + this.canvas.style.height = this.height + 'px' + this.canvas.width = (this.width * Canvas.dpiRatio) | 0 + this.canvas.height = (this.height * Canvas.dpiRatio) | 0 + this.canvas.getContext('2d').scale(Canvas.dpiRatio, Canvas.dpiRatio) + Store.set(this.generateStoreKey('LT:size'), { width: this.canvas.width, height: this.canvas.height }) + } + Canvas.prototype.render = function () { + const ctx = this.canvas.getContext('2d') + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height) + } + Canvas.prototype.getDpiRatio = function () { + return Canvas.dpiRatio + } + Canvas.prototype.destroy = function () { + this.subcribe.unsubscribe() + this.activeLayer = null + this.hoverLayer = null + this.animateLayer = null + this.subcribe = null + this.options = null + this.parentElem = null + this.data = null + this.offscreen = null + this.canvas = null + this.bkImg = null + this.render = null + } + Canvas.dpiRatio = 0 + return Canvas +}(Layer)) +export { Canvas } +// # sourceMappingURL=canvas.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/core.js b/nezha-fronted/src/components/common/@topology/core/src/core.js index 1b469ad2e..e3dd36826 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/core.js +++ b/nezha-fronted/src/components/common/@topology/core/src/core.js @@ -86,6 +86,7 @@ const Topology = /** @class */ (function () { } timer = setTimeout(function () { _this.resize() + timer = null }, 100) } this.calibrateMouse = function (pt) { @@ -819,17 +820,17 @@ const Topology = /** @class */ (function () { Store.set(this.generateStoreKey('LT:fontColor'), this.options.fontColor || '#222222') this.setupDom(parent) this.setupSubscribe() - this.setupMouseEvent() + // this.setupMouseEvent() // Wait for parent dom load - setTimeout(function () { - _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect() - }, 500) - setTimeout(function () { - _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect() - }, 1000) - this.cache() + // setTimeout(function () { + // _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect() + // }, 500) + // setTimeout(function () { + // _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect() + // }, 1000) + // this.cache() window.topology = this - this.dispatch('loaded') + // this.dispatch('loaded') } Object.defineProperty(Topology.prototype, 'ramCaches', { // 内存中的 caches 数量 @@ -1917,7 +1918,7 @@ const Topology = /** @class */ (function () { return offset } Topology.prototype.cache = function () { - if (this.options.cacheLen == 0 || this.data.locked) { return } + if (this.options.cacheLen == 0 || this.data && this.data.locked) { return } if (this.caches.index < this.caches.list.length - 1) { this.caches.list.splice(this.caches.index + 1, this.caches.list.length - this.caches.index - 1) // 删除 indexDB 的值 @@ -2964,7 +2965,7 @@ const Topology = /** @class */ (function () { this.activeLayer.destroy() this.hoverLayer.destroy() this.offscreen.destroy() - document.body.removeChild(this.tipMarkdown) + // document.body.removeChild(this.tipMarkdown) window.removeEventListener('resize', this.winResize) this.parentElem.removeEventListener('scroll', this.onScroll) window.removeEventListener('scroll', this.onScroll) @@ -2987,9 +2988,6 @@ const Topology = /** @class */ (function () { this.data = null console.log(this.options) window.topology = null - createCacheTable() - this.divLayer.clear() - this.activeLayer = null this.activeLayer = null this.hoverLayer = null this.animateLayer = null @@ -3001,11 +2999,18 @@ const Topology = /** @class */ (function () { this.subcribeAnimateMoved = null this.subcribeEmit = null this.offscreen = null + this.parentElem.onresize = null this.parentElem = null + this.input = null this.data = null this.caches = null this.clipboard = null - this.gifs = {} + this.gifs = null + this.tipMarkdown = null + this.tipMarkdownContent = null + this.tipMarkdownArrowUp = null + this.tipMarkdownArrowDown = null + delete this } return Topology }()) diff --git a/nezha-fronted/src/components/common/@topology/core/src/divLayer.js b/nezha-fronted/src/components/common/@topology/core/src/divLayer.js index 27c4565fa..1f4b52e02 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/divLayer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/divLayer.js @@ -1,502 +1,527 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -import { Store } from 'le5le-store'; -import { Lock } from './models/status'; -import { images, PenType } from './models/pen'; -import { Layer } from './layer'; -import { find } from './utils'; -var videos = {}; -var DivLayer = /** @class */ (function (_super) { - __extends(DivLayer, _super); - function DivLayer(parentElem, options, TID) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, TID) || this; - _this.parentElem = parentElem; - _this.options = options; - _this.canvas = document.createElement('div'); - _this.player = document.createElement('div'); - _this.audios = {}; - _this.iframes = {}; - _this.elements = {}; - _this.gifs = {}; - _this.addDiv = function (node) { - if (node.audio) { - if (_this.audios[node.id] && _this.audios[node.id].media.src !== node.audio) { - _this.audios[node.id].media.src = node.audio; - } - setTimeout(function () { - _this.setElemPosition(node, (_this.audios[node.id] && _this.audios[node.id].player) || _this.addMedia(node, 'audio')); - }); - } - if (node.video) { - if (videos[node.id] && videos[node.id].media.src !== node.video) { - videos[node.id].media.src = node.video; - } - setTimeout(function () { - _this.setElemPosition(node, (videos[node.id] && videos[node.id].player) || _this.addMedia(node, 'video')); - }); - } - if (node.iframe) { - if (!_this.iframes[node.id]) { - _this.addIframe(node); - setTimeout(function () { - _this.addDiv(node); - }); - } - else { - if (_this.iframes[node.id].src !== node.iframe) { - _this.iframes[node.id].src = node.iframe; - } - _this.setElemPosition(node, _this.iframes[node.id]); - } - } - if (node.elementId) { - if (!_this.elements[node.id]) { - _this.elements[node.id] = document.getElementById(node.elementId); - if (_this.elements[node.id]) { - _this.canvas.appendChild(_this.elements[node.id]); - } - } - _this.setElemPosition(node, _this.elements[node.id]); - } - if (node.gif) { - if (node.image.indexOf('.gif') < 0) { - node.gif = false; - _this.canvas.removeChild(_this.gifs[node.id]); - _this.gifs[node.id] = undefined; - } - else if (node.img) { - if (_this.gifs[node.id] && _this.gifs[node.id].src !== node.image) { - _this.gifs[node.id].src = node.image; - } - _this.setElemPosition(node, _this.gifs[node.id] || _this.addGif(node)); - } - } - if (node.children) { - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - if (child.type === PenType.Line) { - continue; - } - _this.addDiv(child); - } - } - }; - _this.createPlayer = function () { - _this.player.style.position = 'fixed'; - _this.player.style.outline = 'none'; - _this.player.style.top = '-99999px'; - _this.player.style.height = '40px'; - _this.player.style.padding = '10px 15px'; - _this.player.style.background = 'rgba(200,200,200,.1)'; - _this.player.style.display = 'flex'; - _this.player.style.alignItems = 'center'; - _this.player.style.userSelect = 'initial'; - _this.player.style.pointerEvents = 'initial'; - _this.player.style.zIndex = '1'; - _this.playBtn = document.createElement('i'); - _this.currentTime = document.createElement('span'); - _this.progress = document.createElement('div'); - _this.progressCurrent = document.createElement('div'); - _this.loop = document.createElement('i'); - var fullScreen = document.createElement('i'); - _this.playBtn.className = _this.options.playIcon; - _this.playBtn.style.fontSize = '18px'; - _this.playBtn.style.lineHeight = '20px'; - _this.playBtn.style.cursor = 'pointer'; - _this.currentTime.style.padding = '0 10px'; - _this.currentTime.innerText = '0 / 0'; - _this.progress.style.position = 'relative'; - _this.progress.style.flexGrow = '1'; - _this.progress.style.top = '0'; - _this.progress.style.height = '4px'; - _this.progress.style.background = '#ccc'; - _this.progress.style.borderRadius = '2px'; - _this.progress.style.overflow = 'hidden'; - _this.progress.style.cursor = 'pointer'; - _this.progressCurrent.style.position = 'absolute'; - _this.progressCurrent.style.left = '0'; - _this.progressCurrent.style.top = '0'; - _this.progressCurrent.style.bottom = '0'; - _this.progressCurrent.style.width = '0'; - _this.progressCurrent.style.background = '#52c41a'; - _this.loop.style.margin = '0 10px'; - _this.loop.style.padding = '2px 5px'; - _this.loop.style.borderRadius = '2px'; - _this.loop.className = _this.options.loopIcon; - _this.loop.style.fontSize = '18px'; - _this.loop.style.lineHeight = '20px'; - _this.loop.style.cursor = 'pointer'; - fullScreen.className = _this.options.fullScreenIcon; - fullScreen.style.fontSize = '17px'; - fullScreen.style.lineHeight = '20px'; - fullScreen.style.cursor = 'pointer'; - _this.player.appendChild(_this.playBtn); - _this.player.appendChild(_this.currentTime); - _this.player.appendChild(_this.progress); - _this.progress.appendChild(_this.progressCurrent); - _this.player.appendChild(_this.loop); - _this.player.appendChild(fullScreen); - _this.playBtn.onclick = function () { - if (_this.media.paused) { - _this.media.play(); - _this.playBtn.className = _this.options.pauseIcon; - } - else { - _this.media.pause(); - _this.playBtn.className = _this.options.playIcon; - } - }; - _this.progress.onclick = function (e) { - _this.media.currentTime = (e.offsetX / _this.progress.clientWidth) * _this.media.duration; - }; - _this.loop.onclick = function () { - _this.media.loop = !_this.media.loop; - _this.curNode.playLoop = _this.media.loop; - if (_this.media.loop) { - _this.loop.style.background = '#ddd'; - } - else { - _this.loop.style.background = 'none'; - } - }; - fullScreen.onclick = function () { - _this.media.requestFullscreen(); - }; - }; - _this.getMediaCurrent = function () { - if (!_this.media) { - return; - } - _this.currentTime.innerText = - _this.formatSeconds(_this.media.currentTime) + ' / ' + _this.formatSeconds(_this.media.duration); - _this.progressCurrent.style.width = - (_this.media.currentTime / _this.media.duration) * _this.progress.clientWidth + 'px'; - }; - _this.addMedia = function (node, type) { - var player = document.createElement('div'); - var current = document.createElement('div'); - var media = document.createElement(type); - player.id = node.id; - current.style.position = 'absolute'; - current.style.outline = 'none'; - current.style.left = '0'; - current.style.bottom = '0'; - current.style.height = '2px'; - current.style.background = '#52c41a'; - media.style.position = 'absolute'; - media.style.outline = 'none'; - media.style.left = '0'; - media.style.right = '0'; - media.style.top = '0'; - media.style.bottom = '0'; - if (type === 'video') { - media.style.width = node.rect.width + 'px'; - media.style.height = node.rect.height + 'px'; - } - player.style.background = 'transparent'; - if (node.playType === 1) { - media.autoplay = true; - } - media.loop = node.playLoop; - media.ontimeupdate = function () { - current.style.width = (media.currentTime / media.duration) * node.rect.width + 'px'; - _this.getMediaCurrent(); - if (_this.media === media) { - if (node.playLoop) { - media.loop = true; - _this.loop.style.background = '#ddd'; - } - else { - media.loop = false; - _this.loop.style.background = 'none'; - } - } - }; - media.onended = function () { - Store.set(_this.generateStoreKey('mediaEnd'), node); - if (_this.media === media) { - _this.playBtn.className = _this.options.playIcon; - } - _this.play(node.nextPlay); - }; - media.onloadedmetadata = function () { - _this.getMediaCurrent(); - }; - media.src = node[type]; - player.appendChild(media); - player.appendChild(current); - if (type === 'video') { - videos[node.id] = { - player: player, - current: current, - media: media, - }; - } - else { - _this.audios[node.id] = { - player: player, - current: current, - media: media, - }; - } - _this.canvas.appendChild(player); - return player; - }; - _this.setElemPosition = function (node, elem) { - if (!elem) { - return; - } - elem.style.position = 'absolute'; - elem.style.outline = 'none'; - elem.style.left = node.rect.x + _this.data.x + 'px'; - elem.style.top = node.rect.y + _this.data.y + 'px'; - elem.style.width = node.rect.width + 'px'; - elem.style.height = node.rect.height + 'px'; - elem.style.display = node.visible ? 'inline' : 'none'; // 是否隐藏元素 - if (node.rotate || node.offsetRotate) { - elem.style.transform = "rotate(" + (node.rotate + node.offsetRotate) + "deg)"; - } - if (node.video && videos[node.id] && videos[node.id].media) { - videos[node.id].media.style.width = '100%'; - videos[node.id].media.style.height = '100%'; - } - if (_this.data.locked > Lock.None || node.locked > Lock.None) { - elem.style.userSelect = 'initial'; - elem.style.pointerEvents = 'initial'; - } - else { - elem.style.userSelect = 'none'; - elem.style.pointerEvents = 'none'; - } - }; - _this.removeDiv = function (item) { - if (_this.curNode && item.id === _this.curNode.id) { - _this.curNode = undefined; - _this.media = undefined; - _this.player.style.top = '-99999px'; - } - if (item.audio) { - _this.canvas.removeChild(_this.audios[item.id].player); - _this.audios[item.id] = undefined; - } - if (item.video) { - _this.canvas.removeChild(videos[item.id].player); - videos[item.id] = undefined; - } - if (item.iframe) { - _this.canvas.removeChild(_this.iframes[item.id]); - _this.iframes[item.id] = undefined; - } - if (item.elementId) { - _this.canvas.removeChild(_this.elements[item.id]); - _this.elements[item.id] = undefined; - item.elementId = ''; - } - if (item.gif) { - _this.canvas.removeChild(_this.gifs[item.id]); - _this.gifs[item.id] = undefined; - } - if (item.children) { - for (var _i = 0, _a = item.children; _i < _a.length; _i++) { - var child = _a[_i]; - if (child.type === PenType.Line) { - continue; - } - _this.removeDiv(child); - } - } - }; - if (!_this.options.playIcon) { - _this.options.playIcon = 't-icon t-play'; +import { Store } from 'le5le-store' +import { Lock } from './models/status' +import { images, PenType } from './models/pen' +import { Layer } from './layer' +import { find } from './utils' +const __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) || + function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] } + return extendStatics(d, b) + } + return function (d, b) { + extendStatics(d, b) + function __ () { this.constructor = d } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()) + } +})() +let videos = {} +const DivLayer = /** @class */ (function (_super) { + __extends(DivLayer, _super) + function DivLayer (parentElem, options, TID) { + if (options === void 0) { options = {} } + const _this = _super.call(this, TID) || this + _this.parentElem = parentElem + _this.options = options + _this.canvas = document.createElement('div') + _this.player = document.createElement('div') + _this.audios = {} + _this.iframes = {} + _this.elements = {} + _this.gifs = {} + _this.addDiv = function (node) { + if (node.audio) { + if (_this.audios[node.id] && _this.audios[node.id].media.src !== node.audio) { + _this.audios[node.id].media.src = node.audio } - if (!_this.options.pauseIcon) { - _this.options.pauseIcon = 't-icon t-pause'; + setTimeout(function () { + _this.setElemPosition(node, (_this.audios[node.id] && _this.audios[node.id].player) || _this.addMedia(node, 'audio')) + }) + } + if (node.video) { + if (videos[node.id] && videos[node.id].media.src !== node.video) { + videos[node.id].media.src = node.video } - if (!_this.options.fullScreenIcon) { - _this.options.fullScreenIcon = 't-icon t-full-screen'; + setTimeout(function () { + _this.setElemPosition(node, (videos[node.id] && videos[node.id].player) || _this.addMedia(node, 'video')) + }) + } + if (node.iframe) { + if (!_this.iframes[node.id]) { + _this.addIframe(node) + setTimeout(function () { + _this.addDiv(node) + }) + } else { + if (_this.iframes[node.id].src !== node.iframe) { + _this.iframes[node.id].src = node.iframe + } + _this.setElemPosition(node, _this.iframes[node.id]) } - if (!_this.options.loopIcon) { - _this.options.loopIcon = 't-icon t-loop'; + } + if (node.elementId) { + if (!_this.elements[node.id]) { + _this.elements[node.id] = document.getElementById(node.elementId) + if (_this.elements[node.id]) { + _this.canvas.appendChild(_this.elements[node.id]) + } } - _this.canvas.style.position = 'absolute'; - _this.canvas.style.left = '0'; - _this.canvas.style.top = '0'; - _this.canvas.style.outline = 'none'; - _this.canvas.style.background = 'transparent'; - parentElem.appendChild(_this.canvas); - parentElem.appendChild(_this.player); - _this.createPlayer(); - _this.subcribeDiv = Store.subscribe(_this.generateStoreKey('LT:addDiv'), _this.addDiv); - _this.subcribeDiv = Store.subscribe(_this.generateStoreKey('LT:removeDiv'), _this.removeDiv); - _this.subcribePlay = Store.subscribe(_this.generateStoreKey('LT:play'), function (e) { - _this.playOne(e.pen, e.pause); - }); - _this.subcribeNode = Store.subscribe(_this.generateStoreKey('LT:activeNode'), function (node) { - if (!node || (!node.video && !node.audio)) { - _this.player.style.top = '-99999px'; - return; - } - if (node.audio && _this.audios[node.id]) { - _this.media = _this.audios[node.id].media; - } - else if (node.video && videos[node.id]) { - _this.media = videos[node.id].media; - } - else { - return; - } - _this.curNode = node; - var rect = _this.parentElem.getBoundingClientRect(); - _this.player.style.top = rect.top + _this.parentElem.clientHeight - 40 + 'px'; - _this.player.style.left = rect.left + 'px'; - _this.player.style.width = _this.parentElem.clientWidth + 'px'; - _this.getMediaCurrent(); - if (_this.media.paused) { - _this.playBtn.className = _this.options.playIcon; - } - else { - _this.playBtn.className = _this.options.pauseIcon; - } - }); - document.addEventListener('fullscreenchange', function (e) { - if (!_this.media) { - return; - } - if (document.fullscreen) { - _this.media.controls = true; - _this.media.style.userSelect = 'initial'; - _this.media.style.pointerEvents = 'initial'; - } - else { - _this.media.style.userSelect = 'none'; - _this.media.style.pointerEvents = 'none'; - _this.media.controls = false; - } - }); - return _this; + _this.setElemPosition(node, _this.elements[node.id]) + } + if (node.gif) { + if (node.image.indexOf('.gif') < 0) { + node.gif = false + _this.canvas.removeChild(_this.gifs[node.id]) + _this.gifs[node.id] = undefined + } else if (node.img) { + if (_this.gifs[node.id] && _this.gifs[node.id].src !== node.image) { + _this.gifs[node.id].src = node.image + } + if (_this.gifs[node.id]) { + _this.setElemPosition(node, _this.gifs[node.id]) + } else { + _this.addGif(node) + _this.setElemPosition(node, node.id) + } + } + } + if (node.children) { + for (let _i = 0, _a = node.children; _i < _a.length; _i++) { + const child = _a[_i] + if (child.type === PenType.Line) { + continue + } + _this.addDiv(child) + } + } } - DivLayer.prototype.play = function (idOrTag, pause) { - var _this = this; - if (!idOrTag) { - return; + _this.createPlayer = function () { + _this.player.style.position = 'fixed' + _this.player.style.outline = 'none' + _this.player.style.top = '-99999px' + _this.player.style.height = '40px' + _this.player.style.padding = '10px 15px' + _this.player.style.background = 'rgba(200,200,200,.1)' + _this.player.style.display = 'flex' + _this.player.style.alignItems = 'center' + _this.player.style.userSelect = 'initial' + _this.player.style.pointerEvents = 'initial' + _this.player.style.zIndex = '1' + _this.playBtn = document.createElement('i') + _this.currentTime = document.createElement('span') + _this.progress = document.createElement('div') + _this.progressCurrent = document.createElement('div') + _this.loop = document.createElement('i') + _this.myfullScreen = document.createElement('i') + _this.playBtn.className = _this.options.playIcon + _this.playBtn.style.fontSize = '18px' + _this.playBtn.style.lineHeight = '20px' + _this.playBtn.style.cursor = 'pointer' + _this.currentTime.style.padding = '0 10px' + _this.currentTime.innerText = '0 / 0' + _this.progress.style.position = 'relative' + _this.progress.style.flexGrow = '1' + _this.progress.style.top = '0' + _this.progress.style.height = '4px' + _this.progress.style.background = '#ccc' + _this.progress.style.borderRadius = '2px' + _this.progress.style.overflow = 'hidden' + _this.progress.style.cursor = 'pointer' + _this.progressCurrent.style.position = 'absolute' + _this.progressCurrent.style.left = '0' + _this.progressCurrent.style.top = '0' + _this.progressCurrent.style.bottom = '0' + _this.progressCurrent.style.width = '0' + _this.progressCurrent.style.background = '#52c41a' + _this.loop.style.margin = '0 10px' + _this.loop.style.padding = '2px 5px' + _this.loop.style.borderRadius = '2px' + _this.loop.className = _this.options.loopIcon + _this.loop.style.fontSize = '18px' + _this.loop.style.lineHeight = '20px' + _this.loop.style.cursor = 'pointer' + _this.myfullScreen.className = _this.options.fullScreenIcon + _this.myfullScreen.style.fontSize = '17px' + _this.myfullScreen.style.lineHeight = '20px' + _this.myfullScreen.style.cursor = 'pointer' + _this.player.appendChild(_this.playBtn) + _this.player.appendChild(_this.currentTime) + _this.player.appendChild(_this.progress) + _this.progress.appendChild(_this.progressCurrent) + _this.player.appendChild(_this.loop) + _this.player.appendChild(_this.myfullScreen) + _this.playBtn.onclick = function () { + if (_this.media.paused) { + _this.media.play() + _this.playBtn.className = _this.options.pauseIcon + } else { + _this.media.pause() + _this.playBtn.className = _this.options.playIcon } - var pens = find(idOrTag, this.data.pens); - pens.forEach(function (item) { - _this.playOne(item, pause); - }); - }; - DivLayer.prototype.playOne = function (item, pause) { - if (item.audio && this.audios[item.id] && this.audios[item.id].media) { - if (pause) { - this.audios[item.id].media.pause(); - } - else if (this.audios[item.id].media.paused) { - this.audios[item.id].media.play(); - } + } + _this.progress.onclick = function (e) { + _this.media.currentTime = (e.offsetX / _this.progress.clientWidth) * _this.media.duration + } + _this.loop.onclick = function () { + _this.media.loop = !_this.media.loop + _this.curNode.playLoop = _this.media.loop + if (_this.media.loop) { + _this.loop.style.background = '#ddd' + } else { + _this.loop.style.background = 'none' } - else if (item.video && videos[item.id].media) { - if (pause) { - videos[item.id].media.pause(); - } - else if (videos[item.id].media.paused) { - videos[item.id].media.play(); - } + } + _this.myfullScreen.onclick = function () { + _this.media.requestFullscreen() + } + } + _this.getMediaCurrent = function () { + if (!_this.media) { + return + } + _this.currentTime.innerText = + _this.formatSeconds(_this.media.currentTime) + ' / ' + _this.formatSeconds(_this.media.duration) + _this.progressCurrent.style.width = + (_this.media.currentTime / _this.media.duration) * _this.progress.clientWidth + 'px' + } + _this.addMedia = function (node, type) { + let player = document.createElement('div') + let current = document.createElement('div') + let media = document.createElement(type) + player.id = node.id + current.style.position = 'absolute' + current.style.outline = 'none' + current.style.left = '0' + current.style.bottom = '0' + current.style.height = '2px' + current.style.background = '#52c41a' + media.style.position = 'absolute' + media.style.outline = 'none' + media.style.left = '0' + media.style.right = '0' + media.style.top = '0' + media.style.bottom = '0' + if (type === 'video') { + media.style.width = node.rect.width + 'px' + media.style.height = node.rect.height + 'px' + } + player.style.background = 'transparent' + if (node.playType === 1) { + media.autoplay = true + } + media.loop = node.playLoop + media.ontimeupdate = function () { + current.style.width = (media.currentTime / media.duration) * node.rect.width + 'px' + _this.getMediaCurrent() + if (_this.media === media) { + if (node.playLoop) { + media.loop = true + _this.loop.style.background = '#ddd' + } else { + media.loop = false + _this.loop.style.background = 'none' + } } - }; - DivLayer.prototype.addIframe = function (node) { - var iframe = document.createElement('iframe'); - iframe.scrolling = 'no'; - iframe.frameBorder = '0'; - iframe.src = node.iframe; - this.iframes[node.id] = iframe; - this.canvas.appendChild(iframe); - return iframe; - }; - DivLayer.prototype.addGif = function (node) { - this.gifs[node.id] = node.img; - this.canvas.appendChild(node.img); - return node.img; - }; - DivLayer.prototype.clear = function (shallow) { - this.canvas.innerHTML = ''; - this.audios = {}; - videos = {}; - this.iframes = {}; - this.elements = {}; - this.gifs = {}; - if (!shallow) { - // tslint:disable-next-line:forin - for (var key in images) { - delete images[key]; - } + } + media.onended = function () { + Store.set(_this.generateStoreKey('mediaEnd'), node) + if (_this.media === media) { + _this.playBtn.className = _this.options.playIcon } - this.player.style.top = '-99999px'; - }; - DivLayer.prototype.formatSeconds = function (seconds) { - var h = Math.floor(seconds / 3600); - var m = Math.floor(seconds / 60) % 60; - var s = Math.floor(seconds % 60); - var txt = s + ''; - if (m) { - txt = m + ':' + s; + _this.play(node.nextPlay) + } + media.onloadedmetadata = function () { + _this.getMediaCurrent() + } + media.src = node[type] + player.appendChild(media) + player.appendChild(current) + if (type === 'video') { + videos[node.id] = { + player: player, + current: current, + media: media } - else { - txt = '0:' + s; + } else { + _this.audios[node.id] = { + player: player, + current: current, + media: media } - if (h) { - txt = h + ':' + m + ':' + s; + } + _this.canvas.appendChild(player) + setTimeout(() => { + player = null + current = null + media = null + }, 100) + return player + } + _this.setElemPosition = function (node, elem) { + if (!elem) { + return + } + elem.style.position = 'absolute' + elem.style.outline = 'none' + elem.style.left = node.rect.x + _this.data.x + 'px' + elem.style.top = node.rect.y + _this.data.y + 'px' + elem.style.width = node.rect.width + 'px' + elem.style.height = node.rect.height + 'px' + elem.style.display = node.visible ? 'inline' : 'none' // 是否隐藏元素 + if (node.rotate || node.offsetRotate) { + elem.style.transform = 'rotate(' + (node.rotate + node.offsetRotate) + 'deg)' + } + if (node.video && videos[node.id] && videos[node.id].media) { + videos[node.id].media.style.width = '100%' + videos[node.id].media.style.height = '100%' + } + if (_this.data.locked > Lock.None || node.locked > Lock.None) { + elem.style.userSelect = 'initial' + elem.style.pointerEvents = 'initial' + } else { + elem.style.userSelect = 'none' + elem.style.pointerEvents = 'none' + } + } + _this.removeDiv = function (item) { + if (_this.curNode && item.id === _this.curNode.id) { + _this.curNode = undefined + _this.media = undefined + _this.player.style.top = '-99999px' + } + if (item.audio) { + _this.canvas.removeChild(_this.audios[item.id].player) + _this.audios[item.id] = undefined + } + if (item.video) { + _this.canvas.removeChild(videos[item.id].player) + videos[item.id] = undefined + } + if (item.iframe) { + _this.canvas.removeChild(_this.iframes[item.id]) + _this.iframes[item.id] = undefined + } + if (item.elementId) { + _this.canvas.removeChild(_this.elements[item.id]) + _this.elements[item.id] = undefined + item.elementId = '' + } + if (item.gif) { + _this.canvas.removeChild(_this.gifs[item.id]) + _this.gifs[item.id] = undefined + } + if (item.children) { + for (let _i = 0, _a = item.children; _i < _a.length; _i++) { + const child = _a[_i] + if (child.type === PenType.Line) { + continue + } + _this.removeDiv(child) } - return txt; - }; - DivLayer.prototype.resize = function (size) { - if (size) { - this.canvas.style.width = size.width + 'px'; - this.canvas.style.height = size.height + 'px'; - } - else { - if (this.options.width && this.options.width !== 'auto') { - this.canvas.style.width = this.options.width + 'px'; - } - else { - this.canvas.style.width = this.parentElem.clientWidth + 'px'; - } - if (this.options.height && this.options.height !== 'auto') { - this.canvas.style.height = this.options.height + 'px'; - } - else { - this.canvas.style.height = this.parentElem.clientHeight - 8 + 'px'; - } - } - }; - DivLayer.prototype.render = function () { - for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (!item.getTID()) { - item.setTID(this.TID); - } - this.addDiv(item); - } - }; - DivLayer.prototype.destroy = function () { - _super.prototype.destroy.call(this); - this.clear(); - this.subcribeDiv.unsubscribe(); - this.subcribeNode.unsubscribe(); - this.subcribePlay.unsubscribe(); - }; - return DivLayer; -}(Layer)); -export { DivLayer }; -//# sourceMappingURL=divLayer.js.map \ No newline at end of file + } + } + if (!_this.options.playIcon) { + _this.options.playIcon = 't-icon t-play' + } + if (!_this.options.pauseIcon) { + _this.options.pauseIcon = 't-icon t-pause' + } + if (!_this.options.fullScreenIcon) { + _this.options.fullScreenIcon = 't-icon t-full-screen' + } + if (!_this.options.loopIcon) { + _this.options.loopIcon = 't-icon t-loop' + } + _this.canvas.style.position = 'absolute' + _this.canvas.style.left = '0' + _this.canvas.style.top = '0' + _this.canvas.style.outline = 'none' + _this.canvas.style.background = 'transparent' + parentElem.appendChild(_this.canvas) + parentElem.appendChild(_this.player) + _this.createPlayer() + _this.subcribeDiv = Store.subscribe(_this.generateStoreKey('LT:addDiv'), _this.addDiv) + _this.subcribeDiv = Store.subscribe(_this.generateStoreKey('LT:removeDiv'), _this.removeDiv) + _this.subcribePlay = Store.subscribe(_this.generateStoreKey('LT:play'), function (e) { + _this.playOne(e.pen, e.pause) + }) + _this.subcribeNode = Store.subscribe(_this.generateStoreKey('LT:activeNode'), function (node) { + if (!node || (!node.video && !node.audio)) { + _this.player.style.top = '-99999px' + return + } + if (node.audio && _this.audios[node.id]) { + _this.media = _this.audios[node.id].media + } else if (node.video && videos[node.id]) { + _this.media = videos[node.id].media + } else { + return + } + _this.curNode = node + const rect = _this.parentElem.getBoundingClientRect() + _this.player.style.top = rect.top + _this.parentElem.clientHeight - 40 + 'px' + _this.player.style.left = rect.left + 'px' + _this.player.style.width = _this.parentElem.clientWidth + 'px' + _this.getMediaCurrent() + if (_this.media.paused) { + _this.playBtn.className = _this.options.playIcon + } else { + _this.playBtn.className = _this.options.pauseIcon + } + }) + _this.fullscreenchange = function (e) { + if (!_this.media) { + return + } + if (document.fullscreen) { + _this.media.controls = true + _this.media.style.userSelect = 'initial' + _this.media.style.pointerEvents = 'initial' + } else { + _this.media.style.userSelect = 'none' + _this.media.style.pointerEvents = 'none' + _this.media.controls = false + } + } + document.addEventListener('fullscreenchange', _this.fullscreenchange) + return _this + } + DivLayer.prototype.play = function (idOrTag, pause) { + const _this = this + if (!idOrTag) { + return + } + const pens = find(idOrTag, this.data.pens) + pens.forEach(function (item) { + _this.playOne(item, pause) + }) + } + DivLayer.prototype.playOne = function (item, pause) { + if (item.audio && this.audios[item.id] && this.audios[item.id].media) { + if (pause) { + this.audios[item.id].media.pause() + } else if (this.audios[item.id].media.paused) { + this.audios[item.id].media.play() + } + } else if (item.video && videos[item.id].media) { + if (pause) { + videos[item.id].media.pause() + } else if (videos[item.id].media.paused) { + videos[item.id].media.play() + } + } + } + DivLayer.prototype.addIframe = function (node) { + const iframe = document.createElement('iframe') + iframe.scrolling = 'no' + iframe.frameBorder = '0' + iframe.src = node.iframe + this.iframes[node.id] = iframe + this.canvas.appendChild(iframe) + return iframe + } + DivLayer.prototype.addGif = function (node) { + this.gifs[node.id] = node.img + this.canvas.appendChild(node.img) + } + DivLayer.prototype.clear = function (shallow) { + this.canvas.innerHTML = '' + this.audios = {} + videos = {} + this.iframes = {} + this.elements = {} + this.gifs = {} + if (!shallow) { + // tslint:disable-next-line:forin + for (const key in images) { + delete images[key] + } + } + this.player.style.top = '-99999px' + } + DivLayer.prototype.formatSeconds = function (seconds) { + const h = Math.floor(seconds / 3600) + const m = Math.floor(seconds / 60) % 60 + const s = Math.floor(seconds % 60) + let txt = s + '' + if (m) { + txt = m + ':' + s + } else { + txt = '0:' + s + } + if (h) { + txt = h + ':' + m + ':' + s + } + return txt + } + DivLayer.prototype.resize = function (size) { + if (size) { + this.canvas.style.width = size.width + 'px' + this.canvas.style.height = size.height + 'px' + } else { + if (this.options.width && this.options.width !== 'auto') { + this.canvas.style.width = this.options.width + 'px' + } else { + this.canvas.style.width = this.parentElem.clientWidth + 'px' + } + if (this.options.height && this.options.height !== 'auto') { + this.canvas.style.height = this.options.height + 'px' + } else { + this.canvas.style.height = this.parentElem.clientHeight - 8 + 'px' + } + } + } + DivLayer.prototype.render = function () { + for (let _i = 0, _a = this.data.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (!item.getTID()) { + item.setTID(this.TID) + } + this.addDiv(item) + } + } + DivLayer.prototype.destroy = function () { + _super.prototype.destroy.call(this) + this.clear() + this.subcribeDiv.unsubscribe() + this.subcribeNode.unsubscribe() + this.subcribePlay.unsubscribe() + this.parentElem.removeChild(this.canvas) + this.parentElem.removeChild(this.player) + document.removeEventListener('fullscreenchange', this.fullscreenchange) + Object.keys(this.audios).forEach(key => { + this.audios[key] = null + }) + this.myfullScreen.onclick = null + this.playBtn.onclick = null + this.progress.onclick = null + this.loop.onclick = null + this.subcribeDiv = null + this.subcribeNode = null + this.subcribePlay = null + this.parentElem = null + this.options = null + this.canvas = null + this.player = null + this.audios = null + this.iframes = null + this.elements = null + this.gifs = null + this.playBtn = null + this.currentTime = null + this.progress = null + this.progressCurrent = null + this.loop = null + videos = null + this.iframes = null + this.elements = null + this.gifs = null + this.addDiv = null + this.createPlayer = null + this.setElemPosition = null + } + return DivLayer +}(Layer)) +export { DivLayer } +// # sourceMappingURL=divLayer.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/hoverLayer.js b/nezha-fronted/src/components/common/@topology/core/src/hoverLayer.js index d9602d8a3..1e89b17f3 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/hoverLayer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/hoverLayer.js @@ -1,211 +1,211 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -import { PenType } from './models/pen'; -import { Store } from 'le5le-store'; -import { Lock } from './models/status'; -import { Layer } from './layer'; -import { rgba } from './utils/math'; -var HoverLayer = /** @class */ (function (_super) { - __extends(HoverLayer, _super); - function HoverLayer(options, TID) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, TID) || this; - _this.options = options; - _this.hoverAnchorIndex = -1; - _this.dockLineX = 0; - _this.dockLineY = 0; - Store.set(_this.generateStoreKey('LT:HoverLayer'), _this); - return _this; +import { PenType } from './models/pen' +import { Store } from 'le5le-store' +import { Lock } from './models/status' +import { Layer } from './layer' +import { rgba } from './utils/math' +const __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) || + function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] } + return extendStatics(d, b) + } + return function (d, b) { + extendStatics(d, b) + function __ () { this.constructor = d } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()) + } +})() +const HoverLayer = /** @class */ (function (_super) { + __extends(HoverLayer, _super) + function HoverLayer (options, TID) { + if (options === void 0) { options = {} } + const _this = _super.call(this, TID) || this + _this.options = options + _this.hoverAnchorIndex = -1 + _this.dockLineX = 0 + _this.dockLineY = 0 + Store.set(_this.generateStoreKey('LT:HoverLayer'), _this) + return _this + } + HoverLayer.prototype.lineTo = function (to, toArrow) { + if (toArrow === void 0) { toArrow = 'triangleSolid' } + if (!this.line || this.line.locked) { + return } - HoverLayer.prototype.lineTo = function (to, toArrow) { - if (toArrow === void 0) { toArrow = 'triangleSolid'; } - if (!this.line || this.line.locked) { - return; + this.line.setTo(to, toArrow) + if (this.line.from.id || this.line.to.id) { + this.line.calcControlPoints() + } + Store.set(this.generateStoreKey('pts-') + this.line.id, undefined) + Store.set(this.generateStoreKey('LT:updateLines'), [this.line]) + } + HoverLayer.prototype.lineFrom = function (from) { + if (this.line.locked) { + return + } + this.line.setFrom(from, this.line.fromArrow) + if (this.line.from.id || this.line.to.id) { + this.line.calcControlPoints() + } + Store.set(this.generateStoreKey('pts-') + this.line.id, undefined) + Store.set(this.generateStoreKey('LT:updateLines'), [this.line]) + } + HoverLayer.prototype.render = function (ctx) { + const _this = this + if (this.data.locked === Lock.NoEvent || this.options.hoverColor === 'transparent') { + return + } + ctx.fillStyle = this.options.hoverColor + ctx.save() + // anchors + if (this.options.alwaysAnchor) { + this.data.pens.forEach(function (pen) { + if (pen.type === PenType.Line) { + return } - this.line.setTo(to, toArrow); - if (this.line.from.id || this.line.to.id) { - this.line.calcControlPoints(); + if (pen.hideAnchor) { + return } - Store.set(this.generateStoreKey('pts-') + this.line.id, undefined); - Store.set(this.generateStoreKey('LT:updateLines'), [this.line]); - }; - HoverLayer.prototype.lineFrom = function (from) { - if (this.line.locked) { - return; + for (let _i = 0, _a = pen.rotatedAnchors; _i < _a.length; _i++) { + const anchor = _a[_i] + if (anchor.hidden) { + continue + } + ctx.beginPath() + ctx.arc(anchor.x, anchor.y, anchor.radius || _this.options.anchorRadius, 0, Math.PI * 2) + ctx.strokeStyle = anchor.strokeStyle || _this.options.hoverColor + ctx.fillStyle = anchor.fillStyle || _this.options.anchorFillStyle + ctx.fill() + ctx.stroke() } - this.line.setFrom(from, this.line.fromArrow); - if (this.line.from.id || this.line.to.id) { - this.line.calcControlPoints(); + if (_this.options.autoAnchor) { + ctx.beginPath() + ctx.arc(pen.rect.center.x, pen.rect.center.y, pen.rect.center.radius || _this.options.anchorRadius, 0, Math.PI * 2) + ctx.strokeStyle = _this.options.hoverColor + ctx.fillStyle = _this.options.anchorFillStyle + ctx.fill() + ctx.stroke() } - Store.set(this.generateStoreKey('pts-') + this.line.id, undefined); - Store.set(this.generateStoreKey('LT:updateLines'), [this.line]); - }; - HoverLayer.prototype.render = function (ctx) { - var _this = this; - if (this.data.locked === Lock.NoEvent || this.options.hoverColor === 'transparent') { - return; + }) + } + ctx.restore() + if (this.node && !this.data.locked) { + if (!this.node.getTID()) { + this.node.setTID(this.TID) + } + this.root = this.getRoot(this.node) || this.node + if (this.root) { + ctx.save() + ctx.strokeStyle = this.options.dragColor + ctx.globalAlpha = 0.2 + if (this.root.rotate) { + ctx.translate(this.root.rect.center.x, this.root.rect.center.y) + ctx.rotate(((this.root.rotate + this.root.offsetRotate) * Math.PI) / 180) + ctx.translate(-this.root.rect.center.x, -this.root.rect.center.y) } - ctx.fillStyle = this.options.hoverColor; - ctx.save(); - // anchors - if (this.options.alwaysAnchor) { - this.data.pens.forEach(function (pen) { - if (pen.type === PenType.Line) { - return; - } - if (pen.hideAnchor) { - return; - } - for (var _i = 0, _a = pen.rotatedAnchors; _i < _a.length; _i++) { - var anchor = _a[_i]; - if (anchor.hidden) { - continue; - } - ctx.beginPath(); - ctx.arc(anchor.x, anchor.y, anchor.radius || _this.options.anchorRadius, 0, Math.PI * 2); - ctx.strokeStyle = anchor.strokeStyle || _this.options.hoverColor; - ctx.fillStyle = anchor.fillStyle || _this.options.anchorFillStyle; - ctx.fill(); - ctx.stroke(); - } - if (_this.options.autoAnchor) { - ctx.beginPath(); - ctx.arc(pen.rect.center.x, pen.rect.center.y, pen.rect.center.radius || _this.options.anchorRadius, 0, Math.PI * 2); - ctx.strokeStyle = _this.options.hoverColor; - ctx.fillStyle = _this.options.anchorFillStyle; - ctx.fill(); - ctx.stroke(); - } - }); - } - ctx.restore(); - if (this.node && !this.data.locked) { - if (!this.node.getTID()) { - this.node.setTID(this.TID); - } - this.root = this.getRoot(this.node) || this.node; - if (this.root) { - ctx.save(); - ctx.strokeStyle = this.options.dragColor; - ctx.globalAlpha = 0.2; - if (this.root.rotate) { - ctx.translate(this.root.rect.center.x, this.root.rect.center.y); - ctx.rotate(((this.root.rotate + this.root.offsetRotate) * Math.PI) / 180); - ctx.translate(-this.root.rect.center.x, -this.root.rect.center.y); - } - ctx.beginPath(); - ctx.strokeRect(this.root.rect.x, this.root.rect.y, this.root.rect.width, this.root.rect.height); - ctx.restore(); - } - if (!this.options.hideAnchor) { - for (var i = 0; i < this.node.rotatedAnchors.length; ++i) { - if (this.node.locked || + ctx.beginPath() + ctx.strokeRect(this.root.rect.x, this.root.rect.y, this.root.rect.width, this.root.rect.height) + ctx.restore() + } + if (!this.options.hideAnchor) { + for (let i = 0; i < this.node.rotatedAnchors.length; ++i) { + if (this.node.locked || this.node.hideAnchor || (this.node.rotatedAnchors[i].hidden && this.hoverAnchorIndex !== i)) { - continue; - } - ctx.beginPath(); - ctx.arc(this.node.rotatedAnchors[i].x, this.node.rotatedAnchors[i].y, this.node.rotatedAnchors[i].radius || this.options.anchorRadius, 0, Math.PI * 2); - ctx.strokeStyle = this.node.rotatedAnchors[i].strokeStyle || this.options.hoverColor; - ctx.fillStyle = this.node.rotatedAnchors[i].fillStyle || this.options.anchorFillStyle; - ctx.fill(); - ctx.stroke(); - } - } - if (this.options.autoAnchor) { - ctx.beginPath(); - ctx.arc(this.node.rect.center.x, this.node.rect.center.y, this.node.rect.center.radius || this.options.anchorRadius, 0, Math.PI * 2); - ctx.strokeStyle = this.options.hoverColor; - ctx.fillStyle = this.options.anchorFillStyle; - ctx.fill(); - ctx.stroke(); - } + continue + } + ctx.beginPath() + ctx.arc(this.node.rotatedAnchors[i].x, this.node.rotatedAnchors[i].y, this.node.rotatedAnchors[i].radius || this.options.anchorRadius, 0, Math.PI * 2) + ctx.strokeStyle = this.node.rotatedAnchors[i].strokeStyle || this.options.hoverColor + ctx.fillStyle = this.node.rotatedAnchors[i].fillStyle || this.options.anchorFillStyle + ctx.fill() + ctx.stroke() } - if (this.line && !this.data.locked) { - this.root = this.getRoot(this.line); - if (this.root) { - ctx.save(); - ctx.strokeStyle = this.options.dragColor; - ctx.globalAlpha = 0.2; - if (this.root.rotate) { - ctx.translate(this.root.rect.center.x, this.root.rect.center.y); - ctx.rotate(((this.root.rotate + this.root.offsetRotate) * Math.PI) / 180); - ctx.translate(-this.root.rect.center.x, -this.root.rect.center.y); - } - ctx.beginPath(); - ctx.strokeRect(this.root.rect.x, this.root.rect.y, this.root.rect.width, this.root.rect.height); - ctx.restore(); - } + } + if (this.options.autoAnchor) { + ctx.beginPath() + ctx.arc(this.node.rect.center.x, this.node.rect.center.y, this.node.rect.center.radius || this.options.anchorRadius, 0, Math.PI * 2) + ctx.strokeStyle = this.options.hoverColor + ctx.fillStyle = this.options.anchorFillStyle + ctx.fill() + ctx.stroke() + } + } + if (this.line && !this.data.locked) { + this.root = this.getRoot(this.line) + if (this.root) { + ctx.save() + ctx.strokeStyle = this.options.dragColor + ctx.globalAlpha = 0.2 + if (this.root.rotate) { + ctx.translate(this.root.rect.center.x, this.root.rect.center.y) + ctx.rotate(((this.root.rotate + this.root.offsetRotate) * Math.PI) / 180) + ctx.translate(-this.root.rect.center.x, -this.root.rect.center.y) } - if (this.dockAnchor) { - ctx.save(); - ctx.beginPath(); - ctx.arc(this.dockAnchor.x, this.dockAnchor.y, this.dockAnchor.radius || this.options.anchorRadius, 0, Math.PI * 2); - ctx.strokeStyle = this.options.dockStrokeStyle; - ctx.fillStyle = this.options.dockFillStyle; - ctx.fill(); - ctx.stroke(); - ctx.restore(); - } - if (this.hoverLineCP) { - ctx.beginPath(); - ctx.arc(this.hoverLineCP.x, this.hoverLineCP.y, 5, 0, Math.PI * 2); - ctx.fill(); - } - ctx.strokeStyle = rgba(0.5, this.options.hoverColor); - ctx.lineWidth = 1; - if (this.dockLineX > 0) { - var size = Store.get(this.generateStoreKey('LT:size')); - ctx.beginPath(); - ctx.moveTo(this.dockLineX, -this.data.y); - ctx.lineTo(this.dockLineX, size.height); - ctx.stroke(); - } - if (this.dockLineY > 0) { - var size = Store.get(this.generateStoreKey('LT:size')); - ctx.beginPath(); - ctx.moveTo(-this.data.x, this.dockLineY); - ctx.lineTo(size.width, this.dockLineY); - ctx.stroke(); - } - // Select nodes by drag. - if (this.dragRect) { - ctx.fillStyle = rgba(0.2, this.options.dragColor); - ctx.strokeStyle = this.options.dragColor; - ctx.beginPath(); - ctx.strokeRect(this.dragRect.x, this.dragRect.y, this.dragRect.width, this.dragRect.height); - ctx.fillRect(this.dragRect.x, this.dragRect.y, this.dragRect.width, this.dragRect.height); - } - }; - HoverLayer.prototype.getRoot = function (pen) { - if (!pen.parentId) { - return null; - } - for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (item.id === pen.parentId) { - var n = this.getRoot(item); - return n ? n : item; - } - } - return null; - }; - HoverLayer.prototype.clear = function () { - this.node = undefined; - this.line = undefined; - }; - return HoverLayer; -}(Layer)); -export { HoverLayer }; -//# sourceMappingURL=hoverLayer.js.map \ No newline at end of file + ctx.beginPath() + ctx.strokeRect(this.root.rect.x, this.root.rect.y, this.root.rect.width, this.root.rect.height) + ctx.restore() + } + } + if (this.dockAnchor) { + ctx.save() + ctx.beginPath() + ctx.arc(this.dockAnchor.x, this.dockAnchor.y, this.dockAnchor.radius || this.options.anchorRadius, 0, Math.PI * 2) + ctx.strokeStyle = this.options.dockStrokeStyle + ctx.fillStyle = this.options.dockFillStyle + ctx.fill() + ctx.stroke() + ctx.restore() + } + if (this.hoverLineCP) { + ctx.beginPath() + ctx.arc(this.hoverLineCP.x, this.hoverLineCP.y, 5, 0, Math.PI * 2) + ctx.fill() + } + ctx.strokeStyle = rgba(0.5, this.options.hoverColor) + ctx.lineWidth = 1 + if (this.dockLineX > 0) { + var size = Store.get(this.generateStoreKey('LT:size')) + ctx.beginPath() + ctx.moveTo(this.dockLineX, -this.data.y) + ctx.lineTo(this.dockLineX, size.height) + ctx.stroke() + } + if (this.dockLineY > 0) { + var size = Store.get(this.generateStoreKey('LT:size')) + ctx.beginPath() + ctx.moveTo(-this.data.x, this.dockLineY) + ctx.lineTo(size.width, this.dockLineY) + ctx.stroke() + } + // Select nodes by drag. + if (this.dragRect) { + ctx.fillStyle = rgba(0.2, this.options.dragColor) + ctx.strokeStyle = this.options.dragColor + ctx.beginPath() + ctx.strokeRect(this.dragRect.x, this.dragRect.y, this.dragRect.width, this.dragRect.height) + ctx.fillRect(this.dragRect.x, this.dragRect.y, this.dragRect.width, this.dragRect.height) + } + } + HoverLayer.prototype.getRoot = function (pen) { + if (!pen.parentId) { + return null + } + for (let _i = 0, _a = this.data.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (item.id === pen.parentId) { + const n = this.getRoot(item) + return n || item + } + } + return null + } + HoverLayer.prototype.clear = function () { + this.node = undefined + this.line = undefined + } + return HoverLayer +}(Layer)) +export { HoverLayer } +// # sourceMappingURL=hoverLayer.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/layer.js b/nezha-fronted/src/components/common/@topology/core/src/layer.js index ec2f76780..97c772c64 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/layer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/layer.js @@ -1,19 +1,20 @@ -import { Store } from 'le5le-store'; -var Layer = /** @class */ (function () { - function Layer(TID) { - var _this = this; - this.TID = TID; - this.subcribe = Store.subscribe(this.generateStoreKey('topology-data'), function (val) { - _this.data = val; - }); - } - Layer.prototype.generateStoreKey = function (key) { - return this.TID + "-" + key; - }; - Layer.prototype.destroy = function () { - this.subcribe.unsubscribe(); - }; - return Layer; -}()); -export { Layer }; -//# sourceMappingURL=layer.js.map \ No newline at end of file +import { Store } from 'le5le-store' +const Layer = /** @class */ (function () { + function Layer (TID) { + const _this = this + this.TID = TID + this.subcribe = Store.subscribe(this.generateStoreKey('topology-data'), function (val) { + _this.data = val + }) + } + Layer.prototype.generateStoreKey = function (key) { + return this.TID + '-' + key + } + Layer.prototype.destroy = function () { + this.subcribe.unsubscribe() + this.subcribe = null + } + return Layer +}()) +export { Layer } +// # sourceMappingURL=layer.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/circle.js b/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/circle.js index 7892d6628..d9264503a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/circle.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/circle.js @@ -1,24 +1,23 @@ -import { Store } from 'le5le-store'; -export function circleSolid(ctx, from, to, size, fillStyle) { - size += ctx.lineWidth * 3; - var r = size / 2; - if (ctx.lineWidth < 2) { - ctx.lineWidth = 2; - } - ctx.translate(to.x, to.y); - ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)); - ctx.translate(-to.x, -to.y - ctx.lineWidth / 10); - ctx.arc(to.x - r - ctx.lineWidth / 2, to.y, r, 0, 2 * Math.PI); - ctx.stroke(); - if (fillStyle) { - ctx.fillStyle = fillStyle; - } - else { - ctx.fillStyle = ctx.strokeStyle; - } - ctx.fill(); +import { Store } from 'le5le-store' +export function circleSolid (ctx, from, to, size, fillStyle) { + size += ctx.lineWidth * 3 + const r = size / 2 + if (ctx.lineWidth < 2) { + ctx.lineWidth = 2 + } + ctx.translate(to.x, to.y) + ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)) + ctx.translate(-to.x, -to.y - ctx.lineWidth / 10) + ctx.arc(to.x - r - ctx.lineWidth / 2, to.y, r, 0, 2 * Math.PI) + ctx.stroke() + if (fillStyle) { + ctx.fillStyle = fillStyle + } else { + ctx.fillStyle = ctx.strokeStyle + } + ctx.fill() } -export function circle(ctx, from, to, size) { - circleSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff'); +export function circle (ctx, from, to, size) { + circleSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff') } -//# sourceMappingURL=circle.js.map \ No newline at end of file +// # sourceMappingURL=circle.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/diamond.js b/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/diamond.js index 2851265e0..54731b8f7 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/diamond.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/diamond.js @@ -1,32 +1,31 @@ -import { Store } from 'le5le-store'; -export function diamondSolid(ctx, from, to, size, fillStyle) { - size += ctx.lineWidth * 3; - var r = size / 2; - var arrowWidth = ctx.lineWidth / 10; - if (ctx.lineWidth < 2) { - ctx.lineWidth = 2; - arrowWidth = 0; - } - ctx.translate(to.x, to.y); - ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)); - ctx.translate(-to.x - ctx.lineWidth + arrowWidth * 5, -to.y); - ctx.moveTo(to.x, to.y + arrowWidth); - ctx.lineTo(to.x, to.y - arrowWidth); - ctx.lineTo(to.x - r, to.y - r / 2); - ctx.lineTo(to.x - size, to.y - arrowWidth); - ctx.lineTo(to.x - size, to.y + arrowWidth); - ctx.lineTo(to.x - r, to.y + r / 2); - ctx.closePath(); - ctx.stroke(); - if (fillStyle) { - ctx.fillStyle = fillStyle; - } - else { - ctx.fillStyle = ctx.strokeStyle; - } - ctx.fill(); +import { Store } from 'le5le-store' +export function diamondSolid (ctx, from, to, size, fillStyle) { + size += ctx.lineWidth * 3 + const r = size / 2 + let arrowWidth = ctx.lineWidth / 10 + if (ctx.lineWidth < 2) { + ctx.lineWidth = 2 + arrowWidth = 0 + } + ctx.translate(to.x, to.y) + ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)) + ctx.translate(-to.x - ctx.lineWidth + arrowWidth * 5, -to.y) + ctx.moveTo(to.x, to.y + arrowWidth) + ctx.lineTo(to.x, to.y - arrowWidth) + ctx.lineTo(to.x - r, to.y - r / 2) + ctx.lineTo(to.x - size, to.y - arrowWidth) + ctx.lineTo(to.x - size, to.y + arrowWidth) + ctx.lineTo(to.x - r, to.y + r / 2) + ctx.closePath() + ctx.stroke() + if (fillStyle) { + ctx.fillStyle = fillStyle + } else { + ctx.fillStyle = ctx.strokeStyle + } + ctx.fill() } -export function diamond(ctx, from, to, size) { - diamondSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff'); +export function diamond (ctx, from, to, size) { + diamondSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff') } -//# sourceMappingURL=diamond.js.map \ No newline at end of file +// # sourceMappingURL=diamond.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/line.js b/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/line.js index 2a2d13356..763fba64e 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/line.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/line.js @@ -1,42 +1,40 @@ -export function line(ctx, from, to, size) { - size += ctx.lineWidth * 3; - ctx.translate(to.x, to.y); - ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)); - ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5); - ctx.moveTo(to.x, to.y); - ctx.lineTo(to.x - size, to.y - size / 3); - ctx.moveTo(to.x, to.y); - ctx.lineTo(to.x - size, to.y + size / 3); - ctx.stroke(); +export function line (ctx, from, to, size) { + size += ctx.lineWidth * 3 + ctx.translate(to.x, to.y) + ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)) + ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5) + ctx.moveTo(to.x, to.y) + ctx.lineTo(to.x - size, to.y - size / 3) + ctx.moveTo(to.x, to.y) + ctx.lineTo(to.x - size, to.y + size / 3) + ctx.stroke() } -export function lineUp(ctx, from, to, size) { - size += ctx.lineWidth * 3; - ctx.translate(to.x, to.y); - ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)); - ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5); - if (to.x > from.x) { - ctx.moveTo(to.x, to.y); - ctx.lineTo(to.x - size, to.y - size / 3); - } - else { - ctx.moveTo(to.x, to.y); - ctx.lineTo(to.x - size, to.y + size / 3); - } - ctx.stroke(); +export function lineUp (ctx, from, to, size) { + size += ctx.lineWidth * 3 + ctx.translate(to.x, to.y) + ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)) + ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5) + if (to.x > from.x) { + ctx.moveTo(to.x, to.y) + ctx.lineTo(to.x - size, to.y - size / 3) + } else { + ctx.moveTo(to.x, to.y) + ctx.lineTo(to.x - size, to.y + size / 3) + } + ctx.stroke() } -export function lineDown(ctx, from, to, size) { - size += ctx.lineWidth * 3; - ctx.translate(to.x, to.y); - ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)); - ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5); - if (to.x < from.x) { - ctx.moveTo(to.x, to.y); - ctx.lineTo(to.x - size, to.y - size / 3); - } - else { - ctx.moveTo(to.x, to.y); - ctx.lineTo(to.x - size, to.y + size / 3); - } - ctx.stroke(); +export function lineDown (ctx, from, to, size) { + size += ctx.lineWidth * 3 + ctx.translate(to.x, to.y) + ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)) + ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5) + if (to.x < from.x) { + ctx.moveTo(to.x, to.y) + ctx.lineTo(to.x - size, to.y - size / 3) + } else { + ctx.moveTo(to.x, to.y) + ctx.lineTo(to.x - size, to.y + size / 3) + } + ctx.stroke() } -//# sourceMappingURL=line.js.map \ No newline at end of file +// # sourceMappingURL=line.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/triangle.js b/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/triangle.js index 7d06d6493..5db610a36 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/triangle.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/arrows/triangle.js @@ -1,29 +1,28 @@ -import { Store } from 'le5le-store'; -export function triangleSolid(ctx, from, to, size, fillStyle) { - size += ctx.lineWidth * 3; - var arrowWidth = ctx.lineWidth / 10; - if (ctx.lineWidth < 2) { - ctx.lineWidth = 2; - arrowWidth = 0; - } - ctx.translate(to.x, to.y); - ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)); - ctx.translate(-to.x - ctx.lineWidth + arrowWidth * 5, -to.y); - ctx.moveTo(to.x, to.y + arrowWidth); - ctx.lineTo(to.x, to.y - arrowWidth); - ctx.lineTo(to.x - size, to.y - size / 3); - ctx.lineTo(to.x - size, to.y + size / 3); - ctx.closePath(); - ctx.stroke(); - if (fillStyle) { - ctx.fillStyle = fillStyle; - } - else { - ctx.fillStyle = ctx.strokeStyle; - } - ctx.fill(); +import { Store } from 'le5le-store' +export function triangleSolid (ctx, from, to, size, fillStyle) { + size += ctx.lineWidth * 3 + let arrowWidth = ctx.lineWidth / 10 + if (ctx.lineWidth < 2) { + ctx.lineWidth = 2 + arrowWidth = 0 + } + ctx.translate(to.x, to.y) + ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x)) + ctx.translate(-to.x - ctx.lineWidth + arrowWidth * 5, -to.y) + ctx.moveTo(to.x, to.y + arrowWidth) + ctx.lineTo(to.x, to.y - arrowWidth) + ctx.lineTo(to.x - size, to.y - size / 3) + ctx.lineTo(to.x - size, to.y + size / 3) + ctx.closePath() + ctx.stroke() + if (fillStyle) { + ctx.fillStyle = fillStyle + } else { + ctx.fillStyle = ctx.strokeStyle + } + ctx.fill() } -export function triangle(ctx, from, to, size) { - triangleSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff'); +export function triangle (ctx, from, to, size) { + triangleSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff') } -//# sourceMappingURL=triangle.js.map \ No newline at end of file +// # sourceMappingURL=triangle.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/default.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/default.anchor.js index 3e45148be..8f1e337ba 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/default.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/default.anchor.js @@ -1,9 +1,9 @@ -import { Point } from '../models/point'; -import { Direction } from '../models/direction'; -export function defaultAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)); +import { Point } from '../models/point' +import { Direction } from '../models/direction' +export function defaultAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)) } -//# sourceMappingURL=default.anchor.js.map \ No newline at end of file +// # sourceMappingURL=default.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/default.js b/nezha-fronted/src/components/common/@topology/core/src/middles/default.js index 49d3619cb..310d4c6c6 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/default.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/default.js @@ -1,213 +1,213 @@ -import { rectangle } from './nodes/rectangle'; -import { circle } from './nodes/circle'; -import { triangle } from './nodes/triangle'; -import { diamond } from './nodes/diamond'; -import { leftArrow, rightArrow, twowayArrow } from './nodes/arrow'; -import { text } from './nodes/text'; -import { line as nodeLine } from './nodes/line'; -import { triangleAnchors } from './nodes/triangle.anchor'; -import { arrowAnchors } from './nodes/arrow.anchor'; -import { lineAnchors } from './nodes/line.anchor'; -import { circleIconRect, circleTextRect } from './nodes/circle.rect'; -import { triangleIconRect, triangleTextRect } from './nodes/triangle.rect'; -import { diamondIconRect, diamondTextRect } from './nodes/diamond.rect'; -import { twowayArrowIconRect, twowayArrowTextRect, leftArrowIconRect, leftArrowTextRect, rightArrowIconRect, rightArrowTextRect, } from './nodes/arrow.rect'; -import { lineIconRect, lineTextRect } from './nodes/line.rect'; -import { line, lineControlPoints, calcLineControlPoints } from './lines/line'; -import { polyline, polylineControlPoints, pointInPolyline, calcPolylineControlPoints, dockPolylineControlPoint, } from './lines/polyline'; -import { curve, curveControlPoints, pointInCurve, calcCurveControlPoints, } from './lines/curve'; -import { calcMindControlPoints, } from './lines/mind'; -import { triangleSolid, triangle as arrowTriangle } from './arrows/triangle'; -import { diamondSolid, diamond as arrowDiamond } from './arrows/diamond'; -import { circleSolid, circle as arrowCircle } from './arrows/circle'; -import { circleAnchors } from './nodes/circle.anchor'; -import { lineUp, lineDown, line as arrowLine } from './arrows/line'; -import { pentagon } from './nodes/pentagon'; -import { pentagonIconRect, pentagonTextRect } from './nodes/pentagon.rect'; -import { pentagonAnchors } from './nodes/pentagon.anchor'; -import { hexagon } from './nodes/hexagon'; -import { hexagonAnchors } from './nodes/hexagon.anchor'; -import { hexagonIconRect, hexagonTextRect } from './nodes/hexagon.rect'; -import { pentagram } from './nodes/pentagram'; -import { pentagramAnchors } from './nodes/pentagram.anchor'; -import { pentagramIconRect, pentagramTextRect } from './nodes/pentagram.rect'; -import { cloud } from './nodes/cloud'; -import { cloudAnchors } from './nodes/cloud.anchor'; -import { cloudIconRect, cloudTextRect } from './nodes/cloud.rect'; -import { message } from './nodes/message'; -import { messageIconRect, messageTextRect } from './nodes/message.rect'; -import { messageAnchors } from './nodes/message.anchor'; -import { file } from './nodes/file'; -import { imageIconRect, imageTextRect } from './nodes/image.rect'; -import { imageAnchors } from './nodes/image.anchor'; -import { cube } from './nodes/cube'; -import { cubeAnchors } from './nodes/cube.anchor'; -import { cubeIconRect, cubeTextRect } from './nodes/cube.rect'; -import { people } from './nodes/people'; -import { peopleIconRect, peopleTextRect } from './nodes/people.rect'; -import { rectangleIconRect, rectangleTextRect } from './nodes/rectangle.rect'; -import { graffiti } from './nodes/graffiti'; -import { graffitiAnchors } from './nodes/graffiti.anchor'; -import { mindNodeAnchors } from './nodes/mindNode.anchor'; -import { mindLine } from './nodes/mindLine'; -import { mindLineAnchors } from './nodes/mindLine.anchor'; -import { lines } from './nodes/lines'; +import { rectangle } from './nodes/rectangle' +import { circle } from './nodes/circle' +import { triangle } from './nodes/triangle' +import { diamond } from './nodes/diamond' +import { leftArrow, rightArrow, twowayArrow } from './nodes/arrow' +import { text } from './nodes/text' +import { line as nodeLine } from './nodes/line' +import { triangleAnchors } from './nodes/triangle.anchor' +import { arrowAnchors } from './nodes/arrow.anchor' +import { lineAnchors } from './nodes/line.anchor' +import { circleIconRect, circleTextRect } from './nodes/circle.rect' +import { triangleIconRect, triangleTextRect } from './nodes/triangle.rect' +import { diamondIconRect, diamondTextRect } from './nodes/diamond.rect' +import { twowayArrowIconRect, twowayArrowTextRect, leftArrowIconRect, leftArrowTextRect, rightArrowIconRect, rightArrowTextRect } from './nodes/arrow.rect' +import { lineIconRect, lineTextRect } from './nodes/line.rect' +import { line, lineControlPoints, calcLineControlPoints } from './lines/line' +import { polyline, polylineControlPoints, pointInPolyline, calcPolylineControlPoints, dockPolylineControlPoint } from './lines/polyline' +import { curve, curveControlPoints, pointInCurve, calcCurveControlPoints } from './lines/curve' +import { calcMindControlPoints } from './lines/mind' +import { triangleSolid, triangle as arrowTriangle } from './arrows/triangle' +import { diamondSolid, diamond as arrowDiamond } from './arrows/diamond' +import { circleSolid, circle as arrowCircle } from './arrows/circle' +import { circleAnchors } from './nodes/circle.anchor' +import { lineUp, lineDown, line as arrowLine } from './arrows/line' +import { pentagon } from './nodes/pentagon' +import { pentagonIconRect, pentagonTextRect } from './nodes/pentagon.rect' +import { pentagonAnchors } from './nodes/pentagon.anchor' +import { hexagon } from './nodes/hexagon' +import { hexagonAnchors } from './nodes/hexagon.anchor' +import { hexagonIconRect, hexagonTextRect } from './nodes/hexagon.rect' +import { pentagram } from './nodes/pentagram' +import { pentagramAnchors } from './nodes/pentagram.anchor' +import { pentagramIconRect, pentagramTextRect } from './nodes/pentagram.rect' +import { cloud } from './nodes/cloud' +import { cloudAnchors } from './nodes/cloud.anchor' +import { cloudIconRect, cloudTextRect } from './nodes/cloud.rect' +import { message } from './nodes/message' +import { messageIconRect, messageTextRect } from './nodes/message.rect' +import { messageAnchors } from './nodes/message.anchor' +import { file } from './nodes/file' +import { imageIconRect, imageTextRect } from './nodes/image.rect' +import { imageAnchors } from './nodes/image.anchor' +import { cube } from './nodes/cube' +import { cubeAnchors } from './nodes/cube.anchor' +import { cubeIconRect, cubeTextRect } from './nodes/cube.rect' +import { people } from './nodes/people' +import { peopleIconRect, peopleTextRect } from './nodes/people.rect' +import { rectangleIconRect, rectangleTextRect } from './nodes/rectangle.rect' +import { graffiti } from './nodes/graffiti' +import { graffitiAnchors } from './nodes/graffiti.anchor' +import { mindNodeAnchors } from './nodes/mindNode.anchor' +import { mindLine } from './nodes/mindLine' +import { mindLineAnchors } from './nodes/mindLine.anchor' +import { lines } from './nodes/lines' // Functions of drawing a node. -export var drawNodeFns = {}; +export var drawNodeFns = {} // Calc the occupy rect of icon. -export var iconRectFns = {}; +export var iconRectFns = {} // Calc the occupy rect of text. -export var textRectFns = {}; +export var textRectFns = {} // Calc the anchors of node. -export var anchorsFns = {}; +export var anchorsFns = {} // Functions of drawing a line. -export var drawLineFns = {}; +export var drawLineFns = {} // Functions of drawing a arrow. -export var drawArrowFns = {}; -function init() { - // ********Default nodes.******* - // Combine - drawNodeFns.combine = rectangle; - // Div - drawNodeFns.div = rectangle; - // graffiti - drawNodeFns.graffiti = graffiti; - anchorsFns.graffiti = graffitiAnchors; - // lines - drawNodeFns.lines = lines; - // Square - drawNodeFns.square = rectangle; - // Rectangle - drawNodeFns.rectangle = rectangle; - iconRectFns.rectangle = rectangleIconRect; - textRectFns.rectangle = rectangleTextRect; - // Ciricle - drawNodeFns.circle = circle; - iconRectFns.circle = circleIconRect; - textRectFns.circle = circleTextRect; - anchorsFns.circle = circleAnchors; - // Triangle - drawNodeFns.triangle = triangle; - anchorsFns.triangle = triangleAnchors; - iconRectFns.triangle = triangleIconRect; - textRectFns.triangle = triangleTextRect; - // Diamond - drawNodeFns.diamond = diamond; - iconRectFns.diamond = diamondIconRect; - textRectFns.diamond = diamondTextRect; - // Hexagon - drawNodeFns.hexagon = hexagon; - iconRectFns.hexagon = hexagonIconRect; - textRectFns.hexagon = hexagonTextRect; - anchorsFns.hexagon = hexagonAnchors; - // Pentagon - drawNodeFns.pentagon = pentagon; - iconRectFns.pentagon = pentagonIconRect; - textRectFns.pentagon = pentagonTextRect; - anchorsFns.pentagon = pentagonAnchors; - // Pentagram - drawNodeFns.pentagram = pentagram; - iconRectFns.pentagram = pentagramIconRect; - textRectFns.pentagram = pentagramTextRect; - anchorsFns.pentagram = pentagramAnchors; - // Left arrow - drawNodeFns.leftArrow = leftArrow; - anchorsFns.leftArrow = arrowAnchors; - iconRectFns.leftArrow = leftArrowIconRect; - textRectFns.leftArrow = leftArrowTextRect; - // Right arrow - drawNodeFns.rightArrow = rightArrow; - anchorsFns.rightArrow = arrowAnchors; - iconRectFns.rightArrow = rightArrowIconRect; - textRectFns.rightArrow = rightArrowTextRect; - // Two-way arrow - drawNodeFns.twowayArrow = twowayArrow; - anchorsFns.twowayArrow = arrowAnchors; - iconRectFns.twowayArrow = twowayArrowIconRect; - textRectFns.twowayArrow = twowayArrowTextRect; - // Cloud - drawNodeFns.cloud = cloud; - anchorsFns.cloud = cloudAnchors; - iconRectFns.cloud = cloudIconRect; - textRectFns.cloud = cloudTextRect; - // Message - drawNodeFns.message = message; - anchorsFns.message = messageAnchors; - iconRectFns.message = messageIconRect; - textRectFns.message = messageTextRect; - // File - drawNodeFns.file = file; - // Text - drawNodeFns.text = text; - iconRectFns.text = lineIconRect; - // Line - drawNodeFns.line = nodeLine; - anchorsFns.line = lineAnchors; - iconRectFns.line = lineIconRect; - textRectFns.line = lineTextRect; - // Image - drawNodeFns.image = function (ctx, node) { }; - iconRectFns.image = imageIconRect; - textRectFns.image = imageTextRect; - anchorsFns.image = imageAnchors; - // Cube - drawNodeFns.cube = cube; - anchorsFns.cube = cubeAnchors; - iconRectFns.cube = cubeIconRect; - textRectFns.cube = cubeTextRect; - // People - drawNodeFns.people = people; - iconRectFns.people = peopleIconRect; - textRectFns.people = peopleTextRect; - // MindNode - drawNodeFns.mindNode = rectangle; - anchorsFns.mindNode = mindNodeAnchors; - iconRectFns.mindNode = rectangleIconRect; - textRectFns.mindNode = rectangleTextRect; - // MindLine - drawNodeFns.mindLine = mindLine; - anchorsFns.mindLine = mindLineAnchors; - // ********end******** - // ********Default lines.******* - drawLineFns.line = { - drawFn: line, - drawControlPointsFn: lineControlPoints, - controlPointsFn: calcLineControlPoints, - pointIn: pointInPolyline, - }; - drawLineFns.polyline = { - drawFn: polyline, - drawControlPointsFn: polylineControlPoints, - controlPointsFn: calcPolylineControlPoints, - dockControlPointFn: dockPolylineControlPoint, - pointIn: pointInPolyline, - }; - drawLineFns.curve = { - drawFn: curve, - drawControlPointsFn: curveControlPoints, - controlPointsFn: calcCurveControlPoints, - pointIn: pointInCurve, - }; - drawLineFns.mind = { - drawFn: curve, - drawControlPointsFn: curveControlPoints, - controlPointsFn: calcMindControlPoints, - pointIn: pointInCurve, - }; - // ********end******** - // ********Default nodes.******* - drawArrowFns.triangleSolid = triangleSolid; - drawArrowFns.triangle = arrowTriangle; - drawArrowFns.diamondSolid = diamondSolid; - drawArrowFns.diamond = arrowDiamond; - drawArrowFns.circleSolid = circleSolid; - drawArrowFns.circle = arrowCircle; - drawArrowFns.line = arrowLine; - drawArrowFns.lineUp = lineUp; - drawArrowFns.lineDown = lineDown; - // ********end******** +export var drawArrowFns = {} +function init () { + // ********Default nodes.******* + // Combine + drawNodeFns.combine = rectangle + // Div + drawNodeFns.div = rectangle + // graffiti + drawNodeFns.graffiti = graffiti + anchorsFns.graffiti = graffitiAnchors + // lines + drawNodeFns.lines = lines + // Square + drawNodeFns.square = rectangle + // Rectangle + drawNodeFns.rectangle = rectangle + iconRectFns.rectangle = rectangleIconRect + textRectFns.rectangle = rectangleTextRect + // Ciricle + drawNodeFns.circle = circle + iconRectFns.circle = circleIconRect + textRectFns.circle = circleTextRect + anchorsFns.circle = circleAnchors + // Triangle + drawNodeFns.triangle = triangle + anchorsFns.triangle = triangleAnchors + iconRectFns.triangle = triangleIconRect + textRectFns.triangle = triangleTextRect + // Diamond + drawNodeFns.diamond = diamond + iconRectFns.diamond = diamondIconRect + textRectFns.diamond = diamondTextRect + // Hexagon + drawNodeFns.hexagon = hexagon + iconRectFns.hexagon = hexagonIconRect + textRectFns.hexagon = hexagonTextRect + anchorsFns.hexagon = hexagonAnchors + // Pentagon + drawNodeFns.pentagon = pentagon + iconRectFns.pentagon = pentagonIconRect + textRectFns.pentagon = pentagonTextRect + anchorsFns.pentagon = pentagonAnchors + // Pentagram + drawNodeFns.pentagram = pentagram + iconRectFns.pentagram = pentagramIconRect + textRectFns.pentagram = pentagramTextRect + anchorsFns.pentagram = pentagramAnchors + // Left arrow + drawNodeFns.leftArrow = leftArrow + anchorsFns.leftArrow = arrowAnchors + iconRectFns.leftArrow = leftArrowIconRect + textRectFns.leftArrow = leftArrowTextRect + // Right arrow + drawNodeFns.rightArrow = rightArrow + anchorsFns.rightArrow = arrowAnchors + iconRectFns.rightArrow = rightArrowIconRect + textRectFns.rightArrow = rightArrowTextRect + // Two-way arrow + drawNodeFns.twowayArrow = twowayArrow + anchorsFns.twowayArrow = arrowAnchors + iconRectFns.twowayArrow = twowayArrowIconRect + textRectFns.twowayArrow = twowayArrowTextRect + // Cloud + drawNodeFns.cloud = cloud + anchorsFns.cloud = cloudAnchors + iconRectFns.cloud = cloudIconRect + textRectFns.cloud = cloudTextRect + // Message + drawNodeFns.message = message + anchorsFns.message = messageAnchors + iconRectFns.message = messageIconRect + textRectFns.message = messageTextRect + // File + drawNodeFns.file = file + // Text + drawNodeFns.text = text + iconRectFns.text = lineIconRect + // Line + drawNodeFns.line = nodeLine + anchorsFns.line = lineAnchors + iconRectFns.line = lineIconRect + textRectFns.line = lineTextRect + // Image + drawNodeFns.image = function (ctx, node) { } + iconRectFns.image = imageIconRect + textRectFns.image = imageTextRect + anchorsFns.image = imageAnchors + // Cube + drawNodeFns.cube = cube + anchorsFns.cube = cubeAnchors + iconRectFns.cube = cubeIconRect + textRectFns.cube = cubeTextRect + // People + drawNodeFns.people = people + iconRectFns.people = peopleIconRect + textRectFns.people = peopleTextRect + // MindNode + drawNodeFns.mindNode = rectangle + anchorsFns.mindNode = mindNodeAnchors + iconRectFns.mindNode = rectangleIconRect + textRectFns.mindNode = rectangleTextRect + // MindLine + drawNodeFns.mindLine = mindLine + anchorsFns.mindLine = mindLineAnchors + // ********end******** + // ********Default lines.******* + drawLineFns.line = { + drawFn: line, + drawControlPointsFn: lineControlPoints, + controlPointsFn: calcLineControlPoints, + pointIn: pointInPolyline + } + drawLineFns.polyline = { + drawFn: polyline, + drawControlPointsFn: polylineControlPoints, + controlPointsFn: calcPolylineControlPoints, + dockControlPointFn: dockPolylineControlPoint, + pointIn: pointInPolyline + } + drawLineFns.curve = { + drawFn: curve, + drawControlPointsFn: curveControlPoints, + controlPointsFn: calcCurveControlPoints, + pointIn: pointInCurve + } + drawLineFns.mind = { + drawFn: curve, + drawControlPointsFn: curveControlPoints, + controlPointsFn: calcMindControlPoints, + pointIn: pointInCurve + } + // ********end******** + // ********Default nodes.******* + drawArrowFns.triangleSolid = triangleSolid + drawArrowFns.triangle = arrowTriangle + drawArrowFns.diamondSolid = diamondSolid + drawArrowFns.diamond = arrowDiamond + drawArrowFns.circleSolid = circleSolid + drawArrowFns.circle = arrowCircle + drawArrowFns.line = arrowLine + drawArrowFns.lineUp = lineUp + drawArrowFns.lineDown = lineDown + // ********end******** } -init(); +init() // registerNode: Register a custom node. // name - The name of node. // drawFn - How to draw. @@ -215,16 +215,16 @@ init(); // iconRectFn - How to get the icon rect. // textRectFn - How to get the text rect. // protect - No overwirte the node if exists. -export function registerNode(name, drawFn, anchorsFn, iconRectFn, textRectFn, protect) { - // Exist - if (drawNodeFns[name] && protect) { - return false; - } - drawNodeFns[name] = drawFn; - anchorsFns[name] = anchorsFn; - iconRectFns[name] = iconRectFn; - textRectFns[name] = textRectFn; - return true; +export function registerNode (name, drawFn, anchorsFn, iconRectFn, textRectFn, protect) { + // Exist + if (drawNodeFns[name] && protect) { + return false + } + drawNodeFns[name] = drawFn + anchorsFns[name] = anchorsFn + iconRectFns[name] = iconRectFn + textRectFns[name] = textRectFn + return true } // registerLine: Register a custom line. // name - The name of line. @@ -233,36 +233,36 @@ export function registerNode(name, drawFn, anchorsFn, iconRectFn, textRectFn, pr // controlPointsFn - How to get the controlPoints. // dockControlPointFn - Dock a point to horizontal/vertial or related position. // force - Overwirte the node if exists. -export function registerLine(name, drawFn, drawControlPointsFn, controlPointsFn, dockControlPointFn, pointInFn, getLength, getCenter, getPointByPos, force) { - if (force === void 0) { force = true; } - // Exist - if (drawLineFns[name] && !force) { - return false; - } - drawLineFns[name] = { - drawFn: drawFn, - drawControlPointsFn: drawControlPointsFn, - controlPointsFn: controlPointsFn, - dockControlPointFn: dockControlPointFn, - pointIn: pointInFn, - getLength: getLength, - getCenter: getCenter, - getPointByPos: getPointByPos, - }; - return true; +export function registerLine (name, drawFn, drawControlPointsFn, controlPointsFn, dockControlPointFn, pointInFn, getLength, getCenter, getPointByPos, force) { + if (force === void 0) { force = true } + // Exist + if (drawLineFns[name] && !force) { + return false + } + drawLineFns[name] = { + drawFn: drawFn, + drawControlPointsFn: drawControlPointsFn, + controlPointsFn: controlPointsFn, + dockControlPointFn: dockControlPointFn, + pointIn: pointInFn, + getLength: getLength, + getCenter: getCenter, + getPointByPos: getPointByPos + } + return true } // registerArrow: Register a custom arrow. // name - the name of arrow. // drawFn - how to draw. // force - Overwirte the node if exists. -export function registerArrow(name, drawFn, protect) { - // Exist - if (drawArrowFns[name] && protect) { - return false; - } - drawArrowFns[name] = drawFn; - return true; +export function registerArrow (name, drawFn, protect) { + // Exist + if (drawArrowFns[name] && protect) { + return false + } + drawArrowFns[name] = drawFn + return true } -window.registerTopologyNode = registerNode; -window.registerTopologyLine = registerLine; -//# sourceMappingURL=default.js.map \ No newline at end of file +window.registerTopologyNode = registerNode +window.registerTopologyLine = registerLine +// # sourceMappingURL=default.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/default.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/default.rect.js index 611454946..969ee277e 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/default.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/default.rect.js @@ -1,19 +1,17 @@ -import { Rect } from '../models/rect'; -export function defaultIconRect(node) { - if (node.image && node.imageWidth) { - node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.imageWidth, node.imageHeight); - } - else if (node.icon && node.iconSize) { - node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.iconSize, node.iconSize); - } - else { - node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, (node.rect.height * 3) / 4 - node.paddingTopNum - node.paddingBottomNum); - } - node.fullIconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum); +import { Rect } from '../models/rect' +export function defaultIconRect (node) { + if (node.image && node.imageWidth) { + node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.imageWidth, node.imageHeight) + } else if (node.icon && node.iconSize) { + node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.iconSize, node.iconSize) + } else { + node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, (node.rect.height * 3) / 4 - node.paddingTopNum - node.paddingBottomNum) + } + node.fullIconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum) } -export function defaultTextRect(node) { - var height = node.rect.height - node.paddingTopNum - node.paddingBottomNum; - node.textRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum + (height * 3) / 4, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height / 4); - node.fullTextRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height); +export function defaultTextRect (node) { + const height = node.rect.height - node.paddingTopNum - node.paddingBottomNum + node.textRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum + (height * 3) / 4, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height / 4) + node.fullTextRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height) } -//# sourceMappingURL=default.rect.js.map \ No newline at end of file +// # sourceMappingURL=default.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/index.js b/nezha-fronted/src/components/common/@topology/core/src/middles/index.js index 410e64745..260369402 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/index.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/index.js @@ -1,4 +1,4 @@ -export * from './default'; -export * from './nodes/rectangle'; -export * from './nodes/text'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './default' +export * from './nodes/rectangle' +export * from './nodes/text' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/lines/curve.js b/nezha-fronted/src/components/common/@topology/core/src/middles/lines/curve.js index a73ee0631..373fbcb7e 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/lines/curve.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/lines/curve.js @@ -1,130 +1,128 @@ -import { Store } from 'le5le-store'; -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -import { pointInLine } from '../../utils/canvas'; -import { rgba } from '../../utils/math'; -var distance = 80; -export function curve(ctx, l) { - ctx.beginPath(); - ctx.moveTo(l.from.x, l.from.y); - ctx.bezierCurveTo(l.controlPoints[0].x, l.controlPoints[0].y, l.controlPoints[1].x, l.controlPoints[1].y, l.to.x, l.to.y); - ctx.stroke(); +import { Store } from 'le5le-store' +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +import { pointInLine } from '../../utils/canvas' +import { rgba } from '../../utils/math' +const distance = 80 +export function curve (ctx, l) { + ctx.beginPath() + ctx.moveTo(l.from.x, l.from.y) + ctx.bezierCurveTo(l.controlPoints[0].x, l.controlPoints[0].y, l.controlPoints[1].x, l.controlPoints[1].y, l.to.x, l.to.y) + ctx.stroke() } -export function curveControlPoints(ctx, l) { - ctx.save(); - ctx.fillStyle = rgba(0.5, ctx.strokeStyle + ''); - ctx.lineWidth = 1; - ctx.beginPath(); - ctx.moveTo(l.from.x, l.from.y); - ctx.lineTo(l.controlPoints[0].x, l.controlPoints[0].y); - ctx.stroke(); - ctx.beginPath(); - ctx.moveTo(l.to.x, l.to.y); - ctx.lineTo(l.controlPoints[1].x, l.controlPoints[1].y); - ctx.stroke(); - ctx.fillStyle = '#fff'; - ctx.lineWidth = 2; - for (var _i = 0, _a = l.controlPoints; _i < _a.length; _i++) { - var item = _a[_i]; - ctx.beginPath(); - ctx.arc(item.x, item.y, 4, 0, Math.PI * 2); - ctx.stroke(); - ctx.fill(); - } - ctx.restore(); +export function curveControlPoints (ctx, l) { + ctx.save() + ctx.fillStyle = rgba(0.5, ctx.strokeStyle + '') + ctx.lineWidth = 1 + ctx.beginPath() + ctx.moveTo(l.from.x, l.from.y) + ctx.lineTo(l.controlPoints[0].x, l.controlPoints[0].y) + ctx.stroke() + ctx.beginPath() + ctx.moveTo(l.to.x, l.to.y) + ctx.lineTo(l.controlPoints[1].x, l.controlPoints[1].y) + ctx.stroke() + ctx.fillStyle = '#fff' + ctx.lineWidth = 2 + for (let _i = 0, _a = l.controlPoints; _i < _a.length; _i++) { + const item = _a[_i] + ctx.beginPath() + ctx.arc(item.x, item.y, 4, 0, Math.PI * 2) + ctx.stroke() + ctx.fill() + } + ctx.restore() } -export function calcCurveControlPoints(l) { - if (!l.from.direction) { - l.from.direction = Direction.Bottom; - } +export function calcCurveControlPoints (l) { + if (!l.from.direction) { + l.from.direction = Direction.Bottom + } + if (!l.to.direction) { + l.to.direction = (l.from.direction + 2) % 4 if (!l.to.direction) { - l.to.direction = (l.from.direction + 2) % 4; - if (!l.to.direction) { - l.to.direction = Direction.Left; - } + l.to.direction = Direction.Left } - l.controlPoints = [getControlPt(l.from, l.to), getControlPt(l.to, l.from)]; - Store.set(generateStoreKey(l, 'pts-') + l.id, undefined); + } + l.controlPoints = [getControlPt(l.from, l.to), getControlPt(l.to, l.from)] + Store.set(generateStoreKey(l, 'pts-') + l.id, undefined) } -export function pointInCurve(point, l) { - var points = Store.get(generateStoreKey(l, 'pts-') + l.id); - if (!points) { - points = [l.from]; - if (l.controlPoints) { - for (var i = 0.01; i < 1; i += 0.01) { - points.push(getBezierPoint(i, l.from, l.controlPoints[0], l.controlPoints[1], l.to)); - } - } - points.push(l.to); - Store.set(generateStoreKey(l, 'pts-') + l.id, points); +export function pointInCurve (point, l) { + let points = Store.get(generateStoreKey(l, 'pts-') + l.id) + if (!points) { + points = [l.from] + if (l.controlPoints) { + for (var i = 0.01; i < 1; i += 0.01) { + points.push(getBezierPoint(i, l.from, l.controlPoints[0], l.controlPoints[1], l.to)) + } } - var cnt = points.length - 1; - for (var i = 0; i < cnt; ++i) { - if (pointInLine(point, points[i], points[i + 1])) { - return true; - } + points.push(l.to) + Store.set(generateStoreKey(l, 'pts-') + l.id, points) + } + const cnt = points.length - 1 + for (var i = 0; i < cnt; ++i) { + if (pointInLine(point, points[i], points[i + 1])) { + return true } - return false; + } + return false } // Get a point in bezier. // pos - The position of point in bezier. It is expressed as a percentage(0 - 1). -export function getBezierPoint(pos, from, cp1, cp2, to) { - var x1 = from.x, y1 = from.y; - var x2 = to.x, y2 = to.y; - var cx1 = cp1.x, cy1 = cp1.y; - var cx2 = cp2.x, cy2 = cp2.y; - var x = x1 * (1 - pos) * (1 - pos) * (1 - pos) + +export function getBezierPoint (pos, from, cp1, cp2, to) { + const x1 = from.x; const y1 = from.y + const x2 = to.x; const y2 = to.y + const cx1 = cp1.x; const cy1 = cp1.y + const cx2 = cp2.x; const cy2 = cp2.y + const x = x1 * (1 - pos) * (1 - pos) * (1 - pos) + 3 * cx1 * pos * (1 - pos) * (1 - pos) + 3 * cx2 * pos * pos * (1 - pos) + - x2 * pos * pos * pos; - var y = y1 * (1 - pos) * (1 - pos) * (1 - pos) + + x2 * pos * pos * pos + const y = y1 * (1 - pos) * (1 - pos) * (1 - pos) + 3 * cy1 * pos * (1 - pos) * (1 - pos) + 3 * cy2 * pos * pos * (1 - pos) + - y2 * pos * pos * pos; - return new Point(x, y); + y2 * pos * pos * pos + return new Point(x, y) } -export function getControlPt(pt, to) { - var point = new Point(pt.x, pt.y, pt.direction, pt.anchorIndex, pt.id); - var dis = window.topologyControlPtDistance || distance; - if ((pt.direction === Direction.Up || pt.direction === Direction.Bottom) && Math.abs(pt.x - to.x) < 3) { - if (to.y > pt.y) { - dis = Math.round((to.y - pt.y) / 3); - point.y += dis; - } - else { - dis = Math.round((pt.y - to.y) / 3); - point.y -= dis; - } - return point; +export function getControlPt (pt, to) { + const point = new Point(pt.x, pt.y, pt.direction, pt.anchorIndex, pt.id) + let dis = window.topologyControlPtDistance || distance + if ((pt.direction === Direction.Up || pt.direction === Direction.Bottom) && Math.abs(pt.x - to.x) < 3) { + if (to.y > pt.y) { + dis = Math.round((to.y - pt.y) / 3) + point.y += dis + } else { + dis = Math.round((pt.y - to.y) / 3) + point.y -= dis } - if ((pt.direction === Direction.Left || pt.direction === Direction.Right) && Math.abs(pt.y - to.y) < 3) { - if (to.x > pt.x) { - dis = Math.round((to.x - pt.x) / 3); - point.x += dis; - } - else { - dis = Math.round((pt.x - to.x) / 3); - point.x -= dis; - } - return point; + return point + } + if ((pt.direction === Direction.Left || pt.direction === Direction.Right) && Math.abs(pt.y - to.y) < 3) { + if (to.x > pt.x) { + dis = Math.round((to.x - pt.x) / 3) + point.x += dis + } else { + dis = Math.round((pt.x - to.x) / 3) + point.x -= dis } - switch (pt.direction) { - case Direction.Up: - point.y -= dis; - break; - case Direction.Right: - point.x += dis; - break; - case Direction.Bottom: - point.y += dis; - break; - case Direction.Left: - point.x -= dis; - break; - } - return point; + return point + } + switch (pt.direction) { + case Direction.Up: + point.y -= dis + break + case Direction.Right: + point.x += dis + break + case Direction.Bottom: + point.y += dis + break + case Direction.Left: + point.x -= dis + break + } + return point } -export function generateStoreKey(pen, key) { - return pen.getTID() + "-" + key; +export function generateStoreKey (pen, key) { + return pen.getTID() + '-' + key } -//# sourceMappingURL=curve.js.map \ No newline at end of file +// # sourceMappingURL=curve.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/lines/line.js b/nezha-fronted/src/components/common/@topology/core/src/middles/lines/line.js index 96a714701..92f00d506 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/lines/line.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/lines/line.js @@ -1,11 +1,11 @@ -export function line(ctx, l) { - ctx.beginPath(); - ctx.moveTo(l.from.x, l.from.y); - ctx.lineTo(l.to.x, l.to.y); - ctx.stroke(); +export function line (ctx, l) { + ctx.beginPath() + ctx.moveTo(l.from.x, l.from.y) + ctx.lineTo(l.to.x, l.to.y) + ctx.stroke() } -export function lineControlPoints(ctx, l) { } -export function calcLineControlPoints(l) { - l.controlPoints = []; +export function lineControlPoints (ctx, l) { } +export function calcLineControlPoints (l) { + l.controlPoints = [] } -//# sourceMappingURL=line.js.map \ No newline at end of file +// # sourceMappingURL=line.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/lines/mind.js b/nezha-fronted/src/components/common/@topology/core/src/middles/lines/mind.js index f0c4b86d7..ac5b5ac97 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/lines/mind.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/lines/mind.js @@ -1,32 +1,32 @@ -import { Store } from 'le5le-store'; -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -import { generateStoreKey } from './curve'; -var distance = 20; -export function calcMindControlPoints(l) { - if (!l.from.direction) { - l.from.direction = Direction.Bottom; - } +import { Store } from 'le5le-store' +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +import { generateStoreKey } from './curve' +const distance = 20 +export function calcMindControlPoints (l) { + if (!l.from.direction) { + l.from.direction = Direction.Bottom + } + if (!l.to.direction) { + l.to.direction = (l.from.direction + 2) % 4 if (!l.to.direction) { - l.to.direction = (l.from.direction + 2) % 4; - if (!l.to.direction) { - l.to.direction = Direction.Left; - } + l.to.direction = Direction.Left } - switch (l.from.direction) { - case Direction.Up: - l.controlPoints = [new Point(l.from.x, l.from.y - distance), new Point(l.from.x, l.to.y)]; - break; - case Direction.Right: - l.controlPoints = [new Point(l.from.x + distance, l.from.y), new Point(l.from.x, l.to.y)]; - break; - case Direction.Bottom: - l.controlPoints = [new Point(l.from.x, l.from.y + distance), new Point(l.from.x, l.to.y)]; - break; - case Direction.Left: - l.controlPoints = [new Point(l.from.x - distance, l.from.y), new Point(l.from.x, l.to.y)]; - break; - } - Store.set(generateStoreKey(l, 'pts-') + l.id, undefined); + } + switch (l.from.direction) { + case Direction.Up: + l.controlPoints = [new Point(l.from.x, l.from.y - distance), new Point(l.from.x, l.to.y)] + break + case Direction.Right: + l.controlPoints = [new Point(l.from.x + distance, l.from.y), new Point(l.from.x, l.to.y)] + break + case Direction.Bottom: + l.controlPoints = [new Point(l.from.x, l.from.y + distance), new Point(l.from.x, l.to.y)] + break + case Direction.Left: + l.controlPoints = [new Point(l.from.x - distance, l.from.y), new Point(l.from.x, l.to.y)] + break + } + Store.set(generateStoreKey(l, 'pts-') + l.id, undefined) } -//# sourceMappingURL=mind.js.map \ No newline at end of file +// # sourceMappingURL=mind.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/lines/polyline.js b/nezha-fronted/src/components/common/@topology/core/src/middles/lines/polyline.js index 386305eb1..57a494f84 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/lines/polyline.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/lines/polyline.js @@ -1,309 +1,285 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -import { pointInLine } from '../../utils/canvas'; -var minDistance = 50; -export function polyline(ctx, l) { - ctx.beginPath(); - ctx.moveTo(l.from.x, l.from.y); - for (var _i = 0, _a = l.controlPoints; _i < _a.length; _i++) { - var item = _a[_i]; - ctx.lineTo(item.x, item.y); - } - ctx.lineTo(l.to.x, l.to.y); - ctx.stroke(); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +import { pointInLine } from '../../utils/canvas' +const minDistance = 50 +export function polyline (ctx, l) { + ctx.beginPath() + ctx.moveTo(l.from.x, l.from.y) + for (let _i = 0, _a = l.controlPoints; _i < _a.length; _i++) { + const item = _a[_i] + ctx.lineTo(item.x, item.y) + } + ctx.lineTo(l.to.x, l.to.y) + ctx.stroke() } -export function polylineControlPoints(ctx, l) { - ctx.save(); - ctx.fillStyle = '#fff'; - ctx.lineWidth = 2; - for (var _i = 0, _a = l.controlPoints; _i < _a.length; _i++) { - var item = _a[_i]; - ctx.beginPath(); - ctx.arc(item.x, item.y, 4, 0, Math.PI * 2); - ctx.stroke(); - ctx.fill(); - } - ctx.restore(); +export function polylineControlPoints (ctx, l) { + ctx.save() + ctx.fillStyle = '#fff' + ctx.lineWidth = 2 + for (let _i = 0, _a = l.controlPoints; _i < _a.length; _i++) { + const item = _a[_i] + ctx.beginPath() + ctx.arc(item.x, item.y, 4, 0, Math.PI * 2) + ctx.stroke() + ctx.fill() + } + ctx.restore() } -export function calcPolylineControlPoints(l) { - l.controlPoints = []; - var from = getDirectionPoint(l.from, l.to); - if (l.from.direction) { - l.controlPoints.push(from); - } - var to = getDirectionPoint(l.to, l.from); - var pts; - switch (from.direction) { - case Direction.Up: - pts = getNextPointByUp(from, to); - break; - case Direction.Right: - pts = getNextPointByRight(from, to); - break; - case Direction.Bottom: - pts = getNextPointByBottom(from, to); - break; - case Direction.Left: - pts = getNextPointByLeft(from, to); - break; - } - l.controlPoints.push.apply(l.controlPoints, pts); - if (l.to.direction) { - l.controlPoints.push(to); - } +export function calcPolylineControlPoints (l) { + l.controlPoints = [] + const from = getDirectionPoint(l.from, l.to) + if (l.from.direction) { + l.controlPoints.push(from) + } + const to = getDirectionPoint(l.to, l.from) + let pts + switch (from.direction) { + case Direction.Up: + pts = getNextPointByUp(from, to) + break + case Direction.Right: + pts = getNextPointByRight(from, to) + break + case Direction.Bottom: + pts = getNextPointByBottom(from, to) + break + case Direction.Left: + pts = getNextPointByLeft(from, to) + break + } + l.controlPoints.push.apply(l.controlPoints, pts) + if (l.to.direction) { + l.controlPoints.push(to) + } } -export function pointInPolyline(point, l) { - if (!l.controlPoints || !l.controlPoints.length) { - return pointInLine(point, l.from, l.to, l.lineWidth / 2); +export function pointInPolyline (point, l) { + if (!l.controlPoints || !l.controlPoints.length) { + return pointInLine(point, l.from, l.to, l.lineWidth / 2) + } + if (pointInLine(point, l.from, l.controlPoints[0])) { + return true + } + if (pointInLine(point, l.to, l.controlPoints[l.controlPoints.length - 1])) { + return true + } + for (let i = 0; i < l.controlPoints.length - 1; ++i) { + if (pointInLine(point, l.controlPoints[i], l.controlPoints[i + 1])) { + return true } - if (pointInLine(point, l.from, l.controlPoints[0])) { - return true; - } - if (pointInLine(point, l.to, l.controlPoints[l.controlPoints.length - 1])) { - return true; - } - for (var i = 0; i < l.controlPoints.length - 1; ++i) { - if (pointInLine(point, l.controlPoints[i], l.controlPoints[i + 1])) { - return true; - } - } - return false; + } + return false } -export function dockPolylineControlPoint(point, l) { - var pts = [l.from]; - pts.push.apply(pts, l.controlPoints); - pts.push(l.to); - for (var _i = 0, pts_1 = pts; _i < pts_1.length; _i++) { - var item = pts_1[_i]; - if (Math.abs(point.x - item.x) < 7) { - point.x = item.x; - } - if (Math.abs(point.y - item.y) < 7) { - point.y = item.y; - } +export function dockPolylineControlPoint (point, l) { + const pts = [l.from] + pts.push.apply(pts, l.controlPoints) + pts.push(l.to) + for (let _i = 0, pts_1 = pts; _i < pts_1.length; _i++) { + const item = pts_1[_i] + if (Math.abs(point.x - item.x) < 7) { + point.x = item.x } + if (Math.abs(point.y - item.y) < 7) { + point.y = item.y + } + } } -function getDirectionPoint(pt, to) { - var point = pt.clone(); - switch (pt.direction) { - case Direction.Up: - if (to.y < pt.y) { - point.y -= Math.round((pt.y - to.y) / 2); - } - else { - point.y -= minDistance; - } - break; - case Direction.Right: - if (to.x > pt.x) { - point.x += Math.round((to.x - pt.x) / 2); - } - else { - point.x += minDistance; - } - break; - case Direction.Bottom: - if (to.y > pt.y) { - point.y += Math.round((to.y - pt.y) / 2); - } - else { - point.y += minDistance; - } - break; - case Direction.Left: - if (to.x < pt.x) { - point.x -= Math.round((pt.x - to.x) / 2); - } - else { - point.x -= minDistance; - } - break; - } - return point; +function getDirectionPoint (pt, to) { + const point = pt.clone() + switch (pt.direction) { + case Direction.Up: + if (to.y < pt.y) { + point.y -= Math.round((pt.y - to.y) / 2) + } else { + point.y -= minDistance + } + break + case Direction.Right: + if (to.x > pt.x) { + point.x += Math.round((to.x - pt.x) / 2) + } else { + point.x += minDistance + } + break + case Direction.Bottom: + if (to.y > pt.y) { + point.y += Math.round((to.y - pt.y) / 2) + } else { + point.y += minDistance + } + break + case Direction.Left: + if (to.x < pt.x) { + point.x -= Math.round((pt.x - to.x) / 2) + } else { + point.x -= minDistance + } + break + } + return point } -function getNextPointByUp(from, to) { - if (from.x === to.x || from.y === to.y) { - return []; - } - // The to point above the from point. - if (from.y > to.y) { - if (to.direction === Direction.Up && from.y - to.y > 3 * minDistance) { - if (from.x < to.x) { - if (to.x - from.x < minDistance) { - return [new Point(from.x - 2 * minDistance, from.y), new Point(from.x - 2 * minDistance, to.y)]; - } - return [new Point(from.x, to.y)]; - } - else { - if (from.x - to.x < minDistance) { - return [new Point(from.x + 2 * minDistance, from.y), new Point(from.x + 2 * minDistance, to.y)]; - } - return [new Point(from.x, to.y)]; - } +function getNextPointByUp (from, to) { + if (from.x === to.x || from.y === to.y) { + return [] + } + // The to point above the from point. + if (from.y > to.y) { + if (to.direction === Direction.Up && from.y - to.y > 3 * minDistance) { + if (from.x < to.x) { + if (to.x - from.x < minDistance) { + return [new Point(from.x - 2 * minDistance, from.y), new Point(from.x - 2 * minDistance, to.y)] } - else { - // Left top - if ((to.direction === Direction.Left && from.x > to.x) || (to.direction === Direction.Right && from.x < to.x)) { - return [new Point(to.x, from.y)]; - } - return [new Point(from.x, to.y)]; + return [new Point(from.x, to.y)] + } else { + if (from.x - to.x < minDistance) { + return [new Point(from.x + 2 * minDistance, from.y), new Point(from.x + 2 * minDistance, to.y)] } - // The to point below the from point. - } - else { - if (to.direction === Direction.Bottom) { - if (from.x < to.x) { - return getHorizontalPoints(from, to); - } - else { - var pts = getHorizontalPoints(to, from); - return [pts[1], pts[0]]; - } - } - else { - return [new Point(to.x, from.y)]; - } - } -} -function getNextPointByBottom(from, to) { - if (from.x === to.x || from.y === to.y) { - return []; + return [new Point(from.x, to.y)] + } + } else { + // Left top + if ((to.direction === Direction.Left && from.x > to.x) || (to.direction === Direction.Right && from.x < to.x)) { + return [new Point(to.x, from.y)] + } + return [new Point(from.x, to.y)] } // The to point below the from point. - if (from.y < to.y) { - if (to.direction === Direction.Bottom && to.y - from.y > 3 * minDistance) { - if (from.x < to.x) { - if (to.x - from.x < minDistance) { - return [new Point(from.x - 2 * minDistance, from.y), new Point(from.x - 2 * minDistance, to.y)]; - } - return [new Point(from.x, to.y)]; - } - else { - if (from.x - to.x < minDistance) { - return [new Point(from.x + 2 * minDistance, from.y), new Point(from.x + 2 * minDistance, to.y)]; - } - return [new Point(from.x, to.y)]; - } - } - else { - if ((to.direction === Direction.Left && from.x > to.x) || (to.direction === Direction.Right && from.x < to.x)) { - return [new Point(to.x, from.y)]; - } - return [new Point(from.x, to.y)]; - } - // The to point below the from point. - } - else { - if (to.direction === Direction.Up) { - if (from.x < to.x) { - return getHorizontalPoints(from, to); - } - else { - var pts = getHorizontalPoints(to, from); - return [pts[1], pts[0]]; - } - } - else { - return [new Point(to.x, from.y)]; - } + } else { + if (to.direction === Direction.Bottom) { + if (from.x < to.x) { + return getHorizontalPoints(from, to) + } else { + const pts = getHorizontalPoints(to, from) + return [pts[1], pts[0]] + } + } else { + return [new Point(to.x, from.y)] } + } } -function getNextPointByLeft(from, to) { - if (from.x === to.x || from.y === to.y) { - return []; - } - // The to point is on the left. - if (from.x > to.x) { - if (to.direction === Direction.Left && from.x - to.x > 3 * minDistance) { - if (from.y < to.y) { - if (to.y - from.y < minDistance) { - return [new Point(from.x, from.y + 2 * minDistance), new Point(to.x, from.y + 2 * minDistance)]; - } - return [new Point(to.x, from.y)]; - } - else { - if (from.y - to.y < minDistance) { - return [new Point(from.x, from.y - 2 * minDistance), new Point(to.x, from.y - 2 * minDistance)]; - } - return [new Point(to.x, from.y)]; - } +function getNextPointByBottom (from, to) { + if (from.x === to.x || from.y === to.y) { + return [] + } + // The to point below the from point. + if (from.y < to.y) { + if (to.direction === Direction.Bottom && to.y - from.y > 3 * minDistance) { + if (from.x < to.x) { + if (to.x - from.x < minDistance) { + return [new Point(from.x - 2 * minDistance, from.y), new Point(from.x - 2 * minDistance, to.y)] } - else { - if (to.direction === Direction.Left || + return [new Point(from.x, to.y)] + } else { + if (from.x - to.x < minDistance) { + return [new Point(from.x + 2 * minDistance, from.y), new Point(from.x + 2 * minDistance, to.y)] + } + return [new Point(from.x, to.y)] + } + } else { + if ((to.direction === Direction.Left && from.x > to.x) || (to.direction === Direction.Right && from.x < to.x)) { + return [new Point(to.x, from.y)] + } + return [new Point(from.x, to.y)] + } + // The to point below the from point. + } else { + if (to.direction === Direction.Up) { + if (from.x < to.x) { + return getHorizontalPoints(from, to) + } else { + const pts = getHorizontalPoints(to, from) + return [pts[1], pts[0]] + } + } else { + return [new Point(to.x, from.y)] + } + } +} +function getNextPointByLeft (from, to) { + if (from.x === to.x || from.y === to.y) { + return [] + } + // The to point is on the left. + if (from.x > to.x) { + if (to.direction === Direction.Left && from.x - to.x > 3 * minDistance) { + if (from.y < to.y) { + if (to.y - from.y < minDistance) { + return [new Point(from.x, from.y + 2 * minDistance), new Point(to.x, from.y + 2 * minDistance)] + } + return [new Point(to.x, from.y)] + } else { + if (from.y - to.y < minDistance) { + return [new Point(from.x, from.y - 2 * minDistance), new Point(to.x, from.y - 2 * minDistance)] + } + return [new Point(to.x, from.y)] + } + } else { + if (to.direction === Direction.Left || (to.direction === Direction.Up && from.y < to.y) || (to.direction === Direction.Bottom && from.y > to.y)) { - return [new Point(to.x, from.y)]; - } - return [new Point(from.x, to.y)]; - } - // The to point is on the right. - } - else { - if (to.direction === Direction.Right) { - if (from.y < to.y) { - return getVerticalPoints(from, to); - } - else { - var pts = getVerticalPoints(to, from); - return [pts[1], pts[0]]; - } - } - else { - return [new Point(from.x, to.y)]; - } - } -} -function getNextPointByRight(from, to) { - if (from.x === to.x || from.y === to.y) { - return []; + return [new Point(to.x, from.y)] + } + return [new Point(from.x, to.y)] } // The to point is on the right. - if (from.x < to.x) { - if (to.direction === Direction.Right && to.x - from.x > 3 * minDistance) { - if (from.y < to.y) { - if (to.y - from.y < minDistance) { - return [new Point(from.x, from.y - 2 * minDistance), new Point(to.x, from.y - 2 * minDistance)]; - } - return [new Point(to.x, from.y)]; - } - else { - if (from.y - to.y < minDistance) { - return [new Point(from.x, from.y + 2 * minDistance), new Point(to.x, from.y + 2 * minDistance)]; - } - return [new Point(to.x, from.y)]; - } + } else { + if (to.direction === Direction.Right) { + if (from.y < to.y) { + return getVerticalPoints(from, to) + } else { + const pts = getVerticalPoints(to, from) + return [pts[1], pts[0]] + } + } else { + return [new Point(from.x, to.y)] + } + } +} +function getNextPointByRight (from, to) { + if (from.x === to.x || from.y === to.y) { + return [] + } + // The to point is on the right. + if (from.x < to.x) { + if (to.direction === Direction.Right && to.x - from.x > 3 * minDistance) { + if (from.y < to.y) { + if (to.y - from.y < minDistance) { + return [new Point(from.x, from.y - 2 * minDistance), new Point(to.x, from.y - 2 * minDistance)] } - else { - if (to.direction === Direction.Right || + return [new Point(to.x, from.y)] + } else { + if (from.y - to.y < minDistance) { + return [new Point(from.x, from.y + 2 * minDistance), new Point(to.x, from.y + 2 * minDistance)] + } + return [new Point(to.x, from.y)] + } + } else { + if (to.direction === Direction.Right || (to.direction === Direction.Up && from.y < to.y) || (to.direction === Direction.Bottom && from.y > to.y)) { - return [new Point(to.x, from.y)]; - } - return [new Point(from.x, to.y)]; - } - // The to point is on the left. + return [new Point(to.x, from.y)] + } + return [new Point(from.x, to.y)] } - else { - if (to.direction === Direction.Left) { - if (from.y < to.y) { - return getVerticalPoints(from, to); - } - else { - var pts = getVerticalPoints(to, from); - return [pts[1], pts[0]]; - } - } - else { - return [new Point(from.x, to.y)]; - } + // The to point is on the left. + } else { + if (to.direction === Direction.Left) { + if (from.y < to.y) { + return getVerticalPoints(from, to) + } else { + const pts = getVerticalPoints(to, from) + return [pts[1], pts[0]] + } + } else { + return [new Point(from.x, to.y)] } + } } -function getHorizontalPoints(left, right) { - var x = left.x + (right.x - left.x) / 2; - return [new Point(x, left.y), new Point(x, right.y)]; +function getHorizontalPoints (left, right) { + const x = left.x + (right.x - left.x) / 2 + return [new Point(x, left.y), new Point(x, right.y)] } -function getVerticalPoints(up, bottom) { - var y = up.y + (bottom.y - up.y) / 2; - return [new Point(up.x, y), new Point(bottom.x, y)]; +function getVerticalPoints (up, bottom) { + const y = up.y + (bottom.y - up.y) / 2 + return [new Point(up.x, y), new Point(bottom.x, y)] } -//# sourceMappingURL=polyline.js.map \ No newline at end of file +// # sourceMappingURL=polyline.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.anchor.js index 722c7893e..0221a5849 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.anchor.js @@ -1,7 +1,7 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function arrowAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function arrowAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)) } -//# sourceMappingURL=arrow.anchor.js.map \ No newline at end of file +// # sourceMappingURL=arrow.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.js index 131ddb52c..768ad3e16 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.js @@ -1,45 +1,45 @@ -export function leftArrow(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 2); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 3); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 3); - // ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function leftArrow (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 2) + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 3) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 3) + // ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3); + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3) + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3) + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -export function rightArrow(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 3); - ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height / 3); - ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2); - ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3); - ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 2) / 3); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function rightArrow (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 3) + ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height / 3) + ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2) + ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3) + ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 2) / 3) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -export function twowayArrow(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 2); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3); - ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height / 3); - ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2); - ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3); - ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function twowayArrow (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 2) + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3) + ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height / 3) + ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2) + ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3) + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3) + ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=arrow.js.map \ No newline at end of file +// # sourceMappingURL=arrow.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.rect.js index 3312eb48e..62fc29887 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/arrow.rect.js @@ -1,23 +1,23 @@ -import { Rect } from '../../models/rect'; -export function leftArrowIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '../../models/rect' +export function leftArrowIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function leftArrowTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height / 2, node.rect.height / 3); - node.fullTextRect = node.textRect; +export function leftArrowTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height / 2, node.rect.height / 3) + node.fullTextRect = node.textRect } -export function rightArrowIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +export function rightArrowIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function rightArrowTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height / 2, node.rect.height / 3); - node.fullTextRect = node.textRect; +export function rightArrowTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height / 2, node.rect.height / 3) + node.fullTextRect = node.textRect } -export function twowayArrowIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +export function twowayArrowIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function twowayArrowTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height, node.rect.height / 3); - node.fullTextRect = node.textRect; +export function twowayArrowTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height, node.rect.height / 3) + node.fullTextRect = node.textRect } -//# sourceMappingURL=arrow.rect.js.map \ No newline at end of file +// # sourceMappingURL=arrow.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.anchor.js index 42e9ae462..51222be8d 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.anchor.js @@ -1,18 +1,18 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function circleAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)); - for (var i = 5; i < 360; i += 5) { - if (i % 90 === 0) { - continue; - } - var direction = Math.round(i / 90); - var pt = new Point(node.rect.center.x + (Math.sin((i / 180) * Math.PI) * node.rect.width) / 2, node.rect.center.y + (Math.cos((i / 180) * Math.PI) * node.rect.height) / 2, direction); - pt.hidden = true; - node.anchors.push(pt); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function circleAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)) + for (let i = 5; i < 360; i += 5) { + if (i % 90 === 0) { + continue } + const direction = Math.round(i / 90) + const pt = new Point(node.rect.center.x + (Math.sin((i / 180) * Math.PI) * node.rect.width) / 2, node.rect.center.y + (Math.cos((i / 180) * Math.PI) * node.rect.height) / 2, direction) + pt.hidden = true + node.anchors.push(pt) + } } -//# sourceMappingURL=circle.anchor.js.map \ No newline at end of file +// # sourceMappingURL=circle.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.js index 50033f355..59a951aeb 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.js @@ -1,7 +1,7 @@ -export function circle(ctx, node) { - ctx.beginPath(); - ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function circle (ctx, node) { + ctx.beginPath() + ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=circle.js.map \ No newline at end of file +// # sourceMappingURL=circle.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.rect.js index 3d6c5d726..05e2e573a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/circle.rect.js @@ -1,27 +1,26 @@ -import { Rect } from '../../models/rect'; -export function circleIconRect(node) { - var w = node.rect.width / 2; - var h = node.rect.height / 2; - if (w > h) { - w = h; - } - else { - h = w; - } - var top = node.rect.height / 10; - if (top < 10) { - top = 10; - } - node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h); +import { Rect } from '../../models/rect' +export function circleIconRect (node) { + let w = node.rect.width / 2 + let h = node.rect.height / 2 + if (w > h) { + w = h + } else { + h = w + } + let top = node.rect.height / 10 + if (top < 10) { + top = 10 + } + node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h) } -export function circleTextRect(node) { - var bottom = node.rect.height / 20; - if (bottom < 5) { - bottom = 0; - } - node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + (node.rect.height * 2) / 3 - bottom, node.rect.width / 2, node.rect.height / 3 - 5); - var w = (node.rect.width * 5) / 7; - var h = (node.rect.height * 5) / 7; - node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h); +export function circleTextRect (node) { + let bottom = node.rect.height / 20 + if (bottom < 5) { + bottom = 0 + } + node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + (node.rect.height * 2) / 3 - bottom, node.rect.width / 2, node.rect.height / 3 - 5) + const w = (node.rect.width * 5) / 7 + const h = (node.rect.height * 5) / 7 + node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h) } -//# sourceMappingURL=circle.rect.js.map \ No newline at end of file +// # sourceMappingURL=circle.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.anchor.js index e93fad70f..463fa9c57 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.anchor.js @@ -1,9 +1,9 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function cloudAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 3) / 5, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 9, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 5, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + (node.rect.height * 4) / 5, Direction.Bottom)); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function cloudAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 3) / 5, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 9, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 5, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + (node.rect.height * 4) / 5, Direction.Bottom)) } -//# sourceMappingURL=cloud.anchor.js.map \ No newline at end of file +// # sourceMappingURL=cloud.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.js index ac4abf50b..d8c022c41 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.js @@ -1,11 +1,11 @@ -export function cloud(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 13) / 16); - ctx.bezierCurveTo(node.rect.x - node.rect.width / 15, node.rect.y + (node.rect.height * 13) / 16, node.rect.x - node.rect.width / 15, node.rect.y + (node.rect.height * 7) / 16, node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 7) / 16); - ctx.bezierCurveTo(node.rect.x + node.rect.width / 5, node.rect.y, node.rect.x + (node.rect.width * 4) / 5, node.rect.y, node.rect.x + (node.rect.width * 4) / 5, node.rect.y + (node.rect.height * 7) / 16); - ctx.bezierCurveTo(node.rect.x + (node.rect.width * 16) / 15, node.rect.y + (node.rect.height * 7) / 16, node.rect.x + (node.rect.width * 16) / 15, node.rect.y + (node.rect.height * 13) / 16, node.rect.x + (node.rect.width * 4) / 5, node.rect.y + (node.rect.height * 13) / 16); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function cloud (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 13) / 16) + ctx.bezierCurveTo(node.rect.x - node.rect.width / 15, node.rect.y + (node.rect.height * 13) / 16, node.rect.x - node.rect.width / 15, node.rect.y + (node.rect.height * 7) / 16, node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 7) / 16) + ctx.bezierCurveTo(node.rect.x + node.rect.width / 5, node.rect.y, node.rect.x + (node.rect.width * 4) / 5, node.rect.y, node.rect.x + (node.rect.width * 4) / 5, node.rect.y + (node.rect.height * 7) / 16) + ctx.bezierCurveTo(node.rect.x + (node.rect.width * 16) / 15, node.rect.y + (node.rect.height * 7) / 16, node.rect.x + (node.rect.width * 16) / 15, node.rect.y + (node.rect.height * 13) / 16, node.rect.x + (node.rect.width * 4) / 5, node.rect.y + (node.rect.height * 13) / 16) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=cloud.js.map \ No newline at end of file +// # sourceMappingURL=cloud.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.rect.js index 431ccfcee..964188f3e 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cloud.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '../../models/rect'; -export function cloudIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '../../models/rect' +export function cloudIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function cloudTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + node.rect.height / 4, node.rect.width / 2, (node.rect.height * 6) / 11); - node.fullTextRect = node.textRect; +export function cloudTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + node.rect.height / 4, node.rect.width / 2, (node.rect.height * 6) / 11) + node.fullTextRect = node.textRect } -//# sourceMappingURL=cloud.rect.js.map \ No newline at end of file +// # sourceMappingURL=cloud.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.anchor.js index 28878e002..f294e59ac 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.anchor.js @@ -1,10 +1,10 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function cubeAnchors(node) { - var offset = node.z * Math.sin((45 * Math.PI) / 180); - node.anchors.push(new Point(node.rect.x, node.rect.ey - (node.rect.height - offset) / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + offset / 2, Direction.Up)); - node.anchors.push(new Point(node.rect.ex - offset / 2, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + (node.rect.width - offset) / 2, node.rect.y + node.rect.height, Direction.Bottom)); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function cubeAnchors (node) { + const offset = node.z * Math.sin((45 * Math.PI) / 180) + node.anchors.push(new Point(node.rect.x, node.rect.ey - (node.rect.height - offset) / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + offset / 2, Direction.Up)) + node.anchors.push(new Point(node.rect.ex - offset / 2, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + (node.rect.width - offset) / 2, node.rect.y + node.rect.height, Direction.Bottom)) } -//# sourceMappingURL=cube.anchor.js.map \ No newline at end of file +// # sourceMappingURL=cube.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.js index dfc8fa904..45e776815 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.js @@ -1,5 +1,5 @@ -import { Cube } from './cube.model'; -export function cube(ctx, node) { - new Cube(node.rect, node.z, node.zRotate, node.fillStyle, node.strokeStyle).render(ctx); +import { Cube } from './cube.model' +export function cube (ctx, node) { + new Cube(node.rect, node.z, node.zRotate, node.fillStyle, node.strokeStyle).render(ctx) } -//# sourceMappingURL=cube.js.map \ No newline at end of file +// # sourceMappingURL=cube.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.model.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.model.js index 4296cedfd..c0fc8b860 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.model.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.model.js @@ -1,64 +1,63 @@ -import { Point } from '../../models/point'; -import { pSBC } from '../../utils/math'; -var Surface = /** @class */ (function () { - function Surface(pt1, pt2, pt3, pt4, fillStyle, strokeStyle) { - if (fillStyle === void 0) { fillStyle = ''; } - if (strokeStyle === void 0) { strokeStyle = ''; } - this.points = []; - this.fillStyle = ''; - this.strokeStyle = ''; - this.points.push(pt1); - this.points.push(pt2); - this.points.push(pt3); - this.points.push(pt4); - this.fillStyle = fillStyle; - this.strokeStyle = strokeStyle || fillStyle; +import { Point } from '../../models/point' +import { pSBC } from '../../utils/math' +const Surface = /** @class */ (function () { + function Surface (pt1, pt2, pt3, pt4, fillStyle, strokeStyle) { + if (fillStyle === void 0) { fillStyle = '' } + if (strokeStyle === void 0) { strokeStyle = '' } + this.points = [] + this.fillStyle = '' + this.strokeStyle = '' + this.points.push(pt1) + this.points.push(pt2) + this.points.push(pt3) + this.points.push(pt4) + this.fillStyle = fillStyle + this.strokeStyle = strokeStyle || fillStyle + } + Surface.prototype.render = function (ctx) { + ctx.save() + ctx.fillStyle = this.fillStyle + ctx.strokeStyle = this.strokeStyle + ctx.beginPath() + for (let i = 0; i < this.points.length; ++i) { + if (i) { + ctx.lineTo(this.points[i].x, this.points[i].y) + } else { + ctx.moveTo(this.points[i].x, this.points[i].y) + } } - Surface.prototype.render = function (ctx) { - ctx.save(); - ctx.fillStyle = this.fillStyle; - ctx.strokeStyle = this.strokeStyle; - ctx.beginPath(); - for (var i = 0; i < this.points.length; ++i) { - if (i) { - ctx.lineTo(this.points[i].x, this.points[i].y); - } - else { - ctx.moveTo(this.points[i].x, this.points[i].y); - } - } - ctx.closePath(); - this.fillStyle && ctx.fill(); - ctx.stroke(); - ctx.restore(); - }; - return Surface; -}()); -export { Surface }; -var Cube = /** @class */ (function () { - function Cube(rect, z, zRotate, fillStyle, strokeStyle) { - if (fillStyle === void 0) { fillStyle = '#ddd'; } - if (strokeStyle === void 0) { strokeStyle = '#ccc'; } - this.surfaces = []; - var offset = z * Math.sin((45 * Math.PI) / 180); - var p1 = new Point(rect.x, rect.y + offset); - var p2 = new Point(rect.ex - offset, rect.y + offset); - var p3 = new Point(rect.ex - offset, rect.ey); - var p4 = new Point(rect.x, rect.ey); - // front - this.surfaces.push(new Surface(p1, p2, p3, p4, fillStyle, strokeStyle)); - // up - this.surfaces.push(new Surface(p1, new Point(rect.x + offset, rect.y), new Point(rect.ex, rect.y), p2, pSBC(0.5, fillStyle), strokeStyle)); - // right - this.surfaces.push(new Surface(p2, new Point(rect.ex, rect.y), new Point(rect.ex, rect.ey - offset), p3, pSBC(0.6, fillStyle), strokeStyle)); + ctx.closePath() + this.fillStyle && ctx.fill() + ctx.stroke() + ctx.restore() + } + return Surface +}()) +export { Surface } +const Cube = /** @class */ (function () { + function Cube (rect, z, zRotate, fillStyle, strokeStyle) { + if (fillStyle === void 0) { fillStyle = '#ddd' } + if (strokeStyle === void 0) { strokeStyle = '#ccc' } + this.surfaces = [] + const offset = z * Math.sin((45 * Math.PI) / 180) + const p1 = new Point(rect.x, rect.y + offset) + const p2 = new Point(rect.ex - offset, rect.y + offset) + const p3 = new Point(rect.ex - offset, rect.ey) + const p4 = new Point(rect.x, rect.ey) + // front + this.surfaces.push(new Surface(p1, p2, p3, p4, fillStyle, strokeStyle)) + // up + this.surfaces.push(new Surface(p1, new Point(rect.x + offset, rect.y), new Point(rect.ex, rect.y), p2, pSBC(0.5, fillStyle), strokeStyle)) + // right + this.surfaces.push(new Surface(p2, new Point(rect.ex, rect.y), new Point(rect.ex, rect.ey - offset), p3, pSBC(0.6, fillStyle), strokeStyle)) + } + Cube.prototype.render = function (ctx) { + for (let _i = 0, _a = this.surfaces; _i < _a.length; _i++) { + const item = _a[_i] + item.render(ctx) } - Cube.prototype.render = function (ctx) { - for (var _i = 0, _a = this.surfaces; _i < _a.length; _i++) { - var item = _a[_i]; - item.render(ctx); - } - }; - return Cube; -}()); -export { Cube }; -//# sourceMappingURL=cube.model.js.map \ No newline at end of file + } + return Cube +}()) +export { Cube } +// # sourceMappingURL=cube.model.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.rect.js index 758f0e314..94c3703ef 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/cube.rect.js @@ -1,11 +1,11 @@ -import { Rect } from '../../models/rect'; -export function cubeIconRect(node) { - node.fullIconRect = node.fullTextRect; - node.iconRect = new Rect(node.fullIconRect.x, node.fullIconRect.y, node.fullIconRect.width, (node.fullIconRect.height * 2) / 3); +import { Rect } from '../../models/rect' +export function cubeIconRect (node) { + node.fullIconRect = node.fullTextRect + node.iconRect = new Rect(node.fullIconRect.x, node.fullIconRect.y, node.fullIconRect.width, (node.fullIconRect.height * 2) / 3) } -export function cubeTextRect(node) { - var offset = node.z * Math.sin((45 * Math.PI) / 180); - node.fullTextRect = new Rect(node.rect.x, node.rect.y + offset, node.rect.width - offset, node.rect.height - offset); - node.textRect = new Rect(node.fullTextRect.x + 10, node.fullTextRect.y + (node.fullTextRect.height * 2) / 3, node.fullTextRect.width - 20, node.fullTextRect.height / 3 - 5); +export function cubeTextRect (node) { + const offset = node.z * Math.sin((45 * Math.PI) / 180) + node.fullTextRect = new Rect(node.rect.x, node.rect.y + offset, node.rect.width - offset, node.rect.height - offset) + node.textRect = new Rect(node.fullTextRect.x + 10, node.fullTextRect.y + (node.fullTextRect.height * 2) / 3, node.fullTextRect.width - 20, node.fullTextRect.height / 3 - 5) } -//# sourceMappingURL=cube.rect.js.map \ No newline at end of file +// # sourceMappingURL=cube.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/diamond.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/diamond.js index d78c1c8d9..c756e9acc 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/diamond.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/diamond.js @@ -1,11 +1,11 @@ -export function diamond(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2); - ctx.lineTo(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function diamond (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2) + ctx.lineTo(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=diamond.js.map \ No newline at end of file +// # sourceMappingURL=diamond.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/diamond.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/diamond.rect.js index c78afeb28..b41803197 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/diamond.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/diamond.rect.js @@ -1,27 +1,26 @@ -import { Rect } from '../../models/rect'; -export function diamondIconRect(node) { - var w = node.rect.width / 3; - var h = node.rect.height / 3; - if (w > h) { - w = h; - } - else { - h = w; - } - var top = node.rect.width / 5; - if (top < 10) { - top = 10; - } - node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h); +import { Rect } from '../../models/rect' +export function diamondIconRect (node) { + let w = node.rect.width / 3 + let h = node.rect.height / 3 + if (w > h) { + w = h + } else { + h = w + } + let top = node.rect.width / 5 + if (top < 10) { + top = 10 + } + node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h) } -export function diamondTextRect(node) { - var bottom = node.rect.height / 10; - if (bottom < 5) { - bottom = 0; - } - node.textRect = new Rect(node.rect.x + node.rect.width / 3, node.rect.y + (node.rect.height * 2) / 3 - bottom, node.rect.width / 3, node.rect.height / 3 - 5); - var w = node.rect.width / 2; - var h = (node.rect.height * 1) / 2; - node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h); +export function diamondTextRect (node) { + let bottom = node.rect.height / 10 + if (bottom < 5) { + bottom = 0 + } + node.textRect = new Rect(node.rect.x + node.rect.width / 3, node.rect.y + (node.rect.height * 2) / 3 - bottom, node.rect.width / 3, node.rect.height / 3 - 5) + const w = node.rect.width / 2 + const h = (node.rect.height * 1) / 2 + node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h) } -//# sourceMappingURL=diamond.rect.js.map \ No newline at end of file +// # sourceMappingURL=diamond.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/file.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/file.js index 30fc33523..9c270f73d 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/file.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/file.js @@ -1,16 +1,16 @@ -export function file(ctx, node) { - ctx.beginPath(); - var offsetX = node.rect.width / 6; - ctx.moveTo(node.rect.x, node.rect.y); - ctx.lineTo(node.rect.ex - offsetX, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.y + offsetX); - ctx.lineTo(node.rect.ex, node.rect.ey); - ctx.lineTo(node.rect.x, node.rect.ey); - ctx.closePath(); - ctx.moveTo(node.rect.ex - offsetX, node.rect.y); - ctx.lineTo(node.rect.ex - offsetX, node.rect.y + offsetX); - ctx.lineTo(node.rect.ex, node.rect.y + offsetX); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function file (ctx, node) { + ctx.beginPath() + const offsetX = node.rect.width / 6 + ctx.moveTo(node.rect.x, node.rect.y) + ctx.lineTo(node.rect.ex - offsetX, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.y + offsetX) + ctx.lineTo(node.rect.ex, node.rect.ey) + ctx.lineTo(node.rect.x, node.rect.ey) + ctx.closePath() + ctx.moveTo(node.rect.ex - offsetX, node.rect.y) + ctx.lineTo(node.rect.ex - offsetX, node.rect.y + offsetX) + ctx.lineTo(node.rect.ex, node.rect.y + offsetX); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=file.js.map \ No newline at end of file +// # sourceMappingURL=file.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/graffiti.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/graffiti.anchor.js index 681458c20..145beace7 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/graffiti.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/graffiti.anchor.js @@ -1,18 +1,17 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function graffitiAnchors(node) { - if (!node.points || !node.points.length) { - return; - } - var pt1 = node.points[0]; - var pt2 = node.points[node.points.length - 1]; - if (pt1.x < pt2.x) { - node.anchors.push(new Point(pt1.x, pt1.y, Direction.Left)); - node.anchors.push(new Point(pt2.x, pt2.y, Direction.Right)); - } - else { - node.anchors.push(new Point(pt1.x, pt1.y, Direction.Right)); - node.anchors.push(new Point(pt2.x, pt2.y, Direction.Left)); - } +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function graffitiAnchors (node) { + if (!node.points || !node.points.length) { + return + } + const pt1 = node.points[0] + const pt2 = node.points[node.points.length - 1] + if (pt1.x < pt2.x) { + node.anchors.push(new Point(pt1.x, pt1.y, Direction.Left)) + node.anchors.push(new Point(pt2.x, pt2.y, Direction.Right)) + } else { + node.anchors.push(new Point(pt1.x, pt1.y, Direction.Right)) + node.anchors.push(new Point(pt2.x, pt2.y, Direction.Left)) + } } -//# sourceMappingURL=graffiti.anchor.js.map \ No newline at end of file +// # sourceMappingURL=graffiti.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/graffiti.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/graffiti.js index c274a4f1a..61a1b5a62 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/graffiti.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/graffiti.js @@ -1,14 +1,14 @@ -export function graffiti(ctx, node) { - if (!node.points || !node.points[0]) { - return; - } - ctx.beginPath(); - ctx.moveTo(node.points[0].x, node.points[0].y); - node.points.forEach(function (pt) { - ctx.lineTo(pt.x, pt.y); - }); - node['closePath'] && !node['doing'] && ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function graffiti (ctx, node) { + if (!node.points || !node.points[0]) { + return + } + ctx.beginPath() + ctx.moveTo(node.points[0].x, node.points[0].y) + node.points.forEach(function (pt) { + ctx.lineTo(pt.x, pt.y) + }) + node.closePath && !node.doing && ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=graffiti.js.map \ No newline at end of file +// # sourceMappingURL=graffiti.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.anchor.js index 3ee3c8fcc..b35eaef9b 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.anchor.js @@ -1,21 +1,21 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function hexagonAnchors(node) { - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)); - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); - var ptLT = new Point(node.rect.x + node.rect.width / 10, node.rect.y + node.rect.height / 4, Direction.Left); - ptLT.hidden = true; - node.anchors.push(ptLT); - var ptRT = new Point(node.rect.x + node.rect.width / 10, node.rect.y + (node.rect.height * 3) / 4, Direction.Left); - ptRT.hidden = true; - node.anchors.push(ptRT); - var ptLB = new Point(node.rect.x + (node.rect.width * 9) / 10, node.rect.y + node.rect.height / 4, Direction.Right); - ptLB.hidden = true; - node.anchors.push(ptLB); - var ptRB = new Point(node.rect.x + (node.rect.width * 9) / 10, node.rect.y + (node.rect.height * 3) / 4, Direction.Right); - ptRB.hidden = true; - node.anchors.push(ptRB); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function hexagonAnchors (node) { + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)) + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) + const ptLT = new Point(node.rect.x + node.rect.width / 10, node.rect.y + node.rect.height / 4, Direction.Left) + ptLT.hidden = true + node.anchors.push(ptLT) + const ptRT = new Point(node.rect.x + node.rect.width / 10, node.rect.y + (node.rect.height * 3) / 4, Direction.Left) + ptRT.hidden = true + node.anchors.push(ptRT) + const ptLB = new Point(node.rect.x + (node.rect.width * 9) / 10, node.rect.y + node.rect.height / 4, Direction.Right) + ptLB.hidden = true + node.anchors.push(ptLB) + const ptRB = new Point(node.rect.x + (node.rect.width * 9) / 10, node.rect.y + (node.rect.height * 3) / 4, Direction.Right) + ptRB.hidden = true + node.anchors.push(ptRB) } -//# sourceMappingURL=hexagon.anchor.js.map \ No newline at end of file +// # sourceMappingURL=hexagon.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.js index ec8937f2a..bbf8f0bf1 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.js @@ -1,14 +1,14 @@ -export function hexagon(ctx, node) { - ctx.beginPath(); - var pos = node.rect.width / 5; - ctx.moveTo(node.rect.x + pos, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width - pos, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2); - ctx.lineTo(node.rect.x + node.rect.width - pos, node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x + pos, node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function hexagon (ctx, node) { + ctx.beginPath() + const pos = node.rect.width / 5 + ctx.moveTo(node.rect.x + pos, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width - pos, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2) + ctx.lineTo(node.rect.x + node.rect.width - pos, node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x + pos, node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=hexagon.js.map \ No newline at end of file +// # sourceMappingURL=hexagon.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.rect.js index 3a2573a2c..bbcc2968a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/hexagon.rect.js @@ -1,14 +1,14 @@ -import { Rect } from '../../models/rect'; -export function hexagonIconRect(node) { - var w = (node.rect.width * 3) / 5; - var h = (node.rect.height * 3) / 4; - node.iconRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, h - node.paddingTopNum - node.paddingBottomNum); - node.fullIconRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum); +import { Rect } from '../../models/rect' +export function hexagonIconRect (node) { + const w = (node.rect.width * 3) / 5 + const h = (node.rect.height * 3) / 4 + node.iconRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, h - node.paddingTopNum - node.paddingBottomNum) + node.fullIconRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum) } -export function hexagonTextRect(node) { - var w = (node.rect.width * 3) / 5; - var h = node.rect.height / 4; - node.textRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.rect.height - h + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, h); - node.fullTextRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum); +export function hexagonTextRect (node) { + const w = (node.rect.width * 3) / 5 + const h = node.rect.height / 4 + node.textRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.rect.height - h + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, h) + node.fullTextRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum) } -//# sourceMappingURL=hexagon.rect.js.map \ No newline at end of file +// # sourceMappingURL=hexagon.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/image.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/image.anchor.js index bedad822d..f5ff7fe78 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/image.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/image.anchor.js @@ -1,19 +1,18 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function imageAnchors(node) { - var textWidth = 0; - var textHeight = 0; - if (node.text) { - if (node.paddingRightNum) { - textWidth = node.paddingRightNum; - } - else { - textHeight = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1); - } +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function imageAnchors (node) { + let textWidth = 0 + let textHeight = 0 + if (node.text) { + if (node.paddingRightNum) { + textWidth = node.paddingRightNum + } else { + textHeight = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1) } - node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height - textHeight) / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + (node.rect.width - textWidth) / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width - textWidth, node.rect.y + (node.rect.height - textHeight) / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + (node.rect.width - textWidth) / 2, node.rect.y + node.rect.height - textHeight, Direction.Bottom)); + } + node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height - textHeight) / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + (node.rect.width - textWidth) / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width - textWidth, node.rect.y + (node.rect.height - textHeight) / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + (node.rect.width - textWidth) / 2, node.rect.y + node.rect.height - textHeight, Direction.Bottom)) } -//# sourceMappingURL=image.anchor.js.map \ No newline at end of file +// # sourceMappingURL=image.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/image.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/image.rect.js index c02e0c152..5152ef54a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/image.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/image.rect.js @@ -1,27 +1,25 @@ -import { Rect } from '../../models/rect'; -export function imageIconRect(node) { - var textWidth = 0; - var textHeight = 0; - if (node.text) { - if (node.paddingRightNum) { - textWidth = node.paddingRightNum; - } - else { - textHeight = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1); - } - } - node.iconRect = new Rect(node.rect.x, node.rect.y, node.rect.width - textWidth, node.rect.height - textHeight); - node.fullIconRect = node.rect; -} -export function imageTextRect(node) { +import { Rect } from '../../models/rect' +export function imageIconRect (node) { + let textWidth = 0 + let textHeight = 0 + if (node.text) { if (node.paddingRightNum) { - var width = node.paddingRightNum - 5; - node.textRect = new Rect(node.rect.x + node.rect.width - width, node.rect.y, width, node.rect.height - node.textOffsetY * 2); + textWidth = node.paddingRightNum + } else { + textHeight = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1) } - else { - var height = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1); - node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height - height, node.rect.width - node.textOffsetX * 2, height); - } - node.fullTextRect = node.rect; + } + node.iconRect = new Rect(node.rect.x, node.rect.y, node.rect.width - textWidth, node.rect.height - textHeight) + node.fullIconRect = node.rect } -//# sourceMappingURL=image.rect.js.map \ No newline at end of file +export function imageTextRect (node) { + if (node.paddingRightNum) { + const width = node.paddingRightNum - 5 + node.textRect = new Rect(node.rect.x + node.rect.width - width, node.rect.y, width, node.rect.height - node.textOffsetY * 2) + } else { + const height = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1) + node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height - height, node.rect.width - node.textOffsetX * 2, height) + } + node.fullTextRect = node.rect +} +// # sourceMappingURL=image.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.anchor.js index 76c77404d..be35e466a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.anchor.js @@ -1,14 +1,14 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function lineAnchors(node) { - var y = node.rect.y + node.rect.height / 2; - node.anchors.push(new Point(node.rect.x, y, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width, y, Direction.Right)); - var scale = topology.data.scale || 1; // 取全局的 scale 属性 - for (var i = node.rect.x + 5 * scale; i < node.rect.ex; i += 5 * scale) { - var pt = new Point(i, y, Direction.Bottom); - pt.hidden = true; - node.anchors.push(pt); - } +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function lineAnchors (node) { + const y = node.rect.y + node.rect.height / 2 + node.anchors.push(new Point(node.rect.x, y, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width, y, Direction.Right)) + const scale = topology.data.scale || 1 // 取全局的 scale 属性 + for (let i = node.rect.x + 5 * scale; i < node.rect.ex; i += 5 * scale) { + const pt = new Point(i, y, Direction.Bottom) + pt.hidden = true + node.anchors.push(pt) + } } -//# sourceMappingURL=line.anchor.js.map \ No newline at end of file +// # sourceMappingURL=line.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.js index 1d713bc55..c4f308d85 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.js @@ -1,8 +1,8 @@ -export function line(ctx, node) { - ctx.beginPath(); - var y = node.rect.y + node.rect.height / 2; - ctx.moveTo(node.rect.x, y); - ctx.lineTo(node.rect.x + node.rect.width, y); - ctx.stroke(); +export function line (ctx, node) { + ctx.beginPath() + const y = node.rect.y + node.rect.height / 2 + ctx.moveTo(node.rect.x, y) + ctx.lineTo(node.rect.x + node.rect.width, y) + ctx.stroke() } -//# sourceMappingURL=line.js.map \ No newline at end of file +// # sourceMappingURL=line.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.rect.js index 27993633f..38b011a53 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/line.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '../../models/rect'; -export function lineIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '../../models/rect' +export function lineIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function lineTextRect(node) { - node.fullTextRect = new Rect(node.rect.x + 10, node.rect.y + node.rect.height / 2 - 20, node.rect.width - 20, 20); - node.textRect = node.fullTextRect; +export function lineTextRect (node) { + node.fullTextRect = new Rect(node.rect.x + 10, node.rect.y + node.rect.height / 2 - 20, node.rect.width - 20, 20) + node.textRect = node.fullTextRect } -//# sourceMappingURL=line.rect.js.map \ No newline at end of file +// # sourceMappingURL=line.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/lines.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/lines.js index 899e097c8..e7b01dca8 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/lines.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/lines.js @@ -1,27 +1,25 @@ -export function lines(ctx, node) { - if (!node.points || !node.points[1]) { - return; +export function lines (ctx, node) { + if (!node.points || !node.points[1]) { + return + } + ctx.beginPath() + ctx.moveTo(node.points[0].x, node.points[0].y) + for (let i = 1; i < node.points.length;) { + // curve 控制点 + if (node.points[i].data) { + if (node.points[i + 2]) { + ctx.bezierCurveTo(node.points[i].x, node.points[i].y, node.points[i + 1].x, node.points[i + 1].y, node.points[i + 2].x, node.points[i + 2].y) + i += 2 + } else { + break + } + } else { + ctx.lineTo(node.points[i].x, node.points[i].y) + ++i } - ctx.beginPath(); - ctx.moveTo(node.points[0].x, node.points[0].y); - for (var i = 1; i < node.points.length;) { - // curve 控制点 - if (node.points[i].data) { - if (node.points[i + 2]) { - ctx.bezierCurveTo(node.points[i].x, node.points[i].y, node.points[i + 1].x, node.points[i + 1].y, node.points[i + 2].x, node.points[i + 2].y); - i += 2; - } - else { - break; - } - } - else { - ctx.lineTo(node.points[i].x, node.points[i].y); - ++i; - } - } - node['closePath'] && !node['doing'] && ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); + } + node.closePath && !node.doing && ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=lines.js.map \ No newline at end of file +// # sourceMappingURL=lines.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.anchor.js index f32e0a9a7..32054811b 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.anchor.js @@ -1,9 +1,9 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function messageAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 3) / 8, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 8, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 4, node.rect.ey, Direction.Bottom)); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function messageAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 3) / 8, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 8, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 4, node.rect.ey, Direction.Bottom)) } -//# sourceMappingURL=message.anchor.js.map \ No newline at end of file +// # sourceMappingURL=message.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.js index deebcd0c9..9cd76032f 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.js @@ -1,14 +1,14 @@ -export function message(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 4); - ctx.lineTo(node.rect.x + (node.rect.width * 8) / 16, node.rect.y + (node.rect.height * 3) / 4); - ctx.lineTo(node.rect.x + node.rect.width / 4, node.rect.ey); - ctx.lineTo(node.rect.x + (node.rect.width * 5) / 16, node.rect.y + (node.rect.height * 3) / 4); - ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 3) / 4); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function message (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 4) + ctx.lineTo(node.rect.x + (node.rect.width * 8) / 16, node.rect.y + (node.rect.height * 3) / 4) + ctx.lineTo(node.rect.x + node.rect.width / 4, node.rect.ey) + ctx.lineTo(node.rect.x + (node.rect.width * 5) / 16, node.rect.y + (node.rect.height * 3) / 4) + ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 3) / 4) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=message.js.map \ No newline at end of file +// # sourceMappingURL=message.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.rect.js index 2b9d5b98a..4843e5abd 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/message.rect.js @@ -1,10 +1,10 @@ -import { Rect } from '../../models/rect'; -export function messageIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); - node.fullIconRect = node.iconRect; +import { Rect } from '../../models/rect' +export function messageIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) + node.fullIconRect = node.iconRect } -export function messageTextRect(node) { - node.textRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, (node.rect.height * 3) / 4 - node.paddingTopNum - node.paddingBottomNum); - node.fullTextRect = node.textRect; +export function messageTextRect (node) { + node.textRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, (node.rect.height * 3) / 4 - node.paddingTopNum - node.paddingBottomNum) + node.fullTextRect = node.textRect } -//# sourceMappingURL=message.rect.js.map \ No newline at end of file +// # sourceMappingURL=message.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindLine.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindLine.anchor.js index 22d18797d..b627bb9b7 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindLine.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindLine.anchor.js @@ -1,6 +1,6 @@ -import { Point } from '../../models/point'; -export function mindLineAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height, 4)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height, 2)); +import { Point } from '../../models/point' +export function mindLineAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height, 4)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height, 2)) } -//# sourceMappingURL=mindLine.anchor.js.map \ No newline at end of file +// # sourceMappingURL=mindLine.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindLine.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindLine.js index 23811acd6..dd8a7a0ab 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindLine.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindLine.js @@ -1,8 +1,8 @@ -export function mindLine(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x, node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height); - ctx.closePath(); - ctx.stroke(); +export function mindLine (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x, node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height) + ctx.closePath() + ctx.stroke() } -//# sourceMappingURL=mindLine.js.map \ No newline at end of file +// # sourceMappingURL=mindLine.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindNode.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindNode.anchor.js index f920a3577..a45b7c4e6 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindNode.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/mindNode.anchor.js @@ -1,94 +1,90 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function mindNodeAnchors(node) { - var r = borderRadius(node); - // 上四 - var topN = 5; // 上方节点个数,控制位置,实际节点数依然是 4 个 - for (var i = 0; i < topN; i++) { - if (i === 2) { - continue; - } - var x = node.rect.x + (node.rect.width * (i + 1)) / (topN + 1); - var y = node.rect.y; - if (x < node.rect.x + r) { - // 在左侧圆角 - y = getYByCircle(node.rect.x + r, y + r, x, r, -1); - } - else if (x > node.rect.x + node.rect.width - r) { - // 在右侧圆角 - y = getYByCircle(node.rect.x + node.rect.width - r, y + r, x, r, -1); - } - node.anchors.push(new Point(x, y, Direction.Up)); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function mindNodeAnchors (node) { + const r = borderRadius(node) + // 上四 + const topN = 5 // 上方节点个数,控制位置,实际节点数依然是 4 个 + for (var i = 0; i < topN; i++) { + if (i === 2) { + continue } - // 右三 - var rightN = 3; // 右侧节点数 - for (var i = 0; i < rightN; i++) { - var y = node.rect.y + (node.rect.height * (i + 1)) / (rightN + 1); - var x = node.rect.x + node.rect.width; - if (y < node.rect.y + r) { - // 在上侧圆角以内 - x = getXByCircle(x - r, node.rect.y + r, y, r); - } - else if (y > node.rect.y + node.rect.height - r) { - // 下侧圆角 - x = getXByCircle(x - r, node.rect.y + node.rect.height - r, y, r); - } - node.anchors.push(new Point(x, y, Direction.Right)); + var x = node.rect.x + (node.rect.width * (i + 1)) / (topN + 1) + var y = node.rect.y + if (x < node.rect.x + r) { + // 在左侧圆角 + y = getYByCircle(node.rect.x + r, y + r, x, r, -1) + } else if (x > node.rect.x + node.rect.width - r) { + // 在右侧圆角 + y = getYByCircle(node.rect.x + node.rect.width - r, y + r, x, r, -1) } - // 下四 - var bottomN = 5; // 下侧节点数 - for (var i = 0; i < bottomN; i++) { - if (i === 2) { - continue; - } - var x = node.rect.x + (node.rect.width * (i + 1)) / (bottomN + 1); - var y = node.rect.y + node.rect.height; - if (x < node.rect.x + r) { - // 在左侧圆角 - y = getYByCircle(node.rect.x + r, y - r, x, r); - } - else if (x > node.rect.x + node.rect.width - r) { - // 在右侧圆角 - y = getYByCircle(node.rect.x + node.rect.width - r, y - r, x, r); - } - node.anchors.push(new Point(x, y, Direction.Bottom)); + node.anchors.push(new Point(x, y, Direction.Up)) + } + // 右三 + const rightN = 3 // 右侧节点数 + for (var i = 0; i < rightN; i++) { + var y = node.rect.y + (node.rect.height * (i + 1)) / (rightN + 1) + var x = node.rect.x + node.rect.width + if (y < node.rect.y + r) { + // 在上侧圆角以内 + x = getXByCircle(x - r, node.rect.y + r, y, r) + } else if (y > node.rect.y + node.rect.height - r) { + // 下侧圆角 + x = getXByCircle(x - r, node.rect.y + node.rect.height - r, y, r) } - // 左三 - var leftN = 3; // 左侧节点数 - for (var i = 0; i < leftN; i++) { - var y = node.rect.y + (node.rect.height * (i + 1)) / (leftN + 1); - var x = node.rect.x; - if (y < node.rect.y + r) { - // 在上侧圆角以内 - x = getXByCircle(x + r, node.rect.y + r, y, r, -1); - } - else if (y > node.rect.y + node.rect.height - r) { - // 下侧圆角 - x = getXByCircle(x + r, node.rect.y + node.rect.height - r, y, r, -1); - } - node.anchors.push(new Point(x, y, Direction.Left)); + node.anchors.push(new Point(x, y, Direction.Right)) + } + // 下四 + const bottomN = 5 // 下侧节点数 + for (var i = 0; i < bottomN; i++) { + if (i === 2) { + continue } + var x = node.rect.x + (node.rect.width * (i + 1)) / (bottomN + 1) + var y = node.rect.y + node.rect.height + if (x < node.rect.x + r) { + // 在左侧圆角 + y = getYByCircle(node.rect.x + r, y - r, x, r) + } else if (x > node.rect.x + node.rect.width - r) { + // 在右侧圆角 + y = getYByCircle(node.rect.x + node.rect.width - r, y - r, x, r) + } + node.anchors.push(new Point(x, y, Direction.Bottom)) + } + // 左三 + const leftN = 3 // 左侧节点数 + for (var i = 0; i < leftN; i++) { + var y = node.rect.y + (node.rect.height * (i + 1)) / (leftN + 1) + var x = node.rect.x + if (y < node.rect.y + r) { + // 在上侧圆角以内 + x = getXByCircle(x + r, node.rect.y + r, y, r, -1) + } else if (y > node.rect.y + node.rect.height - r) { + // 下侧圆角 + x = getXByCircle(x + r, node.rect.y + node.rect.height - r, y, r, -1) + } + node.anchors.push(new Point(x, y, Direction.Left)) + } } /** * 得到元素实际计算半径 * @param node 元素 * @returns 元素实际半径 */ -function borderRadius(node) { - var wr = node.borderRadius; - var hr = node.borderRadius; - if (node.borderRadius < 1) { - wr = node.rect.width * node.borderRadius; - hr = node.rect.height * node.borderRadius; - } - var r = wr < hr ? wr : hr; - if (node.rect.width < 2 * r) { - r = node.rect.width / 2; - } - if (node.rect.height < 2 * r) { - r = node.rect.height / 2; - } - return r; +function borderRadius (node) { + let wr = node.borderRadius + let hr = node.borderRadius + if (node.borderRadius < 1) { + wr = node.rect.width * node.borderRadius + hr = node.rect.height * node.borderRadius + } + let r = wr < hr ? wr : hr + if (node.rect.width < 2 * r) { + r = node.rect.width / 2 + } + if (node.rect.height < 2 * r) { + r = node.rect.height / 2 + } + return r } /** * 获取圆的 x 坐标 @@ -98,9 +94,9 @@ function borderRadius(node) { * @param r 半径 * @param sqrt 点可能在左侧,左侧填-1,右侧1(默认值) */ -function getXByCircle(ox, oy, y, r, sqrt) { - if (sqrt === void 0) { sqrt = 1; } - return sqrt * Math.sqrt(Math.pow(r, 2) - Math.pow((y - oy), 2)) + ox; +function getXByCircle (ox, oy, y, r, sqrt) { + if (sqrt === void 0) { sqrt = 1 } + return sqrt * Math.sqrt(Math.pow(r, 2) - Math.pow((y - oy), 2)) + ox } /** * 获取圆的 y 坐标 @@ -110,8 +106,8 @@ function getXByCircle(ox, oy, y, r, sqrt) { * @param r 半径 * @param sqrt 点可以在上侧,也可能在下侧,上侧-1,下侧1(默认) */ -function getYByCircle(ox, oy, x, r, sqrt) { - if (sqrt === void 0) { sqrt = 1; } - return sqrt * Math.sqrt(Math.pow(r, 2) - Math.pow((x - ox), 2)) + oy; +function getYByCircle (ox, oy, x, r, sqrt) { + if (sqrt === void 0) { sqrt = 1 } + return sqrt * Math.sqrt(Math.pow(r, 2) - Math.pow((x - ox), 2)) + oy } -//# sourceMappingURL=mindNode.anchor.js.map \ No newline at end of file +// # sourceMappingURL=mindNode.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.anchor.js index 713c6fb50..71fe63a7a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.anchor.js @@ -1,10 +1,10 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function pentagonAnchors(node) { - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 5, Direction.Right)); - node.anchors.push(new Point(node.rect.x + (node.rect.width * 4) / 5, node.rect.y + node.rect.height, Direction.Bottom)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 5, node.rect.y + node.rect.height, Direction.Bottom)); - node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 2) / 5, Direction.Left)); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function pentagonAnchors (node) { + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 5, Direction.Right)) + node.anchors.push(new Point(node.rect.x + (node.rect.width * 4) / 5, node.rect.y + node.rect.height, Direction.Bottom)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 5, node.rect.y + node.rect.height, Direction.Bottom)) + node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 2) / 5, Direction.Left)) } -//# sourceMappingURL=pentagon.anchor.js.map \ No newline at end of file +// # sourceMappingURL=pentagon.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.js index 538d9aac5..821d0dfaf 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.js @@ -1,12 +1,12 @@ -export function pentagon(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 5); - ctx.lineTo(node.rect.x + (node.rect.width * 4) / 5, node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x + node.rect.width / 5, node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 2) / 5); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function pentagon (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 5) + ctx.lineTo(node.rect.x + (node.rect.width * 4) / 5, node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x + node.rect.width / 5, node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 2) / 5) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=pentagon.js.map \ No newline at end of file +// # sourceMappingURL=pentagon.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.rect.js index b75134f9e..c7095b54e 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagon.rect.js @@ -1,23 +1,22 @@ -import { Rect } from '../../models/rect'; -export function pentagonIconRect(node) { - var w = node.rect.width / 2; - var h = node.rect.height / 2; - if (w > h) { - w = h; - } - else { - h = w; - } - var top = node.rect.height / 7; - if (top < 10) { - top = 10; - } - node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h); +import { Rect } from '../../models/rect' +export function pentagonIconRect (node) { + let w = node.rect.width / 2 + let h = node.rect.height / 2 + if (w > h) { + w = h + } else { + h = w + } + let top = node.rect.height / 7 + if (top < 10) { + top = 10 + } + node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h) } -export function pentagonTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 5) / 7, (node.rect.width * 3) / 5, node.rect.height / 4); - var w = (node.rect.width * 3) / 5; - var h = (node.rect.height * 3) / 5; - node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h); +export function pentagonTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 5) / 7, (node.rect.width * 3) / 5, node.rect.height / 4) + const w = (node.rect.width * 3) / 5 + const h = (node.rect.height * 3) / 5 + node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h) } -//# sourceMappingURL=pentagon.rect.js.map \ No newline at end of file +// # sourceMappingURL=pentagon.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.anchor.js index 5de2f411b..ccae46c9b 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.anchor.js @@ -1,10 +1,10 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function pentagramAnchors(node) { - node.anchors.push(new Point((Math.cos((18 / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin((18 / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point((Math.cos(((18 + 72) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Up)); - node.anchors.push(new Point((Math.cos(((18 + 72 * 2) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 2) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point((Math.cos(((18 + 72 * 3) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 3) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Bottom)); - node.anchors.push(new Point((Math.cos(((18 + 72 * 4) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 4) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Bottom)); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function pentagramAnchors (node) { + node.anchors.push(new Point((Math.cos((18 / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin((18 / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point((Math.cos(((18 + 72) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Up)) + node.anchors.push(new Point((Math.cos(((18 + 72 * 2) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 2) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point((Math.cos(((18 + 72 * 3) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 3) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Bottom)) + node.anchors.push(new Point((Math.cos(((18 + 72 * 4) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 4) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Bottom)) } -//# sourceMappingURL=pentagram.anchor.js.map \ No newline at end of file +// # sourceMappingURL=pentagram.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.js index 2a7ac580d..92ba1285e 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.js @@ -1,11 +1,11 @@ -export function pentagram(ctx, node) { - ctx.beginPath(); - for (var i = 0; i < 5; ++i) { - ctx.lineTo((Math.cos(((18 + 72 * i) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * i) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2); - ctx.lineTo((Math.cos(((54 + 72 * i) / 180) * Math.PI) * node.rect.width) / 4 + node.rect.x + node.rect.width / 2, (-Math.sin(((54 + 72 * i) / 180) * Math.PI) * node.rect.width) / 4 + node.rect.y + node.rect.height / 2); - } - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function pentagram (ctx, node) { + ctx.beginPath() + for (let i = 0; i < 5; ++i) { + ctx.lineTo((Math.cos(((18 + 72 * i) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * i) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2) + ctx.lineTo((Math.cos(((54 + 72 * i) / 180) * Math.PI) * node.rect.width) / 4 + node.rect.x + node.rect.width / 2, (-Math.sin(((54 + 72 * i) / 180) * Math.PI) * node.rect.width) / 4 + node.rect.y + node.rect.height / 2) + } + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=pentagram.js.map \ No newline at end of file +// # sourceMappingURL=pentagram.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.rect.js index f985a33cf..19cf6717f 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/pentagram.rect.js @@ -1,11 +1,11 @@ -import { Rect } from '../../models/rect'; -export function pentagramIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '../../models/rect' +export function pentagramIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function pentagramTextRect(node) { - var w = (node.rect.width * 2) / 5; - var h = (node.rect.height * 2) / 5; - node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h); - node.textRect = node.fullTextRect; +export function pentagramTextRect (node) { + const w = (node.rect.width * 2) / 5 + const h = (node.rect.height * 2) / 5 + node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h) + node.textRect = node.fullTextRect } -//# sourceMappingURL=pentagram.rect.js.map \ No newline at end of file +// # sourceMappingURL=pentagram.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/people.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/people.js index a39937bf4..3bd20d427 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/people.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/people.js @@ -1,17 +1,17 @@ -export function people(ctx, node) { - ctx.beginPath(); - var r = node.rect.width / 4; - var middle = node.rect.x + node.rect.width / 2; - ctx.arc(middle, node.rect.y + r, r, 0, Math.PI * 2); - ctx.moveTo(node.rect.x, node.rect.y + r * 3); - ctx.lineTo(node.rect.ex, node.rect.y + r * 3); - ctx.moveTo(middle, node.rect.y + r * 2); - ctx.lineTo(middle, node.rect.y + r * 4); - ctx.moveTo(middle, node.rect.y + r * 4); - ctx.lineTo(node.rect.x, node.rect.ey); - ctx.moveTo(middle, node.rect.y + r * 4); - ctx.lineTo(node.rect.ex, node.rect.ey); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function people (ctx, node) { + ctx.beginPath() + const r = node.rect.width / 4 + const middle = node.rect.x + node.rect.width / 2 + ctx.arc(middle, node.rect.y + r, r, 0, Math.PI * 2) + ctx.moveTo(node.rect.x, node.rect.y + r * 3) + ctx.lineTo(node.rect.ex, node.rect.y + r * 3) + ctx.moveTo(middle, node.rect.y + r * 2) + ctx.lineTo(middle, node.rect.y + r * 4) + ctx.moveTo(middle, node.rect.y + r * 4) + ctx.lineTo(node.rect.x, node.rect.ey) + ctx.moveTo(middle, node.rect.y + r * 4) + ctx.lineTo(node.rect.ex, node.rect.ey); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=people.js.map \ No newline at end of file +// # sourceMappingURL=people.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/people.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/people.rect.js index 47f39856f..9c64d5d23 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/people.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/people.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '../../models/rect'; -export function peopleIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '../../models/rect' +export function peopleIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function peopleTextRect(node) { - node.textRect = undefined; - node.fullTextRect = node.textRect; +export function peopleTextRect (node) { + node.textRect = undefined + node.fullTextRect = node.textRect } -//# sourceMappingURL=people.rect.js.map \ No newline at end of file +// # sourceMappingURL=people.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/rectangle.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/rectangle.js index 67054433b..efc8c7b12 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/rectangle.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/rectangle.js @@ -1,25 +1,25 @@ -export function rectangle(ctx, node) { - var wr = node.borderRadius; - var hr = node.borderRadius; - if (node.borderRadius < 1) { - wr = node.rect.width * node.borderRadius; - hr = node.rect.height * node.borderRadius; - } - var r = wr < hr ? wr : hr; - if (node.rect.width < 2 * r) { - r = node.rect.width / 2; - } - if (node.rect.height < 2 * r) { - r = node.rect.height / 2; - } - ctx.beginPath(); - ctx.moveTo(node.rect.x + r, node.rect.y); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r); - ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r); - ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function rectangle (ctx, node) { + let wr = node.borderRadius + let hr = node.borderRadius + if (node.borderRadius < 1) { + wr = node.rect.width * node.borderRadius + hr = node.rect.height * node.borderRadius + } + let r = wr < hr ? wr : hr + if (node.rect.width < 2 * r) { + r = node.rect.width / 2 + } + if (node.rect.height < 2 * r) { + r = node.rect.height / 2 + } + ctx.beginPath() + ctx.moveTo(node.rect.x + r, node.rect.y) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r) + ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r) + ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=rectangle.js.map \ No newline at end of file +// # sourceMappingURL=rectangle.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/rectangle.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/rectangle.rect.js index baa8a5016..2d96c2ab5 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/rectangle.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/rectangle.rect.js @@ -1,11 +1,11 @@ -import { Rect } from '../../models/rect'; -export function rectangleIconRect(node) { - node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum); - node.fullIconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum); +import { Rect } from '../../models/rect' +export function rectangleIconRect (node) { + node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum) + node.fullIconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum) } -export function rectangleTextRect(node) { - var height = node.rect.height - node.paddingTopNum - node.paddingBottomNum; - node.textRect = new Rect(node.rect.x + node.paddingLeftNum + height, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum - height, height); - node.fullTextRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height); +export function rectangleTextRect (node) { + const height = node.rect.height - node.paddingTopNum - node.paddingBottomNum + node.textRect = new Rect(node.rect.x + node.paddingLeftNum + height, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum - height, height) + node.fullTextRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height) } -//# sourceMappingURL=rectangle.rect.js.map \ No newline at end of file +// # sourceMappingURL=rectangle.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/text.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/text.js index 67ffcf9d2..9ba5ac339 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/text.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/text.js @@ -1,270 +1,263 @@ -import { Store } from 'le5le-store'; +import { Store } from 'le5le-store' // getWords: Get the word array from text. A single Chinese character is a word. -export function getWords(txt) { - var words = []; - var word = ''; - if (!txt) { - txt = ''; +export function getWords (txt) { + const words = [] + let word = '' + if (!txt) { + txt = '' + } + for (let i = 0; i < txt.length; ++i) { + const ch = txt.charCodeAt(i) + if (ch < 33 || ch > 126) { + if (word) { + words.push(word) + word = '' + } + words.push(txt[i]) + continue + } else { + word += txt[i] } - for (var i = 0; i < txt.length; ++i) { - var ch = txt.charCodeAt(i); - if (ch < 33 || ch > 126) { - if (word) { - words.push(word); - word = ''; - } - words.push(txt[i]); - continue; - } - else { - word += txt[i]; - } - } - if (word) { - words.push(word); - } - return words; + } + if (word) { + words.push(word) + } + return words } // getWrapLines: Get the lines by wrap. // words - the word array of text, to avoid spliting a word. // maxWidth - the max width of the rect. -export function getWrapLines(ctx, words, maxWidth, fontSize) { - var lines = []; - var currentLine = words[0] || ''; - for (var i = 1; i < words.length; ++i) { - var word = words[i] || ''; - var text_1 = currentLine + word; - var chinese = text_1.match(/[\u4e00-\u9fa5]/g) || ''; - var chineseLen = chinese.length; - if ((text_1.length - chineseLen) * fontSize * 0.5 + chineseLen * fontSize < maxWidth) { - currentLine += word; - } - else { - lines.push(currentLine); - currentLine = word; - } +export function getWrapLines (ctx, words, maxWidth, fontSize) { + const lines = [] + let currentLine = words[0] || '' + for (let i = 1; i < words.length; ++i) { + const word = words[i] || '' + const text_1 = currentLine + word + const chinese = text_1.match(/[\u4e00-\u9fa5]/g) || '' + const chineseLen = chinese.length + if ((text_1.length - chineseLen) * fontSize * 0.5 + chineseLen * fontSize < maxWidth) { + currentLine += word + } else { + lines.push(currentLine) + currentLine = word } - lines.push(currentLine); - return lines; + } + lines.push(currentLine) + return lines } -export function getLines(ctx, pen) { - if (pen.text && !pen.text.split) { - pen.text += ''; - } - var lines = []; - switch (pen.whiteSpace) { - case 'nowrap': - lines.push(pen.text); - break; - case 'pre-line': - lines = pen.text.split(/[\n]/g); - break; - default: - var textRect = pen.getTextRect(); - var paragraphs = pen.text.split(/[\n]/g); - for (var i = 0; i < paragraphs.length; ++i) { - var l = getWrapLines(ctx, getWords(paragraphs[i]), textRect.width, pen.fontSize); - lines.push.apply(lines, l); - } - break; - } - return lines; +export function getLines (ctx, pen) { + if (pen.text && !pen.text.split) { + pen.text += '' + } + let lines = [] + switch (pen.whiteSpace) { + case 'nowrap': + lines.push(pen.text) + break + case 'pre-line': + lines = pen.text.split(/[\n]/g) + break + default: + var textRect = pen.getTextRect() + var paragraphs = pen.text.split(/[\n]/g) + for (let i = 0; i < paragraphs.length; ++i) { + const l = getWrapLines(ctx, getWords(paragraphs[i]), textRect.width, pen.fontSize) + lines.push.apply(lines, l) + } + break + } + return lines } -export function calcTextRect(ctx, pen) { - var lines = getLines(ctx, pen); - var width = 0; - for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) { - var item = lines_1[_i]; - ctx.font = (pen.fontStyle || 'normal') + " normal " + (pen.fontWeight || 'normal') + " " + pen.fontSize + "px/" + pen.lineHeight + " " + pen.fontFamily; - var r = ctx.measureText(item); - var w = r.width; - if (w > width) { - width = w; - } +export function calcTextRect (ctx, pen) { + const lines = getLines(ctx, pen) + let width = 0 + for (let _i = 0, lines_1 = lines; _i < lines_1.length; _i++) { + const item = lines_1[_i] + ctx.font = (pen.fontStyle || 'normal') + ' normal ' + (pen.fontWeight || 'normal') + ' ' + pen.fontSize + 'px/' + pen.lineHeight + ' ' + pen.fontFamily + const r = ctx.measureText(item) + const w = r.width + if (w > width) { + width = w } - return { - width: width, - height: lines.length * pen.fontSize * pen.lineHeight, - }; + } + return { + width: width, + height: lines.length * pen.fontSize * pen.lineHeight + } } -function textBk(ctx, str, x, y, height, color) { - if (!str || !color) { - return; - } - var w = ctx.measureText(str).width; - ctx.save(); - ctx.fillStyle = color; - var l = x - w / 2; - var t = y - height / 2; - switch (ctx.textAlign) { - case 'left': - l = x; - break; - case 'right': - l = x - w; - break; - } - switch (ctx.textBaseline) { - case 'top': - t = y; - break; - case 'bottom': - t = y - height; - break; - } - ctx.fillRect(l, t, w, height); - ctx.restore(); +function textBk (ctx, str, x, y, height, color) { + if (!str || !color) { + return + } + const w = ctx.measureText(str).width + ctx.save() + ctx.fillStyle = color + let l = x - w / 2 + let t = y - height / 2 + switch (ctx.textAlign) { + case 'left': + l = x + break + case 'right': + l = x - w + break + } + switch (ctx.textBaseline) { + case 'top': + t = y + break + case 'bottom': + t = y - height + break + } + ctx.fillRect(l, t, w, height) + ctx.restore() } -export function fillText(ctx, lines, x, y, width, height, lineHeight, maxLineLen, bk) { - if (!maxLineLen || maxLineLen > lines.length) { - maxLineLen = lines.length; +export function fillText (ctx, lines, x, y, width, height, lineHeight, maxLineLen, bk) { + if (!maxLineLen || maxLineLen > lines.length) { + maxLineLen = lines.length + } else { + maxLineLen = Math.ceil(maxLineLen) + } + for (let i = 0; i < maxLineLen - 1; ++i) { + if (bk) { + textBk(ctx, lines[i], x, y + i * lineHeight, lineHeight, bk) } - else { - maxLineLen = Math.ceil(maxLineLen); + ctx.fillText(lines[i], x, y + i * lineHeight) + } + if (maxLineLen < lines.length) { + let str = (lines[maxLineLen - 1] || '') + '...' + if (lines[maxLineLen - 1] && ctx.measureText(str).width > width) { + str = lines[maxLineLen - 1].substr(0, lines[maxLineLen - 1].length - 2) + '...' } - for (var i = 0; i < maxLineLen - 1; ++i) { - if (bk) { - textBk(ctx, lines[i], x, y + i * lineHeight, lineHeight, bk); - } - ctx.fillText(lines[i], x, y + i * lineHeight); + if (bk) { + textBk(ctx, str, x, y + (maxLineLen - 1) * lineHeight, lineHeight, bk) } - if (maxLineLen < lines.length) { - var str = (lines[maxLineLen - 1] || '') + '...'; - if (lines[maxLineLen - 1] && ctx.measureText(str).width > width) { - str = lines[maxLineLen - 1].substr(0, lines[maxLineLen - 1].length - 2) + '...'; - } - if (bk) { - textBk(ctx, str, x, y + (maxLineLen - 1) * lineHeight, lineHeight, bk); - } - ctx.fillText(str, x, y + (maxLineLen - 1) * lineHeight); - } - else { - if (bk) { - textBk(ctx, lines[maxLineLen - 1], x, y + (maxLineLen - 1) * lineHeight, lineHeight, bk); - } - ctx.fillText(lines[maxLineLen - 1], x, y + (maxLineLen - 1) * lineHeight); + ctx.fillText(str, x, y + (maxLineLen - 1) * lineHeight) + } else { + if (bk) { + textBk(ctx, lines[maxLineLen - 1], x, y + (maxLineLen - 1) * lineHeight, lineHeight, bk) } + ctx.fillText(lines[maxLineLen - 1], x, y + (maxLineLen - 1) * lineHeight) + } } -export function text(ctx, node) { - if (!node.text) { - return; - } - if (!node.text.split) { - node.text += ''; - } - ctx.save(); - ctx.beginPath(); - delete ctx.shadowColor; - delete ctx.shadowBlur; - ctx.font = (node.fontStyle || 'normal') + " normal " + (node.fontWeight || 'normal') + " " + node.fontSize + "px/" + node.lineHeight + " " + node.fontFamily; - if (node.fontColor) { - ctx.fillStyle = node.fontColor; - } - else { - ctx.fillStyle = Store.get(node.generateStoreKey('LT:fontColor')); - } - if (node.textAlign) { - ctx.textAlign = node.textAlign; - } - if (node.textBaseline) { - ctx.textBaseline = node.textBaseline; - } - var textRect = node.getTextRect(); - if (!textRect) { - ctx.restore(); - return; - } - var lines = getLines(ctx, node); - var lineHeight = node.fontSize * node.lineHeight; - var maxLineLen = node.textMaxLine > 0 && node.textMaxLine < lines.length ? node.textMaxLine : lines.length; - // By default, the text is center aligned. - var x = textRect.x + textRect.width / 2; - var y = textRect.y + (textRect.height - lineHeight * maxLineLen) / 2 + (lineHeight * 4) / 7; - switch (ctx.textAlign) { - case 'left': - x = textRect.x; - break; - case 'right': - x = textRect.x + textRect.width; - break; - } - switch (ctx.textBaseline) { - case 'top': - y = textRect.y + (lineHeight - node.fontSize) / 2; - break; - case 'bottom': - y = textRect.ey - lineHeight * maxLineLen + lineHeight; - break; - } - fillText(ctx, lines, x + node.textOffsetX, y + node.textOffsetY, textRect.width, textRect.height, lineHeight, maxLineLen, node.textBackground); - ctx.restore(); +export function text (ctx, node) { + if (!node.text) { + return + } + if (!node.text.split) { + node.text += '' + } + ctx.save() + ctx.beginPath() + delete ctx.shadowColor + delete ctx.shadowBlur + ctx.font = (node.fontStyle || 'normal') + ' normal ' + (node.fontWeight || 'normal') + ' ' + node.fontSize + 'px/' + node.lineHeight + ' ' + node.fontFamily + if (node.fontColor) { + ctx.fillStyle = node.fontColor + } else { + ctx.fillStyle = Store.get(node.generateStoreKey('LT:fontColor')) + } + if (node.textAlign) { + ctx.textAlign = node.textAlign + } + if (node.textBaseline) { + ctx.textBaseline = node.textBaseline + } + const textRect = node.getTextRect() + if (!textRect) { + ctx.restore() + return + } + const lines = getLines(ctx, node) + const lineHeight = node.fontSize * node.lineHeight + const maxLineLen = node.textMaxLine > 0 && node.textMaxLine < lines.length ? node.textMaxLine : lines.length + // By default, the text is center aligned. + let x = textRect.x + textRect.width / 2 + let y = textRect.y + (textRect.height - lineHeight * maxLineLen) / 2 + (lineHeight * 4) / 7 + switch (ctx.textAlign) { + case 'left': + x = textRect.x + break + case 'right': + x = textRect.x + textRect.width + break + } + switch (ctx.textBaseline) { + case 'top': + y = textRect.y + (lineHeight - node.fontSize) / 2 + break + case 'bottom': + y = textRect.ey - lineHeight * maxLineLen + lineHeight + break + } + fillText(ctx, lines, x + node.textOffsetX, y + node.textOffsetY, textRect.width, textRect.height, lineHeight, maxLineLen, node.textBackground) + ctx.restore() } -export function iconfont(ctx, node) { - ctx.save(); - ctx.textAlign = 'center'; - ctx.textBaseline = 'middle'; - var iconRect = node.getIconRect(); - var x = iconRect.x + iconRect.width / 2; - var y = iconRect.y + iconRect.height / 2; - switch (node.imageAlign) { - case 'top': - y = iconRect.y; - ctx.textBaseline = 'top'; - break; - case 'bottom': - y = iconRect.ey; - ctx.textBaseline = 'bottom'; - break; - case 'left': - x = iconRect.x; - ctx.textAlign = 'left'; - break; - case 'right': - x = iconRect.ex; - ctx.textAlign = 'right'; - break; - case 'left-top': - x = iconRect.x; - y = iconRect.y; - ctx.textAlign = 'left'; - ctx.textBaseline = 'top'; - break; - case 'right-top': - x = iconRect.ex; - y = iconRect.y; - ctx.textAlign = 'right'; - ctx.textBaseline = 'top'; - break; - case 'left-bottom': - x = iconRect.x; - y = iconRect.ey; - ctx.textAlign = 'left'; - ctx.textBaseline = 'bottom'; - break; - case 'right-bottom': - x = iconRect.ex; - y = iconRect.ey; - ctx.textAlign = 'right'; - ctx.textBaseline = 'bottom'; - break; - } - if (node.iconSize > 0) { - ctx.font = node.iconSize + "px " + node.iconFamily; - } - else if (iconRect.width > iconRect.height) { - ctx.font = iconRect.height + "px " + node.iconFamily; - } - else { - ctx.font = iconRect.width + "px " + node.iconFamily; - } - ctx.fillStyle = node.iconColor || Store.get(node.generateStoreKey('LT:iconColor')) || node.fontColor; - if (node.iconRotate) { - ctx.translate(iconRect.center.x, iconRect.center.y); - ctx.rotate((node.iconRotate * Math.PI) / 180); - ctx.translate(-iconRect.center.x, -iconRect.center.y); - } - ctx.beginPath(); - ctx.fillText(node.icon, x, y); - ctx.restore(); +export function iconfont (ctx, node) { + ctx.save() + ctx.textAlign = 'center' + ctx.textBaseline = 'middle' + const iconRect = node.getIconRect() + let x = iconRect.x + iconRect.width / 2 + let y = iconRect.y + iconRect.height / 2 + switch (node.imageAlign) { + case 'top': + y = iconRect.y + ctx.textBaseline = 'top' + break + case 'bottom': + y = iconRect.ey + ctx.textBaseline = 'bottom' + break + case 'left': + x = iconRect.x + ctx.textAlign = 'left' + break + case 'right': + x = iconRect.ex + ctx.textAlign = 'right' + break + case 'left-top': + x = iconRect.x + y = iconRect.y + ctx.textAlign = 'left' + ctx.textBaseline = 'top' + break + case 'right-top': + x = iconRect.ex + y = iconRect.y + ctx.textAlign = 'right' + ctx.textBaseline = 'top' + break + case 'left-bottom': + x = iconRect.x + y = iconRect.ey + ctx.textAlign = 'left' + ctx.textBaseline = 'bottom' + break + case 'right-bottom': + x = iconRect.ex + y = iconRect.ey + ctx.textAlign = 'right' + ctx.textBaseline = 'bottom' + break + } + if (node.iconSize > 0) { + ctx.font = node.iconSize + 'px ' + node.iconFamily + } else if (iconRect.width > iconRect.height) { + ctx.font = iconRect.height + 'px ' + node.iconFamily + } else { + ctx.font = iconRect.width + 'px ' + node.iconFamily + } + ctx.fillStyle = node.iconColor || Store.get(node.generateStoreKey('LT:iconColor')) || node.fontColor + if (node.iconRotate) { + ctx.translate(iconRect.center.x, iconRect.center.y) + ctx.rotate((node.iconRotate * Math.PI) / 180) + ctx.translate(-iconRect.center.x, -iconRect.center.y) + } + ctx.beginPath() + ctx.fillText(node.icon, x, y) + ctx.restore() } -//# sourceMappingURL=text.js.map \ No newline at end of file +// # sourceMappingURL=text.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.anchor.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.anchor.js index dcaacda06..d381ba798 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.anchor.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.anchor.js @@ -1,9 +1,9 @@ -import { Point } from '../../models/point'; -import { Direction } from '../../models/direction'; -export function triangleAnchors(node) { - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + (node.rect.width * 3) / 4, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 4, node.rect.y + node.rect.height / 2, Direction.Left)); +import { Point } from '../../models/point' +import { Direction } from '../../models/direction' +export function triangleAnchors (node) { + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + (node.rect.width * 3) / 4, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 4, node.rect.y + node.rect.height / 2, Direction.Left)) } -//# sourceMappingURL=triangle.anchor.js.map \ No newline at end of file +// # sourceMappingURL=triangle.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.js index c0aceff4d..9fd8ab104 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.js @@ -1,10 +1,10 @@ -export function triangle(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height); - ctx.lineTo(node.rect.x, node.rect.y + node.rect.height); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function triangle (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height) + ctx.lineTo(node.rect.x, node.rect.y + node.rect.height) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=triangle.js.map \ No newline at end of file +// # sourceMappingURL=triangle.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.rect.js b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.rect.js index e79993fbf..48c0c62fa 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/middles/nodes/triangle.rect.js @@ -1,23 +1,22 @@ -import { Rect } from '../../models/rect'; -export function triangleIconRect(node) { - var w = (node.rect.width * 2) / 7; - var h = (node.rect.height * 2) / 7; - if (w > h) { - w = h; - } - else { - h = w; - } - var top = w; - if (top < 10) { - top = 10; - } - node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h); +import { Rect } from '../../models/rect' +export function triangleIconRect (node) { + let w = (node.rect.width * 2) / 7 + let h = (node.rect.height * 2) / 7 + if (w > h) { + w = h + } else { + h = w + } + let top = w + if (top < 10) { + top = 10 + } + node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h) } -export function triangleTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + (node.rect.height * 2) / 3, node.rect.width / 2, node.rect.height / 3 - 5); - var w = node.rect.width / 2; - var h = (node.rect.height * 3) / 7; - node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 2 - 5, w, h); +export function triangleTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + (node.rect.height * 2) / 3, node.rect.width / 2, node.rect.height / 3 - 5) + const w = node.rect.width / 2 + const h = (node.rect.height * 3) / 7 + node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 2 - 5, w, h) } -//# sourceMappingURL=triangle.rect.js.map \ No newline at end of file +// # sourceMappingURL=triangle.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/models/data.js b/nezha-fronted/src/components/common/@topology/core/src/models/data.js index 666317851..059aa54a9 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/models/data.js +++ b/nezha-fronted/src/components/common/@topology/core/src/models/data.js @@ -1,67 +1,64 @@ -import { Node } from './node'; -import { Line } from './line'; -import { Lock } from './status'; -import { s8 } from '../utils'; -import { Store } from 'le5le-store'; -import { Rect } from './rect'; -export function createData(json, tid) { - var data = { - pens: [], - lineName: 'curve', - fromArrow: '', - toArrow: 'triangleSolid', - scale: 1, - locked: Lock.None, - x: 0, - y: 0, - }; - if (typeof json === 'string') { - json = JSON.parse(json); +import { Node } from './node' +import { Line } from './line' +import { Lock } from './status' +import { s8 } from '../utils' +import { Store } from 'le5le-store' +import { Rect } from './rect' +export function createData (json, tid) { + let data = { + pens: [], + lineName: 'curve', + fromArrow: '', + toArrow: 'triangleSolid', + scale: 1, + locked: Lock.None, + x: 0, + y: 0 + } + if (typeof json === 'string') { + json = JSON.parse(json) + } + data = Object.assign(data, json) + data.pens = [] + if (json) { + // for old data. + if (json.nodes) { + for (let _i = 0, _a = json.nodes; _i < _a.length; _i++) { + var item = _a[_i] + item.TID = tid + data.pens.push(new Node(item)) + } + for (let _b = 0, _c = json.lines; _b < _c.length; _b++) { + var item = _c[_b] + item.TID = tid + data.pens.push(new Line(item)) + } } - data = Object.assign(data, json); - data.pens = []; - if (json) { - // for old data. - if (json.nodes) { - for (var _i = 0, _a = json.nodes; _i < _a.length; _i++) { - var item = _a[_i]; - item.TID = tid; - data.pens.push(new Node(item)); - } - for (var _b = 0, _c = json.lines; _b < _c.length; _b++) { - var item = _c[_b]; - item.TID = tid; - data.pens.push(new Line(item)); - } - } - // end. - json.pens && json.pens.forEach(function (item) { - tid && (item.TID = tid); - if (!item.type) { - data.pens.push(new Node(item)); - } - else { - data.pens.push(new Line(item)); - } - }); - if (json.bkImageRect) { - data.bkImageRect = new Rect(json.bkImageRect.x, json.bkImageRect.y, json.bkImageRect.width, json.bkImageRect.height); - } + // end. + json.pens && json.pens.forEach(function (item) { + tid && (item.TID = tid) + if (!item.type) { + data.pens.push(new Node(item)) + } else { + data.pens.push(new Line(item)) + } + }) + if (json.bkImageRect) { + data.bkImageRect = new Rect(json.bkImageRect.x, json.bkImageRect.y, json.bkImageRect.width, json.bkImageRect.height) } - if (data.mqttOptions) { - var opts = ''; - if (typeof data.mqttOptions === 'object') { - opts = JSON.stringify(data.mqttOptions); - } - else { - opts = data.mqttOptions + ''; - } - data.mqttOptions = JSON.parse(opts); + } + if (data.mqttOptions) { + let opts = '' + if (typeof data.mqttOptions === 'object') { + opts = JSON.stringify(data.mqttOptions) + } else { + opts = data.mqttOptions + '' } - else { - data.mqttOptions = { clientId: s8() }; - } - tid && Store.set(tid + '-topology-data', data); - return data; + data.mqttOptions = JSON.parse(opts) + } else { + data.mqttOptions = { clientId: s8() } + } + tid && Store.set(tid + '-topology-data', data) + return data } -//# sourceMappingURL=data.js.map +// # sourceMappingURL=data.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/models/direction.js b/nezha-fronted/src/components/common/@topology/core/src/models/direction.js index 04a70a714..2359c5b30 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/models/direction.js +++ b/nezha-fronted/src/components/common/@topology/core/src/models/direction.js @@ -1,9 +1,9 @@ export var Direction; (function (Direction) { - Direction[Direction["None"] = 0] = "None"; - Direction[Direction["Up"] = 1] = "Up"; - Direction[Direction["Right"] = 2] = "Right"; - Direction[Direction["Bottom"] = 3] = "Bottom"; - Direction[Direction["Left"] = 4] = "Left"; -})(Direction || (Direction = {})); -//# sourceMappingURL=direction.js.map \ No newline at end of file + Direction[Direction.None = 0] = 'None' + Direction[Direction.Up = 1] = 'Up' + Direction[Direction.Right = 2] = 'Right' + Direction[Direction.Bottom = 3] = 'Bottom' + Direction[Direction.Left = 4] = 'Left' +})(Direction || (Direction = {})) +// # sourceMappingURL=direction.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/models/event.js b/nezha-fronted/src/components/common/@topology/core/src/models/event.js index 5ed287b58..1ccf8bd2b 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/models/event.js +++ b/nezha-fronted/src/components/common/@topology/core/src/models/event.js @@ -1,21 +1,21 @@ export var EventType; (function (EventType) { - EventType[EventType["Click"] = 0] = "Click"; - EventType[EventType["DblClick"] = 1] = "DblClick"; - EventType[EventType["WebSocket"] = 2] = "WebSocket"; - EventType[EventType["Mqtt"] = 3] = "Mqtt"; - EventType[EventType["MoveIn"] = 4] = "MoveIn"; - EventType[EventType["MoveOut"] = 5] = "MoveOut"; -})(EventType || (EventType = {})); + EventType[EventType.Click = 0] = 'Click' + EventType[EventType.DblClick = 1] = 'DblClick' + EventType[EventType.WebSocket = 2] = 'WebSocket' + EventType[EventType.Mqtt = 3] = 'Mqtt' + EventType[EventType.MoveIn = 4] = 'MoveIn' + EventType[EventType.MoveOut = 5] = 'MoveOut' +})(EventType || (EventType = {})) export var EventAction; (function (EventAction) { - EventAction[EventAction["Link"] = 0] = "Link"; - EventAction[EventAction["StartAnimate"] = 1] = "StartAnimate"; - EventAction[EventAction["Function"] = 2] = "Function"; - EventAction[EventAction["WindowFn"] = 3] = "WindowFn"; - EventAction[EventAction["SetProps"] = 4] = "SetProps"; - EventAction[EventAction["PauseAnimate"] = 5] = "PauseAnimate"; - EventAction[EventAction["StopAnimate"] = 6] = "StopAnimate"; - EventAction[EventAction["Emit"] = 7] = "Emit"; -})(EventAction || (EventAction = {})); -//# sourceMappingURL=event.js.map \ No newline at end of file + EventAction[EventAction.Link = 0] = 'Link' + EventAction[EventAction.StartAnimate = 1] = 'StartAnimate' + EventAction[EventAction.Function = 2] = 'Function' + EventAction[EventAction.WindowFn = 3] = 'WindowFn' + EventAction[EventAction.SetProps = 4] = 'SetProps' + EventAction[EventAction.PauseAnimate = 5] = 'PauseAnimate' + EventAction[EventAction.StopAnimate = 6] = 'StopAnimate' + EventAction[EventAction.Emit = 7] = 'Emit' +})(EventAction || (EventAction = {})) +// # sourceMappingURL=event.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/models/index.js b/nezha-fronted/src/components/common/@topology/core/src/models/index.js index 20f5e7e1f..2e743ee8b 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/models/index.js +++ b/nezha-fronted/src/components/common/@topology/core/src/models/index.js @@ -1,10 +1,10 @@ -export * from './data'; -export * from './pen'; -export * from './node'; -export * from './line'; -export * from './direction'; -export * from './point'; -export * from './rect'; -export * from './status'; -export * from './event'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './data' +export * from './pen' +export * from './node' +export * from './line' +export * from './direction' +export * from './point' +export * from './rect' +export * from './status' +export * from './event' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/models/line.js b/nezha-fronted/src/components/common/@topology/core/src/models/line.js index 9af7ebe74..2b650f42a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/models/line.js +++ b/nezha-fronted/src/components/common/@topology/core/src/models/line.js @@ -1,551 +1,538 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -import { Pen, PenType } from './pen'; -import { Point } from './point'; -import { drawLineFns, drawArrowFns } from '../middles'; -import { getBezierPoint } from '../middles/lines/curve'; -import { Store } from 'le5le-store'; -import { lineLen, curveLen } from '../utils/canvas'; -import { text } from '../middles/nodes/text'; -import { Rect } from './rect'; -import { abs } from '../utils/math'; -var Line = /** @class */ (function (_super) { - __extends(Line, _super); - function Line(json) { - var _this = _super.call(this) || this; - var defaultData = { - name: 'curve', - fromArrow: '', - toArrow: '', - controlPoints: [], - fromArrowSize: 5, - toArrowSize: 5, - borderWidth: 0, - borderColor: '#000000', - animateColor: '', - animateSpan: 1, - animateFromSize: 0, - animateToSize: 0, - animateDotSize: 3, - textBackground: '#ffffff' - }; - _this.fromData(defaultData, json); - _this.type = PenType.Line; - if (json.from) { - _this.from = new Point(json.from.x, json.from.y, json.from.direction, json.from.anchorIndex, json.from.id, json.autoAnchor); - } - if (json.to) { - _this.to = new Point(json.to.x, json.to.y, json.to.direction, json.to.anchorIndex, json.to.id, json.autoAnchor); - } - // 暂时兼容老数据 - if (json.name === 'mind' && (!json.controlPoints || json.controlPoints.length > 2)) { - json.controlPoints = undefined; - _this.calcControlPoints(true); - } - // end - else if (json.controlPoints) { - _this.controlPoints = []; - for (var _i = 0, _a = json.controlPoints; _i < _a.length; _i++) { - var item = _a[_i]; - _this.controlPoints.push(new Point(item.x, item.y, item.direction, item.anchorIndex, item.id)); - } - } - if (json.children) { - _this.children = []; - json.children.forEach(function (item) { - _this.children.push(new Line(item)); - }); - } - return _this; +import { Pen, PenType } from './pen' +import { Point } from './point' +import { drawLineFns, drawArrowFns } from '../middles' +import { getBezierPoint } from '../middles/lines/curve' +import { Store } from 'le5le-store' +import { lineLen, curveLen } from '../utils/canvas' +import { text } from '../middles/nodes/text' +import { Rect } from './rect' +import { abs } from '../utils/math' +const __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) || + function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] } + return extendStatics(d, b) + } + return function (d, b) { + extendStatics(d, b) + function __ () { this.constructor = d } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()) + } +})() +const Line = /** @class */ (function (_super) { + __extends(Line, _super) + function Line (json) { + const _this = _super.call(this) || this + const defaultData = { + name: 'curve', + fromArrow: '', + toArrow: '', + controlPoints: [], + fromArrowSize: 5, + toArrowSize: 5, + borderWidth: 0, + borderColor: '#000000', + animateColor: '', + animateSpan: 1, + animateFromSize: 0, + animateToSize: 0, + animateDotSize: 3, + textBackground: '#ffffff' } - Line.prototype.setFrom = function (from, fromArrow) { - if (fromArrow === void 0) { fromArrow = ''; } - this.from = from; - this.fromArrow = fromArrow; - this.textRect = undefined; - }; - Line.prototype.setTo = function (to, toArrow) { - if (toArrow === void 0) { toArrow = 'triangleSolid'; } - this.to = to; - this.toArrow = toArrow; - this.textRect = undefined; - }; - Line.prototype.calcControlPoints = function (force) { - if (this.name !== 'line' && this.manualCps && !force) { - return; + _this.fromData(defaultData, json) + _this.type = PenType.Line + if (json.from) { + _this.from = new Point(json.from.x, json.from.y, json.from.direction, json.from.anchorIndex, json.from.id, json.autoAnchor) + } + if (json.to) { + _this.to = new Point(json.to.x, json.to.y, json.to.direction, json.to.anchorIndex, json.to.id, json.autoAnchor) + } + // 暂时兼容老数据 + if (json.name === 'mind' && (!json.controlPoints || json.controlPoints.length > 2)) { + json.controlPoints = undefined + _this.calcControlPoints(true) + } + // end + else if (json.controlPoints) { + _this.controlPoints = [] + for (let _i = 0, _a = json.controlPoints; _i < _a.length; _i++) { + const item = _a[_i] + _this.controlPoints.push(new Point(item.x, item.y, item.direction, item.anchorIndex, item.id)) + } + } + if (json.children) { + _this.children = [] + json.children.forEach(function (item) { + _this.children.push(new Line(item)) + }) + } + return _this + } + Line.prototype.setFrom = function (from, fromArrow) { + if (fromArrow === void 0) { fromArrow = '' } + this.from = from + this.fromArrow = fromArrow + this.textRect = undefined + } + Line.prototype.setTo = function (to, toArrow) { + if (toArrow === void 0) { toArrow = 'triangleSolid' } + this.to = to + this.toArrow = toArrow + this.textRect = undefined + } + Line.prototype.calcControlPoints = function (force) { + if (this.name !== 'line' && this.manualCps && !force) { + return + } + this.textRect = undefined + if (this.from && this.to && drawLineFns[this.name]) { + drawLineFns[this.name].controlPointsFn(this) + } + } + Line.prototype.draw = function (ctx) { + if (this.animateDot) { + ctx.fillStyle = ctx.strokeStyle + if (this.animateType === 'dot') { + ctx.beginPath() + ctx.arc(this.animateDot.x, this.animateDot.y, this.animateDotSize, 0, 2 * Math.PI, false) + ctx.fill() + return + } else if (this.animateType === 'comet') { + const bulles = this.getBubbles() + ctx.save() + for (let _i = 0, bulles_1 = bulles; _i < bulles_1.length; _i++) { + const item = bulles_1[_i] + ctx.globalAlpha = item.a + ctx.beginPath() + ctx.arc(item.pos.x, item.pos.y, item.r, 0, 2 * Math.PI, false) + ctx.fill() } - this.textRect = undefined; - if (this.from && this.to && drawLineFns[this.name]) { - drawLineFns[this.name].controlPointsFn(this); + ctx.restore() + } + } + if (!this.isAnimate && this.borderWidth > 0 && this.borderColor) { + ctx.save() + if (this.lineJoin) { + ctx.lineJoin = this.lineJoin + } + ctx.lineWidth = this.lineWidth + this.borderWidth + ctx.strokeStyle = this.borderColor + if (drawLineFns[this.name]) { + drawLineFns[this.name].drawFn(ctx, this) + } + ctx.restore() + } + switch (this.strokeType) { + case 1: + this.strokeLinearGradient(ctx) + break + } + if ((!this.isAnimate || this.animateType !== 'comet') && drawLineFns[this.name]) { + if (this.lineJoin) { + ctx.lineJoin = this.lineJoin + } + drawLineFns[this.name].drawFn(ctx, this) + } + const scale = Store.get(this.generateStoreKey('LT:scale')) || 1 + if (this.fromArrow && drawArrowFns[this.fromArrow]) { + ctx.save() + ctx.beginPath() + ctx.lineDashOffset = 0 + ctx.setLineDash([]) + ctx.fillStyle = this.fromArrowColor || ctx.strokeStyle + ctx.strokeStyle = ctx.fillStyle + var f = this.to + if (this.name === 'curve') { + f = getBezierPoint(0.95 - this.lineWidth / 100, this.to, this.controlPoints[1], this.controlPoints[0], this.from) + } else if (this.name !== 'line' && this.controlPoints.length) { + f = this.controlPoints[0] + } + drawArrowFns[this.fromArrow](ctx, f, this.from, this.fromArrowSize * scale) + ctx.restore() + } + if (this.toArrow && drawArrowFns[this.toArrow]) { + ctx.save() + ctx.beginPath() + ctx.lineDashOffset = 0 + ctx.setLineDash([]) + ctx.fillStyle = this.toArrowColor || ctx.strokeStyle + ctx.strokeStyle = ctx.fillStyle + var f = this.from + if (this.name === 'curve') { + f = getBezierPoint(0.95 - this.lineWidth / 100, this.from, this.controlPoints[0], this.controlPoints[1], this.to) + } else if (this.name === 'mind') { + f = getBezierPoint(0.96 - this.lineWidth / 100, this.from, this.controlPoints[0], this.controlPoints[1], this.to) + } else if (this.name !== 'line' && this.controlPoints.length) { + f = this.controlPoints[this.controlPoints.length - 1] + } + drawArrowFns[this.toArrow](ctx, f, this.to, this.toArrowSize * scale) + ctx.restore() + } + if (this.text && !this.isAnimate) { + if (!this.textRect) { + this.calcTextRect() + } + text(ctx, this) + } + } + Line.prototype.pointIn = function (pt) { + return drawLineFns[this.name].pointIn(pt, this) + } + Line.prototype.getLen = function () { + switch (this.name) { + case 'line': + return lineLen(this.from, this.to) + case 'polyline': + if (!this.controlPoints || !this.controlPoints.length) { + return lineLen(this.from, this.to) } - }; - Line.prototype.draw = function (ctx) { - if (this.animateDot) { - ctx.fillStyle = ctx.strokeStyle; - if (this.animateType === 'dot') { - ctx.beginPath(); - ctx.arc(this.animateDot.x, this.animateDot.y, this.animateDotSize, 0, 2 * Math.PI, false); - ctx.fill(); - return; - } - else if (this.animateType === 'comet') { - var bulles = this.getBubbles(); - ctx.save(); - for (var _i = 0, bulles_1 = bulles; _i < bulles_1.length; _i++) { - var item = bulles_1[_i]; - ctx.globalAlpha = item.a; - ctx.beginPath(); - ctx.arc(item.pos.x, item.pos.y, item.r, 0, 2 * Math.PI, false); - ctx.fill(); - } - ctx.restore(); - } + var len = 0 + var curPt = this.from + for (let _i = 0, _a = this.controlPoints; _i < _a.length; _i++) { + const pt = _a[_i] + len += lineLen(curPt, pt) + curPt = pt } - if (!this.isAnimate && this.borderWidth > 0 && this.borderColor) { - ctx.save(); - if (this.lineJoin) { - ctx.lineJoin = this.lineJoin; - } - ctx.lineWidth = this.lineWidth + this.borderWidth; - ctx.strokeStyle = this.borderColor; - if (drawLineFns[this.name]) { - drawLineFns[this.name].drawFn(ctx, this); - } - ctx.restore(); + len += lineLen(curPt, this.to) + return len | 0 + case 'curve': + case 'mind': + return curveLen(this.from, this.controlPoints[0], this.controlPoints[1], this.to) + default: + if (drawLineFns[this.name].getLength) { + return drawLineFns[this.name].getLength(this) } - switch (this.strokeType) { - case 1: - this.strokeLinearGradient(ctx); - break; - } - if ((!this.isAnimate || this.animateType !== 'comet') && drawLineFns[this.name]) { - if (this.lineJoin) { - ctx.lineJoin = this.lineJoin; - } - drawLineFns[this.name].drawFn(ctx, this); - } - var scale = Store.get(this.generateStoreKey('LT:scale')) || 1; - if (this.fromArrow && drawArrowFns[this.fromArrow]) { - ctx.save(); - ctx.beginPath(); - ctx.lineDashOffset = 0; - ctx.setLineDash([]); - ctx.fillStyle = this.fromArrowColor || ctx.strokeStyle; - ctx.strokeStyle = ctx.fillStyle; - var f = this.to; - if (this.name === 'curve') { - f = getBezierPoint(0.95 - this.lineWidth / 100, this.to, this.controlPoints[1], this.controlPoints[0], this.from); - } - else if (this.name !== 'line' && this.controlPoints.length) { - f = this.controlPoints[0]; - } - drawArrowFns[this.fromArrow](ctx, f, this.from, this.fromArrowSize * scale); - ctx.restore(); - } - if (this.toArrow && drawArrowFns[this.toArrow]) { - ctx.save(); - ctx.beginPath(); - ctx.lineDashOffset = 0; - ctx.setLineDash([]); - ctx.fillStyle = this.toArrowColor || ctx.strokeStyle; - ctx.strokeStyle = ctx.fillStyle; - var f = this.from; - if (this.name === 'curve') { - f = getBezierPoint(0.95 - this.lineWidth / 100, this.from, this.controlPoints[0], this.controlPoints[1], this.to); - } - else if (this.name === 'mind') { - f = getBezierPoint(0.96 - this.lineWidth / 100, this.from, this.controlPoints[0], this.controlPoints[1], this.to); - } - else if (this.name !== 'line' && this.controlPoints.length) { - f = this.controlPoints[this.controlPoints.length - 1]; - } - drawArrowFns[this.toArrow](ctx, f, this.to, this.toArrowSize * scale); - ctx.restore(); - } - if (this.text && !this.isAnimate) { - if (!this.textRect) { - this.calcTextRect(); - } - text(ctx, this); - } - }; - Line.prototype.pointIn = function (pt) { - return drawLineFns[this.name].pointIn(pt, this); - }; - Line.prototype.getLen = function () { - switch (this.name) { - case 'line': - return lineLen(this.from, this.to); - case 'polyline': - if (!this.controlPoints || !this.controlPoints.length) { - return lineLen(this.from, this.to); - } - var len = 0; - var curPt = this.from; - for (var _i = 0, _a = this.controlPoints; _i < _a.length; _i++) { - var pt = _a[_i]; - len += lineLen(curPt, pt); - curPt = pt; - } - len += lineLen(curPt, this.to); - return len | 0; - case 'curve': - case 'mind': - return curveLen(this.from, this.controlPoints[0], this.controlPoints[1], this.to); - default: - if (drawLineFns[this.name].getLength) { - return drawLineFns[this.name].getLength(this); - } - } - return 0; - }; - Line.prototype.strokeLinearGradient = function (ctx) { - if (!this.lineGradientFromColor || !this.lineGradientToColor) { - return; - } - var from = this.from; - var to = this.to; - // contributor: https://github.com/sunnyguohua/topology - var grd = ctx.createLinearGradient(from.x, from.y, to.x, to.y); - grd.addColorStop(0, this.lineGradientFromColor); - grd.addColorStop(1, this.lineGradientToColor); - ctx.strokeStyle = grd; - }; - Line.prototype.calcTextRect = function () { - var center = this.getCenter(); - var width = Math.abs(this.from.x - this.to.x); - if (width < 100) { - width = 100; - } - if (this.text && !this.text.split) { - this.text += ''; - } - var height = this.lineHeight * + } + return 0 + } + Line.prototype.strokeLinearGradient = function (ctx) { + if (!this.lineGradientFromColor || !this.lineGradientToColor) { + return + } + const from = this.from + const to = this.to + // contributor: https://github.com/sunnyguohua/topology + const grd = ctx.createLinearGradient(from.x, from.y, to.x, to.y) + grd.addColorStop(0, this.lineGradientFromColor) + grd.addColorStop(1, this.lineGradientToColor) + ctx.strokeStyle = grd + } + Line.prototype.calcTextRect = function () { + const center = this.getCenter() + let width = Math.abs(this.from.x - this.to.x) + if (width < 100) { + width = 100 + } + if (this.text && !this.text.split) { + this.text += '' + } + const height = this.lineHeight * this.fontSize * - (this.textMaxLine || (this.text && this.text.split('\n').length) || 1); - this.textRect = new Rect(center.x - width / 2, center.y - height / 2, width, height); - }; - Line.prototype.getTextRect = function () { - // calc every time just in case text line is changed. - this.calcTextRect(); - return this.textRect; - }; - Line.prototype.getCenter = function () { - var center = new Point(this.from.x, this.from.y); - switch (this.name) { - case 'line': - center = this.getLineCenter(this.from, this.to); - break; - case 'polyline': - var i = Math.round(this.controlPoints.length / 2); - center = this.getLineCenter(this.controlPoints[i - 1] || this.from, this.controlPoints[i] || this.to); - break; - case 'curve': - center = getBezierPoint(0.5, this.to, this.controlPoints[1], this.controlPoints[0], this.from); - break; - default: - if (drawLineFns[this.name].getCenter) { - center = drawLineFns[this.name].getCenter(this); - } + (this.textMaxLine || (this.text && this.text.split('\n').length) || 1) + this.textRect = new Rect(center.x - width / 2, center.y - height / 2, width, height) + } + Line.prototype.getTextRect = function () { + // calc every time just in case text line is changed. + this.calcTextRect() + return this.textRect + } + Line.prototype.getCenter = function () { + let center = new Point(this.from.x, this.from.y) + switch (this.name) { + case 'line': + center = this.getLineCenter(this.from, this.to) + break + case 'polyline': + var i = Math.round(this.controlPoints.length / 2) + center = this.getLineCenter(this.controlPoints[i - 1] || this.from, this.controlPoints[i] || this.to) + break + case 'curve': + center = getBezierPoint(0.5, this.to, this.controlPoints[1], this.controlPoints[0], this.from) + break + default: + if (drawLineFns[this.name].getCenter) { + center = drawLineFns[this.name].getCenter(this) } - return center; - }; - Line.prototype.getLineCenter = function (from, to) { - return new Point((from.x + to.x) / 2, (from.y + to.y) / 2); - }; - Line.prototype.getPointByPos = function (pos) { - if (pos <= 0) { - return this.from; + } + return center + } + Line.prototype.getLineCenter = function (from, to) { + return new Point((from.x + to.x) / 2, (from.y + to.y) / 2) + } + Line.prototype.getPointByPos = function (pos) { + if (pos <= 0) { + return this.from + } + switch (this.name) { + case 'line': + return this.getLinePtByPos(this.from, this.to, pos) + case 'polyline': + if (!this.controlPoints || !this.controlPoints.length) { + return this.getLinePtByPos(this.from, this.to, pos) + } else { + const points = [].concat(this.controlPoints, this.to) + let curPt = this.from + for (let _i = 0, points_1 = points; _i < points_1.length; _i++) { + const pt = points_1[_i] + const l = lineLen(curPt, pt) + if (pos > l) { + pos -= l + curPt = pt + } else { + return this.getLinePtByPos(curPt, pt, pos) + } + } + return this.to } - switch (this.name) { - case 'line': - return this.getLinePtByPos(this.from, this.to, pos); - case 'polyline': - if (!this.controlPoints || !this.controlPoints.length) { - return this.getLinePtByPos(this.from, this.to, pos); - } - else { - var points = [].concat(this.controlPoints, this.to); - var curPt = this.from; - for (var _i = 0, points_1 = points; _i < points_1.length; _i++) { - var pt = points_1[_i]; - var l = lineLen(curPt, pt); - if (pos > l) { - pos -= l; - curPt = pt; - } - else { - return this.getLinePtByPos(curPt, pt, pos); - } - } - return this.to; - } - case 'curve': - return getBezierPoint(pos / this.getLen(), this.from, this.controlPoints[0], this.controlPoints[1], this.to); - default: - if (drawLineFns[this.name].getPointByPos) { - return drawLineFns[this.name].getPointByPos(pos, this); - } + case 'curve': + return getBezierPoint(pos / this.getLen(), this.from, this.controlPoints[0], this.controlPoints[1], this.to) + default: + if (drawLineFns[this.name].getPointByPos) { + return drawLineFns[this.name].getPointByPos(pos, this) } - return null; - }; - Line.prototype.getPointByReversePos = function (pos) { - if (pos <= 0) { - return this.to; + } + return null + } + Line.prototype.getPointByReversePos = function (pos) { + if (pos <= 0) { + return this.to + } + switch (this.name) { + case 'line': + return this.getLinePtByPos(this.to, this.from, pos) + case 'polyline': + if (!this.controlPoints || !this.controlPoints.length) { + return this.getLinePtByPos(this.to, this.from, pos) + } else { + const points_3 = [] + this.controlPoints.forEach(function (item) { + points_3.unshift(item) + }) + points_3.unshift(this.to) + let curPt = this.to + for (let _i = 0, points_2 = points_3; _i < points_2.length; _i++) { + const pt = points_2[_i] + const l = lineLen(curPt, pt) + if (pos > l) { + pos -= l + curPt = pt + } else { + return this.getLinePtByPos(curPt, pt, pos) + } + } + return this.from } - switch (this.name) { - case 'line': - return this.getLinePtByPos(this.to, this.from, pos); - case 'polyline': - if (!this.controlPoints || !this.controlPoints.length) { - return this.getLinePtByPos(this.to, this.from, pos); - } - else { - var points_3 = []; - this.controlPoints.forEach(function (item) { - points_3.unshift(item); - }); - points_3.unshift(this.to); - var curPt = this.to; - for (var _i = 0, points_2 = points_3; _i < points_2.length; _i++) { - var pt = points_2[_i]; - var l = lineLen(curPt, pt); - if (pos > l) { - pos -= l; - curPt = pt; - } - else { - return this.getLinePtByPos(curPt, pt, pos); - } - } - return this.from; - } - case 'curve': - return getBezierPoint(pos / this.getLen(), this.to, this.controlPoints[1], this.controlPoints[0], this.from); - default: - if (drawLineFns[this.name].getPointByReversePos) { - return drawLineFns[this.name].getPointByReversePos(pos, this); - } + case 'curve': + return getBezierPoint(pos / this.getLen(), this.to, this.controlPoints[1], this.controlPoints[0], this.from) + default: + if (drawLineFns[this.name].getPointByReversePos) { + return drawLineFns[this.name].getPointByReversePos(pos, this) } - return null; - }; - Line.prototype.getLinePtByPos = function (from, to, pos) { - var length = lineLen(from, to); - if (pos <= 0) { - return from; - } - if (pos >= length) { - return to; - } - var x, y; - x = from.x + (to.x - from.x) * (pos / length); - y = from.y + (to.y - from.y) * (pos / length); - return new Point(x, y); - }; - Line.prototype.calcRectInParent = function (parent) { - var parentW = parent.rect.width - parent.paddingLeftNum - parent.paddingRightNum; - var parentH = parent.rect.height - parent.paddingTopNum - parent.paddingBottomNum; - this.rectInParent = { - x: ((this.from.x - parent.rect.x - parent.paddingLeftNum) * 100) / parentW + '%', - y: ((this.from.y - parent.rect.y - parent.paddingTopNum) * 100) / parentH + '%', - width: 0, - height: 0, - rotate: 0, - }; - }; - // 根据父节点rect计算自己(子节点)的rect - Line.prototype.calcRectByParent = function (parent) { - if (!this.rectInParent) { - return; - } - var parentW = parent.rect.width - parent.paddingLeftNum - parent.paddingRightNum; - var parentH = parent.rect.height - parent.paddingTopNum - parent.paddingBottomNum; - var x = parent.rect.x + + } + return null + } + Line.prototype.getLinePtByPos = function (from, to, pos) { + const length = lineLen(from, to) + if (pos <= 0) { + return from + } + if (pos >= length) { + return to + } + let x, y + x = from.x + (to.x - from.x) * (pos / length) + y = from.y + (to.y - from.y) * (pos / length) + return new Point(x, y) + } + Line.prototype.calcRectInParent = function (parent) { + const parentW = parent.rect.width - parent.paddingLeftNum - parent.paddingRightNum + const parentH = parent.rect.height - parent.paddingTopNum - parent.paddingBottomNum + this.rectInParent = { + x: ((this.from.x - parent.rect.x - parent.paddingLeftNum) * 100) / parentW + '%', + y: ((this.from.y - parent.rect.y - parent.paddingTopNum) * 100) / parentH + '%', + width: 0, + height: 0, + rotate: 0 + } + } + // 根据父节点rect计算自己(子节点)的rect + Line.prototype.calcRectByParent = function (parent) { + if (!this.rectInParent) { + return + } + const parentW = parent.rect.width - parent.paddingLeftNum - parent.paddingRightNum + const parentH = parent.rect.height - parent.paddingTopNum - parent.paddingBottomNum + let x = parent.rect.x + parent.paddingLeftNum + abs(parentW, this.rectInParent.x) + - abs(parentW, this.rectInParent.marginLeft); - var y = parent.rect.y + + abs(parentW, this.rectInParent.marginLeft) + let y = parent.rect.y + parent.paddingTopNum + abs(parentH, this.rectInParent.y) + - abs(parentW, this.rectInParent.marginTop); - if (this.rectInParent.marginLeft === undefined && this.rectInParent.marginRight) { - x -= abs(parentW, this.rectInParent.marginRight); + abs(parentW, this.rectInParent.marginTop) + if (this.rectInParent.marginLeft === undefined && this.rectInParent.marginRight) { + x -= abs(parentW, this.rectInParent.marginRight) + } + if (this.rectInParent.marginTop === undefined && this.rectInParent.marginBottom) { + y -= abs(parentW, this.rectInParent.marginBottom) + } + this.translate(x - this.from.x, y - this.from.y) + } + Line.prototype.initAnimate = function () { + this.animateStart = 0 + this.animateDot = undefined + this.animatePos = 0 + } + Line.prototype.pauseAnimate = function () { + Store.set(this.generateStoreKey('LT:AnimatePlay'), { + pen: this, + stop: true + }) + } + Line.prototype.stopAnimate = function () { + const _this = this + this.pauseAnimate() + this.initAnimate() + setTimeout(function () { + Store.set(_this.generateStoreKey('LT:render'), { + pen: _this, + stop: true + }) + }, 50) + } + Line.prototype.animate = function (now) { + this.animatePos += this.animateSpan + switch (this.animateType) { + case 'beads': + if (this.animateReverse) { + this.lineDashOffset = this.animatePos + } else { + this.lineDashOffset = -this.animatePos } - if (this.rectInParent.marginTop === undefined && this.rectInParent.marginBottom) { - y -= abs(parentW, this.rectInParent.marginBottom); + var len = this.lineWidth + if (len < 5) { + len = 5 } - this.translate(x - this.from.x, y - this.from.y); - }; - Line.prototype.initAnimate = function () { - this.animateStart = 0; - this.animateDot = undefined; - this.animatePos = 0; - }; - Line.prototype.pauseAnimate = function () { - Store.set(this.generateStoreKey('LT:AnimatePlay'), { - pen: this, - stop: true, - }); - }; - Line.prototype.stopAnimate = function () { - var _this = this; - this.pauseAnimate(); - this.initAnimate(); - setTimeout(function () { - Store.set(_this.generateStoreKey('LT:render'), { - pen: _this, - stop: true, - }); - }, 50); - }; - Line.prototype.animate = function (now) { - this.animatePos += this.animateSpan; - switch (this.animateType) { - case 'beads': - if (this.animateReverse) { - this.lineDashOffset = this.animatePos; - } - else { - this.lineDashOffset = -this.animatePos; - } - var len = this.lineWidth; - if (len < 5) { - len = 5; - } - if (this.animateLineDash) { - this.lineDash = this.animateLineDash; - } - else { - this.lineDash = [len, len * 2]; - } - break; - case 'dot': - case 'comet': - this.lineDash = undefined; - var pos = void 0; - if (this.animateReverse) { - pos = this.getPointByReversePos(this.animatePos + this.animateToSize); - } - else { - pos = this.getPointByPos(this.animatePos + this.animateFromSize); - } - this.animateDot = pos; - break; - default: - if (this.animateReverse) { - this.lineDash = [0, this.length - this.animatePos + 1, this.animatePos]; - } - else { - this.lineDash = [this.animatePos, this.length - this.animatePos + 1]; - } - break; + if (this.animateLineDash) { + this.lineDash = this.animateLineDash + } else { + this.lineDash = [len, len * 2] } - if (this.animatePos > this.length + this.animateSpan - this.animateFromSize - this.animateToSize) { - if (++this.animateCycleIndex >= this.animateCycle && this.animateCycle > 0) { - this.animateStart = 0; - this.initAnimate(); - Store.set(this.generateStoreKey('animateEnd'), this); - return; - } - this.animatePos = this.animateSpan; + break + case 'dot': + case 'comet': + this.lineDash = undefined + var pos = void 0 + if (this.animateReverse) { + pos = this.getPointByReversePos(this.animatePos + this.animateToSize) + } else { + pos = this.getPointByPos(this.animatePos + this.animateFromSize) } - }; - Line.prototype.getBubbles = function () { - var bubbles = []; - for (var i = 0; i < 30 && this.animatePos - i > 0; ++i) { - if (this.animateReverse) { - bubbles.push({ - pos: this.getPointByReversePos(this.animatePos - i * 2 + this.animateToSize), - a: 1 - i * 0.03, - r: this.lineWidth - i * 0.01, - }); - } - else { - bubbles.push({ - pos: this.getPointByPos(this.animatePos - i * 2 + this.animateFromSize), - a: 1 - i * 0.03, - r: this.lineWidth - i * 0.01, - }); - } + this.animateDot = pos + break + default: + if (this.animateReverse) { + this.lineDash = [0, this.length - this.animatePos + 1, this.animatePos] + } else { + this.lineDash = [this.animatePos, this.length - this.animatePos + 1] } - return bubbles; - }; - Line.prototype.round = function () { - this.from.round(); - this.to.round(); - }; - Line.prototype.translate = function (x, y) { - if (this.from) { - this.from.x += x; - this.from.y += y; - this.to.x += x; - this.to.y += y; - if (this.text) { - this.textRect = undefined; - } - for (var _i = 0, _a = this.controlPoints; _i < _a.length; _i++) { - var pt = _a[_i]; - pt.x += x; - pt.y += y; - } - } - if (this.children) { - for (var _b = 0, _c = this.children; _b < _c.length; _b++) { - var item = _c[_b]; - item.translate(x, y); - } - } - Store.set(this.generateStoreKey('pts-') + this.id, undefined); - }; - Line.prototype.scale = function (scale, center) { - if (this.from) { - this.from.x = center.x - (center.x - this.from.x) * scale; - this.from.y = center.y - (center.y - this.from.y) * scale; - this.to.x = center.x - (center.x - this.to.x) * scale; - this.to.y = center.y - (center.y - this.to.y) * scale; - this.lineWidth *= scale; - this.borderWidth *= scale; - this.fontSize *= scale; - if (this.text) { - this.textRect = undefined; - } - this.textOffsetX *= scale; - this.textOffsetY *= scale; - for (var _i = 0, _a = this.controlPoints; _i < _a.length; _i++) { - var pt = _a[_i]; - pt.x = center.x - (center.x - pt.x) * scale; - pt.y = center.y - (center.y - pt.y) * scale; - } - } - if (this.children) { - for (var _b = 0, _c = this.children; _b < _c.length; _b++) { - var item = _c[_b]; - item.scale(scale, center); - } - } - Store.set(this.generateStoreKey('pts-') + this.id, undefined); - }; - Line.prototype.hit = function (pt, padding) { - if (padding === void 0) { padding = 0; } - if (this.from.hit(pt, padding) || this.to.hit(pt, padding)) { - return this; - } - }; - Line.prototype.clone = function () { - return new Line(this); - }; - return Line; -}(Pen)); -export { Line }; -//# sourceMappingURL=line.js.map \ No newline at end of file + break + } + if (this.animatePos > this.length + this.animateSpan - this.animateFromSize - this.animateToSize) { + if (++this.animateCycleIndex >= this.animateCycle && this.animateCycle > 0) { + this.animateStart = 0 + this.initAnimate() + Store.set(this.generateStoreKey('animateEnd'), this) + return + } + this.animatePos = this.animateSpan + } + } + Line.prototype.getBubbles = function () { + const bubbles = [] + for (let i = 0; i < 30 && this.animatePos - i > 0; ++i) { + if (this.animateReverse) { + bubbles.push({ + pos: this.getPointByReversePos(this.animatePos - i * 2 + this.animateToSize), + a: 1 - i * 0.03, + r: this.lineWidth - i * 0.01 + }) + } else { + bubbles.push({ + pos: this.getPointByPos(this.animatePos - i * 2 + this.animateFromSize), + a: 1 - i * 0.03, + r: this.lineWidth - i * 0.01 + }) + } + } + return bubbles + } + Line.prototype.round = function () { + this.from.round() + this.to.round() + } + Line.prototype.translate = function (x, y) { + if (this.from) { + this.from.x += x + this.from.y += y + this.to.x += x + this.to.y += y + if (this.text) { + this.textRect = undefined + } + for (let _i = 0, _a = this.controlPoints; _i < _a.length; _i++) { + const pt = _a[_i] + pt.x += x + pt.y += y + } + } + if (this.children) { + for (let _b = 0, _c = this.children; _b < _c.length; _b++) { + const item = _c[_b] + item.translate(x, y) + } + } + Store.set(this.generateStoreKey('pts-') + this.id, undefined) + } + Line.prototype.scale = function (scale, center) { + if (this.from) { + this.from.x = center.x - (center.x - this.from.x) * scale + this.from.y = center.y - (center.y - this.from.y) * scale + this.to.x = center.x - (center.x - this.to.x) * scale + this.to.y = center.y - (center.y - this.to.y) * scale + this.lineWidth *= scale + this.borderWidth *= scale + this.fontSize *= scale + if (this.text) { + this.textRect = undefined + } + this.textOffsetX *= scale + this.textOffsetY *= scale + for (let _i = 0, _a = this.controlPoints; _i < _a.length; _i++) { + const pt = _a[_i] + pt.x = center.x - (center.x - pt.x) * scale + pt.y = center.y - (center.y - pt.y) * scale + } + } + if (this.children) { + for (let _b = 0, _c = this.children; _b < _c.length; _b++) { + const item = _c[_b] + item.scale(scale, center) + } + } + Store.set(this.generateStoreKey('pts-') + this.id, undefined) + } + Line.prototype.hit = function (pt, padding) { + if (padding === void 0) { padding = 0 } + if (this.from.hit(pt, padding) || this.to.hit(pt, padding)) { + return this + } + } + Line.prototype.clone = function () { + return new Line(this) + } + return Line +}(Pen)) +export { Line } +// # sourceMappingURL=line.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/models/point.js b/nezha-fronted/src/components/common/@topology/core/src/models/point.js index b5e0313e4..a7bcfe7fb 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/models/point.js +++ b/nezha-fronted/src/components/common/@topology/core/src/models/point.js @@ -1,53 +1,53 @@ -var Point = /** @class */ (function () { - function Point(x, y, direction, anchorIndex, id, hidden, autoAnchor) { - this.x = x; - this.y = y; - this.direction = direction; - this.anchorIndex = anchorIndex; - this.id = id; - this.hidden = hidden; - this.autoAnchor = autoAnchor; +const Point = /** @class */ (function () { + function Point (x, y, direction, anchorIndex, id, hidden, autoAnchor) { + this.x = x + this.y = y + this.direction = direction + this.anchorIndex = anchorIndex + this.id = id + this.hidden = hidden + this.autoAnchor = autoAnchor + } + Point.prototype.floor = function () { + this.x |= 0 + this.y |= 0 + } + Point.prototype.round = function () { + this.x = Math.round(this.x) + this.y = Math.round(this.y) + } + Point.prototype.clone = function () { + const pt = new Point(this.x, this.y, this.direction, this.anchorIndex, this.id, this.hidden, this.autoAnchor) + if (this.data) { + pt.data = this.data } - Point.prototype.floor = function () { - this.x |= 0; - this.y |= 0; - }; - Point.prototype.round = function () { - this.x = Math.round(this.x); - this.y = Math.round(this.y); - }; - Point.prototype.clone = function () { - var pt = new Point(this.x, this.y, this.direction, this.anchorIndex, this.id, this.hidden, this.autoAnchor); - if (this.data) { - pt.data = this.data; - } - if (this.mode) { - pt.mode = this.mode; - } - return pt; - }; - Point.prototype.hit = function (pt, radius) { - if (radius === void 0) { radius = 5; } - return pt.x > this.x - radius && pt.x < this.x + radius && pt.y > this.y - radius && pt.y < this.y + radius; - }; - Point.prototype.rotate = function (angle, center) { - if (!angle || angle === 360) { - return this; - } - angle *= Math.PI / 180; - var x = (this.x - center.x) * Math.cos(angle) - (this.y - center.y) * Math.sin(angle) + center.x; - var y = (this.x - center.x) * Math.sin(angle) + (this.y - center.y) * Math.cos(angle) + center.y; - this.x = x; - this.y = y; - return this; - }; - Point.prototype.isSameAs = function (pt) { - return this.anchorIndex === pt.anchorIndex && this.direction === pt.direction && this.id === pt.id; - }; - return Point; -}()); -export { Point }; + if (this.mode) { + pt.mode = this.mode + } + return pt + } + Point.prototype.hit = function (pt, radius) { + if (radius === void 0) { radius = 5 } + return pt.x > this.x - radius && pt.x < this.x + radius && pt.y > this.y - radius && pt.y < this.y + radius + } + Point.prototype.rotate = function (angle, center) { + if (!angle || angle === 360) { + return this + } + angle *= Math.PI / 180 + const x = (this.x - center.x) * Math.cos(angle) - (this.y - center.y) * Math.sin(angle) + center.x + const y = (this.x - center.x) * Math.sin(angle) + (this.y - center.y) * Math.cos(angle) + center.y + this.x = x + this.y = y + return this + } + Point.prototype.isSameAs = function (pt) { + return this.anchorIndex === pt.anchorIndex && this.direction === pt.direction && this.id === pt.id + } + return Point +}()) +export { Point } console.log(132123132123) -window.topologyPoint = Point; -window.Le5leTopologyPoint = Point; -//# sourceMappingURL=point.js.map +window.topologyPoint = Point +window.Le5leTopologyPoint = Point +// # sourceMappingURL=point.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/models/rect.js b/nezha-fronted/src/components/common/@topology/core/src/models/rect.js index 3f99987fd..ba64eb706 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/models/rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/models/rect.js @@ -1,94 +1,94 @@ -import { Point } from './point'; -import { pointInRect } from '../utils/canvas'; -var Rect = /** @class */ (function () { - function Rect(x, y, width, height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.center = new Point(0, 0); - if (width < 0) { - width = 0; - } - if (height < 0) { - height = 0; - } - this.init(); +import { Point } from './point' +import { pointInRect } from '../utils/canvas' +const Rect = /** @class */ (function () { + function Rect (x, y, width, height) { + this.x = x + this.y = y + this.width = width + this.height = height + this.center = new Point(0, 0) + if (width < 0) { + width = 0 } - Rect.prototype.init = function () { - this.ex = this.x + this.width; - this.ey = this.y + this.height; - this.calcCenter(); - }; - Rect.prototype.floor = function () { - this.x |= 0; - this.y |= 0; - this.width |= 0; - this.height |= 0; - this.init(); - }; - Rect.prototype.round = function () { - this.x = Math.round(this.x); - this.y = Math.round(this.y); - this.width = Math.round(this.width); - this.height = Math.round(this.height); - this.init(); - }; - Rect.prototype.clone = function () { - return new Rect(this.x, this.y, this.width, this.height); - }; - Rect.prototype.hit = function (pt, padding) { - if (padding === void 0) { padding = 0; } - return pt && pt.x > this.x - padding && pt.x < this.ex + padding && pt.y > this.y - padding && pt.y < this.ey + padding; - }; - Rect.prototype.hitByRect = function (rect) { - return ((rect.x > this.x && rect.x < this.ex && rect.y > this.y && rect.y < this.ey) || + if (height < 0) { + height = 0 + } + this.init() + } + Rect.prototype.init = function () { + this.ex = this.x + this.width + this.ey = this.y + this.height + this.calcCenter() + } + Rect.prototype.floor = function () { + this.x |= 0 + this.y |= 0 + this.width |= 0 + this.height |= 0 + this.init() + } + Rect.prototype.round = function () { + this.x = Math.round(this.x) + this.y = Math.round(this.y) + this.width = Math.round(this.width) + this.height = Math.round(this.height) + this.init() + } + Rect.prototype.clone = function () { + return new Rect(this.x, this.y, this.width, this.height) + } + Rect.prototype.hit = function (pt, padding) { + if (padding === void 0) { padding = 0 } + return pt && pt.x > this.x - padding && pt.x < this.ex + padding && pt.y > this.y - padding && pt.y < this.ey + padding + } + Rect.prototype.hitByRect = function (rect) { + return ((rect.x > this.x && rect.x < this.ex && rect.y > this.y && rect.y < this.ey) || (rect.ex > this.x && rect.ex < this.ex && rect.y > this.y && rect.y < this.ey) || (rect.ex > this.x && rect.ex < this.ex && rect.ey > this.y && rect.ey < this.ey) || - (rect.x > this.x && rect.x < this.ex && rect.ey > this.y && rect.ey < this.ey)); - }; - Rect.prototype.hitRotate = function (point, rotate, center) { - var pts = this.toPoints(); - for (var _i = 0, pts_1 = pts; _i < pts_1.length; _i++) { - var pt = pts_1[_i]; - pt.rotate(rotate, center); - } - return pointInRect(point, pts); - }; - Rect.prototype.calcCenter = function () { - this.center.x = this.x + this.width / 2; - this.center.y = this.y + this.height / 2; - }; - Rect.prototype.toPoints = function () { - return [ - new Point(this.x, this.y), - new Point(this.ex, this.y), - new Point(this.ex, this.ey), - new Point(this.x, this.ey), - ]; - }; - Rect.prototype.translate = function (x, y) { - this.x += x; - this.y += y; - this.ex += x; - this.ey += y; - this.calcCenter(); - }; - Rect.prototype.scale = function (scale, center, scaleY) { - if (!center) { - center = this.center; - } - if (scaleY === undefined) { - scaleY = scale; - } - this.x = center.x - (center.x - this.x) * scale; - this.y = center.y - (center.y - this.y) * scaleY; - this.width *= scale; - this.height *= scaleY; - this.init(); - }; - return Rect; -}()); -export { Rect }; -window.topologyRect = Rect; -//# sourceMappingURL=rect.js.map \ No newline at end of file + (rect.x > this.x && rect.x < this.ex && rect.ey > this.y && rect.ey < this.ey)) + } + Rect.prototype.hitRotate = function (point, rotate, center) { + const pts = this.toPoints() + for (let _i = 0, pts_1 = pts; _i < pts_1.length; _i++) { + const pt = pts_1[_i] + pt.rotate(rotate, center) + } + return pointInRect(point, pts) + } + Rect.prototype.calcCenter = function () { + this.center.x = this.x + this.width / 2 + this.center.y = this.y + this.height / 2 + } + Rect.prototype.toPoints = function () { + return [ + new Point(this.x, this.y), + new Point(this.ex, this.y), + new Point(this.ex, this.ey), + new Point(this.x, this.ey) + ] + } + Rect.prototype.translate = function (x, y) { + this.x += x + this.y += y + this.ex += x + this.ey += y + this.calcCenter() + } + Rect.prototype.scale = function (scale, center, scaleY) { + if (!center) { + center = this.center + } + if (scaleY === undefined) { + scaleY = scale + } + this.x = center.x - (center.x - this.x) * scale + this.y = center.y - (center.y - this.y) * scaleY + this.width *= scale + this.height *= scaleY + this.init() + } + return Rect +}()) +export { Rect } +window.topologyRect = Rect +// # sourceMappingURL=rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/models/status.js b/nezha-fronted/src/components/common/@topology/core/src/models/status.js index 7f77ff6f2..a449671f5 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/models/status.js +++ b/nezha-fronted/src/components/common/@topology/core/src/models/status.js @@ -1,14 +1,14 @@ export var Lock; (function (Lock) { - Lock[Lock["None"] = 0] = "None"; - Lock[Lock["Readonly"] = 1] = "Readonly"; - Lock[Lock["NoMove"] = 2] = "NoMove"; - Lock[Lock["NoEvent"] = 10] = "NoEvent"; -})(Lock || (Lock = {})); + Lock[Lock.None = 0] = 'None' + Lock[Lock.Readonly = 1] = 'Readonly' + Lock[Lock.NoMove = 2] = 'NoMove' + Lock[Lock.NoEvent = 10] = 'NoEvent' +})(Lock || (Lock = {})) export var AnchorMode; (function (AnchorMode) { - AnchorMode[AnchorMode["Default"] = 0] = "Default"; - AnchorMode[AnchorMode["In"] = 1] = "In"; - AnchorMode[AnchorMode["Out"] = 2] = "Out"; -})(AnchorMode || (AnchorMode = {})); -//# sourceMappingURL=status.js.map \ No newline at end of file + AnchorMode[AnchorMode.Default = 0] = 'Default' + AnchorMode[AnchorMode.In = 1] = 'In' + AnchorMode[AnchorMode.Out = 2] = 'Out' +})(AnchorMode || (AnchorMode = {})) +// # sourceMappingURL=status.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/mqtt.js b/nezha-fronted/src/components/common/@topology/core/src/mqtt.js index f1fdcfdbb..56806ee29 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/mqtt.js +++ b/nezha-fronted/src/components/common/@topology/core/src/mqtt.js @@ -1,27 +1,27 @@ -import * as mqtt from 'mqtt/dist/mqtt.min.js'; -var MQTT = /** @class */ (function () { - function MQTT(url, options, topics, cb) { - this.url = url; - this.options = options; - this.topics = topics; - this.cb = cb; - this.fns = {}; - this.init(); +import * as mqtt from 'mqtt/dist/mqtt.min.js' +const MQTT = /** @class */ (function () { + function MQTT (url, options, topics, cb) { + this.url = url + this.options = options + this.topics = topics + this.cb = cb + this.fns = {} + this.init() + } + MQTT.prototype.init = function () { + this.client = mqtt.connect(this.url, this.options) + this.client.on('message', this.cb) + if (this.topics) { + this.client.subscribe(this.topics.split(',')) } - MQTT.prototype.init = function () { - this.client = mqtt.connect(this.url, this.options); - this.client.on('message', this.cb); - if (this.topics) { - this.client.subscribe(this.topics.split(',')); - } - }; - MQTT.prototype.publish = function (topic, message) { - this.client.publish(topic, message); - }; - MQTT.prototype.close = function () { - this.client.end(); - }; - return MQTT; -}()); -export { MQTT }; -//# sourceMappingURL=mqtt.js.map \ No newline at end of file + } + MQTT.prototype.publish = function (topic, message) { + this.client.publish(topic, message) + } + MQTT.prototype.close = function () { + this.client.end() + } + return MQTT +}()) +export { MQTT } +// # sourceMappingURL=mqtt.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/offscreen.js b/nezha-fronted/src/components/common/@topology/core/src/offscreen.js index 38f246911..974135f6b 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/offscreen.js +++ b/nezha-fronted/src/components/common/@topology/core/src/offscreen.js @@ -1,54 +1,53 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -import { Store } from 'le5le-store'; -import { Canvas } from './canvas'; -import { rectInRect } from './utils/rect'; -import { Rect, PenType } from './models'; -var Offscreen = /** @class */ (function (_super) { - __extends(Offscreen, _super); - function Offscreen(parentElem, options, TID) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, parentElem, options, TID) || this; - _this.parentElem = parentElem; - _this.options = options; - _this.activeLayer = Store.get(_this.generateStoreKey('LT:ActiveLayer')); - _this.hoverLayer = Store.get(_this.generateStoreKey('LT:HoverLayer')); - _this.animateLayer = Store.get(_this.generateStoreKey('LT:AnimateLayer')); - Store.set(_this.generateStoreKey('LT:offscreen'), _this.canvas); - return _this; +import { Store } from 'le5le-store' +import { Canvas } from './canvas' +import { rectInRect } from './utils/rect' +import { Rect, PenType } from './models' +const __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) || + function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] } + return extendStatics(d, b) + } + return function (d, b) { + extendStatics(d, b) + function __ () { this.constructor = d } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()) + } +})() +const Offscreen = /** @class */ (function (_super) { + __extends(Offscreen, _super) + function Offscreen (parentElem, options, TID) { + if (options === void 0) { options = {} } + const _this = _super.call(this, parentElem, options, TID) || this + _this.parentElem = parentElem + _this.options = options + _this.activeLayer = Store.get(_this.generateStoreKey('LT:ActiveLayer')) + _this.hoverLayer = Store.get(_this.generateStoreKey('LT:HoverLayer')) + _this.animateLayer = Store.get(_this.generateStoreKey('LT:AnimateLayer')) + Store.set(_this.generateStoreKey('LT:offscreen'), _this.canvas) + } + Offscreen.prototype.render = function () { + _super.prototype.render.call(this) + const ctx = this.canvas.getContext('2d') + ctx.strokeStyle = this.options.color + const canvasRect = new Rect(-this.data.x, -this.data.y, this.width, this.height) + for (let _i = 0, _a = this.data.pens; _i < _a.length; _i++) { + const item = _a[_i] + if (!item.getTID()) { + item.setTID(this.TID) + } + // 连线类型没有 rect,必渲染 + if (!rectInRect(item.rect, canvasRect) && item.type === PenType.Node) { + continue + } + item.render(ctx) } - Offscreen.prototype.render = function () { - _super.prototype.render.call(this); - var ctx = this.canvas.getContext('2d'); - ctx.strokeStyle = this.options.color; - var canvasRect = new Rect(-this.data.x, -this.data.y, this.width, this.height); - for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) { - var item = _a[_i]; - if (!item.getTID()) { - item.setTID(this.TID); - } - // 连线类型没有 rect,必渲染 - if (!rectInRect(item.rect, canvasRect) && item.type === PenType.Node) { - continue; - } - item.render(ctx); - } - this.activeLayer.render(ctx); - this.animateLayer.render(ctx); - this.hoverLayer.render(ctx); - }; - return Offscreen; -}(Canvas)); -export { Offscreen }; -//# sourceMappingURL=offscreen.js.map \ No newline at end of file + this.activeLayer.render(ctx) + this.animateLayer.render(ctx) + this.hoverLayer.render(ctx) + } + return Offscreen +}(Canvas)) +export { Offscreen } +// # sourceMappingURL=offscreen.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/options.js b/nezha-fronted/src/components/common/@topology/core/src/options.js index 9b3aecfd9..07415d062 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/options.js +++ b/nezha-fronted/src/components/common/@topology/core/src/options.js @@ -1,45 +1,45 @@ export var KeyType; (function (KeyType) { - KeyType[KeyType["Any"] = -1] = "Any"; - KeyType[KeyType["CtrlOrAlt"] = 0] = "CtrlOrAlt"; - KeyType[KeyType["Ctrl"] = 1] = "Ctrl"; - KeyType[KeyType["Shift"] = 2] = "Shift"; - KeyType[KeyType["Alt"] = 3] = "Alt"; - KeyType[KeyType["Right"] = 4] = "Right"; -})(KeyType || (KeyType = {})); + KeyType[KeyType.Any = -1] = 'Any' + KeyType[KeyType.CtrlOrAlt = 0] = 'CtrlOrAlt' + KeyType[KeyType.Ctrl = 1] = 'Ctrl' + KeyType[KeyType.Shift = 2] = 'Shift' + KeyType[KeyType.Alt = 3] = 'Alt' + KeyType[KeyType.Right = 4] = 'Right' +})(KeyType || (KeyType = {})) export var KeydownType; (function (KeydownType) { - KeydownType[KeydownType["None"] = -1] = "None"; - KeydownType[KeydownType["Document"] = 0] = "Document"; - KeydownType[KeydownType["Canvas"] = 1] = "Canvas"; -})(KeydownType || (KeydownType = {})); -export var fontKeys = ['fontColor', 'fontFamily', 'fontSize', 'lineHeight', 'textAlign', 'textBaseline']; + KeydownType[KeydownType.None = -1] = 'None' + KeydownType[KeydownType.Document = 0] = 'Document' + KeydownType[KeydownType.Canvas = 1] = 'Canvas' +})(KeydownType || (KeydownType = {})) +export var fontKeys = ['fontColor', 'fontFamily', 'fontSize', 'lineHeight', 'textAlign', 'textBaseline'] export var DefalutOptions = { - cacheLen: 30, - refresh: 30, - fontColor: '#222222', - fontFamily: '"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial', - fontSize: 12, - lineHeight: 1.5, - textAlign: 'center', - textBaseline: 'middle', - color: '#222222', - activeColor: '#1890ff', - hoverColor: '#fa541c', - anchorRadius: 4, - anchorFillStyle: '#fff', - dockStrokeStyle: '#fa541c', - dockFillStyle: '#fa541c', - dragColor: '#1890ff', - rotateCursor: '/assets/img/rotate.cur', - hoverCursor: 'pointer', - minScale: 0.3, - maxScale: 5, - anchorSize: 5, - keydown: KeydownType.Document, - viewPadding: 0, - gridSize: 10, - gridColor: '#f3f3f3', - ruleColor: '#888888', -}; -//# sourceMappingURL=options.js.map \ No newline at end of file + cacheLen: 30, + refresh: 30, + fontColor: '#222222', + fontFamily: '"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial', + fontSize: 12, + lineHeight: 1.5, + textAlign: 'center', + textBaseline: 'middle', + color: '#222222', + activeColor: '#1890ff', + hoverColor: '#fa541c', + anchorRadius: 4, + anchorFillStyle: '#fff', + dockStrokeStyle: '#fa541c', + dockFillStyle: '#fa541c', + dragColor: '#1890ff', + rotateCursor: '/assets/img/rotate.cur', + hoverCursor: 'pointer', + minScale: 0.3, + maxScale: 5, + anchorSize: 5, + keydown: KeydownType.Document, + viewPadding: 0, + gridSize: 10, + gridColor: '#f3f3f3', + ruleColor: '#888888' +} +// # sourceMappingURL=options.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/renderLayer.js b/nezha-fronted/src/components/common/@topology/core/src/renderLayer.js index fdfc9c09f..0f22af1b7 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/renderLayer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/renderLayer.js @@ -1,134 +1,133 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -import { Store } from 'le5le-store'; -import { Canvas } from './canvas'; -import { rgba } from './utils/math'; -import { Rect } from './models'; -var RenderLayer = /** @class */ (function (_super) { - __extends(RenderLayer, _super); - function RenderLayer(parentElem, options, TID) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, parentElem, options, TID) || this; - _this.parentElem = parentElem; - _this.options = options; - _this.render = function () { - if (_this.data && _this.data.bkImage && !_this.bkImg) { - _this.loadBkImg(_this.render); - return; - } - if (!_this.width || !_this.height || !_this.offscreen) { - return; - } - var ctx = _this.canvas.getContext('2d'); - ctx.clearRect(0, 0, _this.canvas.width, _this.canvas.height); - if (_this.data.bkColor || _this.options.bkColor) { - ctx.fillStyle = _this.data.bkColor || _this.options.bkColor; - ctx.fillRect(0, 0, _this.width, _this.height); - } - if (_this.bkImg && _this.data.bkImageRect) { - ctx.drawImage(_this.bkImg, _this.data.bkImageRect.x, _this.data.bkImageRect.y, _this.data.bkImageRect.width, _this.data.bkImageRect.height); - } - if (_this.data.grid || _this.options.grid) { - _this.grid(); - } - if (_this.data.rule || _this.options.rule) { - _this.rule(); - } - ctx.drawImage(_this.offscreen, 0, 0, _this.width, _this.height); - }; - _this.offscreen = Store.get(_this.generateStoreKey('LT:offscreen')); - _this.parentElem.appendChild(_this.canvas); - _this.data = Store.get(_this.generateStoreKey('topology-data')); - return _this; +import { Store } from 'le5le-store' +import { Canvas } from './canvas' +import { rgba } from './utils/math' +import { Rect } from './models' +const __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) || + function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] } + return extendStatics(d, b) + } + return function (d, b) { + extendStatics(d, b) + function __ () { this.constructor = d } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()) + } +})() +const RenderLayer = /** @class */ (function (_super) { + __extends(RenderLayer, _super) + function RenderLayer (parentElem, options, TID) { + if (options === void 0) { options = {} } + const _this = _super.call(this, parentElem, options, TID) || this + _this.parentElem = parentElem + _this.options = options + _this.render = function () { + if (_this.data && _this.data.bkImage && !_this.bkImg) { + _this.loadBkImg(_this) + return + } + if (!_this.width || !_this.height || !_this.offscreen) { + return + } + const ctx = _this.canvas.getContext('2d') + ctx.clearRect(0, 0, _this.canvas.width, _this.canvas.height) + if (_this.data.bkColor || _this.options.bkColor) { + ctx.fillStyle = _this.data.bkColor || _this.options.bkColor + ctx.fillRect(0, 0, _this.width, _this.height) + } + if (_this.bkImg && _this.data.bkImageRect) { + ctx.drawImage(_this.bkImg, _this.data.bkImageRect.x, _this.data.bkImageRect.y, _this.data.bkImageRect.width, _this.data.bkImageRect.height) + } + if (_this.data.grid || _this.options.grid) { + _this.grid() + } + if (_this.data.rule || _this.options.rule) { + _this.rule() + } + ctx.drawImage(_this.offscreen, 0, 0, _this.width, _this.height) } - RenderLayer.prototype.loadBkImg = function (cb) { - var _this = this; - if (!this.data.bkImage) { - return; - } - this.bkImg = new Image(); - this.bkImg.crossOrigin = 'anonymous'; - this.bkImg.src = this.data.bkImage; - this.bkImg.onload = function () { - if (!_this.data.bkImageRect) { - _this.data.bkImageRect = new Rect(0, 0, _this.bkImg.naturalWidth, _this.bkImg.naturalHeight); - } - if (cb) { - cb(); - } - }; - }; - RenderLayer.prototype.clearBkImg = function () { - this.bkImg = undefined; - }; - RenderLayer.prototype.rule = function () { - var ctx = this.canvas.getContext('2d'); - ctx.save(); - ctx.lineWidth = 1; - ctx.strokeStyle = rgba(0.7, this.data.ruleColor || this.options.ruleColor || '#888'); - ctx.beginPath(); - for (var i = 10; i < this.width; i += 10) { - ctx.moveTo(i, 0); - ctx.lineTo(i, 5); - } - for (var i = 10; i < this.height; i += 10) { - ctx.moveTo(0, i); - ctx.lineTo(5, i); - } - ctx.stroke(); - ctx.beginPath(); - ctx.strokeStyle = this.data.ruleColor || this.options.ruleColor || '#888'; - ctx.fillStyle = ctx.strokeStyle; - for (var i = 100; i < this.width; i += 100) { - ctx.moveTo(i, 0); - ctx.lineTo(i, 10); - ctx.fillText(i.toString(), i + 4, 16); - } - for (var i = 100; i < this.height; i += 100) { - ctx.moveTo(0, i); - ctx.lineTo(10, i); - } - ctx.stroke(); - for (var i = 100; i < this.height; i += 100) { - ctx.save(); - ctx.beginPath(); - ctx.translate(16, i - 4); - ctx.rotate((270 * Math.PI) / 180); - ctx.fillText(i.toString(), 0, 0); - ctx.restore(); - } - ctx.restore(); - }; - RenderLayer.prototype.grid = function () { - var ctx = this.canvas.getContext('2d'); - ctx.save(); - ctx.lineWidth = 1; - ctx.strokeStyle = this.data.gridColor || this.options.gridColor || '#f3f3f3'; - ctx.beginPath(); - var size = this.data.gridSize || this.options.gridSize; - for (var i = size; i < this.width; i += size) { - ctx.moveTo(i, 0); - ctx.lineTo(i, this.height); - } - for (var i = size; i < this.height; i += size) { - ctx.moveTo(0, i); - ctx.lineTo(this.width, i); - } - ctx.stroke(); - ctx.restore(); - }; - return RenderLayer; -}(Canvas)); -export { RenderLayer }; -//# sourceMappingURL=renderLayer.js.map \ No newline at end of file + _this.offscreen = Store.get(_this.generateStoreKey('LT:offscreen')) + _this.parentElem.appendChild(_this.canvas) + _this.data = Store.get(_this.generateStoreKey('topology-data')) + } + RenderLayer.prototype.loadBkImg = function (cb) { + const _this = this + if (!this.data.bkImage) { + return + } + this.bkImg = new Image() + this.bkImg.crossOrigin = 'anonymous' + this.bkImg.src = this.data.bkImage + this.bkImg.onload = function () { + if (!_this.data.bkImageRect) { + _this.data.bkImageRect = new Rect(0, 0, _this.bkImg.naturalWidth, _this.bkImg.naturalHeight) + } + if (cb) { + cb() + } + } + } + RenderLayer.prototype.clearBkImg = function () { + this.bkImg = undefined + } + RenderLayer.prototype.rule = function () { + const ctx = this.canvas.getContext('2d') + ctx.save() + ctx.lineWidth = 1 + ctx.strokeStyle = rgba(0.7, this.data.ruleColor || this.options.ruleColor || '#888') + ctx.beginPath() + for (var i = 10; i < this.width; i += 10) { + ctx.moveTo(i, 0) + ctx.lineTo(i, 5) + } + for (var i = 10; i < this.height; i += 10) { + ctx.moveTo(0, i) + ctx.lineTo(5, i) + } + ctx.stroke() + ctx.beginPath() + ctx.strokeStyle = this.data.ruleColor || this.options.ruleColor || '#888' + ctx.fillStyle = ctx.strokeStyle + for (var i = 100; i < this.width; i += 100) { + ctx.moveTo(i, 0) + ctx.lineTo(i, 10) + ctx.fillText(i.toString(), i + 4, 16) + } + for (var i = 100; i < this.height; i += 100) { + ctx.moveTo(0, i) + ctx.lineTo(10, i) + } + ctx.stroke() + for (var i = 100; i < this.height; i += 100) { + ctx.save() + ctx.beginPath() + ctx.translate(16, i - 4) + ctx.rotate((270 * Math.PI) / 180) + ctx.fillText(i.toString(), 0, 0) + ctx.restore() + } + ctx.restore() + } + RenderLayer.prototype.grid = function () { + const ctx = this.canvas.getContext('2d') + ctx.save() + ctx.lineWidth = 1 + ctx.strokeStyle = this.data.gridColor || this.options.gridColor || '#f3f3f3' + ctx.beginPath() + const size = this.data.gridSize || this.options.gridSize + for (var i = size; i < this.width; i += size) { + ctx.moveTo(i, 0) + ctx.lineTo(i, this.height) + } + for (var i = size; i < this.height; i += size) { + ctx.moveTo(0, i) + ctx.lineTo(this.width, i) + } + ctx.stroke() + ctx.restore() + } + return RenderLayer +}(Canvas)) +export { RenderLayer } +// # sourceMappingURL=renderLayer.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/socket.js b/nezha-fronted/src/components/common/@topology/core/src/socket.js index 3049b6db9..19f2b8c44 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/socket.js +++ b/nezha-fronted/src/components/common/@topology/core/src/socket.js @@ -1,24 +1,24 @@ -var Socket = /** @class */ (function () { - function Socket(url, cb) { - this.url = url; - this.cb = cb; - this.fns = {}; - this.init(); +const Socket = /** @class */ (function () { + function Socket (url, cb) { + this.url = url + this.cb = cb + this.fns = {} + this.init() + } + Socket.prototype.init = function () { + const _this = this + this.socket = new WebSocket(this.url) + this.socket.onmessage = this.cb + this.socket.onclose = function () { + console.info('Canvas websocket closed and reconneting...') + _this.init() } - Socket.prototype.init = function () { - var _this = this; - this.socket = new WebSocket(this.url); - this.socket.onmessage = this.cb; - this.socket.onclose = function () { - console.info('Canvas websocket closed and reconneting...'); - _this.init(); - }; - }; - Socket.prototype.close = function () { - this.socket.onclose = undefined; - this.socket.close(); - }; - return Socket; -}()); -export { Socket }; -//# sourceMappingURL=socket.js.map \ No newline at end of file + } + Socket.prototype.close = function () { + this.socket.onclose = undefined + this.socket.close() + } + return Socket +}()) +export { Socket } +// # sourceMappingURL=socket.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/browser.js b/nezha-fronted/src/components/common/@topology/core/src/utils/browser.js index d4ace7502..a7463d06b 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/browser.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/browser.js @@ -1,4 +1,4 @@ -export function isMobile() { - return /Android|webOS|iPad|iPhone|iPod|BlackBerry/i.test(navigator.userAgent); +export function isMobile () { + return /Android|webOS|iPad|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) } -//# sourceMappingURL=browser.js.map \ No newline at end of file +// # sourceMappingURL=browser.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/cacheDB.js b/nezha-fronted/src/components/common/@topology/core/src/utils/cacheDB.js index 6f1721d47..4f6cc526a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/cacheDB.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/cacheDB.js @@ -1,103 +1,103 @@ -export function createCacheTable() { - var request = indexedDB.open('topology-caches'); // 默认版本 1 - request.onupgradeneeded = function (e) { - // 建表 - var db = e.target.result; - if (db.objectStoreNames.contains('caches')) { - db.deleteObjectStore('caches'); - } - db.createObjectStore('caches', { - keyPath: 'dbIndex', - }); - }; +export function createCacheTable () { + const request = indexedDB.open('topology-caches') // 默认版本 1 + request.onupgradeneeded = function (e) { + // 建表 + const db = e.target.result + if (db.objectStoreNames.contains('caches')) { + db.deleteObjectStore('caches') + } + db.createObjectStore('caches', { + keyPath: 'dbIndex' + }) + } + request.onsuccess = function (event) { + const db = request.result + if (!db.objectStoreNames.contains('caches')) { + return + } + const get = db.transaction(['caches'], 'readwrite').objectStore('caches') + get.clear() // 创建表格同时清空 + } + request.onerror = function (e) { + console.warn('数据库打开失败' + e) + } +} +export function spliceCache (index) { + const request = indexedDB.open('topology-caches') // 默认版本 1 + request.onsuccess = function (event) { + const db = request.result + if (!db.objectStoreNames.contains('caches')) { + return + } + const get = db.transaction(['caches'], 'readwrite').objectStore('caches') + get.delete(IDBKeyRange.lowerBound(index)) + } + request.onupgradeneeded = function (e) { + // 建表 + const db = e.target.result + if (db.objectStoreNames.contains('caches')) { + db.deleteObjectStore('caches') + } + db.createObjectStore('caches', { + keyPath: 'dbIndex' + }) + } +} +export function pushCache (data, index, length) { + const request = indexedDB.open('topology-caches') // 默认版本 1 + request.onsuccess = function (event) { + const db = request.result + if (!db.objectStoreNames.contains('caches')) { + return + } + const push = db.transaction(['caches'], 'readwrite').objectStore('caches') + data.dbIndex = index + push.add(data) + const result = push.count() + result.onsuccess = function () { + if (result.result > length) { + // 把最前面的一个扔出去 + push.delete(index - length) + } + } + } + request.onupgradeneeded = function (e) { + // 建表 + const db = e.target.result + if (db.objectStoreNames.contains('caches')) { + db.deleteObjectStore('caches') + } + db.createObjectStore('caches', { + keyPath: 'dbIndex' + }) + } +} +export function getCache (index) { + return new Promise(function (resolve, reject) { + const request = indexedDB.open('topology-caches') // 默认版本 1 request.onsuccess = function (event) { - var db = request.result; - if (!db.objectStoreNames.contains('caches')) { - return; - } - var get = db.transaction(['caches'], 'readwrite').objectStore('caches'); - get.clear(); // 创建表格同时清空 - }; - request.onerror = function (e) { - console.warn('数据库打开失败' + e); - }; -} -export function spliceCache(index) { - var request = indexedDB.open('topology-caches'); // 默认版本 1 - request.onsuccess = function (event) { - var db = request.result; - if (!db.objectStoreNames.contains('caches')) { - return; - } - var get = db.transaction(['caches'], 'readwrite').objectStore('caches'); - get.delete(IDBKeyRange.lowerBound(index)); - }; + const db = request.result + if (!db.objectStoreNames.contains('caches')) { + resolve(null) + return + } + const objectStore = db.transaction(['caches']).objectStore('caches') + const get = objectStore.get(index) + get.onsuccess = function () { + // undefined 也传出去 + resolve(get.result) + } + } request.onupgradeneeded = function (e) { - // 建表 - var db = e.target.result; - if (db.objectStoreNames.contains('caches')) { - db.deleteObjectStore('caches'); - } - db.createObjectStore('caches', { - keyPath: 'dbIndex', - }); - }; + // 建表 + const db = e.target.result + if (db.objectStoreNames.contains('caches')) { + db.deleteObjectStore('caches') + } + db.createObjectStore('caches', { + keyPath: 'dbIndex' + }) + } + }) } -export function pushCache(data, index, length) { - var request = indexedDB.open('topology-caches'); // 默认版本 1 - request.onsuccess = function (event) { - var db = request.result; - if (!db.objectStoreNames.contains('caches')) { - return; - } - var push = db.transaction(['caches'], 'readwrite').objectStore('caches'); - data.dbIndex = index; - push.add(data); - var result = push.count(); - result.onsuccess = function () { - if (result.result > length) { - // 把最前面的一个扔出去 - push.delete(index - length); - } - }; - }; - request.onupgradeneeded = function (e) { - // 建表 - var db = e.target.result; - if (db.objectStoreNames.contains('caches')) { - db.deleteObjectStore('caches'); - } - db.createObjectStore('caches', { - keyPath: 'dbIndex', - }); - }; -} -export function getCache(index) { - return new Promise(function (resolve, reject) { - var request = indexedDB.open('topology-caches'); // 默认版本 1 - request.onsuccess = function (event) { - var db = request.result; - if (!db.objectStoreNames.contains('caches')) { - resolve(null); - return; - } - var objectStore = db.transaction(['caches']).objectStore('caches'); - var get = objectStore.get(index); - get.onsuccess = function () { - // undefined 也传出去 - resolve(get.result); - }; - }; - request.onupgradeneeded = function (e) { - // 建表 - var db = e.target.result; - if (db.objectStoreNames.contains('caches')) { - db.deleteObjectStore('caches'); - } - db.createObjectStore('caches', { - keyPath: 'dbIndex', - }); - }; - }); -} -//# sourceMappingURL=cacheDB.js.map \ No newline at end of file +// # sourceMappingURL=cacheDB.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/canvas.js b/nezha-fronted/src/components/common/@topology/core/src/utils/canvas.js index 4d1d6fe76..75a46430e 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/canvas.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/canvas.js @@ -1,115 +1,114 @@ -import { Point } from '../models/point'; -export function flatNodes(nodes) { - var result = { - nodes: [], - lines: [], - }; - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var item = nodes_1[_i]; - if (item.type) { - result.lines.push(item); - continue; - } - result.nodes.push(item); - if (item.children) { - result.nodes.push.apply(result.nodes, flatNodes(item.children).nodes); - result.lines.push.apply(result.lines, flatNodes(item.children).lines); - } +import { Point } from '../models/point' +export function flatNodes (nodes) { + const result = { + nodes: [], + lines: [] + } + for (let _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + const item = nodes_1[_i] + if (item.type) { + result.lines.push(item) + continue } - return result; -} -export function find(idOrTag, pens) { - var result = []; - pens.forEach(function (item) { - if (item.id === idOrTag || item.tags.indexOf(idOrTag) > -1) { - result.push(item); - } - if (item.children) { - result.push.apply(result, find(idOrTag, item.children)); - } - }); - return result; -} -export function del(idOrTag, pens) { - var deleted = []; - for (var i = 0; i < pens.length; i++) { - if (pens[i].id === idOrTag || pens[i].tags.indexOf(idOrTag) > -1) { - deleted.push(pens[i]); - pens.splice(i, 1); - --i; - } - else if (pens[i].children) { - deleted.push.apply(deleted, del(idOrTag, pens[i].children)); - } + result.nodes.push(item) + if (item.children) { + result.nodes.push.apply(result.nodes, flatNodes(item.children).nodes) + result.lines.push.apply(result.lines, flatNodes(item.children).lines) } - return deleted; + } + return result } -export function getParent(pens, child) { - var parent; - for (var _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { - var item = pens_1[_i]; - if (item.type) { - continue; - } - if (!item.children) { - continue; - } - for (var _a = 0, _b = item.children; _a < _b.length; _a++) { - var subItem = _b[_a]; - if (subItem.id === child.id) { - return item; - } - if (subItem.type) { - continue; - } - if (subItem.children) { - parent = getParent(subItem.children, child); - if (parent) { - return parent; - } - } - } +export function find (idOrTag, pens) { + const result = [] + pens.forEach(function (item) { + if (item.id === idOrTag || item.tags.indexOf(idOrTag) > -1) { + result.push(item) } - return parent; -} -export function pointInRect(point, vertices) { - if (vertices.length < 3) { - return false; + if (item.children) { + result.push.apply(result, find(idOrTag, item.children)) } - var isIn = false; - var last = vertices[vertices.length - 1]; - for (var _i = 0, vertices_1 = vertices; _i < vertices_1.length; _i++) { - var item = vertices_1[_i]; - if (((last.y > point.y) !== (item.y > point.y))) { - if (item.x + ((point.y - item.y) * (last.x - item.x)) / (last.y - item.y) > point.x) { - isIn = !isIn; - } + }) + return result +} +export function del (idOrTag, pens) { + const deleted = [] + for (let i = 0; i < pens.length; i++) { + if (pens[i].id === idOrTag || pens[i].tags.indexOf(idOrTag) > -1) { + deleted.push(pens[i]) + pens.splice(i, 1) + --i + } else if (pens[i].children) { + deleted.push.apply(deleted, del(idOrTag, pens[i].children)) + } + } + return deleted +} +export function getParent (pens, child) { + let parent + for (let _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { + const item = pens_1[_i] + if (item.type) { + continue + } + if (!item.children) { + continue + } + for (let _a = 0, _b = item.children; _a < _b.length; _a++) { + const subItem = _b[_a] + if (subItem.id === child.id) { + return item + } + if (subItem.type) { + continue + } + if (subItem.children) { + parent = getParent(subItem.children, child) + if (parent) { + return parent } - last = item; + } } - return isIn; + } + return parent } -export function pointInLine(point, from, to, padding) { - if (padding === void 0) { padding = 1; } - var angle = Math.atan2(from.y - to.y, to.x - from.x); - padding = padding > 5 ? padding : 5; - var x = Math.sin(angle) * padding; - var y = Math.cos(angle) * padding; - var points = [ - new Point(from.x - x, from.y - y), - new Point(to.x - x, to.y - y), - new Point(to.x + x, to.y + y), - new Point(from.x + x, from.y + y) - ]; - return pointInRect(point, points); +export function pointInRect (point, vertices) { + if (vertices.length < 3) { + return false + } + let isIn = false + let last = vertices[vertices.length - 1] + for (let _i = 0, vertices_1 = vertices; _i < vertices_1.length; _i++) { + const item = vertices_1[_i] + if (((last.y > point.y) !== (item.y > point.y))) { + if (item.x + ((point.y - item.y) * (last.x - item.x)) / (last.y - item.y) > point.x) { + isIn = !isIn + } + } + last = item + } + return isIn } -export function lineLen(from, to) { - var len = Math.sqrt(Math.pow(Math.abs(from.x - to.x), 2) + Math.pow(Math.abs(from.y - to.y), 2)); - return len | 0; +export function pointInLine (point, from, to, padding) { + if (padding === void 0) { padding = 1 } + const angle = Math.atan2(from.y - to.y, to.x - from.x) + padding = padding > 5 ? padding : 5 + const x = Math.sin(angle) * padding + const y = Math.cos(angle) * padding + const points = [ + new Point(from.x - x, from.y - y), + new Point(to.x - x, to.y - y), + new Point(to.x + x, to.y + y), + new Point(from.x + x, from.y + y) + ] + return pointInRect(point, points) } -export function curveLen(from, cp1, cp2, to) { - var path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); - path.setAttribute('d', "M" + from.x + " " + from.y + " C" + cp1.x + " " + cp1.y + " " + cp2.x + " " + cp2.y + " " + to.x + " " + to.y); - return path.getTotalLength() | 0; +export function lineLen (from, to) { + const len = Math.sqrt(Math.pow(Math.abs(from.x - to.x), 2) + Math.pow(Math.abs(from.y - to.y), 2)) + return len | 0 } -//# sourceMappingURL=canvas.js.map \ No newline at end of file +export function curveLen (from, cp1, cp2, to) { + const path = document.createElementNS('http://www.w3.org/2000/svg', 'path') + path.setAttribute('d', 'M' + from.x + ' ' + from.y + ' C' + cp1.x + ' ' + cp1.y + ' ' + cp2.x + ' ' + cp2.y + ' ' + to.x + ' ' + to.y) + return path.getTotalLength() | 0 +} +// # sourceMappingURL=canvas.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/clone.js b/nezha-fronted/src/components/common/@topology/core/src/utils/clone.js index 32ef14905..b267f2ec1 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/clone.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/clone.js @@ -1,24 +1,22 @@ -export function deepClone(o) { - if (Array.isArray(o)) { - var arr_1 = []; - o.forEach(function (item) { - arr_1.push(deepClone(item)); - }); - return arr_1; +export function deepClone (o) { + if (Array.isArray(o)) { + const arr_1 = [] + o.forEach(function (item) { + arr_1.push(deepClone(item)) + }) + return arr_1 + } else if (typeof o === 'object') { + if (o === null) { + return null + } else if (o.constructor === RegExp) { + return o } - else if (typeof o === 'object') { - if (o === null) { - return null; - } - else if (o.constructor === RegExp) { - return o; - } - var _o = {}; - for (var key in o) { - _o[key] = deepClone(o[key]); - } - return _o; + const _o = {} + for (const key in o) { + _o[key] = deepClone(o[key]) } - return o; + return _o + } + return o } -//# sourceMappingURL=clone.js.map \ No newline at end of file +// # sourceMappingURL=clone.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/dom.js b/nezha-fronted/src/components/common/@topology/core/src/utils/dom.js index 9b4d7bc9c..2a32279c8 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/dom.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/dom.js @@ -1,45 +1,45 @@ -import { Store } from 'le5le-store'; -export function createDiv(node) { - var div = document.createElement('div'); - div.style.position = 'absolute'; - div.style.outline = 'none'; - div.style.left = '-9999px'; - div.style.bottom = '-9999px'; - div.style.width = node.rect.width + 'px'; - div.style.height = node.rect.height + 'px'; - if (node.elementId) { - div.id = node.elementId; +import { Store } from 'le5le-store' +export function createDiv (node) { + const div = document.createElement('div') + div.style.position = 'absolute' + div.style.outline = 'none' + div.style.left = '-9999px' + div.style.bottom = '-9999px' + div.style.width = node.rect.width + 'px' + div.style.height = node.rect.height + 'px' + if (node.elementId) { + div.id = node.elementId + } + return div +} +export function createInput (node) { + const input = document.createElement('input') + input.style.position = 'absolute' + input.style.outline = 'none' + input.style.left = '-9999px' + input.style.bottom = '-9999px' + input.style.width = node.rect.width + 'px' + input.style.height = node.rect.height + 'px' + input.style.border = '1px solid #cdcdcd' + input.classList.add('set-text-input') + if (node.elementId) { + input.id = node.elementId + } + return input +} +export function loadJS (url, callback, render) { + const loaderScript = document.createElement('script') + loaderScript.type = 'text/javascript' + loaderScript.src = url + loaderScript.addEventListener('load', function () { + if (callback) { + callback() } - return div; -} -export function createInput(node) { - var input = document.createElement('input'); - input.style.position = 'absolute'; - input.style.outline = 'none'; - input.style.left = '-9999px'; - input.style.bottom = '-9999px'; - input.style.width = node.rect.width + 'px'; - input.style.height = node.rect.height + 'px'; - input.style.border = '1px solid #cdcdcd'; - input.classList.add('set-text-input'); - if (node.elementId) { - input.id = node.elementId; + // how to do + if (render) { + Store.set('LT:render', true) } - return input; + }) + document.body.appendChild(loaderScript) } -export function loadJS(url, callback, render) { - var loaderScript = document.createElement('script'); - loaderScript.type = 'text/javascript'; - loaderScript.src = url; - loaderScript.addEventListener('load', function () { - if (callback) { - callback(); - } - // how to do - if (render) { - Store.set('LT:render', true); - } - }); - document.body.appendChild(loaderScript); -} -//# sourceMappingURL=dom.js.map \ No newline at end of file +// # sourceMappingURL=dom.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/index.js b/nezha-fronted/src/components/common/@topology/core/src/utils/index.js index 8bdeed728..b0972851c 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/index.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/index.js @@ -1,9 +1,9 @@ -export * from './canvas'; -export * from './dom'; -export * from './math'; -export * from './rect'; -export * from './uuid'; -export * from './browser'; -export * from './clone'; -export * from './cacheDB'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './canvas' +export * from './dom' +export * from './math' +export * from './rect' +export * from './uuid' +export * from './browser' +export * from './clone' +export * from './cacheDB' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/math.js b/nezha-fronted/src/components/common/@topology/core/src/utils/math.js index aa8f0baa1..93a4ff52a 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/math.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/math.js @@ -1,74 +1,63 @@ // pSBC - Shade Blend Convert - Version 4.0 - 02/18/2019 // https://github.com/PimpTrizkit/PJs/edit/master/pSBC.js -export function pSBCr(d) { - var i = parseInt, m = Math.round; - var n = d.length, x = {}; - if (n > 9) { - var _a = (d = d.split(',')), r = _a[0], g = _a[1], b = _a[2], a = _a[3]; - n = d.length; - if (n < 3 || n > 4) - return null; - (x.r = i(r[3] == 'a' ? r.slice(5) : r.slice(4))), (x.g = i(g)), (x.b = i(b)), (x.a = a ? parseFloat(a) : -1); - } - else { - if (n == 8 || n == 6 || n < 4) - return null; - if (n < 6) - d = '#' + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : ''); - d = i(d.slice(1), 16); - if (n == 9 || n == 5) - (x.r = (d >> 24) & 255), (x.g = (d >> 16) & 255), (x.b = (d >> 8) & 255), (x.a = m((d & 255) / 0.255) / 1000); - else - (x.r = d >> 16), (x.g = (d >> 8) & 255), (x.b = d & 255), (x.a = -1); - } - return x; +export function pSBCr (d) { + const i = parseInt; const m = Math.round + let n = d.length; const x = {} + if (n > 9) { + const _a = (d = d.split(',')); const r = _a[0]; const g = _a[1]; const b = _a[2]; const a = _a[3] + n = d.length + if (n < 3 || n > 4) { return null } + (x.r = i(r[3] == 'a' ? r.slice(5) : r.slice(4))), (x.g = i(g)), (x.b = i(b)), (x.a = a ? parseFloat(a) : -1) + } else { + if (n == 8 || n == 6 || n < 4) { return null } + if (n < 6) { d = '#' + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : '') } + d = i(d.slice(1), 16) + if (n == 9 || n == 5) { (x.r = (d >> 24) & 255), (x.g = (d >> 16) & 255), (x.b = (d >> 8) & 255), (x.a = m((d & 255) / 0.255) / 1000) } else { (x.r = d >> 16), (x.g = (d >> 8) & 255), (x.b = d & 255), (x.a = -1) } + } + return x } -export function pSBC(p, c0, c1, l) { - var r, g, b, P, f, t, h, m = Math.round, a = typeof c1 == 'string'; - if (typeof p != 'number' || p < -1 || p > 1 || typeof c0 != 'string' || (c0[0] != 'r' && c0[0] != '#') || (c1 && !a)) - return null; - (h = c0.length > 9), - (h = a ? (c1.length > 9 ? true : c1 == 'c' ? !h : false) : h), - (f = pSBCr(c0)), - (P = p < 0), - (t = c1 && c1 != 'c' ? pSBCr(c1) : P ? { r: 0, g: 0, b: 0, a: -1 } : { r: 255, g: 255, b: 255, a: -1 }), - (p = P ? p * -1 : p), - (P = 1 - p); - if (!f || !t) - return null; - if (l) - (r = m(P * f.r + p * t.r)), (g = m(P * f.g + p * t.g)), (b = m(P * f.b + p * t.b)); - else - (r = m(Math.pow((P * Math.pow(f.r, 2) + p * Math.pow(t.r, 2)), 0.5))), - (g = m(Math.pow((P * Math.pow(f.g, 2) + p * Math.pow(t.g, 2)), 0.5))), - (b = m(Math.pow((P * Math.pow(f.b, 2) + p * Math.pow(t.b, 2)), 0.5))); - (a = f.a), (t = t.a), (f = a >= 0 || t >= 0), (a = f ? (a < 0 ? t : t < 0 ? a : a * P + t * p) : 0); - if (h) - return 'rgb' + (f ? 'a(' : '(') + r + ',' + g + ',' + b + (f ? ',' + m(a * 1000) / 1000 : '') + ')'; - else - return ('#' + - (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2)); +export function pSBC (p, c0, c1, l) { + let r; let g; let b; let P; let f; let t; let h; const m = Math.round; let a = typeof c1 == 'string' + if (typeof p != 'number' || p < -1 || p > 1 || typeof c0 != 'string' || (c0[0] != 'r' && c0[0] != '#') || (c1 && !a)) { return null } + (h = c0.length > 9), + (h = a ? (c1.length > 9 ? true : c1 == 'c' ? !h : false) : h), + (f = pSBCr(c0)), + (P = p < 0), + (t = c1 && c1 != 'c' ? pSBCr(c1) : P ? { r: 0, g: 0, b: 0, a: -1 } : { r: 255, g: 255, b: 255, a: -1 }), + (p = P ? p * -1 : p), + (P = 1 - p) + if (!f || !t) { return null } + if (l) { (r = m(P * f.r + p * t.r)), (g = m(P * f.g + p * t.g)), (b = m(P * f.b + p * t.b)) } else { + (r = m(Math.pow((P * Math.pow(f.r, 2) + p * Math.pow(t.r, 2)), 0.5))), + (g = m(Math.pow((P * Math.pow(f.g, 2) + p * Math.pow(t.g, 2)), 0.5))), + (b = m(Math.pow((P * Math.pow(f.b, 2) + p * Math.pow(t.b, 2)), 0.5))) + } + (a = f.a), (t = t.a), (f = a >= 0 || t >= 0), (a = f ? (a < 0 ? t : t < 0 ? a : a * P + t * p) : 0) + if (h) { return 'rgb' + (f ? 'a(' : '(') + r + ',' + g + ',' + b + (f ? ',' + m(a * 1000) / 1000 : '') + ')' } else { + return ('#' + + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2)) + } } -export function rgba(p, c) { - var f = pSBCr(c) || { r: 0, g: 0, b: 0 }; - if (f.a < 0) { - return "rgba(" + f.r + "," + f.g + "," + f.b + "," + p + ")"; - } - return "rgba(" + f.r + "," + f.g + "," + f.b + "," + (p + f.a) + ")"; +export function rgba (p, c) { + const f = pSBCr(c) || { r: 0, g: 0, b: 0 } + if (f.a < 0) { + return 'rgba(' + f.r + ',' + f.g + ',' + f.b + ',' + p + ')' + } + return 'rgba(' + f.r + ',' + f.g + ',' + f.b + ',' + (p + f.a) + ')' } -export function abs(num, percent) { - if (+percent) { - return +percent; - } - if (!percent || percent[percent.length - 1] !== '%') { - return 0; - } - percent = percent.substr(0, percent.length - 1); - return (num * +percent) / 100; +export function abs (num, percent) { + if (+percent) { + return +percent + } + if (!percent || percent[percent.length - 1] !== '%') { + return 0 + } + percent = percent.substr(0, percent.length - 1) + return (num * +percent) / 100 } -export function distance(pt1, pt2) { - var x = pt1.x - pt2.x; - var y = pt1.y - pt2.y; - return Math.sqrt(x * x + y * y); +export function distance (pt1, pt2) { + const x = pt1.x - pt2.x + const y = pt1.y - pt2.y + return Math.sqrt(x * x + y * y) } -//# sourceMappingURL=math.js.map \ No newline at end of file +// # sourceMappingURL=math.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/padding.js b/nezha-fronted/src/components/common/@topology/core/src/utils/padding.js index 3e9842b5d..175af0e24 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/padding.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/padding.js @@ -4,25 +4,23 @@ * @return {array} output */ export var formatPadding = function (padding) { - var top = 0; - var left = 0; - var right = 0; - var bottom = 0; - if (typeof padding === 'number') { - top = left = right = bottom = padding; - } - else if (typeof padding === 'string') { - var intPadding = parseInt(padding, 10); - top = left = right = bottom = intPadding; - } - else if (Array.isArray(padding)) { - top = padding[0]; - right = !isNil(padding[1]) ? padding[1] : padding[0]; - bottom = !isNil(padding[2]) ? padding[2] : padding[0]; - left = !isNil(padding[3]) ? padding[3] : right; - } - return [top, right, bottom, left]; -}; + let top = 0 + let left = 0 + let right = 0 + let bottom = 0 + if (typeof padding === 'number') { + top = left = right = bottom = padding + } else if (typeof padding === 'string') { + const intPadding = parseInt(padding, 10) + top = left = right = bottom = intPadding + } else if (Array.isArray(padding)) { + top = padding[0] + right = !isNil(padding[1]) ? padding[1] : padding[0] + bottom = !isNil(padding[2]) ? padding[2] : padding[0] + left = !isNil(padding[3]) ? padding[3] : right + } + return [top, right, bottom, left] +} /** * Checks if `value` is `null` or `undefined`. * @@ -41,7 +39,7 @@ export var formatPadding = function (padding) { * isNil(NaN) * // => false */ -function isNil(value) { - return value == null; +function isNil (value) { + return value == null } -//# sourceMappingURL=padding.js.map \ No newline at end of file +// # sourceMappingURL=padding.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/rect.js b/nezha-fronted/src/components/common/@topology/core/src/utils/rect.js index 481c2bdc4..b21f73816 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/rect.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/rect.js @@ -1,96 +1,93 @@ -import { Node } from '../models/node'; -import { Line } from '../models/line'; -import { getBezierPoint } from '../middles/lines/curve'; -import { Rect } from '../models/rect'; +import { Node } from '../models/node' +import { Line } from '../models/line' +import { getBezierPoint } from '../middles/lines/curve' +import { Rect } from '../models/rect' /** * 不包含画布偏移量 * */ -export function getRect(pens) { - var points = []; - for (var _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { - var item = pens_1[_i]; - if (item instanceof Node) { - var pts = item.rect.toPoints(); - if (item.rotate) { - for (var _a = 0, pts_1 = pts; _a < pts_1.length; _a++) { - var pt = pts_1[_a]; - pt.rotate(item.rotate, item.rect.center); - } - } - points.push.apply(points, pts); +export function getRect (pens) { + const points = [] + for (let _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { + const item = pens_1[_i] + if (item instanceof Node) { + const pts = item.rect.toPoints() + if (item.rotate) { + for (let _a = 0, pts_1 = pts; _a < pts_1.length; _a++) { + const pt = pts_1[_a] + pt.rotate(item.rotate, item.rect.center) } - else if (item instanceof Line) { - if (item.children) { - item.children.forEach(function (child) { - points.push(child.from); - points.push(child.to); - if (Array.isArray(child.controlPoints)) { - points.push.apply(points, child.controlPoints); - } - if (child.name === 'curve') { - for (var i = 0.01; i < 1; i += 0.02) { - points.push(getBezierPoint(i, child.from, child.controlPoints[0], child.controlPoints[1], child.to)); - } - } - }); - } - else if (item.from) { - points.push(item.from); - points.push(item.to); - if (Array.isArray(item.controlPoints)) { - points.push.apply(points, item.controlPoints); - } - if (item.name === 'curve') { - for (var i = 0.01; i < 1; i += 0.02) { - points.push(getBezierPoint(i, item.from, item.controlPoints[0], item.controlPoints[1], item.to)); - } - } + } + points.push.apply(points, pts) + } else if (item instanceof Line) { + if (item.children) { + item.children.forEach(function (child) { + points.push(child.from) + points.push(child.to) + if (Array.isArray(child.controlPoints)) { + points.push.apply(points, child.controlPoints) + } + if (child.name === 'curve') { + for (let i = 0.01; i < 1; i += 0.02) { + points.push(getBezierPoint(i, child.from, child.controlPoints[0], child.controlPoints[1], child.to)) } + } + }) + } else if (item.from) { + points.push(item.from) + points.push(item.to) + if (Array.isArray(item.controlPoints)) { + points.push.apply(points, item.controlPoints) } + if (item.name === 'curve') { + for (let i = 0.01; i < 1; i += 0.02) { + points.push(getBezierPoint(i, item.from, item.controlPoints[0], item.controlPoints[1], item.to)) + } + } + } } - var _b = getBboxOfPoints(points), x1 = _b.x1, y1 = _b.y1, x2 = _b.x2, y2 = _b.y2; - return new Rect(x1, y1, x2 - x1, y2 - y1); + } + const _b = getBboxOfPoints(points); const x1 = _b.x1; const y1 = _b.y1; const x2 = _b.x2; const y2 = _b.y2 + return new Rect(x1, y1, x2 - x1, y2 - y1) } -export function getBboxOfPoints(points) { - var x1 = Infinity; - var y1 = Infinity; - var x2 = -Infinity; - var y2 = -Infinity; - for (var _i = 0, points_1 = points; _i < points_1.length; _i++) { - var item = points_1[_i]; - var x = item.x, y = item.y; - if (isNaN(x) || isNaN(y)) - continue; - x1 = Math.min(x1, x); - y1 = Math.min(y1, y); - x2 = Math.max(x2, x); - y2 = Math.max(y2, y); - } - return { x1: x1, y1: y1, x2: x2, y2: y2 }; +export function getBboxOfPoints (points) { + let x1 = Infinity + let y1 = Infinity + let x2 = -Infinity + let y2 = -Infinity + for (let _i = 0, points_1 = points; _i < points_1.length; _i++) { + const item = points_1[_i] + const x = item.x; const y = item.y + if (isNaN(x) || isNaN(y)) { continue } + x1 = Math.min(x1, x) + y1 = Math.min(y1, y) + x2 = Math.max(x2, x) + y2 = Math.max(y2, y) + } + return { x1: x1, y1: y1, x2: x2, y2: y2 } } -export function rectInRect(source, target) { - return !( +export function rectInRect (source, target) { + return !( // 括号内表明 在范围外的 四个区域 - source.x > target.ex || source.ex < target.x || source.ey < target.y || source.y > target.ey); + source.x > target.ex || source.ex < target.x || source.ey < target.y || source.y > target.ey) } /** * 合并大小全部传入的 rects * */ -export function getMoreRect() { - var rects = []; - for (var _i = 0; _i < arguments.length; _i++) { - rects[_i] = arguments[_i]; +export function getMoreRect () { + const rects = [] + for (let _i = 0; _i < arguments.length; _i++) { + rects[_i] = arguments[_i] + } + const rect = new Rect(rects[0].x, rects[0].y, rects[0].width, rects[0].height) + for (let i = 1; i < rects.length; i++) { + const currentRect = rects[i] + if (currentRect) { + rect.x > currentRect.x && (rect.x = currentRect.x) + rect.y > currentRect.y && (rect.y = currentRect.y) + rect.ex < currentRect.ex && (rect.ex = currentRect.ex) + rect.ey < currentRect.ey && (rect.ey = currentRect.ey) } - var rect = new Rect(rects[0].x, rects[0].y, rects[0].width, rects[0].height); - for (var i = 1; i < rects.length; i++) { - var currentRect = rects[i]; - if (currentRect) { - rect.x > currentRect.x && (rect.x = currentRect.x); - rect.y > currentRect.y && (rect.y = currentRect.y); - rect.ex < currentRect.ex && (rect.ex = currentRect.ex); - rect.ey < currentRect.ey && (rect.ey = currentRect.ey); - } - } - return new Rect(rect.x, rect.y, rect.ex - rect.x, rect.ey - rect.y); + } + return new Rect(rect.x, rect.y, rect.ex - rect.x, rect.ey - rect.y) } -//# sourceMappingURL=rect.js.map \ No newline at end of file +// # sourceMappingURL=rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/core/src/utils/uuid.js b/nezha-fronted/src/components/common/@topology/core/src/utils/uuid.js index f70ffdf27..3af14ec44 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/utils/uuid.js +++ b/nezha-fronted/src/components/common/@topology/core/src/utils/uuid.js @@ -1,13 +1,13 @@ -export function s4() { - return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); +export function s4 () { + return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) } -export function s8() { - return (((1 + Math.random()) * 0x100000000) | 0).toString(16).substring(1); +export function s8 () { + return (((1 + Math.random()) * 0x100000000) | 0).toString(16).substring(1) } -export function s12() { - return s4() + s8(); +export function s12 () { + return s4() + s8() } -export function s16() { - return s8() + s8(); +export function s16 () { + return s8() + s8() } -//# sourceMappingURL=uuid.js.map \ No newline at end of file +// # sourceMappingURL=uuid.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/index.js index 2e942cbe9..f20e77a90 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/index.js @@ -1,13 +1,13 @@ -export * from './src/data'; -export * from './src/subprocess'; -export * from './src/db'; -export * from './src/document'; -export * from './src/internalStorage'; -export * from './src/externStorage'; -export * from './src/queue'; -export * from './src/manually'; -export * from './src/display'; -export * from './src/parallel'; -export * from './src/comment'; -export * from './src/register'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './src/data' +export * from './src/subprocess' +export * from './src/db' +export * from './src/document' +export * from './src/internalStorage' +export * from './src/externStorage' +export * from './src/queue' +export * from './src/manually' +export * from './src/display' +export * from './src/parallel' +export * from './src/comment' +export * from './src/register' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/comment.anchor.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/comment.anchor.js index 4aea35c9f..9f8c65502 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/comment.anchor.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/comment.anchor.js @@ -1,5 +1,5 @@ -import { Point, Direction } from '@topology/core'; -export function flowCommentAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); +import { Point, Direction } from '@topology/core' +export function flowCommentAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) } -//# sourceMappingURL=comment.anchor.js.map \ No newline at end of file +// # sourceMappingURL=comment.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/comment.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/comment.js index fe057b393..7312fdc77 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/comment.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/comment.js @@ -1,10 +1,10 @@ -export function flowComment(ctx, node) { - ctx.beginPath(); - var offsetX = node.rect.width / 4; - ctx.moveTo(node.rect.x + offsetX, node.rect.y); - ctx.lineTo(node.rect.x, node.rect.y); - ctx.lineTo(node.rect.x, node.rect.ey); - ctx.lineTo(node.rect.x + offsetX, node.rect.ey); - ctx.stroke(); +export function flowComment (ctx, node) { + ctx.beginPath() + const offsetX = node.rect.width / 4 + ctx.moveTo(node.rect.x + offsetX, node.rect.y) + ctx.lineTo(node.rect.x, node.rect.y) + ctx.lineTo(node.rect.x, node.rect.ey) + ctx.lineTo(node.rect.x + offsetX, node.rect.ey) + ctx.stroke() } -//# sourceMappingURL=comment.js.map \ No newline at end of file +// # sourceMappingURL=comment.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/index.js index 9d1302143..1d7326487 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/comment/index.js @@ -1,3 +1,3 @@ -export * from './comment'; -export * from './comment.anchor'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './comment' +export * from './comment.anchor' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.anchor.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.anchor.js index 514f86e28..cac00c481 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.anchor.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.anchor.js @@ -1,8 +1,8 @@ -import { Point, Direction } from '@topology/core'; -export function flowDataAnchors(node) { - node.anchors.push(new Point(node.rect.x + node.rect.width / 14, node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + (node.rect.width * 4) / 7, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + (node.rect.width * 13) / 14, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + (node.rect.width * 3) / 7, node.rect.ey, Direction.Bottom)); +import { Point, Direction } from '@topology/core' +export function flowDataAnchors (node) { + node.anchors.push(new Point(node.rect.x + node.rect.width / 14, node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + (node.rect.width * 4) / 7, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + (node.rect.width * 13) / 14, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + (node.rect.width * 3) / 7, node.rect.ey, Direction.Bottom)) } -//# sourceMappingURL=data.anchor.js.map \ No newline at end of file +// # sourceMappingURL=data.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.js index d49a37784..eacfedc2d 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.js @@ -1,12 +1,12 @@ -export function flowData(ctx, node) { - ctx.beginPath(); - var offsetX = node.rect.width / 7; - ctx.moveTo(node.rect.x + offsetX, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.y); - ctx.lineTo(node.rect.x + node.rect.width - offsetX, node.rect.ey); - ctx.lineTo(node.rect.x, node.rect.ey); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowData (ctx, node) { + ctx.beginPath() + const offsetX = node.rect.width / 7 + ctx.moveTo(node.rect.x + offsetX, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.y) + ctx.lineTo(node.rect.x + node.rect.width - offsetX, node.rect.ey) + ctx.lineTo(node.rect.x, node.rect.ey) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=data.js.map \ No newline at end of file +// # sourceMappingURL=data.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.rect.js index ffc557720..1f6358943 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/data.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function flowDataIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowDataIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowDataTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.width / 7, node.rect.y, (node.rect.width * 5) / 7, node.rect.height); - node.fullTextRect = node.textRect; +export function flowDataTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.width / 7, node.rect.y, (node.rect.width * 5) / 7, node.rect.height) + node.fullTextRect = node.textRect } -//# sourceMappingURL=data.rect.js.map \ No newline at end of file +// # sourceMappingURL=data.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/index.js index 788eb0add..6c4fdde38 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/data/index.js @@ -1,4 +1,4 @@ -export * from './data'; -export * from './data.anchor'; -export * from './data.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './data' +export * from './data.anchor' +export * from './data.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/db.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/db.js index 28f1ab1cc..1818fca6e 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/db.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/db.js @@ -1,14 +1,14 @@ -export function flowDb(ctx, node) { - ctx.beginPath(); - var offsetY = node.rect.height / 7; - ctx.moveTo(node.rect.x, node.rect.y + offsetY); - ctx.bezierCurveTo(node.rect.x, (node.rect.y - offsetY / 2) | 0, node.rect.ex, (node.rect.y - offsetY / 2) | 0, node.rect.ex, node.rect.y + offsetY); - ctx.lineTo(node.rect.ex, node.rect.ey - offsetY); - ctx.bezierCurveTo(node.rect.ex, (node.rect.ey + offsetY / 2) | 0, node.rect.x, (node.rect.ey + offsetY / 2) | 0, node.rect.x, node.rect.ey - offsetY); - ctx.closePath(); - ctx.moveTo(node.rect.x, node.rect.ey - offsetY); - ctx.bezierCurveTo(node.rect.x, (node.rect.ey - offsetY * 2) | 0, node.rect.ex, (node.rect.ey - offsetY * 2) | 0, node.rect.ex, node.rect.ey - offsetY); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowDb (ctx, node) { + ctx.beginPath() + const offsetY = node.rect.height / 7 + ctx.moveTo(node.rect.x, node.rect.y + offsetY) + ctx.bezierCurveTo(node.rect.x, (node.rect.y - offsetY / 2) | 0, node.rect.ex, (node.rect.y - offsetY / 2) | 0, node.rect.ex, node.rect.y + offsetY) + ctx.lineTo(node.rect.ex, node.rect.ey - offsetY) + ctx.bezierCurveTo(node.rect.ex, (node.rect.ey + offsetY / 2) | 0, node.rect.x, (node.rect.ey + offsetY / 2) | 0, node.rect.x, node.rect.ey - offsetY) + ctx.closePath() + ctx.moveTo(node.rect.x, node.rect.ey - offsetY) + ctx.bezierCurveTo(node.rect.x, (node.rect.ey - offsetY * 2) | 0, node.rect.ex, (node.rect.ey - offsetY * 2) | 0, node.rect.ex, node.rect.ey - offsetY); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=db.js.map \ No newline at end of file +// # sourceMappingURL=db.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/db.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/db.rect.js index 2184e95f1..c241436eb 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/db.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/db.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function flowDbIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowDbIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowDbTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height / 8, node.rect.width, (node.rect.height * 5) / 8); - node.fullTextRect = node.textRect; +export function flowDbTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height / 8, node.rect.width, (node.rect.height * 5) / 8) + node.fullTextRect = node.textRect } -//# sourceMappingURL=db.rect.js.map \ No newline at end of file +// # sourceMappingURL=db.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/index.js index 08e40a7ad..ebd9d9b2d 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/db/index.js @@ -1,3 +1,3 @@ -export * from './db'; -export * from './db.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './db' +export * from './db.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.anchor.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.anchor.js index 466f1e9bf..1ac171af7 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.anchor.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.anchor.js @@ -1,8 +1,8 @@ -import { Point, Direction } from '@topology/core'; -export function flowDisplayAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)); +import { Point, Direction } from '@topology/core' +export function flowDisplayAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)) } -//# sourceMappingURL=display.anchor.js.map \ No newline at end of file +// # sourceMappingURL=display.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.js index 9a2f0e31c..8b95f257f 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.js @@ -1,13 +1,13 @@ -export function flowDisplay(ctx, node) { - ctx.beginPath(); - var offsetX = node.rect.width / 8; - ctx.moveTo(node.rect.x + offsetX, node.rect.y); - ctx.lineTo(node.rect.ex - offsetX, node.rect.y); - ctx.bezierCurveTo(node.rect.ex + offsetX / 3, node.rect.y, node.rect.ex + offsetX / 3, node.rect.ey, node.rect.ex - offsetX, node.rect.ey); - ctx.lineTo(node.rect.x + offsetX, node.rect.ey); - ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowDisplay (ctx, node) { + ctx.beginPath() + const offsetX = node.rect.width / 8 + ctx.moveTo(node.rect.x + offsetX, node.rect.y) + ctx.lineTo(node.rect.ex - offsetX, node.rect.y) + ctx.bezierCurveTo(node.rect.ex + offsetX / 3, node.rect.y, node.rect.ex + offsetX / 3, node.rect.ey, node.rect.ex - offsetX, node.rect.ey) + ctx.lineTo(node.rect.x + offsetX, node.rect.ey) + ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=display.js.map \ No newline at end of file +// # sourceMappingURL=display.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.rect.js index 3ab0553de..04489b05e 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/display.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function flowDisplayIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowDisplayIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowDisplayTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.width / 8, node.rect.y, (node.rect.width * 3) / 4, node.rect.height); - node.fullTextRect = node.textRect; +export function flowDisplayTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.width / 8, node.rect.y, (node.rect.width * 3) / 4, node.rect.height) + node.fullTextRect = node.textRect } -//# sourceMappingURL=display.rect.js.map \ No newline at end of file +// # sourceMappingURL=display.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/index.js index 7b536b56b..a5fde552c 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/display/index.js @@ -1,4 +1,4 @@ -export * from './display'; -export * from './display.anchor'; -export * from './display.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './display' +export * from './display.anchor' +export * from './display.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.anchor.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.anchor.js index 5da99c502..7e07066f4 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.anchor.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.anchor.js @@ -1,8 +1,8 @@ -import { Point, Direction } from '@topology/core'; -export function flowDocumentAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + (node.rect.height * 6) / 7, Direction.Bottom)); +import { Point, Direction } from '@topology/core' +export function flowDocumentAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + (node.rect.height * 6) / 7, Direction.Bottom)) } -//# sourceMappingURL=document.anchor.js.map \ No newline at end of file +// # sourceMappingURL=document.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.js index 5871cc392..612e57baf 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.js @@ -1,15 +1,15 @@ -export function flowDocument(ctx, node) { - ctx.beginPath(); - var x = node.rect.x + node.rect.width / 2; - var y = node.rect.y + (node.rect.height * 6) / 7; - var offsetY = node.rect.height / 6; - ctx.moveTo(node.rect.x, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.y); - ctx.lineTo(node.rect.ex, y); - ctx.bezierCurveTo(node.rect.ex - 20, y - offsetY, x + node.rect.width / 5, y - offsetY, x, y); - ctx.bezierCurveTo(x - node.rect.width / 5, y + offsetY, node.rect.x, y + offsetY, node.rect.x, y); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowDocument (ctx, node) { + ctx.beginPath() + const x = node.rect.x + node.rect.width / 2 + const y = node.rect.y + (node.rect.height * 6) / 7 + const offsetY = node.rect.height / 6 + ctx.moveTo(node.rect.x, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.y) + ctx.lineTo(node.rect.ex, y) + ctx.bezierCurveTo(node.rect.ex - 20, y - offsetY, x + node.rect.width / 5, y - offsetY, x, y) + ctx.bezierCurveTo(x - node.rect.width / 5, y + offsetY, node.rect.x, y + offsetY, node.rect.x, y) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=document.js.map \ No newline at end of file +// # sourceMappingURL=document.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.rect.js index 8e2e9c55f..cc14b8847 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/document.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function flowDocumentIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowDocumentIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowDocumentTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, (node.rect.height * 5) / 7); - node.fullTextRect = node.textRect; +export function flowDocumentTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, (node.rect.height * 5) / 7) + node.fullTextRect = node.textRect } -//# sourceMappingURL=document.rect.js.map \ No newline at end of file +// # sourceMappingURL=document.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/index.js index 73fa82f66..259555a06 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/document/index.js @@ -1,4 +1,4 @@ -export * from './document'; -export * from './document.anchor'; -export * from './document.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './document' +export * from './document.anchor' +export * from './document.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.anchor.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.anchor.js index 10f56ba01..49dc9757e 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.anchor.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.anchor.js @@ -1,8 +1,8 @@ -import { Point, Direction } from '@topology/core'; -export function flowExternStorageAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)); - node.anchors.push(new Point(node.rect.x + (node.rect.width * 8) / 15, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + (node.rect.width * 13) / 14, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + (node.rect.width * 8) / 15, node.rect.ey, Direction.Bottom)); +import { Point, Direction } from '@topology/core' +export function flowExternStorageAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left)) + node.anchors.push(new Point(node.rect.x + (node.rect.width * 8) / 15, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + (node.rect.width * 13) / 14, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + (node.rect.width * 8) / 15, node.rect.ey, Direction.Bottom)) } -//# sourceMappingURL=externStorage.anchor.js.map \ No newline at end of file +// # sourceMappingURL=externStorage.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.js index 98394c309..ebf2d07fa 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.js @@ -1,12 +1,12 @@ -export function flowExternStorage(ctx, node) { - ctx.beginPath(); - var offsetX = node.rect.width / 10; - ctx.moveTo(node.rect.x + offsetX * 2, node.rect.y); - ctx.bezierCurveTo(node.rect.x - (offsetX * 2) / 3, node.rect.y, node.rect.x - (offsetX * 2) / 3, node.rect.ey, node.rect.x + offsetX * 2, node.rect.ey); - ctx.lineTo(node.rect.ex, node.rect.ey); - ctx.bezierCurveTo(node.rect.ex - offsetX, node.rect.ey, node.rect.ex - offsetX, node.rect.y, node.rect.ex, node.rect.y); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowExternStorage (ctx, node) { + ctx.beginPath() + const offsetX = node.rect.width / 10 + ctx.moveTo(node.rect.x + offsetX * 2, node.rect.y) + ctx.bezierCurveTo(node.rect.x - (offsetX * 2) / 3, node.rect.y, node.rect.x - (offsetX * 2) / 3, node.rect.ey, node.rect.x + offsetX * 2, node.rect.ey) + ctx.lineTo(node.rect.ex, node.rect.ey) + ctx.bezierCurveTo(node.rect.ex - offsetX, node.rect.ey, node.rect.ex - offsetX, node.rect.y, node.rect.ex, node.rect.y) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=externStorage.js.map \ No newline at end of file +// # sourceMappingURL=externStorage.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.rect.js index 7217d76e0..f5d27824a 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/externStorage.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function flowExternStorageIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowExternStorageIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowExternStorageTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.width / 6, node.rect.y, (node.rect.width * 3) / 4, node.rect.height); - node.fullTextRect = node.textRect; +export function flowExternStorageTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.width / 6, node.rect.y, (node.rect.width * 3) / 4, node.rect.height) + node.fullTextRect = node.textRect } -//# sourceMappingURL=externStorage.rect.js.map \ No newline at end of file +// # sourceMappingURL=externStorage.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/index.js index 1c0ffd989..c6855e19b 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/externStorage/index.js @@ -1,4 +1,4 @@ -export * from './externStorage'; -export * from './externStorage.anchor'; -export * from './externStorage.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './externStorage' +export * from './externStorage.anchor' +export * from './externStorage.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/index.js index 3ba1d38a2..48dd8d514 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/index.js @@ -1,3 +1,3 @@ -export * from './internalStorage'; -export * from './internalStorage.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './internalStorage' +export * from './internalStorage.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/internalStorage.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/internalStorage.js index 8d405fd18..242b1d4e5 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/internalStorage.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/internalStorage.js @@ -1,16 +1,16 @@ -export function flowInternalStorage(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.ey); - ctx.lineTo(node.rect.x, node.rect.ey); - ctx.closePath(); - var offset = node.rect.width / 7; - ctx.moveTo(node.rect.x, node.rect.y + offset); - ctx.lineTo(node.rect.ex, node.rect.y + offset); - ctx.moveTo(node.rect.x + offset, node.rect.y); - ctx.lineTo(node.rect.x + offset, node.rect.ey); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowInternalStorage (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.ey) + ctx.lineTo(node.rect.x, node.rect.ey) + ctx.closePath() + const offset = node.rect.width / 7 + ctx.moveTo(node.rect.x, node.rect.y + offset) + ctx.lineTo(node.rect.ex, node.rect.y + offset) + ctx.moveTo(node.rect.x + offset, node.rect.y) + ctx.lineTo(node.rect.x + offset, node.rect.ey); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=internalStorage.js.map \ No newline at end of file +// # sourceMappingURL=internalStorage.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/internalStorage.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/internalStorage.rect.js index c2b926203..b4fd53aa2 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/internalStorage.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/internalStorage/internalStorage.rect.js @@ -1,10 +1,10 @@ -import { Rect } from '@topology/core'; -export function flowInternalStorageIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowInternalStorageIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowInternalStorageTextRect(node) { - var offset = node.rect.width / 7; - node.textRect = new Rect(node.rect.x + offset, node.rect.y + offset, node.rect.width - offset, node.rect.height - offset); - node.fullTextRect = node.textRect; +export function flowInternalStorageTextRect (node) { + const offset = node.rect.width / 7 + node.textRect = new Rect(node.rect.x + offset, node.rect.y + offset, node.rect.width - offset, node.rect.height - offset) + node.fullTextRect = node.textRect } -//# sourceMappingURL=internalStorage.rect.js.map \ No newline at end of file +// # sourceMappingURL=internalStorage.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/index.js index 69d5e8d72..e6364e0ce 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/index.js @@ -1,4 +1,4 @@ -export * from './manually'; -export * from './manually.anchor'; -export * from './manually.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './manually' +export * from './manually.anchor' +export * from './manually.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.anchor.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.anchor.js index 07853bcd1..e3826e953 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.anchor.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.anchor.js @@ -1,8 +1,8 @@ -import { Point, Direction } from '@topology/core'; -export function flowManuallyAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 5) / 8, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 8, Direction.Up)); - node.anchors.push(new Point(node.rect.ex, node.rect.y + node.rect.height / 2, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom)); +import { Point, Direction } from '@topology/core' +export function flowManuallyAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 5) / 8, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 8, Direction.Up)) + node.anchors.push(new Point(node.rect.ex, node.rect.y + node.rect.height / 2, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom)) } -//# sourceMappingURL=manually.anchor.js.map \ No newline at end of file +// # sourceMappingURL=manually.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.js index edd138a58..f3a21b25b 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.js @@ -1,12 +1,12 @@ -export function flowManually(ctx, node) { - ctx.beginPath(); - var offsetY = node.rect.height / 4; - ctx.moveTo(node.rect.x, node.rect.y + offsetY); - ctx.lineTo(node.rect.ex, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.ey); - ctx.lineTo(node.rect.x, node.rect.ey); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowManually (ctx, node) { + ctx.beginPath() + const offsetY = node.rect.height / 4 + ctx.moveTo(node.rect.x, node.rect.y + offsetY) + ctx.lineTo(node.rect.ex, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.ey) + ctx.lineTo(node.rect.x, node.rect.ey) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=manually.js.map \ No newline at end of file +// # sourceMappingURL=manually.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.rect.js index 35c4d8b6a..6dd5d4ad5 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/manually/manually.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function flowManuallyIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowManuallyIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowManuallyTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height / 4, node.rect.width, (node.rect.height * 3) / 4); - node.fullTextRect = node.textRect; +export function flowManuallyTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height / 4, node.rect.width, (node.rect.height * 3) / 4) + node.fullTextRect = node.textRect } -//# sourceMappingURL=manually.rect.js.map \ No newline at end of file +// # sourceMappingURL=manually.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/index.js index 60da6db77..f3a02216a 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/index.js @@ -1,3 +1,3 @@ -export * from './parallel'; -export * from './parallel.anchor'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './parallel' +export * from './parallel.anchor' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/parallel.anchor.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/parallel.anchor.js index d1546d43c..c2f5e9da3 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/parallel.anchor.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/parallel.anchor.js @@ -1,6 +1,6 @@ -import { Point, Direction } from '@topology/core'; -export function flowParallelAnchors(node) { - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)); +import { Point, Direction } from '@topology/core' +export function flowParallelAnchors (node) { + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom)) } -//# sourceMappingURL=parallel.anchor.js.map \ No newline at end of file +// # sourceMappingURL=parallel.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/parallel.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/parallel.js index 7642aabe4..860ed8de2 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/parallel.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/parallel/parallel.js @@ -1,9 +1,9 @@ -export function flowParallel(ctx, node) { - ctx.beginPath(); - ctx.moveTo(node.rect.x, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.y); - ctx.moveTo(node.rect.x, node.rect.ey); - ctx.lineTo(node.rect.ex, node.rect.ey); - ctx.stroke(); +export function flowParallel (ctx, node) { + ctx.beginPath() + ctx.moveTo(node.rect.x, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.y) + ctx.moveTo(node.rect.x, node.rect.ey) + ctx.lineTo(node.rect.ex, node.rect.ey) + ctx.stroke() } -//# sourceMappingURL=parallel.js.map \ No newline at end of file +// # sourceMappingURL=parallel.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/index.js index 9182d276f..f0abcee58 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/index.js @@ -1,3 +1,3 @@ -export * from './queue'; -export * from './queue.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './queue' +export * from './queue.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/queue.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/queue.js index 9f874aaca..fa2d90ac7 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/queue.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/queue.js @@ -1,9 +1,9 @@ -export function flowQueue(ctx, node) { - ctx.beginPath(); - ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2); - ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.ey); - ctx.lineTo(node.rect.ex, node.rect.ey); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowQueue (ctx, node) { + ctx.beginPath() + ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2) + ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.ey) + ctx.lineTo(node.rect.ex, node.rect.ey); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=queue.js.map \ No newline at end of file +// # sourceMappingURL=queue.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/queue.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/queue.rect.js index 1d14b8390..385fbe67e 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/queue.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/queue/queue.rect.js @@ -1,11 +1,11 @@ -import { Rect } from '@topology/core'; -export function flowQueueIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowQueueIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowQueueTextRect(node) { - var w = (node.rect.width * 5) / 7; - var h = (node.rect.height * 5) / 7; - node.textRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h); - node.fullTextRect = node.textRect; +export function flowQueueTextRect (node) { + const w = (node.rect.width * 5) / 7 + const h = (node.rect.height * 5) / 7 + node.textRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h) + node.fullTextRect = node.textRect } -//# sourceMappingURL=queue.rect.js.map \ No newline at end of file +// # sourceMappingURL=queue.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/register.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/register.js index 88179ebd1..c5bd4ad4a 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/register.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/register.js @@ -1,26 +1,26 @@ -import { registerNode } from '@topology/core'; -import { flowData, flowDataAnchors, flowDataIconRect, flowDataTextRect } from './data'; -import { flowSubprocess, flowSubprocessIconRect, flowSubprocessTextRect } from './subprocess'; -import { flowDb, flowDbIconRect, flowDbTextRect } from './db'; -import { flowDocument, flowDocumentAnchors, flowDocumentIconRect, flowDocumentTextRect } from './document'; -import { flowInternalStorage, flowInternalStorageIconRect, flowInternalStorageTextRect } from './internalStorage'; -import { flowExternStorage, flowExternStorageAnchors, flowExternStorageIconRect, flowExternStorageTextRect } from './externStorage'; -import { flowQueue, flowQueueIconRect, flowQueueTextRect } from './queue'; -import { flowManually, flowManuallyAnchors, flowManuallyIconRect, flowManuallyTextRect } from './manually'; -import { flowDisplay, flowDisplayAnchors, flowDisplayIconRect, flowDisplayTextRect } from './display'; -import { flowParallel, flowParallelAnchors } from './parallel'; -import { flowComment, flowCommentAnchors } from './comment'; -export function register() { - registerNode('flowData', flowData, flowDataAnchors, flowDataIconRect, flowDataTextRect); - registerNode('flowSubprocess', flowSubprocess, null, flowSubprocessIconRect, flowSubprocessTextRect); - registerNode('flowDb', flowDb, null, flowDbIconRect, flowDbTextRect); - registerNode('flowDocument', flowDocument, flowDocumentAnchors, flowDocumentIconRect, flowDocumentTextRect); - registerNode('flowInternalStorage', flowInternalStorage, null, flowInternalStorageIconRect, flowInternalStorageTextRect); - registerNode('flowExternStorage', flowExternStorage, flowExternStorageAnchors, flowExternStorageIconRect, flowExternStorageTextRect); - registerNode('flowQueue', flowQueue, null, flowQueueIconRect, flowQueueTextRect); - registerNode('flowManually', flowManually, flowManuallyAnchors, flowManuallyIconRect, flowManuallyTextRect); - registerNode('flowDisplay', flowDisplay, flowDisplayAnchors, flowDisplayIconRect, flowDisplayTextRect); - registerNode('flowParallel', flowParallel, flowParallelAnchors, null, null); - registerNode('flowComment', flowComment, flowCommentAnchors, null, null); +import { registerNode } from '@topology/core' +import { flowData, flowDataAnchors, flowDataIconRect, flowDataTextRect } from './data' +import { flowSubprocess, flowSubprocessIconRect, flowSubprocessTextRect } from './subprocess' +import { flowDb, flowDbIconRect, flowDbTextRect } from './db' +import { flowDocument, flowDocumentAnchors, flowDocumentIconRect, flowDocumentTextRect } from './document' +import { flowInternalStorage, flowInternalStorageIconRect, flowInternalStorageTextRect } from './internalStorage' +import { flowExternStorage, flowExternStorageAnchors, flowExternStorageIconRect, flowExternStorageTextRect } from './externStorage' +import { flowQueue, flowQueueIconRect, flowQueueTextRect } from './queue' +import { flowManually, flowManuallyAnchors, flowManuallyIconRect, flowManuallyTextRect } from './manually' +import { flowDisplay, flowDisplayAnchors, flowDisplayIconRect, flowDisplayTextRect } from './display' +import { flowParallel, flowParallelAnchors } from './parallel' +import { flowComment, flowCommentAnchors } from './comment' +export function register () { + registerNode('flowData', flowData, flowDataAnchors, flowDataIconRect, flowDataTextRect) + registerNode('flowSubprocess', flowSubprocess, null, flowSubprocessIconRect, flowSubprocessTextRect) + registerNode('flowDb', flowDb, null, flowDbIconRect, flowDbTextRect) + registerNode('flowDocument', flowDocument, flowDocumentAnchors, flowDocumentIconRect, flowDocumentTextRect) + registerNode('flowInternalStorage', flowInternalStorage, null, flowInternalStorageIconRect, flowInternalStorageTextRect) + registerNode('flowExternStorage', flowExternStorage, flowExternStorageAnchors, flowExternStorageIconRect, flowExternStorageTextRect) + registerNode('flowQueue', flowQueue, null, flowQueueIconRect, flowQueueTextRect) + registerNode('flowManually', flowManually, flowManuallyAnchors, flowManuallyIconRect, flowManuallyTextRect) + registerNode('flowDisplay', flowDisplay, flowDisplayAnchors, flowDisplayIconRect, flowDisplayTextRect) + registerNode('flowParallel', flowParallel, flowParallelAnchors, null, null) + registerNode('flowComment', flowComment, flowCommentAnchors, null, null) } -//# sourceMappingURL=register.js.map \ No newline at end of file +// # sourceMappingURL=register.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/index.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/index.js index 06b9d1e1e..83655bd9d 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/index.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/index.js @@ -1,3 +1,3 @@ -export * from './subprocess'; -export * from './subprocess.rect'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './subprocess' +export * from './subprocess.rect' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/subprocess.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/subprocess.js index 799e25f1d..43f61baca 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/subprocess.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/subprocess.js @@ -1,16 +1,16 @@ -export function flowSubprocess(ctx, node) { - ctx.beginPath(); - var offsetX = node.rect.width / 7; - ctx.moveTo(node.rect.x, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.y); - ctx.lineTo(node.rect.ex, node.rect.ey); - ctx.lineTo(node.rect.x, node.rect.ey); - ctx.closePath(); - ctx.moveTo(node.rect.x + offsetX, node.rect.y); - ctx.lineTo(node.rect.x + offsetX, node.rect.ey); - ctx.moveTo(node.rect.ex - offsetX, node.rect.y); - ctx.lineTo(node.rect.ex - offsetX, node.rect.ey); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function flowSubprocess (ctx, node) { + ctx.beginPath() + const offsetX = node.rect.width / 7 + ctx.moveTo(node.rect.x, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.y) + ctx.lineTo(node.rect.ex, node.rect.ey) + ctx.lineTo(node.rect.x, node.rect.ey) + ctx.closePath() + ctx.moveTo(node.rect.x + offsetX, node.rect.y) + ctx.lineTo(node.rect.x + offsetX, node.rect.ey) + ctx.moveTo(node.rect.ex - offsetX, node.rect.y) + ctx.lineTo(node.rect.ex - offsetX, node.rect.ey); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=subprocess.js.map \ No newline at end of file +// # sourceMappingURL=subprocess.js.map diff --git a/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/subprocess.rect.js b/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/subprocess.rect.js index f01e80dc9..61d6ec549 100644 --- a/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/subprocess.rect.js +++ b/nezha-fronted/src/components/common/@topology/flow-diagram/src/subprocess/subprocess.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function flowSubprocessIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function flowSubprocessIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function flowSubprocessTextRect(node) { - node.textRect = new Rect(node.rect.x + node.rect.width / 7, node.rect.y, (node.rect.width * 5) / 7, node.rect.height); - node.fullTextRect = node.textRect; +export function flowSubprocessTextRect (node) { + node.textRect = new Rect(node.rect.x + node.rect.width / 7, node.rect.y, (node.rect.width * 5) / 7, node.rect.height) + node.fullTextRect = node.textRect } -//# sourceMappingURL=subprocess.rect.js.map \ No newline at end of file +// # sourceMappingURL=subprocess.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/layout/index.js b/nezha-fronted/src/components/common/@topology/layout/index.js index 53e15641f..d07c49563 100644 --- a/nezha-fronted/src/components/common/@topology/layout/index.js +++ b/nezha-fronted/src/components/common/@topology/layout/index.js @@ -1,3 +1,3 @@ -export * from './src/align'; -export * from './src/layout'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './src/align' +export * from './src/layout' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/layout/src/align.js b/nezha-fronted/src/components/common/@topology/layout/src/align.js index 2020772b3..c0f44db3e 100644 --- a/nezha-fronted/src/components/common/@topology/layout/src/align.js +++ b/nezha-fronted/src/components/common/@topology/layout/src/align.js @@ -1,63 +1,63 @@ -import { Node } from '@topology/core'; -export function alignNodes(pens, rect, align) { - for (var _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { - var item = pens_1[_i]; - if (!(item instanceof Node)) { - continue; - } - switch (align) { - case 'left': - item.rect.x = rect.x; - break; - case 'right': - item.rect.x = rect.ex - item.rect.width; - break; - case 'top': - item.rect.y = rect.y; - break; - case 'bottom': - item.rect.y = rect.ey - item.rect.height; - break; - case 'center': - item.rect.x = rect.center.x - item.rect.width / 2; - break; - case 'middle': - item.rect.y = rect.center.y - item.rect.height / 2; - break; - } - item.rect.floor(); - item.rect.calcCenter(); - item.init(); - item.calcChildrenRect(); +import { Node } from '@topology/core' +export function alignNodes (pens, rect, align) { + for (let _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { + const item = pens_1[_i] + if (!(item instanceof Node)) { + continue } + switch (align) { + case 'left': + item.rect.x = rect.x + break + case 'right': + item.rect.x = rect.ex - item.rect.width + break + case 'top': + item.rect.y = rect.y + break + case 'bottom': + item.rect.y = rect.ey - item.rect.height + break + case 'center': + item.rect.x = rect.center.x - item.rect.width / 2 + break + case 'middle': + item.rect.y = rect.center.y - item.rect.height / 2 + break + } + item.rect.floor() + item.rect.calcCenter() + item.init() + item.calcChildrenRect() + } } -export function spaceBetween(pens, width) { - var space = 0; - var cnt = 0; - for (var _i = 0, pens_2 = pens; _i < pens_2.length; _i++) { - var item = pens_2[_i]; - if (!(item instanceof Node)) { - continue; - } - space += item.rect.width; - ++cnt; +export function spaceBetween (pens, width) { + let space = 0 + let cnt = 0 + for (let _i = 0, pens_2 = pens; _i < pens_2.length; _i++) { + var item = pens_2[_i] + if (!(item instanceof Node)) { + continue } - space = (width - space) / (cnt - 1); - var left = 0; - for (var _a = 0, pens_3 = pens; _a < pens_3.length; _a++) { - var item = pens_3[_a]; - if (!(item instanceof Node)) { - continue; - } - if (!left) { - left = item.rect.x; - } - item.rect.x = left; - left += item.rect.width + space; - item.rect.floor(); - item.rect.calcCenter(); - item.init(); - item.calcChildrenRect(); + space += item.rect.width + ++cnt + } + space = (width - space) / (cnt - 1) + let left = 0 + for (let _a = 0, pens_3 = pens; _a < pens_3.length; _a++) { + var item = pens_3[_a] + if (!(item instanceof Node)) { + continue } + if (!left) { + left = item.rect.x + } + item.rect.x = left + left += item.rect.width + space + item.rect.floor() + item.rect.calcCenter() + item.init() + item.calcChildrenRect() + } } -//# sourceMappingURL=align.js.map \ No newline at end of file +// # sourceMappingURL=align.js.map diff --git a/nezha-fronted/src/components/common/@topology/layout/src/layout.js b/nezha-fronted/src/components/common/@topology/layout/src/layout.js index 9e279675e..3c953d0ad 100644 --- a/nezha-fronted/src/components/common/@topology/layout/src/layout.js +++ b/nezha-fronted/src/components/common/@topology/layout/src/layout.js @@ -1,50 +1,50 @@ -import { PenType, getRect } from '@topology/core'; -import { alignNodes, spaceBetween } from './align'; -export function layout(pens, params) { - var spaceWidth = params.spaceWidth || 30; - var spaceHeight = params.spaceHeight || 30; - var rect = getRect(pens); - var left = rect.x; - var top = rect.y; - var rows = []; - var row = []; - var maxHeight = 0; - for (var _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { - var item = pens_1[_i]; - if (item.type === PenType.Line) { - continue; - } - if (params.nodeWidth > 0) { - item.rect.width = params.nodeWidth; - } - if (params.nodeHeight > 0) { - item.rect.height = params.nodeHeight; - } - if (item.rect.height > maxHeight) { - maxHeight = item.rect.height; - } - item.rect.x = left; - item.rect.y = top; - item.rect.init(); - row.push(item); - left += item.rect.width + spaceWidth; - if (left > params.maxWidth || (params.maxCount > 0 && row.length >= params.maxCount)) { - rows.push(row); - row = []; - left = rect.x; - top += maxHeight + spaceHeight; - maxHeight = 0; - } +import { PenType, getRect } from '@topology/core' +import { alignNodes, spaceBetween } from './align' +export function layout (pens, params) { + const spaceWidth = params.spaceWidth || 30 + const spaceHeight = params.spaceHeight || 30 + const rect = getRect(pens) + let left = rect.x + let top = rect.y + const rows = [] + let row = [] + let maxHeight = 0 + for (let _i = 0, pens_1 = pens; _i < pens_1.length; _i++) { + var item = pens_1[_i] + if (item.type === PenType.Line) { + continue } - rows.push(row); - for (var _a = 0, rows_1 = rows; _a < rows_1.length; _a++) { - var item = rows_1[_a]; - var r = getRect(item); - r.width = params.maxWidth; - alignNodes(item, r, 'middle'); - if (params.maxCount > 0) { - spaceBetween(item, params.maxWidth); - } + if (params.nodeWidth > 0) { + item.rect.width = params.nodeWidth } + if (params.nodeHeight > 0) { + item.rect.height = params.nodeHeight + } + if (item.rect.height > maxHeight) { + maxHeight = item.rect.height + } + item.rect.x = left + item.rect.y = top + item.rect.init() + row.push(item) + left += item.rect.width + spaceWidth + if (left > params.maxWidth || (params.maxCount > 0 && row.length >= params.maxCount)) { + rows.push(row) + row = [] + left = rect.x + top += maxHeight + spaceHeight + maxHeight = 0 + } + } + rows.push(row) + for (let _a = 0, rows_1 = rows; _a < rows_1.length; _a++) { + var item = rows_1[_a] + const r = getRect(item) + r.width = params.maxWidth + alignNodes(item, r, 'middle') + if (params.maxCount > 0) { + spaceBetween(item, params.maxWidth) + } + } } -//# sourceMappingURL=layout.js.map \ No newline at end of file +// # sourceMappingURL=layout.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/index.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/index.js index 7dfdd32c0..da99c0d5b 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/index.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/index.js @@ -1,4 +1,4 @@ -export * from './src/lifeline'; -export * from './src/focus'; -export * from './src/register'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './src/lifeline' +export * from './src/focus' +export * from './src/register' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.anchor.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.anchor.js index 085d1da2d..17f24b4d7 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.anchor.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.anchor.js @@ -1,15 +1,15 @@ -import { Point, Direction } from '@topology/core'; -export function sequenceFocusAnchors(node) { - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom)); - var dis = 5; - for (var i = dis; node.rect.y + i < node.rect.ey; i = i + dis) { - var pt1 = new Point(node.rect.x, node.rect.y + i, Direction.Left); - var pt2 = new Point(node.rect.ex, node.rect.y + i, Direction.Right); - pt1.hidden = true; - pt2.hidden = true; - node.anchors.push(pt1); - node.anchors.push(pt2); - } +import { Point, Direction } from '@topology/core' +export function sequenceFocusAnchors (node) { + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom)) + const dis = 5 + for (let i = dis; node.rect.y + i < node.rect.ey; i = i + dis) { + const pt1 = new Point(node.rect.x, node.rect.y + i, Direction.Left) + const pt2 = new Point(node.rect.ex, node.rect.y + i, Direction.Right) + pt1.hidden = true + pt2.hidden = true + node.anchors.push(pt1) + node.anchors.push(pt2) + } } -//# sourceMappingURL=focus.anchor.js.map \ No newline at end of file +// # sourceMappingURL=focus.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.js index ba15e4cd5..d8aa56ed7 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.js @@ -1,13 +1,12 @@ -export function sequenceFocus(ctx, node) { - ctx.beginPath(); - ctx.rect(node.rect.x, node.rect.y, node.rect.width, node.rect.height); - if (this.fillStyle) { - ctx.fillStyle = this.fillStyle; - } - else { - ctx.fillStyle = '#fff'; - } - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); +export function sequenceFocus (ctx, node) { + ctx.beginPath() + ctx.rect(node.rect.x, node.rect.y, node.rect.width, node.rect.height) + if (this.fillStyle) { + ctx.fillStyle = this.fillStyle + } else { + ctx.fillStyle = '#fff' + } + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() } -//# sourceMappingURL=focus.js.map \ No newline at end of file +// # sourceMappingURL=focus.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.rect.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.rect.js index 3b1a03067..5434e23f1 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.rect.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/focus.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function sequenceFocusIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function sequenceFocusIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function sequenceFocusTextRect(node) { - node.textRect = new Rect(0, 0, 0, 0); - node.fullTextRect = node.textRect; +export function sequenceFocusTextRect (node) { + node.textRect = new Rect(0, 0, 0, 0) + node.fullTextRect = node.textRect } -//# sourceMappingURL=focus.rect.js.map \ No newline at end of file +// # sourceMappingURL=focus.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/index.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/index.js index cef1c365a..1c21a9d54 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/index.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/focus/index.js @@ -1,4 +1,4 @@ -export * from './focus'; -export * from './focus.rect'; -export * from './focus.anchor'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './focus' +export * from './focus.rect' +export * from './focus.anchor' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/index.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/index.js index 6256cc24d..bf8f1dc44 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/index.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/index.js @@ -1,4 +1,4 @@ -export * from './lifeline'; -export * from './lifeline.rect'; -export * from './lifeline.anchor'; -//# sourceMappingURL=index.js.map \ No newline at end of file +export * from './lifeline' +export * from './lifeline.rect' +export * from './lifeline.anchor' +// # sourceMappingURL=index.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.anchor.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.anchor.js index b07d7c087..c6b16c787 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.anchor.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.anchor.js @@ -1,9 +1,9 @@ -import { Point, Direction } from '@topology/core'; -export function lifelineAnchors(node) { - node.anchors.push(new Point(node.rect.x, node.rect.y + 25, Direction.Left)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)); - node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + 25, Direction.Right)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + 50, Direction.Bottom)); - node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom)); +import { Point, Direction } from '@topology/core' +export function lifelineAnchors (node) { + node.anchors.push(new Point(node.rect.x, node.rect.y + 25, Direction.Left)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up)) + node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + 25, Direction.Right)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + 50, Direction.Bottom)) + node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom)) } -//# sourceMappingURL=lifeline.anchor.js.map \ No newline at end of file +// # sourceMappingURL=lifeline.anchor.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.js index e387404aa..868b57cae 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.js @@ -1,35 +1,35 @@ -export function lifeline(ctx, node) { - var height = 50; - var wr = node.borderRadius; - var hr = node.borderRadius; - if (node.borderRadius < 1) { - wr = node.rect.width * node.borderRadius; - hr = node.rect.height * node.borderRadius; - } - var r = wr < hr ? wr : hr; - if (node.rect.width < 2 * r) { - r = node.rect.width / 2; - } - if (height < 2 * r) { - r = height / 2; - } - ctx.beginPath(); - ctx.moveTo(node.rect.x + r, node.rect.y); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + height, r); - ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + height, node.rect.x, node.rect.y + height, r); - ctx.arcTo(node.rect.x, node.rect.y + height, node.rect.x, node.rect.y, r); - ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r); - ctx.closePath(); - (node.fillStyle || node.bkType) && ctx.fill(); - ctx.stroke(); - ctx.save(); - ctx.beginPath(); - ctx.lineWidth = 1; - ctx.setLineDash([7, 7]); - var middle = node.rect.x + node.rect.width / 2; - ctx.moveTo(middle, node.rect.y + height + 1); - ctx.lineTo(middle, node.rect.ey); - ctx.stroke(); - ctx.restore(); +export function lifeline (ctx, node) { + const height = 50 + let wr = node.borderRadius + let hr = node.borderRadius + if (node.borderRadius < 1) { + wr = node.rect.width * node.borderRadius + hr = node.rect.height * node.borderRadius + } + let r = wr < hr ? wr : hr + if (node.rect.width < 2 * r) { + r = node.rect.width / 2 + } + if (height < 2 * r) { + r = height / 2 + } + ctx.beginPath() + ctx.moveTo(node.rect.x + r, node.rect.y) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + height, r) + ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + height, node.rect.x, node.rect.y + height, r) + ctx.arcTo(node.rect.x, node.rect.y + height, node.rect.x, node.rect.y, r) + ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r) + ctx.closePath(); + (node.fillStyle || node.bkType) && ctx.fill() + ctx.stroke() + ctx.save() + ctx.beginPath() + ctx.lineWidth = 1 + ctx.setLineDash([7, 7]) + const middle = node.rect.x + node.rect.width / 2 + ctx.moveTo(middle, node.rect.y + height + 1) + ctx.lineTo(middle, node.rect.ey) + ctx.stroke() + ctx.restore() } -//# sourceMappingURL=lifeline.js.map \ No newline at end of file +// # sourceMappingURL=lifeline.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.rect.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.rect.js index 557945cc7..e233c04e5 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.rect.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/lifeline/lifeline.rect.js @@ -1,9 +1,9 @@ -import { Rect } from '@topology/core'; -export function lifelineIconRect(node) { - node.iconRect = new Rect(0, 0, 0, 0); +import { Rect } from '@topology/core' +export function lifelineIconRect (node) { + node.iconRect = new Rect(0, 0, 0, 0) } -export function lifelineTextRect(node) { - node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 50); - node.fullTextRect = node.textRect; +export function lifelineTextRect (node) { + node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 50) + node.fullTextRect = node.textRect } -//# sourceMappingURL=lifeline.rect.js.map \ No newline at end of file +// # sourceMappingURL=lifeline.rect.js.map diff --git a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/register.js b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/register.js index 4ac8868ec..78c9a74b7 100644 --- a/nezha-fronted/src/components/common/@topology/sequence-diagram/src/register.js +++ b/nezha-fronted/src/components/common/@topology/sequence-diagram/src/register.js @@ -1,8 +1,8 @@ -import { registerNode } from '@topology/core'; -import { lifeline, lifelineAnchors, lifelineIconRect, lifelineTextRect } from './lifeline'; -import { sequenceFocus, sequenceFocusAnchors, sequenceFocusIconRect, sequenceFocusTextRect } from './focus'; -export function register() { - registerNode('lifeline', lifeline, lifelineAnchors, lifelineIconRect, lifelineTextRect); - registerNode('sequenceFocus', sequenceFocus, sequenceFocusAnchors, sequenceFocusIconRect, sequenceFocusTextRect); +import { registerNode } from '@topology/core' +import { lifeline, lifelineAnchors, lifelineIconRect, lifelineTextRect } from './lifeline' +import { sequenceFocus, sequenceFocusAnchors, sequenceFocusIconRect, sequenceFocusTextRect } from './focus' +export function register () { + registerNode('lifeline', lifeline, lifelineAnchors, lifelineIconRect, lifelineTextRect) + registerNode('sequenceFocus', sequenceFocus, sequenceFocusAnchors, sequenceFocusIconRect, sequenceFocusTextRect) } -//# sourceMappingURL=register.js.map \ No newline at end of file +// # sourceMappingURL=register.js.map diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index ba9a23670..ece24ddfd 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -327,7 +327,7 @@ import { myCubec, myCubeAnchors } from '../project/L5/services/canvas.js' -import {getTopology, getTopologyImg, setTopology, setTopologyImg} from '../js/common' +import { getTopology, getTopologyImg, setTopology, setTopologyImg } from '../js/common' import CanvasProps from '../project/L5/CanvasProps' import topologyTopTool from '../project/L5/topologyTopTool' import popDataMain from '../project/popData/Main' diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue index 0b57cdfa6..516d52eaa 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue @@ -161,7 +161,7 @@ export default { immediate: true, handler (n) { if (n) { - // console.log(n) + // console.log(n) } } } diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue index 13bccf885..276d9aa53 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue @@ -761,7 +761,7 @@ export default { document.body.style.height = 'auto' // document.getElementsByTagName('html')[0].style.overflow = 'visible' const position = dom.getBoundingClientRect() - this.getPdf(dom, -1 * position.left, -1 * position.top,this.searchTime) + this.getPdf(dom, -1 * position.left, -1 * position.top, this.searchTime) // this.getPdf(dom, 0, 0) }, 2000) } diff --git a/nezha-fronted/src/components/common/detailView/list/endpoint/endpointDetail.vue b/nezha-fronted/src/components/common/detailView/list/endpoint/endpointDetail.vue index 7fb683510..fcec0cb52 100644 --- a/nezha-fronted/src/components/common/detailView/list/endpoint/endpointDetail.vue +++ b/nezha-fronted/src/components/common/detailView/list/endpoint/endpointDetail.vue @@ -108,7 +108,7 @@ export default { label: this.$t('project.endpoint.state'), prop: 'state', show: true, - minWidth: 200, + minWidth: 200 } // { // label: this.$t('project.endpoint.status'), diff --git a/nezha-fronted/src/components/common/detailView/view/detailViewRight.vue b/nezha-fronted/src/components/common/detailView/view/detailViewRight.vue index 85df004a8..7b461e674 100644 --- a/nezha-fronted/src/components/common/detailView/view/detailViewRight.vue +++ b/nezha-fronted/src/components/common/detailView/view/detailViewRight.vue @@ -200,7 +200,7 @@ export default { endpointTabTitle: [ { prop: 'panelTab', name: this.$t('overall.detail') }, { prop: 'endpointAlertMessage', name: this.$t('overall.alert') }, - { prop: 'endpointQuery', name: this.$t('project.metrics.metrics') }, + { prop: 'endpointQuery', name: this.$t('project.metrics.metrics') }, { prop: 'log', name: this.$t('overall.logs') } ] }, diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index 653e3fe72..0473e2214 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -7,7 +7,7 @@ import moment from 'moment-timezone' const exceptClassName = ['prevent-clickoutside', 'config-dropdown', 'nz-pop', 'el-picker', 'chart-box-dropdown', 'metric-dropdown', 'el-cascader__dropdown', 'no-style-class', 'el-message-box', 'nz-dashboard-dropdown', 'el-autocomplete-suggestion', 'nz-temp-box', 'el-time-panel', 'el-dropdown-menu', 'el-select-dropdown'] // clickoutside排除的class(白名单) no-style-class:没有任何样式的class export const clickoutside = { // 初始化指令 - bind(el, binding, vnode) { + bind (el, binding, vnode) { if (!binding.expression) return const unsavedChange = localStorage.getItem('nz-unnsaved-change') let oldValue @@ -17,7 +17,7 @@ export const clickoutside = { } catch (e) { } - function documentHandler(e) { + function documentHandler (e) { if (el.contains(e.target)) { return false } else { @@ -67,16 +67,16 @@ export const clickoutside = { el.__vueClickOutside__ = documentHandler document.addEventListener('mousedown', documentHandler) }, - update(el, binding, vnode) { + update (el, binding, vnode) { el.__newValue__ = binding.value.obj }, - unbind(el, binding) { + unbind (el, binding) { // 解除事件监听 document.removeEventListener('mousedown', el.__vueClickOutside__) delete el.__vueClickOutside__ } } -function isEqual(o1, o2) { +function isEqual (o1, o2) { var isEqualForInner = function (obj1, obj2) { const o1 = obj1 instanceof Object const o2 = obj2 instanceof Object @@ -113,8 +113,8 @@ export const myLoading = { } } } -function myLoadingFunction(el, binding, vnode) { - let className = binding.arg || 'el-loading-mask' +function myLoadingFunction (el, binding, vnode) { + const className = binding.arg || 'el-loading-mask' const ds = el.getElementsByClassName(className)[0] if (binding.value) { if (ds) { @@ -149,7 +149,7 @@ function myLoadingFunction(el, binding, vnode) { // div内部加入内容 // div.innerHTML = '加载中...' // el 元素设置相对定位 div设置绝对定位 - el.setAttribute('class',elClassName + ' elrelative') + el.setAttribute('class', elClassName + ' elrelative') // el.setAttribute('class',className) // 设置绝对定位 div.setAttribute('class', className) @@ -166,7 +166,7 @@ export const cancelWithChange = { const unsavedChange = localStorage.getItem('nz-unnsaved-change') const oldValue = JSON.parse(JSON.stringify(binding.value.obj)) el.__newValue__ = oldValue - function domClick(e) { + function domClick (e) { if (unsavedChange == 'on' && !isEqual(oldValue, el.__newValue__)) { MessageBox.confirm(i18n.t('tip.confirmCancel'), { confirmButtonText: i18n.t('tip.yes'), @@ -184,7 +184,7 @@ export const cancelWithChange = { el.__vueDomClick__ = domClick el.addEventListener('click', domClick) }, - update(el, binding, vnode) { + update (el, binding, vnode) { el.__newValue__ = binding.value.obj }, unbind: function (el, binding) { @@ -196,7 +196,7 @@ export const cancelWithChange = { // 底部上滑框窗口控制 export const bottomBoxWindow = { // 鼠标拖动二级列表 - listResize(vm, e) { + listResize (vm, e) { window.resizing = true const mainListDom = document.querySelector('.main-list') // 主列表 const subBoxDom = document.querySelector('.sub-box') // 副列表 @@ -269,7 +269,7 @@ export const bottomBoxWindow = { document.onmouseup = null } }, - exitFullScreen(vm) { + exitFullScreen (vm) { window.resizing = true const contentRightDom = document.querySelector('.list-page') // 右侧内容区 const contentRightHeight = contentRightDom.offsetHeight// 可视高度 @@ -293,7 +293,7 @@ export const bottomBoxWindow = { }) }, 210) }, - fullScreen(vm) { + fullScreen (vm) { window.resizing = true const contentRightDom = document.querySelector('.list-page') // 右侧内容区 const contentRightHeight = contentRightDom.offsetHeight - 9// 可视高度 @@ -306,7 +306,7 @@ export const bottomBoxWindow = { document.querySelector('.sub-list').style.height = contentRightHeight + 'px' window.resizing = false }, - showSubListWatch(vm, n) { + showSubListWatch (vm, n) { vm.bottomBox.inTransform = n if (!n) { vm.mainTableHeight = vm.$tableHeight.normal // 重置table的高度 @@ -350,7 +350,7 @@ export const bottomBoxWindow = { } } } -export function stringTimeParseToUnix(stringTime) { +export function stringTimeParseToUnix (stringTime) { let time = new Date(stringTime).getTime() let offset = localStorage.getItem('nz-sys-timezone') offset = moment.tz(offset).format('Z') @@ -359,7 +359,7 @@ export function stringTimeParseToUnix(stringTime) { time = time + localOffset - offset * 60 * 60 * 1000 return parseInt(time / 1000) } -export function stringTimeParseToUnixMs(stringTime) { +export function stringTimeParseToUnixMs (stringTime) { let time = new Date(stringTime).getTime() let offset = localStorage.getItem('nz-sys-timezone') offset = moment.tz(offset).format('Z') @@ -368,7 +368,7 @@ export function stringTimeParseToUnixMs(stringTime) { time = time + localOffset - offset * 60 * 60 * 1000 return parseInt(time) } -export function getTime(size, unit) { // 计算时间 +export function getTime (size, unit) { // 计算时间 const now = new Date(bus.computeTimezone(new Date().getTime())) if (unit) { switch (unit) { @@ -409,7 +409,7 @@ export function getTime(size, unit) { // 计算时间 second = second < 10 ? '0' + second : second return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second } -export function calcDurationByStringTime(startTime, endTime) { +export function calcDurationByStringTime (startTime, endTime) { const durationSecond = stringTimeParseToUnix(endTime) - stringTimeParseToUnix(startTime) let result = `${durationSecond % 60}s` if (durationSecond > 60) { @@ -420,7 +420,7 @@ export function calcDurationByStringTime(startTime, endTime) { } return result } -export function calcDurationByStringTimeB(startTime, endTime) { +export function calcDurationByStringTimeB (startTime, endTime) { const durationSecond = stringTimeParseToUnix(endTime) - stringTimeParseToUnix(startTime) let result = `${durationSecond % 60}s` if (durationSecond >= 60 * 60 * 24) { @@ -435,7 +435,7 @@ export function calcDurationByStringTimeB(startTime, endTime) { return result } -export function calcDurationByStringTimeMs(startTime, endTime) { +export function calcDurationByStringTimeMs (startTime, endTime) { let durationSecond = stringTimeParseToUnixMs(endTime) - stringTimeParseToUnixMs(startTime) let result = '' if (durationSecond < 1000) { @@ -457,7 +457,7 @@ export function calcDurationByStringTimeMs(startTime, endTime) { return result } -export function unixTimeParseToString(unixTime, fmt = 'YYYY-MM-DD HH:mm:ss') { +export function unixTimeParseToString (unixTime, fmt = 'YYYY-MM-DD HH:mm:ss') { const date = new Date(unixTime * 1000) const o = { 'M+': date.getMonth() + 1, // 月份 @@ -484,10 +484,10 @@ export const chartResizeTool = { containerBlankWidth: 30, // 容器空白占位宽度(#listContainer的padding) titleHeight: 40, // 标题dom高度 timeouter: null, - stepWidth(containerWidth) { // 单元宽度,参数为容器总宽度 + stepWidth (containerWidth) { // 单元宽度,参数为容器总宽度 return Math.floor((containerWidth - this.containerBlankWidth) / 12) }, - start(vm, originalData, event, chartIndexs) { + start (vm, originalData, event, chartIndexs) { const $self = this const data = JSON.parse(JSON.stringify(originalData)) // 将初始对象复制,后续操作使用复制对象 const shadow = vm.$refs.resizeShadow ? vm.$refs.resizeShadow : vm.$refs[0].resizeShadow // 缩放时底部阴影dom @@ -511,7 +511,7 @@ export const chartResizeTool = { // 3.鼠标松开,将resize-box宽高改为resize-shadow宽高,结束 document.addEventListener('mouseup', mouseupListener) - function moveListener(e) { + function moveListener (e) { const mouseX = e.clientX const mouseY = e.clientY const w = `${Math.floor(originalWidth + (mouseX - mouseOriginalX) - chartBlankWidth)}px` @@ -526,7 +526,7 @@ export const chartResizeTool = { const remainderHeight = (box.offsetHeight + chartBlankHeight - shadowNewHeight) % step // 高的余数 boxStepHandler(remainderWidth, remainderHeight) } - function mouseupListener(e) { + function mouseupListener (e) { data.span = Math.round((shadow.offsetWidth + chartBlankWidth) / step) data.height = Math.round((shadow.offsetHeight + chartBlankHeight) / step) box.style.width = `${Math.floor(data.span * step) - chartBlankWidth}px` @@ -543,7 +543,7 @@ export const chartResizeTool = { document.removeEventListener('mousemove', moveListener) document.removeEventListener('mouseup', mouseupListener) } - function boxStepHandler(width, height, chartIndex) { // param: 宽高变化量,大于0放大,小于0缩小 + function boxStepHandler (width, height, chartIndex) { // param: 宽高变化量,大于0放大,小于0缩小 let widthChange = false let heightChange = false if (width > step / 2) { // 放大shadow宽 @@ -600,7 +600,7 @@ export const chartResizeTool = { // table 方法 export const tableSet = { // 是否需要排序 - sortableShow(prop, from) { + sortableShow (prop, from) { switch (prop) { case 'state': { if (from === 'operationlog' || from === 'alertSilence') { @@ -657,7 +657,7 @@ export const tableSet = { } }, // prop字段 - propTitle(prop, from) { + propTitle (prop, from) { switch (from) { case 'asset': switch (prop) { @@ -781,7 +781,7 @@ export const tableSet = { } }, // 本地正序 - asce(prop) { + asce (prop) { return function (obj1, obj2) { let val1 = obj1[prop] let val2 = obj2[prop] @@ -819,7 +819,7 @@ export const tableSet = { } }, // 本地倒序 - desc(prop) { + desc (prop) { return function (obj1, obj2) { let val1 = obj1[prop] let val2 = obj2[prop] @@ -857,7 +857,7 @@ export const tableSet = { } }, // 转化时间字符串为时间戳 - strTodate(str) { + strTodate (str) { let date = str.trim() date = date.substring(0, 19) date = date.replace(/-/g, '/') // 必须把日期'-'转为'/' @@ -865,7 +865,7 @@ export const tableSet = { } } -export function getMetricTypeValue(queryItem, type) { +export function getMetricTypeValue (queryItem, type) { let copy = JSON.parse(JSON.stringify(queryItem)) switch (type) { case 'min': { @@ -942,31 +942,31 @@ export function getMetricTypeValue(queryItem, type) { } } -export function blankPromise() { +export function blankPromise () { return new Promise(resolve => { resolve() }) } -export function clickLegend(echart, legendName, index) { +export function clickLegend (echart, legendName, index) { if (echart) { // } } -export function showTableTooltip(content, show = true, e) { +export function showTableTooltip (content, show = true, e) { if (show) { const dom = document.querySelector('.table-tooltip') dom.innerHTML = content dom.setAttribute('style', `visibility: visible; top: ${e.clientY - e.offsetY + e.target.offsetHeight * 0.5 - dom.offsetHeight * 0.5}px; left: ${e.clientX - e.offsetX + e.target.offsetWidth}px`) } } -export function hideTableTooltip() { +export function hideTableTooltip () { const dom = document.querySelector('.table-tooltip') dom.setAttribute('style', 'visibility: hidden;') dom.innerHTML = '' } /* 数字转换保留小数,数字很小时转为科学计数法, dot为保留几位小数 */ -export function formatScientificNotation(value, dot = 2) { +export function formatScientificNotation (value, dot = 2) { let val = value ? parseFloat(Number(value).toFixed(dot)) : 0 if (val === 0) { val = Number(value).toPrecision(dot + 1) @@ -982,7 +982,7 @@ export function formatScientificNotation(value, dot = 2) { } } */ /* 处理legend的别名 */ -export function dealLegendAlias(legend, expression) { +export function dealLegendAlias (legend, expression) { if (/\{\{.+\}\}/.test(expression)) { const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) { const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2) diff --git a/nezha-fronted/src/components/common/mixin/subDataList.js b/nezha-fronted/src/components/common/mixin/subDataList.js index 22641b1b8..f072dd2b9 100644 --- a/nezha-fronted/src/components/common/mixin/subDataList.js +++ b/nezha-fronted/src/components/common/mixin/subDataList.js @@ -5,7 +5,7 @@ export default { type: Array }, targetTab: String, - from: String, + from: String }, data () { return { diff --git a/nezha-fronted/src/components/common/project/popData/assetTable.vue b/nezha-fronted/src/components/common/project/popData/assetTable.vue index 430ab2717..993e5b73f 100644 --- a/nezha-fronted/src/components/common/project/popData/assetTable.vue +++ b/nezha-fronted/src/components/common/project/popData/assetTable.vue @@ -114,7 +114,7 @@ export default { label: this.$t('asset.alertNum'), prop: 'alertNum', show: true, - width: 120, + width: 120 }, { label: this.$t('asset.endpointNum2'), prop: 'endpointNum', diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 7bcd59d10..4558d056c 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -782,7 +782,7 @@ export default { return } if (!getTopology(this.topologyIndex)) { - let canvas = new Topology('topology-canvas' + this.topologyIndexF, canvasOptions) + let canvas = new Topology('topology-canvas' + this.topologyIndexF) // canvas.open(data) setTopology(this.topologyIndex, canvas) canvas = null @@ -794,7 +794,7 @@ export default { getTopology(this.topologyIndex).data.name = this.obj.name } getTopology(this.topologyIndex).data.projectId = this.obj.id - getTopology(this.topologyIndex).lock(1) + // getTopology(this.topologyIndex).lock(1) this.getModule()// 获取module resolve() @@ -1753,7 +1753,7 @@ export default { res.data.list.forEach((item, index) => { item.imageName = item.name delete item.name - promiseArr.push(topologyImg['img' + item.id]|| dealImg(`monitor/project/topo/icon/${item.id}/1`, item.id)) + promiseArr.push(topologyImg['img' + item.id] || dealImg(`monitor/project/topo/icon/${item.id}/1`, item.id)) imgArr.push({ ...item }) }) Promise.all(promiseArr).then((res2, header) => { @@ -2286,49 +2286,49 @@ export default { if (getTopology(this.topologyIndex)) { console.log(getTopology(this.topologyIndex)) // getTopology(this.topologyIndex).open({ pens: [] }) - getTopology(this.topologyIndex).off('contextmenu', this.onContextMenu) - getTopology(this.topologyIndex).data.pens.forEach(item => { - item.img = null - item.image = null - item.lastImage = null - }) - getTopology(this.topologyIndex).activeLayer.data.pens.forEach(item => { - item.img = null - item.image = null - item.lastImage = null - }) - getTopology(this.topologyIndex).animateLayer.data.pens.forEach(item => { - item.img = null - item.image = null - item.lastImage = null - }) - getTopology(this.topologyIndex).caches.list.forEach((cache) => { - cache.pens.forEach(item => { - item.img = null - item.image = null - item.lastImage = null - }) - }) - getTopology(this.topologyIndex).animateLayer.data.pens.forEach(item => { - item.img = null - item.image = null - item.lastImage = null - }) - getTopology(this.topologyIndex).canvas.data.pens.forEach(item => { - item.img = null - item.image = null - item.lastImage = null - }) - getTopology(this.topologyIndex).divLayer.data.pens.forEach(item => { - item.img = null - item.image = null - item.lastImage = null - }) - getTopology(this.topologyIndex).hoverLayer.data.pens.forEach(item => { - item.img = null - item.image = null - item.lastImage = null - }) + // getTopology(this.topologyIndex).off('contextmenu', this.onContextMenu) + // getTopology(this.topologyIndex).data.pens.forEach(item => { + // item.img = null + // item.image = null + // item.lastImage = null + // }) + // getTopology(this.topologyIndex).activeLayer.data.pens.forEach(item => { + // item.img = null + // item.image = null + // item.lastImage = null + // }) + // getTopology(this.topologyIndex).animateLayer.data.pens.forEach(item => { + // item.img = null + // item.image = null + // item.lastImage = null + // }) + // getTopology(this.topologyIndex).caches.list.forEach((cache) => { + // cache.pens.forEach(item => { + // item.img = null + // item.image = null + // item.lastImage = null + // }) + // }) + // getTopology(this.topologyIndex).animateLayer.data.pens.forEach(item => { + // item.img = null + // item.image = null + // item.lastImage = null + // }) + // getTopology(this.topologyIndex).canvas.data.pens.forEach(item => { + // item.img = null + // item.image = null + // item.lastImage = null + // }) + // getTopology(this.topologyIndex).divLayer.data.pens.forEach(item => { + // item.img = null + // item.image = null + // item.lastImage = null + // }) + // getTopology(this.topologyIndex).hoverLayer.data.pens.forEach(item => { + // item.img = null + // item.image = null + // item.lastImage = null + // }) getTopology(this.topologyIndex).destroy() const StoreData = le5leStore.get() // const arr = [] diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js index 849301126..5ef019c40 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js +++ b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js @@ -93,7 +93,7 @@ export default { default: return false } }, - isThresholdConfig(type) { + isThresholdConfig (type) { switch (type) { case 'line': case 'area': diff --git a/nezha-fronted/src/components/common/table/asset/assetTable.vue b/nezha-fronted/src/components/common/table/asset/assetTable.vue index f80c1f57d..f468b513a 100644 --- a/nezha-fronted/src/components/common/table/asset/assetTable.vue +++ b/nezha-fronted/src/components/common/table/asset/assetTable.vue @@ -299,7 +299,7 @@ export default { hideTableTooltip, tableDataSort (item) { let orderBy = '' - let str = item.prop + const str = item.prop if (str === 'dc') { orderBy = str } diff --git a/nezha-fronted/src/components/layout/header.vue b/nezha-fronted/src/components/layout/header.vue index d3a989478..9465ac999 100644 --- a/nezha-fronted/src/components/layout/header.vue +++ b/nezha-fronted/src/components/layout/header.vue @@ -83,7 +83,7 @@ export default { }, data () { return { - username: '', + username: '', name: '', language: 'en', // 顶部菜单相关 diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index ee988fa0a..d436e0cbc 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -830,7 +830,7 @@ export default { this.panelReloadOnlyPanel() }, htmlToPdf () { - let dom = document.getElementsByClassName(this.pdfId)[0] + const dom = document.getElementsByClassName(this.pdfId)[0] if (dom) { // dom = dom.getElementsByClassName('vue-grid-layout')[0] this.htmlTitle = this.showPanel.name diff --git a/nezha-fronted/src/store/user.js b/nezha-fronted/src/store/user.js index 930d49e38..b891da96c 100644 --- a/nezha-fronted/src/store/user.js +++ b/nezha-fronted/src/store/user.js @@ -71,7 +71,6 @@ const user = { }, actions: { loginSuccess (store, res) { - const defaultAppearance = { system_name: localStorage.getItem('nz-sys-name'), system_logo: localStorage.getItem('nz-sys-logo'), diff --git a/nezha-fronted/static/config.json b/nezha-fronted/static/config.json index 3151969db..de525c212 100644 --- a/nezha-fronted/static/config.json +++ b/nezha-fronted/static/config.json @@ -1 +1 @@ -{"baseUrl":"http://192.168.40.42:8080/", "version": "22.05"} +{"baseUrl":"/", "version": "22.04"}