- 카드: 군산각 카드를 옮겨 그림, 토끼 로딩, 실패하면 '날씨각에서 날씨 보기' 링크, 8초 제한, nginx 대체 화면, '자세히 보기' 버튼만 링크 - 크기: 폭은 자리에 맞춰 자동, 높이는 폭에 따라 비율대로(기본형 245~320px, 상세형 400~520px) - 부하: 지역별 카드 데이터 5분 저장, 저장분이 비면 지역마다 한 요청만 새로 만듦, 노출 수는 Redis 에 쌓았다가 관리자 조회 때 DB(widget_view_daily)로 옮김 - 사용 방법 페이지: 지역(앱 지역은 바꾸지 않음)·모양·배경 고르기, 미리보기, 코드 복사. 들어오는 길은 문의 창 버튼(토스에서는 숨김)과 검색 - GA: 위젯_안내_보기, 위젯_옵션_고름, 위젯_코드_복사 - 문서: docs/위젯_운영.md, 백엔드 테스트 실행법(CLAUDE.md)
48 lines
2.2 KiB
TypeScript
48 lines
2.2 KiB
TypeScript
import type { RegionData } from '@nalssigak/shared/api/client/types.gen'
|
|
import type { MyGak } from './myGakState'
|
|
import type { WeatherWhyPayload } from './weatherWhy'
|
|
import { createContext, use } from 'react'
|
|
/** square: 1:1 비율일 때 slides 대신 찍을 틀 (없으면 slides). url: 같이 보낼 링크 (없으면 사이트 주소) */
|
|
export type SharePayload = { title: string; slides: HTMLElement[]; square?: HTMLElement[]; url?: string }
|
|
|
|
/** 지역 창 '고르기만' 모드: current 는 '지금 보는 곳'으로 표시할 지역 코드 */
|
|
export type RegionPick = { current: string; onPick: (r: RegionData) => void }
|
|
|
|
/** 댓글이 달린 곳: 운영 포스트 또는 사람 글 */
|
|
export type CommentTarget = { postId: number } | { talkId: number }
|
|
type CommentsState = { type: 'comments'; draft?: string } & CommentTarget
|
|
|
|
export type SheetState =
|
|
| { type: 'gak'; indexId: number }
|
|
| { type: 'article'; articleId: number }
|
|
| { type: 'share'; share: SharePayload }
|
|
| CommentsState
|
|
| { type: 'seasonWeek' }
|
|
| { type: 'login'; then?: CommentsState; why?: 'level' }
|
|
| { type: 'me' }
|
|
/** pick: 앱 지역은 그대로 두고 고른 지역만 돌려받는 '고르기만' 모드 (위젯 페이지 미리보기). 창 상태는 방문 기록에 저장하지 않아 함수를 넣어도 된다 */
|
|
| { type: 'region'; pick?: RegionPick }
|
|
| { type: 'mix'; shared?: MyGak }
|
|
| { type: 'myGak'; gak: MyGak; shot?: HTMLElement | null }
|
|
| { type: 'install' }
|
|
| { type: 'weatherWhy'; why: WeatherWhyPayload }
|
|
| { type: 'tarot' }
|
|
| { type: 'level' }
|
|
| { type: 'levelUp'; level: number }
|
|
| { type: 'gameHelp' }
|
|
| { type: 'contact' }
|
|
| null
|
|
|
|
/** 창이 열리며 쌓아 둔 방문 기록이 지금 맨 위인지. 창 안에서 주소를 옮기면 그 기록이 맨 위가 아니게 된다 */
|
|
export const sheetEntryOnTop = () => (window.history.state as { sheet?: boolean } | null)?.sheet === true
|
|
|
|
export type SheetApi = { open: (s: Exclude<SheetState, null>) => void; close: () => void }
|
|
|
|
export const SheetContext = createContext<SheetApi | null>(null)
|
|
|
|
export function useSheet() {
|
|
const ctx = use(SheetContext)
|
|
if (!ctx) throw new Error('useSheet must be used inside SheetProvider')
|
|
return ctx
|
|
}
|