提交 0b8a427f 编写于 作者: 郭胜强

feat: 实现API:uni.createContext、uni.drawCanvas

上级 2a4f7467
......@@ -92,3 +92,18 @@ export const canvasToTempFilePath = {
}
}
}
export const drawCanvas = {
canvasId: {
type: String,
require: true
},
actions: {
type: Array,
require: true
},
reserve: {
type: Boolean,
default: false
}
}
......@@ -422,6 +422,16 @@ class CanvasContext {
this.subpath = [this.subpath.shift()]
}
}
clearActions () {
this.actions = []
this.path = []
this.subpath = []
}
getActions () {
var actions = [...this.actions]
this.clearActions()
return actions
}
}
[...methods1, ...methods2].forEach(function (method) {
......@@ -700,3 +710,23 @@ export function canvasToTempFilePath ({
callbackId: cId
})
}
export function createContext () {
return new CanvasContext()
}
export function drawCanvas ({
canvasId,
actions,
reserve
}) {
const app = getApp()
if (app.$route && app.$route.params.__id__) {
operateCanvas(canvasId, app.$route.params.__id__, 'actionsChanged', {
actions,
reserve
})
} else {
UniServiceJSBridge.emit('onError', 'drawCanvas:fail')
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册