|
@@ -30,10 +30,10 @@ const rotateView = (draw: Draw) => {
|
|
|
|
|
|
export const getImage = (draw: Draw, format: string) =>
|
|
export const getImage = (draw: Draw, format: string) =>
|
|
draw.stage!.toBlob({
|
|
draw.stage!.toBlob({
|
|
- pixelRatio: 1,
|
|
|
|
|
|
+ pixelRatio: 2,
|
|
mimeType: format,
|
|
mimeType: format,
|
|
quality: 1,
|
|
quality: 1,
|
|
- }) as Promise<Blob>;
|
|
|
|
|
|
+ }) as Promise<Blob | null>;
|
|
|
|
|
|
export const getHeaderActions = (draw: Draw) => {
|
|
export const getHeaderActions = (draw: Draw) => {
|
|
|
|
|
|
@@ -98,7 +98,11 @@ export const getHeaderActions = (draw: Draw) => {
|
|
draw.config.showGrid = false
|
|
draw.config.showGrid = false
|
|
const pop = draw.mode.push(Mode.readonly)
|
|
const pop = draw.mode.push(Mode.readonly)
|
|
await nextTick()
|
|
await nextTick()
|
|
- saveAs(await getImage(draw, 'image/jpeg'), `${filename}.jpg`);
|
|
|
|
|
|
+ const blob = await getImage(draw, 'image/jpeg')
|
|
|
|
+ if (!blob) {
|
|
|
|
+ throw '截图失败'
|
|
|
|
+ }
|
|
|
|
+ saveAs(blob, `${filename}.jpg`);
|
|
pop()
|
|
pop()
|
|
draw.config.showGrid = oldShowGrid
|
|
draw.config.showGrid = oldShowGrid
|
|
})
|
|
})
|
|
@@ -115,7 +119,11 @@ export const getHeaderActions = (draw: Draw) => {
|
|
draw.config.showGrid = false
|
|
draw.config.showGrid = false
|
|
draw.config.back = undefined
|
|
draw.config.back = undefined
|
|
await nextTick()
|
|
await nextTick()
|
|
- await saveAs(await getImage(draw, 'image/png'), `${filename}.png`);
|
|
|
|
|
|
+ const blob = await getImage(draw, 'image/png')
|
|
|
|
+ if (!blob) {
|
|
|
|
+ throw '截图失败'
|
|
|
|
+ }
|
|
|
|
+ await saveAs(blob, `${filename}.png`);
|
|
pop()
|
|
pop()
|
|
draw.config.back = oldBack
|
|
draw.config.back = oldBack
|
|
draw.config.showGrid = oldShowGrid
|
|
draw.config.showGrid = oldShowGrid
|