import Taro from '@tarojs/api' ; import { findDOM } from '../utils' ; import { MethodHandler } from '../utils/handler' ; todo export const canvasToTempFilePath = ( { canvasId , fileType , quality , success , fail , complete } , inst ) => { const handle = new MethodHandler ( { name : 'canvasToTempFilePath' , success , fail , complete } ) ; const el = findDOM ( inst ) as HTMLElement ; const canvas = el ?. querySelector ( `canvas[canvas-id="${ canvasId }"]` ) as HTMLCanvasElement ; try { const dataURL = canvas ?. toDataURL ( `image/${ fileType || 'png' }` , quality ) ; return handle . success ( { tempFilePath : dataURL } ) ; } catch ( e ) { return handle . fail ( { errMsg : e . message } ) ; } } ;