Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-gojs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴斌
vue-gojs
Commits
c3433f26
Commit
c3433f26
authored
Sep 20, 2023
by
吴斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:动态数据,修改阈值。
parent
1f6bb6b6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
51 deletions
+44
-51
README.md
README.md
+4
-0
App.vue
src/App.vue
+0
-0
source-collapse.vue
src/components/source-panel/source-collapse.vue
+3
-3
GOJSKit.ts
src/kit/GOJSKit.ts
+6
-5
LinkTemplateKit.ts
src/kit/LinkTemplateKit.ts
+3
-3
NodeTemplateKit.ts
src/kit/NodeTemplateKit.ts
+28
-32
index.vue
src/pages/index.vue
+0
-8
No files found.
README.md
View file @
c3433f26
# Vue-gojs
# Vue-gojs
使用 node 版本为
[
v18.18.0
](
https://nodejs.org/download/release/v18.18.0/node-v18.18.0-win-x64.zip
)
项目启动
```
bash
```
bash
npm install
npm install
npm run dev
npm run dev
...
...
src/App.vue
View file @
c3433f26
This diff is collapsed.
Click to expand it.
src/components/source-panel/source-collapse.vue
View file @
c3433f26
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
import
{
onMounted
,
ref
}
from
'vue'
;
import
{
onMounted
,
ref
}
from
'vue'
;
import
go
from
'gojs'
import
go
from
'gojs'
import
{
$
}
from
'../../kit/GOJSKit'
import
{
GO
}
from
'../../kit/GOJSKit'
import
{
SourcePictureNodeTemplate
}
from
'../../kit/NodeTemplateKit'
;
import
{
SourcePictureNodeTemplate
}
from
'../../kit/NodeTemplateKit'
;
import
{
picModel
}
from
'../../kit/ModelData.ts'
import
{
picModel
}
from
'../../kit/ModelData.ts'
...
@@ -22,8 +22,8 @@ var sourcePalette: any = ref(null)
...
@@ -22,8 +22,8 @@ var sourcePalette: any = ref(null)
var
sourceModel
:
any
=
ref
(
null
)
var
sourceModel
:
any
=
ref
(
null
)
function
init
(){
function
init
(){
sourcePalette
=
$
(
go
.
Palette
,
props
.
category
,
{
sourcePalette
=
GO
(
go
.
Palette
,
props
.
category
,
{
layout
:
$
(
go
.
GridLayout
,
{
alignment
:
go
.
GridLayout
.
Location
}),
layout
:
GO
(
go
.
GridLayout
,
{
alignment
:
go
.
GridLayout
.
Location
}),
nodeTemplate
:
SourcePictureNodeTemplate
,
nodeTemplate
:
SourcePictureNodeTemplate
,
allowZoom
:
false
allowZoom
:
false
})
})
...
...
src/kit/GOJSKit.ts
View file @
c3433f26
import
go
from
'gojs'
;
import
go
from
'gojs'
;
export
var
$
=
go
.
GraphObject
.
make
;
export
var
GO
=
go
.
GraphObject
.
make
;
/**
/**
* 用于连接的锚点效果
* 用于连接的锚点效果
...
@@ -9,8 +9,8 @@ export var $ = go.GraphObject.make;
...
@@ -9,8 +9,8 @@ export var $ = go.GraphObject.make;
* @param {Boolean} output 是否可以从此锚点连接出去
* @param {Boolean} output 是否可以从此锚点连接出去
* @param {Boolean} input 是否可以连接到此锚点
* @param {Boolean} input 是否可以连接到此锚点
*/
*/
export
function
makePort
(
name
,
spot
,
output
,
input
)
{
export
function
makePort
(
name
:
any
,
spot
:
any
,
output
:
any
,
input
:
any
)
{
return
$
(
go
.
Shape
,
"Circle"
,
return
GO
(
go
.
Shape
,
"Circle"
,
{
{
fill
:
null
,
fill
:
null
,
stroke
:
null
,
stroke
:
null
,
...
@@ -28,10 +28,11 @@ export function makePort(name, spot, output, input) {
...
@@ -28,10 +28,11 @@ export function makePort(name, spot, output, input) {
* @param {Node} node 节点
* @param {Node} node 节点
* @param {Boolean} show 是否展示
* @param {Boolean} show 是否展示
*/
*/
export
function
showSmallPorts
(
node
,
show
)
{
export
function
showSmallPorts
(
node
:
any
,
show
:
any
)
{
node
.
ports
.
each
(
function
(
port
)
{
node
.
ports
.
each
(
function
(
port
:
any
)
{
if
(
port
.
portId
!==
""
)
{
// don't change the default port, which is the big shape
if
(
port
.
portId
!==
""
)
{
// don't change the default port, which is the big shape
port
.
fill
=
show
?
"rgba(0,0,0,.3)"
:
null
;
port
.
fill
=
show
?
"rgba(0,0,0,.3)"
:
null
;
}
}
});
});
}
}
src/kit/LinkTemplateKit.ts
View file @
c3433f26
import
{
$
}
from
'./GOJSKit'
import
{
GO
}
from
'./GOJSKit'
import
go
from
'gojs'
import
go
from
'gojs'
export
var
linkSelectionAdornmentTemplate
=
export
var
linkSelectionAdornmentTemplate
=
$
(
go
.
Adornment
,
"Link"
,
GO
(
go
.
Adornment
,
"Link"
,
$
(
go
.
Shape
,
GO
(
go
.
Shape
,
// isPanelMain declares that this Shape shares the Link.geometry
// isPanelMain declares that this Shape shares the Link.geometry
{
isPanelMain
:
true
,
fill
:
null
,
stroke
:
"deepskyblue"
,
strokeWidth
:
1
},
{
isPanelMain
:
true
,
fill
:
null
,
stroke
:
"deepskyblue"
,
strokeWidth
:
1
},
new
go
.
Binding
(
"stroke"
).
makeTwoWay
()
new
go
.
Binding
(
"stroke"
).
makeTwoWay
()
...
...
src/kit/NodeTemplateKit.ts
View file @
c3433f26
import
{
$
,
makePort
,
showSmallPorts
}
from
'./GOJSKit.js'
;
import
{
GO
,
makePort
,
showSmallPorts
}
from
'./GOJSKit.js'
;
import
go
from
'gojs'
;
import
go
from
'gojs'
;
// 节点选中时的边框效果
// 节点选中时的边框效果
export
var
nodeSelectionAdornmentTemplate
=
export
var
nodeSelectionAdornmentTemplate
=
$
(
go
.
Adornment
,
"Auto"
,
GO
(
go
.
Adornment
,
"Auto"
,
$
(
go
.
Shape
,
{
fill
:
null
,
stroke
:
"deepskyblue"
,
strokeWidth
:
1.5
,
strokeDashArray
:
[
4
,
2
]
}),
GO
(
go
.
Shape
,
{
fill
:
null
,
stroke
:
"deepskyblue"
,
strokeWidth
:
1.5
,
strokeDashArray
:
[
4
,
2
]
}),
$
(
go
.
Placeholder
)
GO
(
go
.
Placeholder
)
);
);
// 表示节点旋转的锚点效果
// 表示节点旋转的锚点效果
export
const
makeKitTopRotatingTool
=
()
=>
(
export
const
makeKitTopRotatingTool
=
()
=>
(
class
KitTopRotatingTool
extends
go
.
RotatingTool
{
class
KitTopRotatingTool
extends
go
.
RotatingTool
{
updateAdornments
(
part
)
{
updateAdornments
(
part
:
any
)
{
go
.
RotatingTool
.
prototype
.
updateAdornments
.
call
(
this
,
part
)
go
.
RotatingTool
.
prototype
.
updateAdornments
.
call
(
this
,
part
)
const
adornment
=
part
.
findAdornment
(
'Rotating'
);
const
adornment
=
part
.
findAdornment
(
'Rotating'
);
if
(
adornment
!==
null
)
{
if
(
adornment
!==
null
)
{
adornment
.
location
=
part
.
rotateObject
.
getDocumentPoint
(
new
go
.
Spot
(
0.5
,
0
,
0
,
-
30
))
// above middle top
adornment
.
location
=
part
.
rotateObject
.
getDocumentPoint
(
new
go
.
Spot
(
0.5
,
0
,
0
,
-
30
))
// above middle top
}
}
}
}
//动一下就是 90 度
// rotate(newangle) {
// go.RotatingTool.prototype.rotate.call(this, newangle + 90)
// }
}
}
)
)
export
var
nodeRotateAdornmentTemplate
=
export
var
nodeRotateAdornmentTemplate
=
$
(
go
.
Adornment
,
GO
(
go
.
Adornment
,
{
locationSpot
:
go
.
Spot
.
Center
,
locationObjectName
:
"CIRCLE"
},
{
locationSpot
:
go
.
Spot
.
Center
,
locationObjectName
:
"CIRCLE"
},
$
(
go
.
Shape
,
"Circle"
,
{
name
:
"CIRCLE"
,
cursor
:
"pointer"
,
desiredSize
:
new
go
.
Size
(
7
,
7
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
GO
(
go
.
Shape
,
"Circle"
,
{
name
:
"CIRCLE"
,
cursor
:
"pointer"
,
desiredSize
:
new
go
.
Size
(
7
,
7
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
$
(
go
.
Shape
,
{
geometryString
:
"M3.5 7 L3.5 30"
,
isGeometryPositioned
:
true
,
stroke
:
"deepskyblue"
,
strokeWidth
:
1.5
,
strokeDashArray
:
[
4
,
2
]
})
GO
(
go
.
Shape
,
{
geometryString
:
"M3.5 7 L3.5 30"
,
isGeometryPositioned
:
true
,
stroke
:
"deepskyblue"
,
strokeWidth
:
1.5
,
strokeDashArray
:
[
4
,
2
]
})
);
);
// 可以调整节点大小的锚点效果
// 可以调整节点大小的锚点效果
export
var
nodeResizeAdornmentTemplate
=
export
var
nodeResizeAdornmentTemplate
=
$
(
go
.
Adornment
,
"Spot"
,
GO
(
go
.
Adornment
,
"Spot"
,
{
locationSpot
:
go
.
Spot
.
Right
},
{
locationSpot
:
go
.
Spot
.
Right
},
$
(
go
.
Placeholder
),
GO
(
go
.
Placeholder
),
$
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
TopLeft
,
cursor
:
"nw-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
GO
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
TopLeft
,
cursor
:
"nw-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
$
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
Top
,
cursor
:
"n-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
GO
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
Top
,
cursor
:
"n-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
$
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
TopRight
,
cursor
:
"ne-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
GO
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
TopRight
,
cursor
:
"ne-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
$
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
Left
,
cursor
:
"w-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
GO
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
Left
,
cursor
:
"w-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
$
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
Right
,
cursor
:
"e-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
GO
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
Right
,
cursor
:
"e-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
$
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
BottomLeft
,
cursor
:
"se-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
GO
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
BottomLeft
,
cursor
:
"se-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
$
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
Bottom
,
cursor
:
"s-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
GO
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
Bottom
,
cursor
:
"s-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
}),
$
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
BottomRight
,
cursor
:
"sw-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
})
GO
(
go
.
Shape
,
{
alignment
:
go
.
Spot
.
BottomRight
,
cursor
:
"sw-resize"
,
desiredSize
:
new
go
.
Size
(
6
,
6
),
fill
:
"lightblue"
,
stroke
:
"deepskyblue"
})
);
);
export
var
SourcePictureNodeTemplate
=
export
var
SourcePictureNodeTemplate
=
$
(
go
.
Node
,
"Vertical"
,
GO
(
go
.
Node
,
"Vertical"
,
$
(
go
.
Picture
,
GO
(
go
.
Picture
,
{
width
:
80
,
height
:
80
},
{
width
:
80
,
height
:
80
},
new
go
.
Binding
(
"source"
,
"img"
)
new
go
.
Binding
(
"source"
,
"img"
)
),
),
$
(
go
.
TextBlock
,
GO
(
go
.
TextBlock
,
{
margin
:
8
,
text
:
"123"
},
{
margin
:
8
,
text
:
"123"
},
new
go
.
Binding
(
"text"
,
"name"
))
new
go
.
Binding
(
"text"
,
"name"
))
)
)
export
var
DiagramPictureNodeTemplate
=
$
(
go
.
Node
,
"Spot"
,
export
var
DiagramPictureNodeTemplate
=
GO
(
go
.
Node
,
"Spot"
,
new
go
.
Binding
(
'location'
,
"loc"
,
go
.
Point
.
parse
).
makeTwoWay
(
go
.
Point
.
stringify
),
new
go
.
Binding
(
'location'
,
"loc"
,
go
.
Point
.
parse
).
makeTwoWay
(
go
.
Point
.
stringify
),
{
selectable
:
true
,
selectionAdornmentTemplate
:
nodeSelectionAdornmentTemplate
},
{
selectable
:
true
,
selectionAdornmentTemplate
:
nodeSelectionAdornmentTemplate
},
{
resizable
:
true
,
resizeObjectName
:
"PANEL"
,
resizeAdornmentTemplate
:
nodeResizeAdornmentTemplate
},
{
resizable
:
true
,
resizeObjectName
:
"PANEL"
,
resizeAdornmentTemplate
:
nodeResizeAdornmentTemplate
},
{
rotatable
:
true
,
rotateAdornmentTemplate
:
nodeRotateAdornmentTemplate
,
locationSpot
:
go
.
Spot
.
Center
},
{
rotatable
:
true
,
rotateAdornmentTemplate
:
nodeRotateAdornmentTemplate
,
locationSpot
:
go
.
Spot
.
Center
},
{
resizable
:
true
,
resizeObjectName
:
"view"
},
{
resizable
:
true
,
resizeObjectName
:
"view"
},
new
go
.
Binding
(
'angle'
).
makeTwoWay
(),
new
go
.
Binding
(
'angle'
).
makeTwoWay
(),
$
(
go
.
Panel
,
"Vertical"
,
GO
(
go
.
Panel
,
"Vertical"
,
{
name
:
"PANEL"
,
cursor
:
"pointer"
,
background
:
"lightblue"
},
{
name
:
"PANEL"
,
cursor
:
"pointer"
,
background
:
"lightblue"
},
$
(
go
.
Panel
,
"Viewbox"
,{
name
:
"view"
,
viewboxStretch
:
go
.
GraphObject
.
Uniform
},
GO
(
go
.
Panel
,
"Viewbox"
,{
name
:
"view"
,
viewboxStretch
:
go
.
GraphObject
.
Uniform
},
new
go
.
Binding
(
"desiredSize"
,
"size"
,
go
.
Size
.
parse
).
makeTwoWay
(
go
.
Size
.
stringify
),
new
go
.
Binding
(
"desiredSize"
,
"size"
,
go
.
Size
.
parse
).
makeTwoWay
(
go
.
Size
.
stringify
),
$
(
go
.
Picture
,
new
go
.
Binding
(
"source"
,
"img"
)),
GO
(
go
.
Picture
,
new
go
.
Binding
(
"source"
,
"img"
)),
),
),
$
(
go
.
TextBlock
,
{
margin
:
4
,
text
:
""
,
editable
:
true
,
background
:
"green"
,
alignment
:
go
.
Spot
.
Bottom
,
alignmentFocus
:
go
.
Spot
.
Top
},
new
go
.
Binding
(
"text"
,
"name"
).
makeTwoWay
()),
GO
(
go
.
TextBlock
,
{
margin
:
4
,
text
:
""
,
editable
:
true
,
background
:
"green"
,
alignment
:
go
.
Spot
.
Bottom
,
alignmentFocus
:
go
.
Spot
.
Top
},
new
go
.
Binding
(
"text"
,
"name"
).
makeTwoWay
()),
),
),
// four small named ports, one on each side:
// four small named ports, one on each side:
makePort
(
"T"
,
go
.
Spot
.
Top
,
true
,
true
),
makePort
(
"T"
,
go
.
Spot
.
Top
,
true
,
true
),
...
@@ -78,8 +74,8 @@ export var DiagramPictureNodeTemplate = $(go.Node, "Spot",
...
@@ -78,8 +74,8 @@ export var DiagramPictureNodeTemplate = $(go.Node, "Spot",
makePort
(
"R"
,
go
.
Spot
.
Right
,
true
,
true
),
makePort
(
"R"
,
go
.
Spot
.
Right
,
true
,
true
),
makePort
(
"B"
,
go
.
Spot
.
Bottom
,
true
,
true
),
makePort
(
"B"
,
go
.
Spot
.
Bottom
,
true
,
true
),
{
// handle mouse enter/leave events to show/hide the ports
{
// handle mouse enter/leave events to show/hide the ports
mouseEnter
:
function
(
e
,
node
)
{
showSmallPorts
(
node
,
true
);
console
.
log
(
myDiagram
.
model
.
toJson
())
},
mouseEnter
:
function
(
_e
,
node
)
{
showSmallPorts
(
node
,
true
);
},
mouseLeave
:
function
(
e
,
node
)
{
showSmallPorts
(
node
,
false
);
}
mouseLeave
:
function
(
_
e
,
node
)
{
showSmallPorts
(
node
,
false
);
}
}
}
);
);
src/pages/index.vue
deleted
100644 → 0
View file @
1f6bb6b6
<
template
>
</
template
>
<
script
setup
lang=
"ts"
>
</
script
>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment