Compare commits

..

No commits in common. "718404918686ee91f3789081c9df88da2dde61c0" and "2d52a1668f5f9b54d339b0b25598832f999330bb" have entirely different histories.

4 changed files with 28 additions and 54 deletions

View file

@ -25,24 +25,22 @@ export function detectVariant(title) {
/**
* 금요일 기준의 이번 주차 시작일 (YYYY-MM-DD, KST) 반환
* 다음 금요일 (금요일 공휴일로 목요일 선공개되는 경우 대응)
* // 이번 금요일
* // 지난 금요일
* // 직전 금요일
* /// 이전 금요일
*/
export function currentWeekFriday(now = dayjs().tz(KST)) {
const dow = now.day(); // 0=일 ... 4=목 5=금 6=토
// 목요일은 내일이 금요일이므로 -1
const diff = dow === 4 ? -1 : (dow >= 5 ? dow - 5 : dow + 2);
const dow = now.day(); // 0=일 ... 5=금 6=토
// 금요일 기준 diff: 금(5)이면 0, 토(6)이면 -1, 일(0)이면 -2, 월(1)이면 -3 ...
const diff = dow >= 5 ? dow - 5 : dow + 2;
return now.startOf('day').subtract(diff, 'day').format('YYYY-MM-DD');
}
/**
* 썬데이 메이플 표시 가능한 요일대 (~)
* 목요일은 금요일 공휴일 케이스 대응용. 해당 주차 row 없으면 어차피 available: false.
* ~일요일인지
*/
export function isInSundayWindow(now = dayjs().tz(KST)) {
const dow = now.day();
return dow === 4 || dow === 5 || dow === 6 || dow === 0;
return dow === 5 || dow === 6 || dow === 0;
}
/**

View file

@ -27,9 +27,9 @@ async function runPolling() {
}
/**
* 매주 /09:00 KST 실행 (금요일이 공휴일이면 목요일에 게시되는 경우 대응)
* 매주 요일 09:00 KST 실행
*/
export function scheduleSundayMapleCron() {
cron.schedule('0 9 * * 4,5', runPolling, { timezone: 'Asia/Seoul' });
console.log('[sunday-maple cron] 매주 목/금 09:00 KST 스케줄 등록');
cron.schedule('0 9 * * 5', runPolling, { timezone: 'Asia/Seoul' });
console.log('[sunday-maple cron] 매주 요일 09:00 KST 스케줄 등록');
}

View file

@ -17,62 +17,42 @@ const DELAY_DEFAULT = 200
*/
export default function GlobalTooltip() {
const [state, setState] = useState({ open: false, text: '', placement: 'top', coords: null })
const triggerRef = useRef(null) //
const pendingRef = useRef(null) // delay title ( )
const triggerRef = useRef(null)
const tooltipRef = useRef(null)
const timerRef = useRef(null)
const titleMap = useRef(new WeakMap())
useEffect(() => {
function stripTitle(el) {
const t = el.getAttribute('title')
if (t && !titleMap.current.has(el)) {
titleMap.current.set(el, t)
el.removeAttribute('title')
}
}
function restoreTitle(el) {
function restoreTitle() {
const el = triggerRef.current
if (el && titleMap.current.has(el)) {
el.setAttribute('title', titleMap.current.get(el))
const prev = titleMap.current.get(el)
el.setAttribute('title', prev)
titleMap.current.delete(el)
}
}
function hide() {
clearTimeout(timerRef.current)
restoreTitle(pendingRef.current)
restoreTitle(triggerRef.current)
pendingRef.current = null
restoreTitle()
triggerRef.current = null
setState((s) => (s.open ? { ...s, open: false } : s))
}
function showFor(target) {
//
if (triggerRef.current === target || pendingRef.current === target) return
// pending
if (pendingRef.current) {
clearTimeout(timerRef.current)
restoreTitle(pendingRef.current)
pendingRef.current = null
}
const nativeTitle = target.getAttribute('title')
const dataTooltip = target.getAttribute('data-tooltip')
const text = nativeTitle || dataTooltip
if (!text) return
if (nativeTitle) stripTitle(target)
pendingRef.current = target
if (nativeTitle && !titleMap.current.has(target)) {
titleMap.current.set(target, nativeTitle)
target.removeAttribute('title')
}
const placement = target.getAttribute('data-tooltip-placement') || 'top'
const delay = Number(target.getAttribute('data-tooltip-delay')) || DELAY_DEFAULT
clearTimeout(timerRef.current)
timerRef.current = setTimeout(() => {
triggerRef.current = target
pendingRef.current = null
setState({ open: true, text, placement, coords: null })
}, delay)
}
@ -80,22 +60,19 @@ export default function GlobalTooltip() {
function handleOver(e) {
const target = e.target.closest?.('[title], [data-tooltip]')
if (!target) return
if (triggerRef.current === target || pendingRef.current === target) return
// trigger
if (triggerRef.current === target) return
//
if (triggerRef.current && triggerRef.current !== target) {
restoreTitle(triggerRef.current)
restoreTitle()
triggerRef.current = null
setState((s) => (s.open ? { ...s, open: false } : s))
}
showFor(target)
}
function handleOut(e) {
const active = triggerRef.current || pendingRef.current
if (!active) return
if (!triggerRef.current) return
const rt = e.relatedTarget
if (rt && active.contains(rt)) return
if (rt && triggerRef.current.contains(rt)) return
hide()
}
@ -121,8 +98,7 @@ export default function GlobalTooltip() {
window.removeEventListener('scroll', hide, true)
window.removeEventListener('resize', hide)
clearTimeout(timerRef.current)
restoreTitle(pendingRef.current)
restoreTitle(triggerRef.current)
restoreTitle()
}
}, [])

View file

@ -1,6 +1,6 @@
export const SECTIONS = {
notice: { label: '공지사항', dataKey: 'notice', pageSize: 5, kind: 'text' },
update: { label: '업데이트', dataKey: 'update_notice', pageSize: 5, kind: 'text' },
notice: { label: '메이플스토리 공지사항', dataKey: 'notice', pageSize: 5, kind: 'text' },
update: { label: '메이플스토리 업데이트', dataKey: 'update_notice', pageSize: 5, kind: 'text' },
event: {
label: '진행 중인 이벤트',
dataKey: 'event_notice',