📌fix: 배경화면 이미지 불러오기 기능 부분 수정
This commit is contained in:
parent
1d724e275d
commit
8299cef5a3
@ -34,11 +34,11 @@ export default function ImgLoad() {
|
||||
|
||||
const handleModal = () => {
|
||||
setFloorPlanState({ ...floorPlanState, refFileModalOpen: false, toggleRotate: false })
|
||||
setCurrentCanvasPlan({
|
||||
...currentCanvasPlan,
|
||||
bgImageName: refImage?.name ?? null,
|
||||
mapPositionAddress,
|
||||
})
|
||||
// setCurrentCanvasPlan({
|
||||
// ...currentCanvasPlan,
|
||||
// bgImageName: refImage?.name ?? null,
|
||||
// mapPositionAddress,
|
||||
// })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -131,12 +131,16 @@ export function useRefFiles() {
|
||||
// setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: currentCanvasPlan.id, mapPositionAddress: queryRef.current.value }))
|
||||
}
|
||||
|
||||
/**
|
||||
* 배경 이미지 로드를 위한 세팅
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (!currentBgImage) {
|
||||
return
|
||||
}
|
||||
console.log('🚀 ~ useEffect ~ currentBgImage:', currentBgImage)
|
||||
handleBackImageLoadToCanvas(`plan-images/${currentCanvasPlan.id}.png`)
|
||||
// handleBackImageLoadToCanvas(`plan-images/${currentCanvasPlan.id}.png`)
|
||||
handleBackImageLoadToCanvas(currentBgImage)
|
||||
setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: refImage?.name ?? null, mapPositionAddress: queryRef.current.value }))
|
||||
}, [currentBgImage])
|
||||
|
||||
@ -147,15 +151,15 @@ export function useRefFiles() {
|
||||
const handleUploadImageRefFile = async (file) => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
formData.append('fileName', currentCanvasPlan.id)
|
||||
// formData.append('fileName', currentCanvasPlan.id)
|
||||
|
||||
// const res = await post({ url: `${process.env.NEXT_PUBLIC_API_SERVER_PATH}/api/image-upload`, data: formData })
|
||||
const res = await post({ url: `http://localhost:3000/api/image-upload`, data: formData })
|
||||
const res = await post({ url: `${process.env.NEXT_PUBLIC_HOST_URL}/image/upload`, data: formData })
|
||||
console.log('🚀 ~ handleUploadImageRefFile ~ res:', res)
|
||||
const image = await readImage(res.fileNm)
|
||||
console.log('🚀 ~ handleUploadImageRefFile ~ file:', image)
|
||||
// const image = await readImage(res.filePath)
|
||||
// console.log('🚀 ~ handleUploadImageRefFile ~ file:', image)
|
||||
|
||||
setCurrentBgImage(image)
|
||||
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
||||
setRefImage(file)
|
||||
}
|
||||
|
||||
|
||||
@ -394,6 +394,7 @@ export function usePlan(params = {}) {
|
||||
canvas,
|
||||
plans,
|
||||
currentCanvasPlan,
|
||||
setCurrentCanvasPlan,
|
||||
selectedPlan,
|
||||
saveCanvas,
|
||||
handleCurrentPlan,
|
||||
|
||||
@ -72,7 +72,8 @@ const writeImage = async (fileName, file) => {
|
||||
}
|
||||
|
||||
const readImage = async (fileName) => {
|
||||
const file = await fs.readFile(`${FILE_PATH}/${fileName}`)
|
||||
// const file = await fs.readFile(`${FILE_PATH}/${fileName}`)
|
||||
const file = await fs.readFile(`${process.env.NEXT_PUBLIC_HOST_URL}${fileName}`)
|
||||
// .then((res) => {
|
||||
// console.log('readImage-then', res)
|
||||
// })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user