Merge remote-tracking branch 'origin/main'

This commit is contained in:
lideqin
2023-11-07 16:12:34 +08:00
7 changed files with 70 additions and 28 deletions
+8 -4
View File
@@ -53,10 +53,14 @@ export default {
}
},
watch: {
fileIds (value) {
if (value) {
this.getFileList()
}
fileIds: {
handler (value) {
if (value) {
this.getFileList()
}
},
immediate: true,
deep: true
}
},
data () {
+23 -11
View File
@@ -93,7 +93,7 @@ export default {
graph: null,
loadEnd: false,
selectedNodeId: null,
lastQueryId: null
lastQueryId: null // 记录上次查询的节点id
}
},
watch: {
@@ -115,6 +115,12 @@ export default {
mounted () {
this.$nextTick(() => {
this.loadEnd = true
window.onresize = () => {
const width = document.getElementById(this.domId).clientWidth
const height = document.getElementById(this.domId).clientHeight
this.graph.changeSize(width, height)
this.graph.fitCenter()
}
})
},
methods: {
@@ -153,7 +159,7 @@ export default {
})
// 文本的部分
let textContent = (cfg.num || '') + ' ' + (cfg.name || '')
let textContent = (cfg.num || '') + ' ' + (cfg.name || '')
// if (textContent.length > 40) {
// textContent = textContent.slice(0, 20) + '\n' + textContent.slice(20, 40) + '\n' + textContent.slice(40)
// } else if (textContent.length > 20) {
@@ -302,6 +308,12 @@ export default {
if (this.lastQueryId) {
this.graph.setItemState(this.lastQueryId, 'selected', false)
}
if (this.selectedNodeId) {
this.graph.setItemState(this.selectedNodeId, 'selected', false)
}
const node = this.graph.findById(nodeId)
this.selectedNodeId = nodeId
this.$emit('select', node._cfg.model)
this.lastQueryId = nodeId
const matrix = item.get('group').getMatrix()
const point = {
@@ -311,19 +323,19 @@ export default {
const width = this.graph.get('width')
const height = this.graph.get('height')
// 找到视口中心
var viewCenter = {
const viewCenter = {
x: width / 2,
y: height / 2
}
var modelCenter = this.graph.getPointByCanvas(viewCenter.x, viewCenter.y)
var viewportMatrix = this.graph.get('group').getMatrix()
const modelCenter = this.graph.getPointByCanvas(viewCenter.x, viewCenter.y)
const viewportMatrix = this.graph.get('group').getMatrix()
// 画布平移的目标位置,最终目标是graph.translate(dx, dy);
var dx = (modelCenter.x - point.x) * viewportMatrix[0]
var dy = (modelCenter.y - point.y) * viewportMatrix[4]
var lastX = 0
var lastY = 0
var newX = void 0
var newY = void 0
const dx = (modelCenter.x - point.x) * viewportMatrix[0]
const dy = (modelCenter.y - point.y) * viewportMatrix[4]
let lastX = 0
let lastY = 0
let newX = void 0
let newY = void 0
// 动画每次平移一点,直到目标位置
this.graph.get('canvas').animate({
onFrame: (ratio) => {