diff --git a/src/core/helpers/protocol/canvas.js b/src/core/helpers/protocol/canvas.js index 8001579746f620f4a4046151ec1f89f38a819e37..fb9b55611b3a6cfee1160783fb0e911d1d8e3a2c 100644 --- a/src/core/helpers/protocol/canvas.js +++ b/src/core/helpers/protocol/canvas.js @@ -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 + } +} diff --git a/src/core/service/api/context/canvas.js b/src/core/service/api/context/canvas.js index 5469cf8fcb333588a018a0e8247ac6ff821576a6..1c8872e15fb68161c6730dcb8c73d5528ca9271b 100644 --- a/src/core/service/api/context/canvas.js +++ b/src/core/service/api/context/canvas.js @@ -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') + } +}