Skip to content

Commit

Permalink
feat: topo
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxiaobo1010 committed Nov 8, 2022
1 parent d0bb89c commit 87de66d
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/api/Dlink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function getDlinkJson(type = 'Topic', params) {
export async function deleteTopic(
Topic = '$dg/user/router/thing/111/cmd/delete'
) {
console.warn(`${location.href} unSubscribe ${Topic}`)
// console.warn(`${location.href} unSubscribe ${Topic}`)
return {
code: 200,
msg: 'success',
Expand Down
13 changes: 12 additions & 1 deletion src/store/modules/topo.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const mutations = {
canvas.contextmenu.attrs.name == 'staticimage' ||
canvas.contextmenu.attrs.name == 'sprite' ||
canvas.contextmenu.attrs.name == 'vuecomponent' ||
canvas.contextmenu.attrs.name == 'amiscomponent' ||
canvas.contextmenu.attrs.name == 'printer'
) {
contextmenu = canvas.contextmenu
Expand Down Expand Up @@ -316,7 +317,8 @@ const mutations = {
thing.type == 'knovaimage' ||
thing.type == 'staticimage' ||
thing.type == 'gifimage' ||
thing.type == 'vuecomponent'
thing.type == 'vuecomponent' ||
thing.type == 'amiscomponent'
) {
console.log('konvaimage', thing)
// state.createdEvidence = Evidence
Expand Down Expand Up @@ -349,6 +351,15 @@ const mutations = {
productid: thing.productid,
})
)
} else if (thing.type == 'amiscomponent') {
simpleImage = addNodeEvent(
_.merge(canvas.handlerArgs, {
type: 'createAmisComponent',
chart: thing.chart,
data: thing.data,
productid: thing.productid,
})
)
} else if (thing.type == 'gifimage') {
simpleImage = addNodeEvent(
_.merge(canvas.handlerArgs, {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/konva/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ function addNodeEvent(args) {
case 'createVueComponent':
return topoBasic.createVueComponent(args)
break
case 'createAmisComponent':
return topoBasic.createAmisComponent(args)
break
case 'createHistory': // 历史数据按钮
return createHistory(thing, saleInfo, randomXy, args)
break
Expand Down
92 changes: 89 additions & 3 deletions src/utils/konva/core/topoBasic.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ const topoBasic = {
simpleImage = new Konva.Image({
name: 'staticimage',
id: args.productid + '_staticimage' + topoId,
x: Axis.x,
y: Axis.y,
x: 100,
y: 100,
image: imageObj,
width: args.data.width,
height: args.data.height,
Expand Down Expand Up @@ -372,14 +372,43 @@ const topoBasic = {

let vueComponet = ''
const topoId = uuid(5)
if (args.data.src) {
console.log('1111111触发了', args)
let src = args.data.src
if (src.indexOf('http') < 0) {
console.log(' this.$FileServe', Vue.prototype.$FileServe)
src = Vue.prototype.$FileServe + src
}
var imageObj = new Image()
imageObj.src = src
// imageObj.onload = () => {
var simpleImage = new Konva.Image({
id: args.data.id || 'vue_component_' + topoId,
x: 100,
y: 100,
image: imageObj,
width: args.data.width,
height: args.data.height,
type: args.chart,
source: args.data.source,
name: 'vuecomponent',
text: args.data.text,
// handler: 'dblclick',
draggable: true,
})
simpleImage.setAttrs({
src: src,
})
return simpleImage
}
vueComponet = new Konva.Rect({
x: 100,
y: 100,
width: args.data.width || 300,
height: args.data.height || 200,
type: args.chart,
fill: args.data.fill || 'rgba(30, 30, 30,0.7)',
text: args.text,
text: args.data.text,
source: args.data.source,
name: 'vuecomponent',
id: args.data.id || 'vue_component_' + topoId,
Expand All @@ -392,6 +421,63 @@ const topoBasic = {

return vueComponet
},
createAmisComponent(args) {
console.info(
'src/utils/konva/core/topoBasic.js',
'gifImage',
// args.path,
args
)
if (args.data.src) {
let src = args.data.src
if (src.indexOf('http') < 0) {
console.log(' this.$FileServe', Vue.prototype.$FileServe)
src = Vue.prototype.$FileServe + src
}
var imageObj = new Image()
imageObj.src = src
// imageObj.onload = () => {
var simpleImage = new Konva.Image({
id: args.data.id || 'amis_component_' + topoId,
x: 100,
y: 100,
image: imageObj,
width: args.data.width,
height: args.data.height,
type: args.chart,
source: args.data.source,
name: 'amiscomponent',
text: args.data.text,
// handler: 'dblclick',
draggable: true,
})
simpleImage.setAttrs({
src: src,
})
return simpleImage
}
let vueComponet = ''
const topoId = uuid(5)
vueComponet = new Konva.Rect({
x: 100,
y: 100,
width: args.data.width || 300,
height: args.data.height || 200,
type: args.chart,
fill: args.data.fill || 'rgba(30, 30, 30,0.7)',
text: args.data.text,
source: args.data.source,
name: 'amiscomponent',
id: args.data.id || 'amis_component_' + topoId,
draggable: true,
})

// vueComponet.setAttrs({
// src: args.image,
// })

return vueComponet
},
/**
* @description 绑定组态
*/
Expand Down
9 changes: 5 additions & 4 deletions src/utils/konva/core/topoStage.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ const topoStage = {
if (node.attrs.type == 'konvaimage') {
let item = node.attrs
list.push(item)
console.log('这是图片1111111', node)
console.log('进行图片展示', node)
// console.log('这是图片1111111', node)
// console.log('进行图片展示', node)
if (window.location.hash.indexOf('type=device') < 0) {
let image = new Image()
node.setAttrs({
Expand Down Expand Up @@ -244,8 +244,9 @@ const topoStage = {
// BgimageObj.src = bgSrc
// layer.batchDraw()
// stage.batchDraw()
}
if (node.attrs.type == 'staticimage') {
// if (node.attrs.type == 'staticimage')
} else {
console.log('11111111')
let image = new Image()
node.setAttrs({
image: image,
Expand Down
3 changes: 2 additions & 1 deletion src/views/CloudFunction/lowcode/components/ViewEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
console.log(this.$refs.monacoCode.$refs.monacoEditor.editor.getValue())
this.$refs['form'].validate(async (valid) => {
if (valid) {
const { title, type, key } = this.form
const { title, type, key, flag } = this.form
const params = {
data: JSON.parse(
this.$refs.monacoCode.$refs.monacoEditor.editor.getValue()
Expand All @@ -393,6 +393,7 @@
title,
type,
key,
flag,
}
if (this.type == 'add') {
const res = await postView(params)
Expand Down
Loading

0 comments on commit 87de66d

Please sign in to comment.