|
@@ -165,7 +165,21 @@ async function dataSearch(type = "") {
|
|
|
noData = true;
|
|
|
}
|
|
|
|
|
|
+ // 取得當前日期並計算三天前的日期
|
|
|
+ const currentDate = new Date();
|
|
|
+ const threeDaysAgo = new Date();
|
|
|
+ threeDaysAgo.setDate(currentDate.getDate() - 3);
|
|
|
+
|
|
|
+
|
|
|
response.data.columns.forEach((item, index) => {
|
|
|
+ // 將 ColumnDate 轉換成日期物件
|
|
|
+ const columnDate = new Date(item.ColumnDate);
|
|
|
+
|
|
|
+ // 判斷 ColumnDate 是否在三天內
|
|
|
+ const isNew = columnDate >= threeDaysAgo && columnDate <= currentDate;
|
|
|
+
|
|
|
+ const newItemClass = isNew ? '' : 'd-none'; // 非三天內則隱藏 New 標籤
|
|
|
+
|
|
|
let tagList = item.ColumnTag.split(',');
|
|
|
let tagsHtml = '';
|
|
|
|
|
@@ -184,6 +198,7 @@ async function dataSearch(type = "") {
|
|
|
<h5 class="text-dark title">${item.ColumnTitle}</h5>
|
|
|
<div class="tags-container columns-tag mt-3 me-auto">${tagsHtml}</div>
|
|
|
</div>
|
|
|
+ <span class="new-item ${newItemClass}">NEW</span>
|
|
|
</div>
|
|
|
</a>
|
|
|
</div>`;
|