提交 8fc893ed 编写于 作者: D DCloud_LXH

fix: canvas drawImage error question/139758

上级 d3f562d5
...@@ -36,10 +36,16 @@ import { TEMP_PATH, inflateRaw, deflateRaw } from '@dcloudio/uni-platform' ...@@ -36,10 +36,16 @@ import { TEMP_PATH, inflateRaw, deflateRaw } from '@dcloudio/uni-platform'
//#endregion //#endregion
//#region UniServiceJSBridge //#region UniServiceJSBridge
export type OperateCanvasType =
| 'actionsChanged'
| 'getImageData'
| 'putImageData'
| 'toTempFilePath'
function operateCanvas( function operateCanvas(
canvasId: string, canvasId: string,
pageId: number, pageId: number,
type: unknown, type: OperateCanvasType,
data: any, data: any,
callback?: Callback callback?: Callback
) { ) {
......
import { ref, computed, ExtractPropTypes, Ref, onMounted } from 'vue' import { ref, computed, ExtractPropTypes, Ref, onMounted } from 'vue'
import { extend } from '@vue/shared' import { extend } from '@vue/shared'
import type { Actions } from '@dcloudio/uni-api' import type { Actions, OperateCanvasType } from '@dcloudio/uni-api'
import { import {
useAttrs, useAttrs,
useContextInfo, useContextInfo,
...@@ -73,11 +73,8 @@ const props = { ...@@ -73,11 +73,8 @@ const props = {
} }
type Props = ExtractPropTypes<typeof props> type Props = ExtractPropTypes<typeof props>
type triggerMethodsName = type MultipleArray = Array<Array<number | string | number[]>>
| 'actionsChanged' type LinearGradient = Parameters<CanvasFillStrokeStyles['createLinearGradient']>
| 'getImageData'
| 'putImageData'
| 'toTempFilePath'
export default /*#__PURE__*/ defineBuiltInComponent({ export default /*#__PURE__*/ defineBuiltInComponent({
inheritAttrs: false, inheritAttrs: false,
...@@ -271,10 +268,6 @@ function useMethods( ...@@ -271,10 +268,6 @@ function useMethods(
} }
preloadImage(actions) preloadImage(actions)
for (let index = 0; index < actions.length; index++) { for (let index = 0; index < actions.length; index++) {
type MultipleArray = Array<Array<number | string | number[]>>
type LinearGradient = Parameters<
CanvasFillStrokeStyles['createLinearGradient']
>
const action = actions[index] const action = actions[index]
let method = action.method let method = action.method
const data = action.data const data = action.data
...@@ -377,7 +370,7 @@ function useMethods( ...@@ -377,7 +370,7 @@ function useMethods(
let otherData = dataArray.slice(1) let otherData = dataArray.slice(1)
_images = _images || {} _images = _images || {}
if ( if (
checkImageLoaded( !checkImageLoaded(
url, url,
actions.slice(index + 1), actions.slice(index + 1),
resolve, resolve,
...@@ -700,7 +693,7 @@ function useMethods( ...@@ -700,7 +693,7 @@ function useMethods(
} }
function _handleSubscribe( function _handleSubscribe(
type: triggerMethodsName, type: OperateCanvasType,
data: any, data: any,
resolve: (res: { callbackId: number; data: any }) => void resolve: (res: { callbackId: number; data: any }) => void
) { ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册