메인 달력 날씨 업데이트

This commit is contained in:
nevermoregb 2025-04-08 00:54:59 +09:00
parent 1c483ef727
commit c43614c743

View File

@ -61,7 +61,7 @@
</template>
<script setup>
import { inject, onMounted, reactive, ref, watch } from 'vue';
import { inject, onMounted, reactive, ref, watch, nextTick } from 'vue';
import { fetchHolidays } from '@c/calendar/holiday';
import { useUserInfoStore } from '@/stores/useUserInfoStore';
import { useProjectStore } from '@/stores/useProjectStore';
@ -344,7 +344,7 @@
useFilterEventList(month, day);
};
//
//
const colorToday = e => {
if (todayEL != null && !todayEL.classList.contains('fc-day-today')) todayEL.classList.add('fc-day-today');
};
@ -506,6 +506,8 @@
selectAllow: selectInfo => isSelectableDate(selectInfo.start),
dateClick: handleDateClick,
dayCellDidMount: arg => {
//
addWeatherInfo(arg);
const dateCell = arg.el;
//
@ -536,6 +538,40 @@
},
});
//
const addWeatherInfo = arg => {
const dateStr = $common.dateFormatter(arg.date, 'YMD');
//
const theDayWeatherInfo = dailyWeatherList.value.find(weather => weather.date === dateStr);
if (theDayWeatherInfo) {
//
const weatherIconUrl = `https://openweathermap.org/img/wn/${theDayWeatherInfo.icon}.png`;
const weatherEl = document.createElement('img');
weatherEl.src = weatherIconUrl;
weatherEl.alt = theDayWeatherInfo.description;
weatherEl.className = 'weather-icon';
weatherEl.style.width = '28px';
weatherEl.style.height = '28px';
//
const dayTopEl = arg.el.querySelector('.fc-daygrid-day-top');
dayTopEl.classList.add('align-items-center');
dayTopEl.prepend(weatherEl); //
}
};
//
watch(dailyWeatherList, async () => {
await nextTick(); // DOM
document.querySelectorAll('.fc-daygrid-day').forEach(dayCell => {
addWeatherInfo({
el: dayCell,
date: dayCell.dataset.date,
});
});
});
const handleWheelEvent = e => {
handleCloseModal();
};
@ -570,12 +606,6 @@
param.append('month', month);
param.append('day', day);
// if (!weatherStore.dailyWeatherList?.length) {
// await weatherStore.getWeatherInfo();
// //dailyWeatherList.value = weatherStore.dailyWeatherList;
// console.log('dailyWeatherList.value: ', dailyWeatherList.value);
// }
//
await fetchCategoryList();
await fetchEventList(param);