|
@@ -117,13 +117,21 @@
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
const loading = ref(true);
|
|
const loading = ref(true);
|
|
|
|
|
+ const allNewsData = ref([]); // 전체 데이터를 누적하여 저장
|
|
|
const newsData = ref([]);
|
|
const newsData = ref([]);
|
|
|
const snsData = ref([]);
|
|
const snsData = ref([]);
|
|
|
const totalCount = ref(0);
|
|
const totalCount = ref(0);
|
|
|
|
|
+ const loadedPages = ref(new Set()); // 이미 로드한 백엔드 페이지 추적
|
|
|
|
|
|
|
|
// API에서 보도자료 데이터 가져오기
|
|
// API에서 보도자료 데이터 가져오기
|
|
|
- const fetchPressList = async (page = 1) => {
|
|
|
|
|
|
|
+ const fetchPressList = async (page = 1, reset = false) => {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 이미 로드한 페이지는 스킵
|
|
|
|
|
+ if (!reset && loadedPages.value.has(page)) {
|
|
|
|
|
+ console.log(`페이지 ${page}는 이미 로드됨`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
|
|
|
|
|
// 공지사항과 동일한 방식으로 호출
|
|
// 공지사항과 동일한 방식으로 호출
|
|
@@ -143,14 +151,15 @@
|
|
|
const currentPageNum = page || 1;
|
|
const currentPageNum = page || 1;
|
|
|
const pageSize = 20; // 백엔드의 페이지 사이즈와 동일
|
|
const pageSize = 20; // 백엔드의 페이지 사이즈와 동일
|
|
|
|
|
|
|
|
- // console.log("보도자료(media) API 응답:", {
|
|
|
|
|
- // totalCount: totalCount.value,
|
|
|
|
|
- // listCount: response.list.length,
|
|
|
|
|
- // currentPage: currentPageNum,
|
|
|
|
|
- // pageSize,
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ console.log("보도자료(media) API 응답:", {
|
|
|
|
|
+ totalCount: totalCount.value,
|
|
|
|
|
+ listCount: response.list.length,
|
|
|
|
|
+ currentPage: currentPageNum,
|
|
|
|
|
+ pageSize,
|
|
|
|
|
+ backendPage: page,
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- newsData.value = response.list.map((item, index) => {
|
|
|
|
|
|
|
+ const newData = response.list.map((item, index) => {
|
|
|
// 번호 = 전체개수 - ((현재페이지-1) * 페이지크기 + 인덱스)
|
|
// 번호 = 전체개수 - ((현재페이지-1) * 페이지크기 + 인덱스)
|
|
|
const displayNumber =
|
|
const displayNumber =
|
|
|
totalCount.value - ((currentPageNum - 1) * pageSize + index);
|
|
totalCount.value - ((currentPageNum - 1) * pageSize + index);
|
|
@@ -165,26 +174,36 @@
|
|
|
link: item.etc1 || "#", // etc1 필드에 외부 링크 저장
|
|
link: item.etc1 || "#", // etc1 필드에 외부 링크 저장
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ if (reset) {
|
|
|
|
|
+ // 리셋 모드: 전체 데이터 초기화
|
|
|
|
|
+ allNewsData.value = newData;
|
|
|
|
|
+ loadedPages.value = new Set([page]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 누적 모드: 새 데이터를 적절한 위치에 삽입
|
|
|
|
|
+ const startIndex = (page - 1) * pageSize;
|
|
|
|
|
+ allNewsData.value.splice(startIndex, pageSize, ...newData);
|
|
|
|
|
+ loadedPages.value.add(page);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // newsData를 allNewsData로 업데이트
|
|
|
|
|
+ newsData.value = [...allNewsData.value];
|
|
|
} else {
|
|
} else {
|
|
|
console.error("JSON 응답 형식이 올바르지 않습니다:", response);
|
|
console.error("JSON 응답 형식이 올바르지 않습니다:", response);
|
|
|
// 에러시 기본 더미 데이터 사용
|
|
// 에러시 기본 더미 데이터 사용
|
|
|
- setDefaultPressData();
|
|
|
|
|
}
|
|
}
|
|
|
} else if (typeof response === "string") {
|
|
} else if (typeof response === "string") {
|
|
|
// HTML 응답인 경우 (백엔드에서 AJAX 감지 실패시)
|
|
// HTML 응답인 경우 (백엔드에서 AJAX 감지 실패시)
|
|
|
console.warn("HTML 응답을 받았습니다. AJAX 감지가 실패했을 수 있습니다.");
|
|
console.warn("HTML 응답을 받았습니다. AJAX 감지가 실패했을 수 있습니다.");
|
|
|
console.log("HTML 내용:", response.substring(0, 200) + "...");
|
|
console.log("HTML 내용:", response.substring(0, 200) + "...");
|
|
|
// 기본 더미 데이터 사용
|
|
// 기본 더미 데이터 사용
|
|
|
- setDefaultPressData();
|
|
|
|
|
} else {
|
|
} else {
|
|
|
console.error("예상하지 못한 응답 형식:", typeof response, response);
|
|
console.error("예상하지 못한 응답 형식:", typeof response, response);
|
|
|
// 기본 더미 데이터 사용
|
|
// 기본 더미 데이터 사용
|
|
|
- setDefaultPressData();
|
|
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error("보도자료 데이터 로드 실패:", error);
|
|
console.error("보도자료 데이터 로드 실패:", error);
|
|
|
// 에러시 기본 더미 데이터 사용
|
|
// 에러시 기본 더미 데이터 사용
|
|
|
- setDefaultPressData();
|
|
|
|
|
} finally {
|
|
} finally {
|
|
|
loading.value = false;
|
|
loading.value = false;
|
|
|
}
|
|
}
|
|
@@ -214,229 +233,15 @@
|
|
|
}));
|
|
}));
|
|
|
} else {
|
|
} else {
|
|
|
console.error("SNS JSON 응답 형식이 올바르지 않습니다:", response);
|
|
console.error("SNS JSON 응답 형식이 올바르지 않습니다:", response);
|
|
|
- setDefaultSnsData();
|
|
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
console.error("SNS 예상하지 못한 응답 형식:", typeof response, response);
|
|
console.error("SNS 예상하지 못한 응답 형식:", typeof response, response);
|
|
|
- setDefaultSnsData();
|
|
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error("SNS 데이터 로드 실패:", error);
|
|
console.error("SNS 데이터 로드 실패:", error);
|
|
|
- setDefaultSnsData();
|
|
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // 기본 SNS 더미 데이터 설정
|
|
|
|
|
- const setDefaultSnsData = () => {
|
|
|
|
|
- snsData.value = [
|
|
|
|
|
- {
|
|
|
|
|
- id: 1,
|
|
|
|
|
- title: "그린웨일글로벌, 녹색인프라 수출펀드 첫 투자기업 선정. 그린웨일글로벌",
|
|
|
|
|
- image: "/img/img--sns1.png",
|
|
|
|
|
- link: "#",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 2,
|
|
|
|
|
- title: "그린웨일글로벌, 녹색인프라 수출펀드 첫 투자기업 선정. 그린웨일글로벌",
|
|
|
|
|
- image: "/img/img--sns2.png",
|
|
|
|
|
- link: "#",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 3,
|
|
|
|
|
- title: "그린웨일글로벌, 녹색인프라 수출펀드 첫 투자기업 선정. 그린웨일글로벌",
|
|
|
|
|
- image: "/img/img--sns3.png",
|
|
|
|
|
- link: "#",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 4,
|
|
|
|
|
- title: "그린웨일글로벌, 녹색인프라 수출펀드 첫 투자기업 선정. 그린웨일글로벌",
|
|
|
|
|
- image: "/img/img--sns4.png",
|
|
|
|
|
- link: "#",
|
|
|
|
|
- },
|
|
|
|
|
- ];
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // 기본 더미 데이터 설정
|
|
|
|
|
- const setDefaultPressData = () => {
|
|
|
|
|
- newsData.value = [
|
|
|
|
|
- {
|
|
|
|
|
- id: 1,
|
|
|
|
|
- title: "그린플라스틱연합, ESG친환경대전서 '자원순환 탄소중립 GPA 컨퍼런스' 개최",
|
|
|
|
|
- date: "2025.07.11",
|
|
|
|
|
- image: "/img/img--news.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 2,
|
|
|
|
|
- title: "친환경 플라스틱 기술 개발 동향",
|
|
|
|
|
- date: "2025.07.10",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 3,
|
|
|
|
|
- title: "탄소중립 실현을 위한 플라스틱 재활용 기술",
|
|
|
|
|
- date: "2025.07.09",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 4,
|
|
|
|
|
- title: "바이오플라스틱 시장 전망과 기술 동향",
|
|
|
|
|
- date: "2025.07.08",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 5,
|
|
|
|
|
- title: "플라스틱 감축을 위한 정부 정책 변화",
|
|
|
|
|
- date: "2025.07.07",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 6,
|
|
|
|
|
- title: "순환경제와 플라스틱 재활용 산업",
|
|
|
|
|
- date: "2025.07.06",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 7,
|
|
|
|
|
- title: "해양 플라스틱 오염 해결을 위한 혁신 기술",
|
|
|
|
|
- date: "2025.07.05",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 8,
|
|
|
|
|
- title: "친환경 포장재 개발 현황",
|
|
|
|
|
- date: "2025.07.04",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 9,
|
|
|
|
|
- title: "플라스틱 대체재 소재 연구 동향",
|
|
|
|
|
- date: "2025.07.03",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 10,
|
|
|
|
|
- title: "ESG 경영과 플라스틱 감축 전략",
|
|
|
|
|
- date: "2025.07.02",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 11,
|
|
|
|
|
- title: "글로벌 플라스틱 규제 동향",
|
|
|
|
|
- date: "2025.07.01",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 12,
|
|
|
|
|
- title: "생분해성 플라스틱 상용화 전망",
|
|
|
|
|
- date: "2025.06.30",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 13,
|
|
|
|
|
- title: "플라스틱 없는 일주일 캠페인",
|
|
|
|
|
- date: "2025.06.29",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 14,
|
|
|
|
|
- title: "재활용 플라스틱 품질 향상 기술",
|
|
|
|
|
- date: "2025.06.28",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 15,
|
|
|
|
|
- title: "플라스틱 순환경제 구축 방안",
|
|
|
|
|
- date: "2025.06.27",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 16,
|
|
|
|
|
- title: "친환경 소재 개발 투자 확대",
|
|
|
|
|
- date: "2025.06.26",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 17,
|
|
|
|
|
- title: "마이크로플라스틱 저감 기술",
|
|
|
|
|
- date: "2025.06.25",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 18,
|
|
|
|
|
- title: "플라스틱 재활용률 제고 방안",
|
|
|
|
|
- date: "2025.06.24",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 19,
|
|
|
|
|
- title: "바이오매스 기반 플라스틱 개발",
|
|
|
|
|
- date: "2025.06.23",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 20,
|
|
|
|
|
- title: "환경친화적 플라스틱 산업 전망",
|
|
|
|
|
- date: "2025.06.22",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 21,
|
|
|
|
|
- title: "플라스틱 폐기물 감축 정책",
|
|
|
|
|
- date: "2025.06.21",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 22,
|
|
|
|
|
- title: "지속가능한 포장재 솔루션",
|
|
|
|
|
- date: "2025.06.20",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 23,
|
|
|
|
|
- title: "플라스틱 리사이클링 혁신 기술",
|
|
|
|
|
- date: "2025.06.19",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 24,
|
|
|
|
|
- title: "친환경 플라스틱 인증 시스템",
|
|
|
|
|
- date: "2025.06.18",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 25,
|
|
|
|
|
- title: "탄소 발자국 감축을 위한 플라스틱 대안",
|
|
|
|
|
- date: "2025.06.17",
|
|
|
|
|
- image: "/img/img--cycle--center.png",
|
|
|
|
|
- link: "/",
|
|
|
|
|
- },
|
|
|
|
|
- ];
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
// 페이지네이션 로직
|
|
// 페이지네이션 로직
|
|
|
const currentPage = ref(1);
|
|
const currentPage = ref(1);
|
|
|
const itemsPerPage = 10; // 프론트엔드에서 10개씩 표시
|
|
const itemsPerPage = 10; // 프론트엔드에서 10개씩 표시
|
|
@@ -452,18 +257,29 @@
|
|
|
// 백엔드에서 필요한 데이터가 있는지 확인하고 필요시 API 호출
|
|
// 백엔드에서 필요한 데이터가 있는지 확인하고 필요시 API 호출
|
|
|
const needToFetchData = (targetPage) => {
|
|
const needToFetchData = (targetPage) => {
|
|
|
const startIndex = (targetPage - 1) * itemsPerPage;
|
|
const startIndex = (targetPage - 1) * itemsPerPage;
|
|
|
- const endIndex = startIndex + itemsPerPage - 1;
|
|
|
|
|
- return endIndex >= newsData.value.length && newsData.value.length < totalCount.value;
|
|
|
|
|
|
|
+ const endIndex = targetPage * itemsPerPage;
|
|
|
|
|
+
|
|
|
|
|
+ // 필요한 데이터의 백엔드 페이지들 계산
|
|
|
|
|
+ const startBackendPage = Math.floor(startIndex / backendPageSize) + 1;
|
|
|
|
|
+ const endBackendPage = Math.ceil(endIndex / backendPageSize);
|
|
|
|
|
+
|
|
|
|
|
+ // 아직 로드되지 않은 페이지가 있는지 확인
|
|
|
|
|
+ for (let i = startBackendPage; i <= endBackendPage; i++) {
|
|
|
|
|
+ if (!loadedPages.value.has(i)) {
|
|
|
|
|
+ return i; // 로드가 필요한 백엔드 페이지 번호 반환
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null; // 모든 필요한 데이터가 이미 로드됨
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const goToPage = async (page) => {
|
|
const goToPage = async (page) => {
|
|
|
if (page >= 1 && page <= totalPages.value) {
|
|
if (page >= 1 && page <= totalPages.value) {
|
|
|
currentPage.value = page;
|
|
currentPage.value = page;
|
|
|
|
|
|
|
|
- if (needToFetchData(page)) {
|
|
|
|
|
- // 백엔드 페이지 계산: 프론트 페이지를 백엔드 페이지로 변환
|
|
|
|
|
- const backendPage = Math.ceil((page * itemsPerPage) / backendPageSize);
|
|
|
|
|
- await fetchPressList(backendPage);
|
|
|
|
|
|
|
+ const backendPageToLoad = needToFetchData(page);
|
|
|
|
|
+ if (backendPageToLoad !== null) {
|
|
|
|
|
+ console.log(`프론트엔드 페이지 ${page}를 위해 백엔드 페이지 ${backendPageToLoad} 로드`);
|
|
|
|
|
+ await fetchPressList(backendPageToLoad);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -482,7 +298,7 @@
|
|
|
|
|
|
|
|
// 컴포넌트 마운트 시 데이터 로드
|
|
// 컴포넌트 마운트 시 데이터 로드
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- fetchPressList(1);
|
|
|
|
|
|
|
+ fetchPressList(1, true); // reset=true로 초기 로드
|
|
|
fetchSnsList();
|
|
fetchSnsList();
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|