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) 반환 * 금요일 기준의 이번 주차 시작일 (YYYY-MM-DD, KST) 반환
* 다음 금요일 (금요일 공휴일로 목요일 선공개되는 경우 대응) * // 직전 금요일
* // 이번 금요일 * /// 이전 금요일
* // 지난 금요일
*/ */
export function currentWeekFriday(now = dayjs().tz(KST)) { export function currentWeekFriday(now = dayjs().tz(KST)) {
const dow = now.day(); // 0=일 ... 4=목 5=금 6=토 const dow = now.day(); // 0=일 ... 5=금 6=토
// 목요일은 내일이 금요일이므로 -1 // 금요일 기준 diff: 금(5)이면 0, 토(6)이면 -1, 일(0)이면 -2, 월(1)이면 -3 ...
const diff = dow === 4 ? -1 : (dow >= 5 ? dow - 5 : dow + 2); const diff = dow >= 5 ? dow - 5 : dow + 2;
return now.startOf('day').subtract(diff, 'day').format('YYYY-MM-DD'); return now.startOf('day').subtract(diff, 'day').format('YYYY-MM-DD');
} }
/** /**
* 썬데이 메이플 표시 가능한 요일대 (~) * ~일요일인지
* 목요일은 금요일 공휴일 케이스 대응용. 해당 주차 row 없으면 어차피 available: false.
*/ */
export function isInSundayWindow(now = dayjs().tz(KST)) { export function isInSundayWindow(now = dayjs().tz(KST)) {
const dow = now.day(); 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() { export function scheduleSundayMapleCron() {
cron.schedule('0 9 * * 4,5', runPolling, { timezone: 'Asia/Seoul' }); cron.schedule('0 9 * * 5', runPolling, { timezone: 'Asia/Seoul' });
console.log('[sunday-maple cron] 매주 목/금 09:00 KST 스케줄 등록'); console.log('[sunday-maple cron] 매주 요일 09:00 KST 스케줄 등록');
} }

View file

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

View file

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