|
@@ -20,12 +20,12 @@ export default defineComponent({
|
|
const { show } = toRefs(props)
|
|
const { show } = toRefs(props)
|
|
const firstRender = ref(true)
|
|
const firstRender = ref(true)
|
|
const src = /(localhost|192)/.test(location.host)
|
|
const src = /(localhost|192)/.test(location.host)
|
|
- ? 'http://192.168.3.114:3000/' // 'https://test.lexiaoya.cn/whiteboard-noCollab'
|
|
|
|
|
|
+ ? 'https://test.lexiaoya.cn/whiteboard-noCollab'
|
|
: `${location.origin}/whiteboard-noCollab`
|
|
: `${location.origin}/whiteboard-noCollab`
|
|
|
|
|
|
const exportImg = (event: MessageEvent) => {
|
|
const exportImg = (event: MessageEvent) => {
|
|
const data = event.data
|
|
const data = event.data
|
|
- console.log('🚀 ~ event:', event)
|
|
|
|
|
|
+ // console.log('🚀 ~ event:', data)
|
|
if (data.api === 'excalidraw_exportImg') {
|
|
if (data.api === 'excalidraw_exportImg') {
|
|
imgs.base64 = data.base64
|
|
imgs.base64 = data.base64
|
|
imgs.exported = true
|
|
imgs.exported = true
|
|
@@ -72,28 +72,33 @@ export default defineComponent({
|
|
if (imgs.saveLoading) {
|
|
if (imgs.saveLoading) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ console.log('开始')
|
|
imgs.saveLoading = true
|
|
imgs.saveLoading = true
|
|
- // 判断是否已经生成图片
|
|
|
|
- if (imgs.image) {
|
|
|
|
- saveImg()
|
|
|
|
- } else {
|
|
|
|
- const container: any = document.getElementById(`app`)
|
|
|
|
- html2canvas(container, {
|
|
|
|
- allowTaint: true,
|
|
|
|
- useCORS: true,
|
|
|
|
- backgroundColor: null
|
|
|
|
|
|
+ const container: any = document.getElementById(`app`)
|
|
|
|
+ html2canvas(container, {
|
|
|
|
+ allowTaint: true,
|
|
|
|
+ useCORS: true,
|
|
|
|
+ backgroundColor: null
|
|
|
|
+ })
|
|
|
|
+ .then(async (canvas) => {
|
|
|
|
+ // console.log("🚀 ~ canvas:", canvas)
|
|
|
|
+ // document.body.appendChild(canvas)
|
|
|
|
+ // const url = await canvas.toDataURL()
|
|
|
|
+ try {
|
|
|
|
+ imgs.image = canvas.toDataURL()
|
|
|
|
+
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log(error)
|
|
|
|
+ }
|
|
|
|
+ console.log("🚀 ~ imgs.image:", imgs.image)
|
|
|
|
+ saveImg()
|
|
|
|
+ })
|
|
|
|
+ .catch((error) => {
|
|
|
|
+ console.log("🚀 ~ error:", error)
|
|
|
|
+ closeToast()
|
|
|
|
+ imgs.saveLoading = false
|
|
|
|
+ imgs.exported = false
|
|
})
|
|
})
|
|
- .then(async (canvas) => {
|
|
|
|
- const url = canvas.toDataURL('image/png')
|
|
|
|
- imgs.image = url
|
|
|
|
- saveImg()
|
|
|
|
- })
|
|
|
|
- .catch(() => {
|
|
|
|
- closeToast()
|
|
|
|
- imgs.saveLoading = false
|
|
|
|
- imgs.exported = false
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return () => (
|
|
return () => (
|
|
@@ -115,16 +120,13 @@ export default defineComponent({
|
|
}}
|
|
}}
|
|
></iframe>
|
|
></iframe>
|
|
{imgs.exported ? (
|
|
{imgs.exported ? (
|
|
- <img class={styles.img} src={imgs.base64} />
|
|
|
|
|
|
+ <img crossorigin="anonymous" class={styles.img} src={imgs.base64} />
|
|
) : (
|
|
) : (
|
|
<div
|
|
<div
|
|
class={styles.rightItem}
|
|
class={styles.rightItem}
|
|
- onClick={() => {
|
|
|
|
- // onSaveImg()
|
|
|
|
- // props.close()
|
|
|
|
- }}
|
|
|
|
|
|
+ onClick={() => props.close()}
|
|
>
|
|
>
|
|
- <Icon name='close' size={30} color="#fff" />
|
|
|
|
|
|
+ <Icon name="close" size={30} color="#fff" />
|
|
</div>
|
|
</div>
|
|
)}
|
|
)}
|
|
</div>
|
|
</div>
|