📌fix: 이미지 불러오기 기능 수정
This commit is contained in:
parent
f194eb603c
commit
70c3956625
@ -66,15 +66,20 @@ export function useRefFiles() {
|
||||
}
|
||||
|
||||
const refFileSetting = (file) => {
|
||||
if (file && ['image/png', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/gif'].includes(file.type)) {
|
||||
// setRefImage(file)
|
||||
file.name.split('.').pop() === 'dwg' ? handleUploadConvertRefFile(file) : handleUploadImageRefFile(file)
|
||||
console.log('🚀 ~ refFileSetting ~ file:', file)
|
||||
if (file.name.split('.').pop() === 'dwg') {
|
||||
handleUploadConvertRefFile(file)
|
||||
} else {
|
||||
swalFire({
|
||||
text: '이미지가 아닙니다.',
|
||||
type: 'alert',
|
||||
icon: 'error',
|
||||
})
|
||||
if (file && ['image/png', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/gif'].includes(file.type)) {
|
||||
// file.name.split('.').pop() === 'dwg' ? handleUploadConvertRefFile(file) : handleUploadImageRefFile(file)
|
||||
handleUploadImageRefFile(file)
|
||||
} else {
|
||||
swalFire({
|
||||
text: '이미지가 아닙니다.',
|
||||
type: 'alert',
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -121,14 +126,13 @@ export function useRefFiles() {
|
||||
}
|
||||
|
||||
const res = await get({
|
||||
url: `http://localhost:3000/api/html2canvas?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`,
|
||||
url: `${process.env.NEXT_PUBLIC_HOST_URL}/map/convert?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`,
|
||||
})
|
||||
console.log('🚀 ~ handleMapImageDown ~ res:', res)
|
||||
const file = await readImage(res.fileNm)
|
||||
console.log('🚀 ~ handleMapImageDown ~ file:', file)
|
||||
setCurrentBgImage(file)
|
||||
// handleBackImageLoadToCanvas(`plan-images/${currentCanvasPlan.id}.png`)
|
||||
// setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: currentCanvasPlan.id, mapPositionAddress: queryRef.current.value }))
|
||||
// const file = await readImage(res.fileNm)
|
||||
// console.log('🚀 ~ handleMapImageDown ~ file:', file)
|
||||
// setCurrentBgImage(file)
|
||||
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +162,6 @@ export function useRefFiles() {
|
||||
console.log('🚀 ~ handleUploadImageRefFile ~ res:', res)
|
||||
// const image = await readImage(res.filePath)
|
||||
// console.log('🚀 ~ handleUploadImageRefFile ~ file:', image)
|
||||
|
||||
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
||||
setRefImage(file)
|
||||
}
|
||||
@ -171,15 +174,21 @@ export function useRefFiles() {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
await promisePost({ url: converterUrl, data: formData })
|
||||
.then((res) => {
|
||||
convertDwgToPng(res.data.Files[0].FileName, res.data.Files[0].FileData)
|
||||
swalFire({ text: '파일 변환 성공' })
|
||||
setRefImage(res.data.Files[0].FileData)
|
||||
})
|
||||
.catch((err) => {
|
||||
swalFire({ text: '파일 변환 실패', icon: 'error' })
|
||||
})
|
||||
const res = await post({ url: converterUrl, data: formData })
|
||||
console.log('🚀 ~ handleUploadConvertRefFile ~ res:', res)
|
||||
const result = await post({ url: `${process.env.NEXT_PUBLIC_HOST_URL}/cad/convert`, data: res })
|
||||
console.log('🚀 ~ handleUploadConvertRefFile ~ result:', result)
|
||||
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${result.filePath}`)
|
||||
setRefImage(res.Files[0].FileData)
|
||||
// await promisePost({ url: converterUrl, data: formData })
|
||||
// .then((res) => {
|
||||
// convertDwgToPng(res.data.Files[0].FileName, res.data.Files[0].FileData)
|
||||
// swalFire({ text: '파일 변환 성공' })
|
||||
// setRefImage(res.data.Files[0].FileData)
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// swalFire({ text: '파일 변환 실패', icon: 'error' })
|
||||
// })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user