diff --git a/frontend/src/components/canvas/components/Editor/Preview.vue b/frontend/src/components/canvas/components/Editor/Preview.vue index 61fc45c893..5d11fc0b66 100644 --- a/frontend/src/components/canvas/components/Editor/Preview.vue +++ b/frontend/src/components/canvas/components/Editor/Preview.vue @@ -31,7 +31,7 @@ class="dialog-css" :destroy-on-close="true" > - + {{ $t('chart.export') }} diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index 0e340487aa..4dcc72c839 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -153,7 +153,7 @@ :destroy-on-close="true" :show-close="true" > - + {{ $t('chart.export') }} diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index d57a3442f1..e3fb03ece1 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1512,6 +1512,7 @@ export default { save_to_panel: 'Save to template', export_to_panel: 'Export to template', export_to_pdf: 'Export to PDF', + export_to_img: 'Export to Image', preview: 'Preview', fullscreen_preview: 'Fullscreen Preview', new_tab_preview: 'New Tab Preview', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index ad7bfb75fa..b3987c27a7 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1513,6 +1513,7 @@ export default { save_to_panel: '保存爲模闆', export_to_panel: '導出爲模闆', export_to_pdf: '導出爲PDF', + export_to_img: '導出爲图片', preview: '預覽', fullscreen_preview: '全屏預覽', new_tab_preview: '新Tab頁預覽', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index d64157aab0..e370c19d5d 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1520,6 +1520,7 @@ export default { save_to_panel: '保存为模板', export_to_panel: '导出为模板', export_to_pdf: '导出为PDF', + export_to_img: '导出为图片', preview: '预览', fullscreen_preview: '全屏预览', new_tab_preview: '新Tab页预览', diff --git a/frontend/src/views/panel/list/PanelViewShow.vue b/frontend/src/views/panel/list/PanelViewShow.vue index 9ff03807e4..f6c96880f9 100644 --- a/frontend/src/views/panel/list/PanelViewShow.vue +++ b/frontend/src/views/panel/list/PanelViewShow.vue @@ -35,14 +35,14 @@ - - - - - - - - + + + + {{ $t('panel.export_to_panel') }} + {{ $t('panel.export_to_pdf') }} + {{ $t('panel.export_to_img') }} + + @@ -138,6 +138,7 @@ import { queryAll } from '@/api/panel/pdfTemplate' import ShareHead from '@/views/panel/GrantAuth/ShareHead' import { initPanelData } from '@/api/panel/panel' import { proxyInitPanelData } from '@/api/panel/shareProxy' +import { dataURLToBlob } from '@/components/canvas/utils/utils' export default { name: 'PanelViewShow', components: { Preview, SaveToTemplate, PDFPreExport, ShareHead }, @@ -282,6 +283,34 @@ export default { }, 50) }, + downloadAsImage() { + this.dataLoading = true + setTimeout(() => { + this.exporting = true + setTimeout(() => { + const canvasID = document.getElementById('canvasInfoTemp') + const a = document.createElement('a') + html2canvas(canvasID).then(canvas => { + this.exporting = false + const dom = document.body.appendChild(canvas) + dom.style.display = 'none' + a.style.display = 'none' + document.body.removeChild(dom) + const blob = dataURLToBlob(dom.toDataURL('image/png', 1)) + a.setAttribute('href', URL.createObjectURL(blob)) + a.setAttribute('download', this.$store.state.panel.panelInfo.name + '.png') + document.body.appendChild(a) + a.click() + URL.revokeObjectURL(blob) + document.body.removeChild(a) + setTimeout(() => { + this.dataLoading = false + }, 300) + }) + }, 500) + }, 0) + }, + downloadAsPDF() { // this.pdfExportShow = true //