Compare commits
No commits in common. "dc501d8f87f2e5f1a955b0d32dbde79a46b1200c" and "e25fb7495f6acb9364c0dca0a11f962089b82a5c" have entirely different histories.
dc501d8f87
...
e25fb7495f
@ -4,6 +4,6 @@ VITE_OSS_URL = https://lxx-web-1313840333.cos.ap-chengdu.myqcloud.com
|
||||
VITE_CDN_URL = https://dmgcdn-1313840333.cos.ap-guangzhou.myqcloud.com
|
||||
VITE_SERVER_URL = http://127.0.0.1:9053/api/main
|
||||
# VITE_SERVER_URL = http://test.web.xuexiaole.com/api/main
|
||||
VITE_XXL_VERSION=2.13.7
|
||||
VITE_XXL_VERSION=2.13.6
|
||||
VITE_INIT_VCONSOLE = 0
|
||||
VITE_TEACHER_ADMIN_URL = https://test.edu.xuexiaole.com
|
||||
|
||||
@ -37,9 +37,6 @@ async function drawBackground(src: string, taskId = paintTaskId) {
|
||||
|
||||
const draw = async (imgSrc: string) => {
|
||||
const img = new Image()
|
||||
if (/^https?:\/\//i.test(imgSrc)) {
|
||||
img.crossOrigin = 'anonymous'
|
||||
}
|
||||
img.src = imgSrc
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
img.onload = () => resolve()
|
||||
@ -117,26 +114,16 @@ function handleSaveAsync(): Promise<{ blob: Blob | null; data: string | null }>
|
||||
const canvas = canvasRef.value as HTMLCanvasElement
|
||||
const pointData = JSON.stringify(signaturePad.toData())
|
||||
const resolveWithFallback = (blob: Blob | null) => {
|
||||
try {
|
||||
resolve({
|
||||
blob: blob || dataUrlToBlob(canvas.toDataURL('image/jpeg', 0.85)),
|
||||
data: pointData,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('canvas export error', error)
|
||||
resolve({ blob: null, data: pointData })
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (typeof canvas.toBlob === 'function') {
|
||||
canvas.toBlob(resolveWithFallback, 'image/jpeg', 0.85)
|
||||
} else {
|
||||
resolveWithFallback(null)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('canvas export error', error)
|
||||
resolve({ blob: null, data: pointData })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ async function save() {
|
||||
const { blob, data } = await signaturePadRef.value.handleSaveAsync()
|
||||
|
||||
if (!blob) {
|
||||
return XMessage.error(data ? '画板图片导出失败,请重试' : '内容为空,无法保存')
|
||||
return XMessage.error('内容为空,无法保存')
|
||||
}
|
||||
|
||||
if (typeof props.uploadFile !== 'function') {
|
||||
@ -192,12 +192,13 @@ watch(showCanvas, async (nv: boolean) => {
|
||||
pen()
|
||||
const bg = viewPic.value
|
||||
const data = props.isAndroid ? '' : props.submitAnswerPicOriginal || ''
|
||||
if (data) {
|
||||
signaturePadRef.value?.handleLoad?.(data)
|
||||
} else if (bg) {
|
||||
if (bg) {
|
||||
await signaturePadRef.value?.setBackgroundImage?.(bg)
|
||||
}
|
||||
if (!showCanvas.value || currentSessionId !== canvasSessionId) return
|
||||
if (data) {
|
||||
signaturePadRef.value?.handleLoad?.(data)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user