Compare commits

...
7 Commits
17 changed files with 383 additions and 89 deletions

No files matched your search

+8
View File
@@ -156,6 +156,13 @@ class HeroStat(WebPacketProtocol):
tone: Literal["normal", "warn", "rain"] = Field(description="normal=기본, warn=조심(노랑), rain=비(파랑)") tone: Literal["normal", "warn", "rain"] = Field(description="normal=기본, warn=조심(노랑), rain=비(파랑)")
class WeatherWhy(WebPacketProtocol):
label: str
weight: int = Field(description="비중 % (합 100)")
score: int = Field(description="이 조건 점수 0~100")
note: str = Field(description="지금 값 (예: 체감 19°, 편한 범위 18~24° 안)")
class Hero(WebPacketProtocol): class Hero(WebPacketProtocol):
now_at: datetime now_at: datetime
sky_mode: Literal["morning", "day", "sunset", "night"] sky_mode: Literal["morning", "day", "sunset", "night"]
@@ -168,6 +175,7 @@ class Hero(WebPacketProtocol):
will_rain_2h: Optional[bool] = None will_rain_2h: Optional[bool] = None
weather_score: Optional[int] = None weather_score: Optional[int] = None
weather_slots: dict[str, int] = Field(default_factory=dict, description="오늘 구간별 날씨 점수 {morning·day·evening·night: 점수}") weather_slots: dict[str, int] = Field(default_factory=dict, description="오늘 구간별 날씨 점수 {morning·day·evening·night: 점수}")
weather_why: dict[str, list[WeatherWhy]] = Field(default_factory=dict, description="구간별 날씨 점수 근거(조건·비중·조건 점수·지금 값). 키는 weather_slots 와 같다")
top1: Optional[TopIndex] = None top1: Optional[TopIndex] = None
bubble: Optional[str] = None bubble: Optional[str] = None
moon_name: Optional[str] = Field(default=None, description="오늘 밤 달 모양: 삭·초승달·상현달·차오르는 달·보름달·기우는 달·하현달·그믐달") moon_name: Optional[str] = Field(default=None, description="오늘 밤 달 모양: 삭·초승달·상현달·차오르는 달·보름달·기우는 달·하현달·그믐달")
+2 -1
View File
@@ -22,7 +22,7 @@ from crud.season_crud import SeasonCRUD
from crud.weather_crud import WeatherCRUD from crud.weather_crud import WeatherCRUD
from router.v1.feed.protocol import ( from router.v1.feed.protocol import (
BandArticle, BandEvent, Bands, Cut, GakSlide, Hero, HeroStat, HourCell, HoursSlide, PostData, Res_Feed, Row, RowsSlide, SunsetSlide, BandArticle, BandEvent, Bands, Cut, GakSlide, Hero, HeroStat, HourCell, HoursSlide, PostData, Res_Feed, Row, RowsSlide, SunsetSlide,
PlanSlide, PlanStep, TopIndex, WeekDay, WeekGak, WeekSlide, PlanSlide, PlanStep, TopIndex, WeatherWhy, WeekDay, WeekGak, WeekSlide,
) )
from services.air_service import GRADE_LABEL as AIR_GRADE_LABEL from services.air_service import GRADE_LABEL as AIR_GRADE_LABEL
from services.air_service import pm10_grade, pm25_grade from services.air_service import pm10_grade, pm25_grade
@@ -443,6 +443,7 @@ class FeedService:
discomfort=cur.discomfort_index if cur else None, discomfort_label=discomfort_label(cur.discomfort_index) if cur else None, discomfort=cur.discomfort_index if cur else None, discomfort_label=discomfort_label(cur.discomfort_index) if cur else None,
rain_2h_text=now_w.rain_2h_text if now_w else None, will_rain_2h=now_w.will_rain_2h if now_w else None, rain_2h_text=now_w.rain_2h_text if now_w else None, will_rain_2h=now_w.will_rain_2h if now_w else None,
weather_score=board.weather_score if board else None, weather_slots=board.weather_slots if board else {}, weather_score=board.weather_score if board else None, weather_slots=board.weather_slots if board else {},
weather_why={k: [WeatherWhy(label=w.label, weight=w.weight, score=w.score, note=w.note) for w in ws] for k, ws in board.weather_why.items()} if board else {},
top1=_top(top) if top else None, bubble=bubble, top1=_top(top) if top else None, bubble=bubble,
moon_name=moon[0].name if moon else None, moon_pct=round(moon[0].lit * 100) if moon else None, moon_name=moon[0].name if moon else None, moon_pct=round(moon[0].lit * 100) if moon else None,
stats=[HeroStat(icon=x.icon, label=x.label, value=x.value, tone=x.tone) for x in hero_stats(x_in)], stats=[HeroStat(icon=x.icon, label=x.label, value=x.value, tone=x.tone) for x in hero_stats(x_in)],
+27 -4
View File
@@ -40,6 +40,26 @@ WEATHER_SCORE_DEF = SimpleNamespace(
}, },
zero_rules=[], windows=[{"from": NIGHT_END_HOUR, "to": 24 + NIGHT_END_HOUR}], zero_rules=[], windows=[{"from": NIGHT_END_HOUR, "to": 24 + NIGHT_END_HOUR}],
) )
WEATHER_AXIS_NAME = {"temp": "기온", "rain": "비", "wind": "바람", "humidity": "습도", "air": "미세먼지", "sun": "햇볕"}
def strict_weather(raw: int) -> int:
"""날씨 점수는 높을수록 깐깐하게: 90점까지는 8/9, 그 위는 두 배로 깎아 100점은 모든 조건이 완벽할 때만 (96 → 92)."""
return round(raw * 8 / 9) if raw <= 90 else round(80 + (raw - 90) * 2)
@dataclass
class WeatherWhy:
label: str
weight: int
score: int
note: str
def weather_why(r: Result) -> list[WeatherWhy]:
"""날씨 점수를 이룬 조건들. 비중 큰 것부터."""
axes = sorted((a for a in WEATHER_AXIS_NAME if getattr(WEATHER_SCORE_DEF, f"weight_{a}")), key=lambda a: -getattr(WEATHER_SCORE_DEF, f"weight_{a}"))
return [WeatherWhy(label=WEATHER_AXIS_NAME[a], weight=getattr(WEATHER_SCORE_DEF, f"weight_{a}"), score=r.factors[a], note=r.notes.get(a, "")) for a in axes]
SEASONS = ("겨울", "봄", "여름", "가을") SEASONS = ("겨울", "봄", "여름", "가을")
@@ -83,6 +103,7 @@ class IndexBoard:
weather_score: Optional[int] weather_score: Optional[int]
items: list[IndexItem] items: list[IndexItem]
weather_slots: dict[str, int] = field(default_factory=dict) weather_slots: dict[str, int] = field(default_factory=dict)
weather_why: dict[str, list[WeatherWhy]] = field(default_factory=dict)
@property @property
def ranked(self) -> list[IndexItem]: def ranked(self) -> list[IndexItem]:
@@ -187,7 +208,7 @@ def shown_slot(key: str) -> str:
return "night" if key == EARLY else key return "night" if key == EARLY else key
def _shown_parts(parts: dict[str, int], cur: str) -> dict[str, int]: def _shown_parts(parts: dict, cur: str) -> dict:
"""구간 점수를 아침·낮·저녁·밤 순으로. 0~5시면 밤은 전날 밤 구간을 쓴다.""" """구간 점수를 아침·낮·저녁·밤 순으로. 0~5시면 밤은 전날 밤 구간을 쓴다."""
shown = {shown_slot(k): v for k, v in parts.items() if k != ("night" if cur == EARLY else EARLY)} shown = {shown_slot(k): v for k, v in parts.items() if k != ("night" if cur == EARLY else EARLY)}
return {k: shown[k] for k in SLOTS if k in shown} return {k: shown[k] for k in SLOTS if k in shown}
@@ -362,7 +383,9 @@ class IndexService:
trend=[by_key[(d.index_id, day)] for day in slots if (d.index_id, day) in by_key], active=False, in_season=False, trend=[by_key[(d.index_id, day)] for day in slots if (d.index_id, day) in by_key], active=False, in_season=False,
)) ))
return ErrorType.SUCCESS, IndexBoard( return ErrorType.SUCCESS, IndexBoard(
region=region, day=today, weather_score=weather_parts.get(cur), items=items, weather_slots=_shown_parts(weather_parts, cur), region=region, day=today, weather_score=weather_parts[cur].score if cur in weather_parts else None, items=items,
weather_slots=_shown_parts({k: r.score for k, r in weather_parts.items()}, cur),
weather_why=_shown_parts({k: weather_why(r) for k, r in weather_parts.items()}, cur),
) )
async def custom(self, region_code: str, defns: list) -> tuple[ErrorType, Optional[tuple[str, list[dict[str, Result]]]]]: async def custom(self, region_code: str, defns: list) -> tuple[ErrorType, Optional[tuple[str, list[dict[str, Result]]]]]:
@@ -395,7 +418,7 @@ class IndexService:
out.append({shown_slot(k): r for k, r in parts.items() if k != ("night" if cur == EARLY else EARLY)}) out.append({shown_slot(k): r for k, r in parts.items() if k != ("night" if cur == EARLY else EARLY)})
return ErrorType.SUCCESS, (shown_slot(cur), out) return ErrorType.SUCCESS, (shown_slot(cur), out)
async def ensure(self, region: Region, now: datetime) -> tuple[ErrorType, Optional[dict[str, int]]]: async def ensure(self, region: Region, now: datetime) -> tuple[ErrorType, Optional[dict[str, Result]]]:
"""재료(예보·미세먼지)가 지수 계산 뒤에 바뀌었으면 오늘~모레와 이번 주말을 다시 계산한다. 오늘 구간별 날씨 점수도 같이 낸다.""" """재료(예보·미세먼지)가 지수 계산 뒤에 바뀌었으면 오늘~모레와 이번 주말을 다시 계산한다. 오늘 구간별 날씨 점수도 같이 낸다."""
_, _, _, warnings, ultra = await asyncio.gather( _, _, _, warnings, ultra = await asyncio.gather(
self.weather_service.ensure_vilage(region, now), self.weather_service.ensure_mid(region, now), self.air_service.ensure(now), self.weather_service.ensure_vilage(region, now), self.weather_service.ensure_mid(region, now), self.air_service.ensure(now),
@@ -426,7 +449,7 @@ class IndexService:
) )
today_ctx = Context(day=today, is_holiday=False, moon=0, sunset_score=None, lookahead_rain_prob=0, rain_hours=rain_hours(by_at, today), **base_ctx) today_ctx = Context(day=today, is_holiday=False, moon=0, sunset_score=None, lookahead_rain_prob=0, rain_hours=rain_hours(by_at, today), **base_ctx)
sunset_at = sun_times(today, float(region.lat), float(region.lon)).sunset_at sunset_at = sun_times(today, float(region.lat), float(region.lon)).sunset_at
weather_parts = {k: r.score for k, r in slot_results(WEATHER_SCORE_DEF, today, region, by_at, by_om, today_ctx, sunset_at, now).items()} weather_parts = {k: replace(r, score=strict_weather(r.score)) for k, r in slot_results(WEATHER_SCORE_DEF, today, region, by_at, by_om, today_ctx, sunset_at, now).items()}
issued = max([r.issued_at for r in rows] + [d.issued_at for d in daily_rows or []]) issued = max([r.issued_at for r in rows] + [d.issued_at for d in daily_rows or []])
inputs_at = max(issued, air.measured_at) if air else issued inputs_at = max(issued, air.measured_at) if air else issued
+7 -4
View File
@@ -14,9 +14,12 @@ from common.utils.kma_time import kst_midnight, now_kst
from crud.region_crud import RegionCRUD from crud.region_crud import RegionCRUD
from crud.weather_crud import WeatherCRUD from crud.weather_crud import WeatherCRUD
from router.router import app from router.router import app
from services.calc.index_calc import rank_score from services.calc.index_calc import AXES, Result, rank_score
from services.index_service import IndexService, _nearest_slot_end_hour, _slot_end_hour, season_of, slot_days, slot_label, windows_for from services.index_service import IndexService, _nearest_slot_end_hour, _slot_end_hour, season_of, slot_days, slot_label, windows_for
_RESULT_50 = Result(score=50, factors={a: 50 for a in AXES}, notes={}, zero_reason=None, summary="")
_WEATHER_50 = {k: _RESULT_50 for k in ("morning", "day", "evening", "night", "early")}
REGION = "1141000000" REGION = "1141000000"
@@ -142,7 +145,7 @@ async def test_board_puts_out_of_season_gak_last_without_rank_or_badge(monkeypat
scores = [SimpleNamespace(index_id=x, score_date=today, score=v, slots={}) for x, v in ((1, 50), (2, 60), (3, 99))] scores = [SimpleNamespace(index_id=x, score_date=today, score=v, slots={}) for x, v in ((1, 50), (2, 60), (3, 99))]
crud = SimpleNamespace(definitions=lambda s: _async(defs), scores=lambda s, *a: _async(scores)) crud = SimpleNamespace(definitions=lambda s: _async(defs), scores=lambda s, *a: _async(scores))
service = IndexService(RegionCRUD(), crud, None, None, None, None, None, None) service = IndexService(RegionCRUD(), crud, None, None, None, None, None, None)
monkeypatch.setattr(service, "ensure", lambda *a: _async((ErrorType.SUCCESS, {"morning": 50, "day": 50, "evening": 50, "night": 50, "early": 50}))) monkeypatch.setattr(service, "ensure", lambda *a: _async((ErrorType.SUCCESS, _WEATHER_50)))
_, board = await service.board(REGION) _, board = await service.board(REGION)
view = [(i.definition.code, i.active, i.in_season, i.season) for i in board.items] view = [(i.definition.code, i.active, i.in_season, i.season) for i in board.items]
# 점수가 가장 높아도 제철이 아니면 순위 밖 맨 끝. 계절 표시는 제철 달이 정해진 각에만 # 점수가 가장 높아도 제철이 아니면 순위 밖 맨 끝. 계절 표시는 제철 달이 정해진 각에만
@@ -162,7 +165,7 @@ async def test_board_ranks_by_score_times_priority_weight(monkeypatch):
scores = [SimpleNamespace(index_id=x, score_date=today, score=v, slots={}) for x, v in ((1, 90), (2, 80), (3, 70))] scores = [SimpleNamespace(index_id=x, score_date=today, score=v, slots={}) for x, v in ((1, 90), (2, 80), (3, 70))]
crud = SimpleNamespace(definitions=lambda s: _async(defs), scores=lambda s, *a: _async(scores)) crud = SimpleNamespace(definitions=lambda s: _async(defs), scores=lambda s, *a: _async(scores))
service = IndexService(RegionCRUD(), crud, None, None, None, None, None, None) service = IndexService(RegionCRUD(), crud, None, None, None, None, None, None)
monkeypatch.setattr(service, "ensure", lambda *a: _async((ErrorType.SUCCESS, {"morning": 50, "day": 50, "evening": 50, "night": 50, "early": 50}))) monkeypatch.setattr(service, "ensure", lambda *a: _async((ErrorType.SUCCESS, _WEATHER_50)))
err, board = await service.board(REGION) err, board = await service.board(REGION)
assert err is ErrorType.SUCCESS assert err is ErrorType.SUCCESS
# 하 90점(63) < 중 80점(68) < 상 70점(70). 보이는 점수는 그대로 # 하 90점(63) < 중 80점(68) < 상 70점(70). 보이는 점수는 그대로
@@ -179,7 +182,7 @@ async def test_board_ranks_each_slot_with_priority_weight(monkeypatch):
scores = [SimpleNamespace(index_id=x, score_date=today, score=80, slots=slots[x]) for x in (1, 2)] scores = [SimpleNamespace(index_id=x, score_date=today, score=80, slots=slots[x]) for x in (1, 2)]
crud = SimpleNamespace(definitions=lambda s: _async(defs), scores=lambda s, *a: _async(scores)) crud = SimpleNamespace(definitions=lambda s: _async(defs), scores=lambda s, *a: _async(scores))
service = IndexService(RegionCRUD(), crud, None, None, None, None, None, None) service = IndexService(RegionCRUD(), crud, None, None, None, None, None, None)
monkeypatch.setattr(service, "ensure", lambda *a: _async((ErrorType.SUCCESS, {k: 50 for k in every}))) monkeypatch.setattr(service, "ensure", lambda *a: _async((ErrorType.SUCCESS, {k: _RESULT_50 for k in every})))
monkeypatch.setattr("services.index_service._with_slot", lambda row, data: SimpleNamespace(score=data["score"])) monkeypatch.setattr("services.index_service._with_slot", lambda row, data: SimpleNamespace(score=data["score"]))
_, board = await service.board(REGION) _, board = await service.board(REGION)
ranks = {i.definition.code: i.slot_ranks for i in board.items} ranks = {i.definition.code: i.slot_ranks for i in board.items}
+23
View File
@@ -340,3 +340,26 @@ def test_umbrella_lost_needs_rain_that_stopped():
assert evaluate(defn, [[_h(13), _h(14)]], after_rain).score >= 80 assert evaluate(defn, [[_h(13), _h(14)]], after_rain).score >= 80
assert evaluate(defn, [[_h(13), _h(14)]], CTX).zero_reason == "앞서 내린 비가 없어 0점" assert evaluate(defn, [[_h(13), _h(14)]], CTX).zero_reason == "앞서 내린 비가 없어 0점"
assert evaluate(defn, [[_h(10, rain=RainType.RAIN)]], replace(CTX, rain_hours=frozenset({9, 10}))).score == 0 assert evaluate(defn, [[_h(10, rain=RainType.RAIN)]], replace(CTX, rain_hours=frozenset({9, 10}))).score == 0
def test_weather_score_is_strict_near_top():
"""좋은 날(96)도 92 수준, 100점은 모든 조건이 완벽할 때만. 낮은 점수도 조금씩 내려간다."""
from services.index_service import strict_weather
assert strict_weather(100) == 100
assert strict_weather(96) == 92
assert strict_weather(99) < 100
assert strict_weather(75) < 75
scores = [strict_weather(s) for s in range(101)]
assert scores == sorted(scores)
def test_weather_why_lists_every_condition_heaviest_first():
from services.index_service import WEATHER_SCORE_DEF, weather_why
ctx = Context(day=date(2026, 10, 2), is_holiday=False, pm25=12, air_label="좋음", moon=0, sunset_score=None, wind_warning=False, lookahead_rain_prob=0)
r = evaluate(WEATHER_SCORE_DEF, [[_h(h, feels=19.0, prob=0, wind=2.0, hum=55, sunshine_ratio=0.9) for h in range(9, 22)]], ctx)
why = weather_why(r)
assert [w.label for w in why] == ["기온", "비", "햇볕", "바람", "습도", "미세먼지"]
assert sum(w.weight for w in why) == 100
assert why[0].note.startswith("체감 19°")
Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 25 KiB

@@ -3,8 +3,8 @@
import { type DefaultError, type InfiniteData, infiniteQueryOptions, queryOptions, type UseMutationOptions } from '@tanstack/react-query'; import { type DefaultError, type InfiniteData, infiniteQueryOptions, queryOptions, type UseMutationOptions } from '@tanstack/react-query';
import { client } from '../client.gen'; import { client } from '../client.gen';
import { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from '../sdk.gen'; import { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listPresets, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from '../sdk.gen';
import type { AddCommentData, AddCommentError, AddCommentResponse, AddMyGakData, AddMyGakError, AddMyGakResponse, AddTalkData, AddTalkError, AddTalkResponse, AuthConfigData, AuthConfigResponse, BlockTalkAuthorData, BlockTalkAuthorError, BlockTalkAuthorResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, DeleteMyGakData, DeleteMyGakError, DeleteMyGakResponse, DeleteTalkData, DeleteTalkError, DeleteTalkResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetImageData, GetImageError, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetTalkImageData, GetTalkImageError, GetTodayGuPageData, GetTodayGuPageError, GetTodayGuPageResponse, GetTodayPageData, GetTodayPageError, GetTodayPageResponse, GetWatchSummaryData, GetWatchSummaryError, GetWatchSummaryResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekRankingData, GetWeekRankingResponse, GetWeekResponse, GoogleLoginData, GoogleLoginError, GoogleLoginResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, LikeTalkData, LikeTalkError, LikeTalkResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListMyGakData, ListMyGakError, ListMyGakResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, ListTalksData, ListTalksError, ListTalksResponse, LoginData, LoginError, LoginResponse, LogoutData, LogoutError, LogoutResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, ReportTalkData, ReportTalkError, ReportTalkResponse, SavePostData, SavePostError, SavePostResponse, ScoreMyGakData, ScoreMyGakError, ScoreMyGakResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnlikeTalkData, UnlikeTalkError, UnlikeTalkResponse, UnsavePostData, UnsavePostError, UnsavePostResponse, UpdateMeData, UpdateMeError, UpdateMeResponse, UploadTalkImageData, UploadTalkImageError, UploadTalkImageResponse } from '../types.gen'; import type { AddCommentData, AddCommentError, AddCommentResponse, AddMyGakData, AddMyGakError, AddMyGakResponse, AddTalkData, AddTalkError, AddTalkResponse, AuthConfigData, AuthConfigResponse, BlockTalkAuthorData, BlockTalkAuthorError, BlockTalkAuthorResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, DeleteMyGakData, DeleteMyGakError, DeleteMyGakResponse, DeleteTalkData, DeleteTalkError, DeleteTalkResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetImageData, GetImageError, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetTalkImageData, GetTalkImageError, GetTodayGuPageData, GetTodayGuPageError, GetTodayGuPageResponse, GetTodayPageData, GetTodayPageError, GetTodayPageResponse, GetWatchSummaryData, GetWatchSummaryError, GetWatchSummaryResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekRankingData, GetWeekRankingResponse, GetWeekResponse, GoogleLoginData, GoogleLoginError, GoogleLoginResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, LikeTalkData, LikeTalkError, LikeTalkResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListMyGakData, ListMyGakError, ListMyGakResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListPresetsData, ListPresetsResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, ListTalksData, ListTalksError, ListTalksResponse, LoginData, LoginError, LoginResponse, LogoutData, LogoutError, LogoutResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, ReportTalkData, ReportTalkError, ReportTalkResponse, SavePostData, SavePostError, SavePostResponse, ScoreMyGakData, ScoreMyGakError, ScoreMyGakResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnlikeTalkData, UnlikeTalkError, UnlikeTalkResponse, UnsavePostData, UnsavePostError, UnsavePostResponse, UpdateMeData, UpdateMeError, UpdateMeResponse, UploadTalkImageData, UploadTalkImageError, UploadTalkImageResponse } from '../types.gen';
export type QueryKey<TOptions extends Options> = [ export type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
@@ -779,6 +779,24 @@ export const addMyGakMutation = (options?: Partial<Options<AddMyGakData>>): UseM
return mutationOptions; return mutationOptions;
}; };
export const listPresetsQueryKey = (options?: Options<ListPresetsData>) => createQueryKey('listPresets', options);
/**
* 공식 각을 내 각 조건으로 옮긴 목록 (내 각 만들기에서 골라 채우기)
*/
export const listPresetsOptions = (options?: Options<ListPresetsData>) => queryOptions<ListPresetsResponse, DefaultError, ListPresetsResponse, ReturnType<typeof listPresetsQueryKey>>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await listPresets({
...options,
...queryKey[0],
signal,
throwOnError: true
});
return data;
},
queryKey: listPresetsQueryKey(options)
});
/** /**
* 조건들의 그 동네 오늘 점수 (로그인 없이, 받은 링크의 각도) * 조건들의 그 동네 오늘 점수 (로그인 없이, 받은 링크의 각도)
*/ */
+2 -2
View File
@@ -1,4 +1,4 @@
// This file is auto-generated by @hey-api/openapi-ts // This file is auto-generated by @hey-api/openapi-ts
export { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from './sdk.gen'; export { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listPresets, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from './sdk.gen';
export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AddMyGakData, type AddMyGakError, type AddMyGakErrors, type AddMyGakResponse, type AddMyGakResponses, type AddTalkData, type AddTalkError, type AddTalkErrors, type AddTalkResponse, type AddTalkResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, type AuthConfigData, type AuthConfigResponse, type AuthConfigResponses, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type BlockTalkAuthorData, type BlockTalkAuthorError, type BlockTalkAuthorErrors, type BlockTalkAuthorResponse, type BlockTalkAuthorResponses, type BodyUploadTalkImageV1TalkImagePost, type ClientOptions, type CommentData, type CommuteData, Confidence, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type DeleteMyGakData, type DeleteMyGakError, type DeleteMyGakErrors, type DeleteMyGakResponse, type DeleteMyGakResponses, type DeleteTalkData, type DeleteTalkError, type DeleteTalkErrors, type DeleteTalkResponse, type DeleteTalkResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetImageData, type GetImageError, type GetImageErrors, type GetImageResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetTalkImageData, type GetTalkImageError, type GetTalkImageErrors, type GetTalkImageResponses, type GetTodayGuPageData, type GetTodayGuPageError, type GetTodayGuPageErrors, type GetTodayGuPageResponse, type GetTodayGuPageResponses, type GetTodayPageData, type GetTodayPageError, type GetTodayPageErrors, type GetTodayPageResponse, type GetTodayPageResponses, type GetWatchSummaryData, type GetWatchSummaryError, type GetWatchSummaryErrors, type GetWatchSummaryResponse, type GetWatchSummaryResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekRankingData, type GetWeekRankingResponse, type GetWeekRankingResponses, type GetWeekResponse, type GetWeekResponses, type GoogleLoginData, type GoogleLoginError, type GoogleLoginErrors, type GoogleLoginResponse, type GoogleLoginResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HeroStat, type HourCell, type HoursSlide, type HttpValidationError, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type LikeTalkData, type LikeTalkError, type LikeTalkErrors, type LikeTalkResponse, type LikeTalkResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListMyGakData, type ListMyGakError, type ListMyGakErrors, type ListMyGakResponse, type ListMyGakResponses, type ListPlacesData, type ListPlacesError, type ListPlacesErrors, type ListPlacesResponse, type ListPlacesResponses, type ListRegionsData, type ListRegionsError, type ListRegionsErrors, type ListRegionsResponse, type ListRegionsResponses, type ListSavedData, type ListSavedError, type ListSavedErrors, type ListSavedResponse, type ListSavedResponses, type ListTalksData, type ListTalksError, type ListTalksErrors, type ListTalksResponse, type ListTalksResponses, type LoginData, type LoginError, type LoginErrors, type LoginResponse, type LoginResponses, type LogoutData, type LogoutError, type LogoutErrors, type LogoutResponse, type LogoutResponses, type Me, type MeData, type MeError, type MeErrors, type MeResponse, type MeResponses, Line truncated export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AddMyGakData, type AddMyGakError, type AddMyGakErrors, type AddMyGakResponse, type AddMyGakResponses, type AddTalkData, type AddTalkError, type AddTalkErrors, type AddTalkResponse, type AddTalkResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, type AuthConfigData, type AuthConfigResponse, type AuthConfigResponses, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type BlockTalkAuthorData, type BlockTalkAuthorError, type BlockTalkAuthorErrors, type BlockTalkAuthorResponse, type BlockTalkAuthorResponses, type BodyUploadTalkImageV1TalkImagePost, type ClientOptions, type CommentData, type CommuteData, Confidence, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type DeleteMyGakData, type DeleteMyGakError, type DeleteMyGakErrors, type DeleteMyGakResponse, type DeleteMyGakResponses, type DeleteTalkData, type DeleteTalkError, type DeleteTalkErrors, type DeleteTalkResponse, type DeleteTalkResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetImageData, type GetImageError, type GetImageErrors, type GetImageResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetTalkImageData, type GetTalkImageError, type GetTalkImageErrors, type GetTalkImageResponses, type GetTodayGuPageData, type GetTodayGuPageError, type GetTodayGuPageErrors, type GetTodayGuPageResponse, type GetTodayGuPageResponses, type GetTodayPageData, type GetTodayPageError, type GetTodayPageErrors, type GetTodayPageResponse, type GetTodayPageResponses, type GetWatchSummaryData, type GetWatchSummaryError, type GetWatchSummaryErrors, type GetWatchSummaryResponse, type GetWatchSummaryResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekRankingData, type GetWeekRankingResponse, type GetWeekRankingResponses, type GetWeekResponse, type GetWeekResponses, type GoogleLoginData, type GoogleLoginError, type GoogleLoginErrors, type GoogleLoginResponse, type GoogleLoginResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HeroStat, type HourCell, type HoursSlide, type HttpValidationError, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type LikeTalkData, type LikeTalkError, type LikeTalkErrors, type LikeTalkResponse, type LikeTalkResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListMyGakData, type ListMyGakError, type ListMyGakErrors, type ListMyGakResponse, type ListMyGakResponses, type ListPlacesData, type ListPlacesError, type ListPlacesErrors, type ListPlacesResponse, type ListPlacesResponses, type ListPresetsData, type ListPresetsResponse, type ListPresetsResponses, type ListRegionsData, type ListRegionsError, type ListRegionsErrors, type ListRegionsResponse, type ListRegionsResponses, type ListSavedData, type ListSavedError, type ListSavedErrors, type ListSavedResponse, type ListSavedResponses, type ListTalksData, type ListTalksError, type ListTalksErrors, type ListTalksResponse, type ListTalksResponses, type LoginData, type LoginError, type LoginErrors, type LoginResponse, type LoginResponses, type LogoutData, type LogoutError, type LogoutErrors, type LogoutResponse, type LogoutResponses, type Me, tyLine truncated
+6 -1
View File
@@ -2,7 +2,7 @@
import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client'; import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';
import { client } from './client.gen'; import { client } from './client.gen';
import type { AddCommentData, AddCommentErrors, AddCommentResponses, AddMyGakData, AddMyGakErrors, AddMyGakResponses, AddTalkData, AddTalkErrors, AddTalkResponses, AuthConfigData, AuthConfigResponses, BlockTalkAuthorData, BlockTalkAuthorErrors, BlockTalkAuthorResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, DeleteMyGakData, DeleteMyGakErrors, DeleteMyGakResponses, DeleteTalkData, DeleteTalkErrors, DeleteTalkResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetImageData, GetImageErrors, GetImageResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetTalkImageData, GetTalkImageErrors, GetTalkImageResponses, GetTodayGuPageData, GetTodayGuPageErrors, GetTodayGuPageResponses, GetTodayPageData, GetTodayPageErrors, GetTodayPageResponses, GetWatchSummaryData, GetWatchSummaryErrors, GetWatchSummaryResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekRankingData, GetWeekRankingResponses, GetWeekResponses, GoogleLoginData, GoogleLoginErrors, GoogleLoginResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, LikeTalkData, LikeTalkErrors, LikeTalkResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListMyGakData, ListMyGakErrors, ListMyGakResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, ListTalksData, ListTalksErrors, ListTalksResponses, LoginData, LoginErrors, LoginResponses, LogoutData, LogoutErrors, LogoutResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, RefreshData, RefreshErrors, RefreshResponses, ReportTalkData, ReportTalkErrors, ReportTalkResponses, SavePostData, SavePostErrors, SavePostResponses, ScoreMyGakData, ScoreMyGakErrors, ScoreMyGakResponses, SignupData, SignupErrors, SignupResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnlikeTalkData, UnlikeTalkErrors, UnlikeTalkResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses, UpdateMeData, UpdateMeErrors, UpdateMeResponses, UploadTalkImageData, UploadTalkImageErrors, UploadTalkImageResponses } from './types.gen'; import type { AddCommentData, AddCommentErrors, AddCommentResponses, AddMyGakData, AddMyGakErrors, AddMyGakResponses, AddTalkData, AddTalkErrors, AddTalkResponses, AuthConfigData, AuthConfigResponses, BlockTalkAuthorData, BlockTalkAuthorErrors, BlockTalkAuthorResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, DeleteMyGakData, DeleteMyGakErrors, DeleteMyGakResponses, DeleteTalkData, DeleteTalkErrors, DeleteTalkResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetImageData, GetImageErrors, GetImageResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetTalkImageData, GetTalkImageErrors, GetTalkImageResponses, GetTodayGuPageData, GetTodayGuPageErrors, GetTodayGuPageResponses, GetTodayPageData, GetTodayPageErrors, GetTodayPageResponses, GetWatchSummaryData, GetWatchSummaryErrors, GetWatchSummaryResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekRankingData, GetWeekRankingResponses, GetWeekResponses, GoogleLoginData, GoogleLoginErrors, GoogleLoginResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, LikeTalkData, LikeTalkErrors, LikeTalkResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListMyGakData, ListMyGakErrors, ListMyGakResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListPresetsData, ListPresetsResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, ListTalksData, ListTalksErrors, ListTalksResponses, LoginData, LoginErrors, LoginResponses, LogoutData, LogoutErrors, LogoutResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, RefreshData, RefreshErrors, RefreshResponses, ReportTalkData, ReportTalkErrors, ReportTalkResponses, SavePostData, SavePostErrors, SavePostResponses, ScoreMyGakData, ScoreMyGakErrors, ScoreMyGakResponses, SignupData, SignupErrors, SignupResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnlikeTalkData, UnlikeTalkErrors, UnlikeTalkResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses, UpdateMeData, UpdateMeErrors, UpdateMeResponses, UploadTalkImageData, UploadTalkImageErrors, UploadTalkImageResponses } from './types.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & { export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
/** /**
@@ -252,6 +252,11 @@ export const addMyGak = <ThrowOnError extends boolean = true>(options: Options<A
} }
}); });
/**
* 공식 각을 내 각 조건으로 옮긴 목록 (내 각 만들기에서 골라 채우기)
*/
export const listPresets = <ThrowOnError extends boolean = true>(options?: Options<ListPresetsData, ThrowOnError>): RequestResult<ListPresetsResponses, unknown, ThrowOnError> => (options?.client ?? client).get<ListPresetsResponses, unknown, ThrowOnError>({ url: '/v1/my-gak/presets', ...options });
/** /**
* 조건들의 그 동네 오늘 점수 (로그인 없이, 받은 링크의 각도) * 조건들의 그 동네 오늘 점수 (로그인 없이, 받은 링크의 각도)
*/ */
+89
View File
@@ -625,6 +625,14 @@ export type Hero = {
weather_slots?: { weather_slots?: {
[key: string]: number; [key: string]: number;
}; };
/**
* Weather Why
*
* 구간별 날씨 점수 근거(조건·비중·조건 점수·지금 값). 키는 weather_slots 와 같다
*/
weather_why?: {
[key: string]: Array<WeatherWhy>;
};
top1?: TopIndex | null; top1?: TopIndex | null;
/** /**
* Bubble * Bubble
@@ -867,6 +875,28 @@ export type MyGakData = {
rule: MyGakRule; rule: MyGakRule;
}; };
/**
* MyGakPreset
*/
export type MyGakPreset = {
/**
* Code
*/
code: string;
/**
* Name
*/
name: string;
/**
* Icon
*/
icon: string;
/**
* 공식 각을 내 각 조건으로 비슷하게 옮긴 값. 점수는 공식 각과 다를 수 있음
*/
rule: MyGakRule;
};
/** /**
* MyGakRule * MyGakRule
*/ */
@@ -1766,6 +1796,21 @@ export type ResMyGakList = {
items?: Array<MyGakData>; items?: Array<MyGakData>;
}; };
/**
* Res_MyGakPresets
*/
export type ResMyGakPresets = {
result?: ErrorInfo;
/**
* Msg
*/
msg?: string | null;
/**
* Items
*/
items?: Array<MyGakPreset>;
};
/** /**
* Res_MyGakScore * Res_MyGakScore
*/ */
@@ -3152,6 +3197,34 @@ export type WeatherSlot = {
note: string; note: string;
}; };
/**
* WeatherWhy
*/
export type WeatherWhy = {
/**
* Label
*/
label: string;
/**
* Weight
*
* 비중 % (합 100)
*/
weight: number;
/**
* Score
*
* 이 조건 점수 0~100
*/
score: number;
/**
* Note
*
* 지금 값 (예: 체감 19°, 편한 범위 18~24° 안)
*/
note: string;
};
/** /**
* WeekDay * WeekDay
*/ */
@@ -4470,6 +4543,22 @@ export type AddMyGakResponses = {
export type AddMyGakResponse = AddMyGakResponses[keyof AddMyGakResponses]; export type AddMyGakResponse = AddMyGakResponses[keyof AddMyGakResponses];
export type ListPresetsData = {
body?: never;
path?: never;
query?: never;
url: '/v1/my-gak/presets';
};
export type ListPresetsResponses = {
/**
* Successful Response
*/
200: ResMyGakPresets;
};
export type ListPresetsResponse = ListPresetsResponses[keyof ListPresetsResponses];
export type ScoreMyGakData = { export type ScoreMyGakData = {
body: ReqMyGakScore; body: ReqMyGakScore;
path?: never; path?: never;
+5 -3
View File
@@ -28,6 +28,7 @@ import { ago, ARTICLE_CAT, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateR
import { GoogleButton } from './googleLogin' import { GoogleButton } from './googleLogin'
import { useInstall, useInstallable } from './install' import { useInstall, useInstallable } from './install'
import { InstallSheet } from './installBanner' import { InstallSheet } from './installBanner'
import { WeatherWhySheet } from './weatherWhy'
import { MixSheet } from './myGak' import { MixSheet } from './myGak'
import { ownPage, useRegion } from './regionContext' import { ownPage, useRegion } from './regionContext'
import { useSky } from './skyContext' import { useSky } from './skyContext'
@@ -76,7 +77,7 @@ export function SheetProvider({ children }: { children: ReactNode }) {
) )
} }
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', install: '홈 화면에 추가' } as const const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', install: '홈 화면에 추가', weatherWhy: '날씨 점수는 이렇게 나와요' } as const
/** 아래에서 올라오는 창: 네이티브 <dialog>라 ESC·포커스 가두기·포커스 되돌리기가 기본으로 된다 */ /** 아래에서 올라오는 창: 네이티브 <dialog>라 ESC·포커스 가두기·포커스 되돌리기가 기본으로 된다 */
function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) { function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) {
@@ -138,6 +139,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
{state.type === 'region' && <RegionSheet onDone={onClose} />} {state.type === 'region' && <RegionSheet onDone={onClose} />}
{state.type === 'mix' && <MixSheet shared={state.shared} onDone={onClose} />} {state.type === 'mix' && <MixSheet shared={state.shared} onDone={onClose} />}
{state.type === 'install' && <InstallSheet />} {state.type === 'install' && <InstallSheet />}
{state.type === 'weatherWhy' && <WeatherWhySheet d={state.why} />}
</div> </div>
)} )}
{!state && <RegionLinks />} {!state && <RegionLinks />}
@@ -532,7 +534,7 @@ function ShareSheet({ share }: { share: SharePayload }) {
if (images[size] || failed[size]) return if (images[size] || failed[size]) return
let alive = true let alive = true
const today = new Date().toLocaleDateString('ko-KR', { month: 'long', day: 'numeric', weekday: 'long' }) const today = new Date().toLocaleDateString('ko-KR', { month: 'long', day: 'numeric', weekday: 'long' })
shareImage(share.slides, { size, sky: kind, sub: `${region.name} · ${today}`, host: new URL(SITE_URL).host }).then( shareImage(size === 'square' && share.square ? share.square : share.slides, { size, sky: kind, sub: `${region.name} · ${today}`, host: new URL(SITE_URL).host }).then(
(blob) => { (blob) => {
if (!alive) return if (!alive) return
const src = URL.createObjectURL(blob) const src = URL.createObjectURL(blob)
@@ -547,7 +549,7 @@ function ShareSheet({ share }: { share: SharePayload }) {
return () => { return () => {
alive = false alive = false
} }
}, [size, images, failed, share.slides, kind, region.name]) }, [size, images, failed, share.slides, share.square, kind, region.name])
useEffect(() => { useEffect(() => {
const list = srcs.current const list = srcs.current
+38 -21
View File
@@ -15,7 +15,7 @@ import { useFeedTalks } from './talkState'
import { useRegion } from './regionContext' import { useRegion } from './regionContext'
import { useSheet } from './sheetContext' import { useSheet } from './sheetContext'
import { useSky } from './skyContext' import { useSky } from './skyContext'
import { GakShareCard, HeroShareCard, type HeroShare } from './shareCards' import { DayShareCard, DayShareGrid, GakShareCard, type DayShare } from './shareCards'
import { SendIcon } from './svg' import { SendIcon } from './svg'
import { Ic, Rail, Sec, Skel, StateBox, TAP44, Thumb } from './ui' import { Ic, Rail, Sec, Skel, StateBox, TAP44, Thumb } from './ui'
import { deg, slotAt } from './weatherText' import { deg, slotAt } from './weatherText'
@@ -86,7 +86,7 @@ function atSlot(items: TopIndex[], kind: TimeKind | null): TopIndex[] {
] ]
} }
type HeroProps = { hero?: HeroData | null; today?: ResWeatherToday; ranked: TopIndex[]; feedLoad: Load; todayLoad: Load } type HeroProps = { hero?: HeroData | null; today?: ResWeatherToday; ranked: TopIndex[]; all: TopIndex[]; feedLoad: Load; todayLoad: Load }
type Weather = 'clear' | 'partly' | 'cloudy' | 'rain' | 'snow' | 'sleet' type Weather = 'clear' | 'partly' | 'cloudy' | 'rain' | 'snow' | 'sleet'
@@ -108,11 +108,13 @@ const CLOUDS = [
] ]
const CLOUD_N: Record<Weather, number> = { clear: 0, partly: 2, cloudy: 3, rain: 3, snow: 3, sleet: 3 } const CLOUD_N: Record<Weather, number> = { clear: 0, partly: 2, cloudy: 3, rain: 3, snow: 3, sleet: 3 }
function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) { function Hero({ hero, today, ranked, all, feedLoad, todayLoad }: HeroProps) {
const { open } = useSheet() const { open } = useSheet()
const { region } = useRegion() const { region } = useRegion()
const tplRef = useRef<HTMLDivElement>(null) const tplRef = useRef<HTMLDivElement>(null)
const share = () => tplRef.current && open({ type: 'share', share: { title: `${region.name} 오늘 날씨`, slides: [tplRef.current] } }) const gridRef = useRef<HTMLDivElement>(null)
const share = () =>
tplRef.current && open({ type: 'share', share: { title: `${region.name} 오늘 날씨`, slides: [tplRef.current], square: gridRef.current ? [gridRef.current] : undefined } })
const { preview, setServerKind, setPreview } = useSky() const { preview, setServerKind, setPreview } = useSky()
const mode: Mode = preview ?? 'now' const mode: Mode = preview ?? 'now'
const clock = useNow() const clock = useNow()
@@ -137,6 +139,10 @@ function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) {
const weather = weatherOf(slotOf(mode)) const weather = weatherOf(slotOf(mode))
const slotScore = mode === 'now' ? undefined : hero?.weather_slots?.[SLOT_KEY[mode]] const slotScore = mode === 'now' ? undefined : hero?.weather_slots?.[SLOT_KEY[mode]]
const score = slotScore ?? hero?.weather_score const score = slotScore ?? hero?.weather_score
// 점수 옆 ? 버튼: 보고 있는 시간대(지금이면 지금 구간)의 날씨 점수 근거
const whyKey = mode === 'now' ? SLOT_KEY[nowKind] : SLOT_KEY[mode]
const why = hero?.weather_why?.[whyKey]
const whyLabel = mode === 'now' || mode === nowKind ? '지금' : PREVIEW[mode].label
const slotTop = mode === 'now' ? undefined : ranked.find((g) => g.active) const slotTop = mode === 'now' ? undefined : ranked.find((g) => g.active)
const top1 = slotTop ?? hero?.top1 const top1 = slotTop ?? hero?.top1
// 저녁(노을)부터는 가운데 동그라미가 오늘 밤 달 모양이 된다 // 저녁(노을)부터는 가운데 동그라미가 오늘 밤 달 모양이 된다
@@ -148,26 +154,27 @@ function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) {
const rain = weather === 'rain' || weather === 'sleet' const rain = weather === 'rain' || weather === 'sleet'
const snow = weather === 'snow' || weather === 'sleet' const snow = weather === 'snow' || weather === 'sleet'
const shareData: HeroShare = { // 공유 이미지: 아침~밤 네 시간대 모두. 점수는 시간대 점수, 각은 그 시간대 1등
kind, const days: DayShare[] = KINDS.map((k) => {
sky: weather, const isNow = k === nowKind
date: `${t.mo}월 ${t.d}일 ${WEEKDAYS[t.wd]}요일`, const s = slotOf(isNow ? 'now' : k)
place: region.name, const top = atSlot(all, k).find((g) => g.active)
label: `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`, return {
score, kind: k,
bubble, label: PREVIEW[k].label,
summary: top1?.summary, now: isNow,
status: status.map((x) => ({ label: x.label, value: x.value, warn: x.tone === 'warn' })), icon: k === 'night' && weatherOf(s) === 'clear' ? 'moon' : WEATHER_ICON[weatherOf(s)],
slots: KINDS.map((k) => { temp: s?.temp_c != null ? deg(s.temp_c) : '–',
const s = slotOf(k === nowKind ? 'now' : k) score: hero?.weather_slots?.[SLOT_KEY[k]] ?? (isNow ? hero?.weather_score : null),
return { label: k === nowKind ? '지금' : PREVIEW[k].label, icon: k === 'night' && weatherOf(s) === 'clear' ? 'moon' : WEATHER_ICON[weatherOf(s)], temp: s?.temp_c != null ? deg(s.temp_c) : '–', on: k === kind } gak: top ? { name: top.name, icon: top.icon } : null,
}), }
} })
// 시안 D4-2: 가운데 해(점수)와 하늘 날씨, 결론 두 줄, 상태 한 줄, 아래 하루 흐름 칸(누르면 그 시간대 하늘로) // 시안 D4-2: 가운데 해(점수)와 하늘 날씨, 결론 두 줄, 상태 한 줄, 아래 하루 흐름 칸(누르면 그 시간대 하늘로)
return ( return (
<div className="b-hero relative mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3" data-t={kind} data-sky={weather}> <div className="b-hero relative mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3" data-t={kind} data-sky={weather}>
<HeroShareCard d={shareData} ref={tplRef} /> <DayShareCard days={days} ref={tplRef} />
<DayShareGrid days={days} ref={gridRef} />
<div className="b-stars pointer-events-none absolute inset-0" aria-hidden="true"> <div className="b-stars pointer-events-none absolute inset-0" aria-hidden="true">
{STARS.map((s, i) => ( {STARS.map((s, i) => (
<i key={i} className="absolute size-[3px] rounded-full shadow-[0_0_6px_#fff]" style={s} /> <i key={i} className="absolute size-[3px] rounded-full shadow-[0_0_6px_#fff]" style={s} />
@@ -205,6 +212,16 @@ function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) {
<small className="block font-jua text-[12px]">{failed(feedLoad) ? '점수를 못 불러왔어요' : `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`}</small> <small className="block font-jua text-[12px]">{failed(feedLoad) ? '점수를 못 불러왔어요' : `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`}</small>
<b className="block font-bagel text-[52px] leading-[0.95] font-normal">{heroVal(feedLoad, score, 'w-[84px]')}</b> <b className="block font-bagel text-[52px] leading-[0.95] font-normal">{heroVal(feedLoad, score, 'w-[84px]')}</b>
</span> </span>
{why && score != null && (
<button
type="button"
onClick={() => open({ type: 'weatherWhy', why: { label: whyLabel, score, why } })}
aria-label={`${whyLabel} 날씨 점수 ${score}점, 어떻게 나왔는지 보기`}
className={cx('absolute right-0 bottom-1 z-[2] grid size-7 cursor-pointer place-items-center rounded-full bg-white font-jua text-[16px] text-(--orange-deep) shadow-[0_2px_6px_rgb(40_48_74/0.25)]', TAP44)}
>
?
</button>
)}
</div> </div>
</div> </div>
<div className="relative z-[3] text-center"> <div className="relative z-[3] text-center">
@@ -388,7 +405,7 @@ export function TodayPage() {
return ( return (
// 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다 // 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다
<section key={region.code} aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}> <section key={region.code} aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}>
<Hero hero={f?.hero} today={today.data} ranked={stories} feedLoad={load} todayLoad={loadOf(today)} /> <Hero hero={f?.hero} today={today.data} ranked={stories} all={f?.stories ?? []} feedLoad={load} todayLoad={loadOf(today)} />
<FeedComposer onPosted={(t) => setMine((m) => [t, ...m])} /> <FeedComposer onPosted={(t) => setMine((m) => [t, ...m])} />
{mine.map((t) => ( {mine.map((t) => (
<TalkCard key={t.talk_id} t={t} /> <TalkCard key={t.talk_id} t={t} />
+27 -7
View File
@@ -7,8 +7,8 @@ import { PostFrame } from './Post'
type Mountain = { name: string; region: string; lat: number; lon: number; peak: string } type Mountain = { name: string; region: string; lat: number; lon: number; peak: string }
type Stage = 'peak' | 'soon' | 'before' | 'after' type Stage = 'peak' | 'soon' | 'before' | 'after'
// 지도 그림(public/foliage/korea-map.webp, 1024×1536)의 위경도 → 그림 위 위치. generated-images/foliage-map/korea_outline.json 과 같은 값 // 지도 그림(public/foliage/korea-map.webp, 정사각형)의 위경도 → 그림 위 위치. generated-images/foliage-map/south_outline.json 과 같은 값
const MAP = { lon0: 124.0, lon1: 132.2, lat0: 33.0, lat1: 43.1, w: 900, h: 1407, scale: 1.09168, ox: 20.74, cw: 1024, ch: 1536 } const MAP = { lon0: 124.5, lat1: 38.75, k: 0.809017, s: 153.5327, ox: 40, oy: 62.92, size: 1024 }
const PEAK_DAYS = 3 // 절정일 앞뒤 이만큼은 '지금 절정' const PEAK_DAYS = 3 // 절정일 앞뒤 이만큼은 '지금 절정'
const SOON_DAYS = 7 const SOON_DAYS = 7
const SEASON = { from: '09-20', to: '11-25' } const SEASON = { from: '09-20', to: '11-25' }
@@ -22,10 +22,27 @@ const STAGE: Record<Stage, { label: string; dot: string }> = {
} }
const pos = (m: Mountain) => ({ const pos = (m: Mountain) => ({
left: `${((MAP.ox + ((m.lon - MAP.lon0) / (MAP.lon1 - MAP.lon0)) * MAP.w * MAP.scale) / MAP.cw) * 100}%`, left: `${((MAP.ox + (m.lon - MAP.lon0) * MAP.k * MAP.s) / MAP.size) * 100}%`,
top: `${((((MAP.lat1 - m.lat) / (MAP.lat1 - MAP.lat0)) * MAP.h * MAP.scale) / MAP.ch) * 100}%`, top: `${((MAP.oy + (MAP.lat1 - m.lat) * MAP.s) / MAP.size) * 100}%`,
}) })
// 점이 붙은 곳은 이름을 점 왼쪽·위·아래로 돌려 겹치지 않게. 없으면 오른쪽
type Side = 'left' | 'right' | 'top' | 'bottom'
const SIDE: Record<string, Side> = {
광덕산: 'left',
설악산: 'top',
금원산: 'top',
두륜산: 'left',
'한라산(1100도로)': 'left',
}
const LABEL_AT: Record<Side, string> = {
right: 'left-full top-1/2 -translate-y-1/2',
left: 'right-full top-1/2 -translate-y-1/2',
top: 'bottom-full left-1/2 -translate-x-1/2',
bottom: 'top-full left-1/2 -translate-x-1/2',
}
const short = (name: string) => name.replace(/\(.*\)$/, '')
const DAY = 86_400_000 const DAY = 86_400_000
const days = (from: string, to: string) => Math.round((Date.parse(to) - Date.parse(from)) / DAY) const days = (from: string, to: string) => Math.round((Date.parse(to) - Date.parse(from)) / DAY)
@@ -56,7 +73,7 @@ export function FoliageCard() {
<div className="relative bg-[#e6f2ff] px-4 pt-4 pb-3"> <div className="relative bg-[#e6f2ff] px-4 pt-4 pb-3">
<p className="m-0 text-[13px] font-extrabold opacity-75">단풍 지도 · {md(today)}</p> <p className="m-0 text-[13px] font-extrabold opacity-75">단풍 지도 · {md(today)}</p>
<p className="m-0 mt-1 font-jua text-[24px] leading-tight">서울 근교 {seoul.name} 절정 예상 {md(seoul.peak)}</p> <p className="m-0 mt-1 font-jua text-[24px] leading-tight">서울 근교 {seoul.name} 절정 예상 {md(seoul.peak)}</p>
<div className="relative mx-auto mt-2 aspect-[2/3] w-[86%]"> <div className="relative mx-auto mt-1 aspect-square w-full">
<img src="/foliage/korea-map.webp" alt="한반도 지도" className="absolute inset-0 size-full" /> <img src="/foliage/korea-map.webp" alt="한반도 지도" className="absolute inset-0 size-full" />
{mountains.map((m) => ( {mountains.map((m) => (
<button <button
@@ -64,10 +81,13 @@ export function FoliageCard() {
type="button" type="button"
onClick={() => setPicked(m.name === picked ? null : m.name)} onClick={() => setPicked(m.name === picked ? null : m.name)}
aria-label={`${m.name} ${STAGE[m.stage].label}, 절정 예상 ${md(m.peak)}`} aria-label={`${m.name} ${STAGE[m.stage].label}, 절정 예상 ${md(m.peak)}`}
className="absolute -translate-x-1/2 -translate-y-1/2 cursor-pointer p-1.5" className="absolute -translate-x-1/2 -translate-y-1/2 cursor-pointer p-1"
style={pos(m)} style={pos(m)}
> >
<i className={cx('block size-3.5 rounded-full border-2 border-white shadow-[0_1px_4px_rgb(40_48_74/0.35)]', STAGE[m.stage].dot, m.name === picked && 'size-5')} /> <i className={cx('block size-3 rounded-full border-2 border-white shadow-[0_1px_4px_rgb(40_48_74/0.35)]', STAGE[m.stage].dot, m.name === picked && 'size-4.5')} />
<span className={cx('absolute py-1 text-[10.5px] leading-none font-extrabold whitespace-nowrap text-(--ink2) [text-shadow:0_0_3px_#fff,0_0_3px_#fff]', LABEL_AT[SIDE[m.name] ?? 'right'])}>
{short(m.name)}
</span>
</button> </button>
))} ))}
{sel && ( {sel && (
+5 -5
View File
@@ -4,7 +4,7 @@ import { cx } from '../lib/utils'
import { gakName, shareUrl, SLOTS, type MyGak, type Slot, useMyGak, useMyGakScores } from './myGakState' import { gakName, shareUrl, SLOTS, type MyGak, type Slot, useMyGak, useMyGakScores } from './myGakState'
import { useRegion } from './regionContext' import { useRegion } from './regionContext'
import { useSheet } from './sheetContext' import { useSheet } from './sheetContext'
import { Sec } from './ui' import { Rail, Sec } from './ui'
const SLOT_WORD = Object.fromEntries(SLOTS) as Record<Slot, string> const SLOT_WORD = Object.fromEntries(SLOTS) as Record<Slot, string>
@@ -49,9 +49,9 @@ export function MyGakRow() {
return ( return (
<> <>
<Sec title="내 각" sub="내가 정한 날씨 조건으로 오늘 점수를 매겨요" /> <Sec title="내 각" sub="내가 정한 날씨 조건으로 오늘 점수를 매겨요" />
<div className="flex snap-x gap-2 overflow-x-auto px-3 pb-1 [scrollbar-width:none]"> <Rail label="내 각">
{items.map((g, i) => ( {items.map((g, i) => (
<div key={g.id ?? 'local'} className="flex w-[220px] shrink-0 snap-start flex-col gap-1.5 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]"> <div key={g.id ?? 'local'} className="flex w-[220px] flex-col gap-1.5 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]">
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<b className="font-jua text-[17px] leading-tight font-normal">{g.name}</b> <b className="font-jua text-[17px] leading-tight font-normal">{g.name}</b>
<Score s={scores[i]} /> <Score s={scores[i]} />
@@ -67,11 +67,11 @@ export function MyGakRow() {
</div> </div>
</div> </div>
))} ))}
<button type="button" onClick={() => open({ type: 'mix' })} className="flex w-[120px] shrink-0 cursor-pointer snap-start flex-col items-center justify-center gap-1 rounded-[22px] border-2 border-dashed border-(--line) p-3 font-jua text-[15px] text-(--ink2)"> <button type="button" onClick={() => open({ type: 'mix' })} className="flex w-[120px] cursor-pointer flex-col items-center justify-center gap-1 rounded-[22px] border-2 border-dashed border-(--line) p-3 font-jua text-[15px] text-(--ink2)">
<span className="text-[26px] leading-none">+</span> <span className="text-[26px] leading-none">+</span>
내 각 만들기 내 각 만들기
</button> </button>
</div> </Rail>
</> </>
) )
} }
+66 -38
View File
@@ -1,8 +1,8 @@
import type { Ref } from 'react' import type { Ref } from 'react'
import { createPortal } from 'react-dom' import { createPortal } from 'react-dom'
import type { TopIndex } from '../api/client/types.gen'
import { cx } from '../lib/utils' import { cx } from '../lib/utils'
import { MEDALS } from './lib' import type { TopIndex } from '../api/client/types.gen'
import { MEDALS, type TimeKind } from './lib'
import { Ic } from './ui' import { Ic } from './ui'
/** 공유 이미지 전용 틀. 화면 밖에 그려 두고 보내기 때 이것만 찍는다 (화면의 버튼은 이미지에서 빠지므로 글자만으로 만든다) */ /** 공유 이미지 전용 틀. 화면 밖에 그려 두고 보내기 때 이것만 찍는다 (화면의 버튼은 이미지에서 빠지므로 글자만으로 만든다) */
@@ -15,50 +15,78 @@ function Offscreen({ children }: { children: React.ReactNode }) {
) )
} }
export type HeroShare = { export type DayShare = {
kind: string kind: TimeKind
sky: string
date: string
place: string
label: string label: string
now: boolean
icon: string
temp: string
score?: number | null score?: number | null
bubble?: string | null gak?: { name: string; icon: string } | null
summary?: string | null
status: { label: string; value: string; warn: boolean }[]
slots: { label: string; icon: string; temp: string; on: boolean }[]
} }
export function HeroShareCard({ d, ref }: { d: HeroShare; ref: Ref<HTMLDivElement> }) { function DayLabel({ d, size }: { d: DayShare; size: string }) {
return (
<span className={cx('flex items-center gap-1.5 font-jua leading-none', size)}>
{d.label}
{d.now && <small className="rounded-full bg-[#ff7a45] px-2 py-0.5 font-sans text-[13px] font-extrabold text-white">지금</small>}
</span>
)
}
/** 히어로 공유: 아침·낮·저녁·밤 네 줄. 줄마다 그 시간대 하늘에 날씨·기온, 날씨 점수, 그 시간 1등 각. 로고·지역·날짜는 공유 틀이 그린다 */
export function DayShareCard({ days, ref }: { days: DayShare[]; ref: Ref<HTMLDivElement> }) {
return ( return (
<Offscreen> <Offscreen>
<div ref={ref} className="b-hero relative flex aspect-[4/5] flex-col overflow-hidden px-5 pt-5 pb-4 text-center" data-t={d.kind} data-sky={d.sky}> <div ref={ref} className="flex aspect-[4/5] flex-col">
<p className="m-0 text-left text-[14px] font-bold opacity-80"> {days.map((d) => (
{d.date} · {d.place} <div key={d.kind} className="b-hero grid flex-1 grid-cols-[96px_1fr_auto] items-center gap-3 px-4" data-t={d.kind}>
</p> <span className="flex flex-col gap-1.5">
<div className="b-sun mx-auto mt-5 grid aspect-square w-36 place-items-center rounded-full"> <DayLabel d={d} size="text-[28px]" />
<span> <span className="flex items-center gap-1 font-jua text-[22px] leading-none">
<small className="block font-jua text-[13px]">{d.label}</small> <Ic name={d.icon} className="h-7 w-7 object-contain" />
<b className="block font-bagel text-[58px] leading-[0.95] font-normal">{d.score ?? '–'}</b> {d.temp}
</span> </span>
</div>
<p className="m-0 mt-4 font-jua text-[26px] leading-tight">{d.bubble}</p>
{d.summary && <p className="m-0 mt-1 text-[15px] font-bold opacity-80">{d.summary}</p>}
<p className="m-0 mt-2 flex flex-wrap justify-center gap-x-2 font-jua text-[14px]">
{d.status.map((x) => (
<span key={x.label} className={cx('whitespace-nowrap', x.warn && 'b-warn')}>
<span className="opacity-75">{x.label}</span> {x.value}
</span> </span>
))} <span className="flex min-w-0 items-center gap-2">
</p> {d.gak && <Ic name={d.gak.icon} className="w-10 shrink-0" />}
<div className="b-strip mt-auto grid grid-cols-4 gap-1 rounded-[18px] p-[3px]"> <b className="font-jua text-[24px] leading-tight font-normal break-keep">{d.gak?.name ?? '쉬어 가요'}</b>
{d.slots.map((s) => (
<span key={s.label} className={cx('flex flex-col items-center rounded-[14px] py-1.5', s.on && 'b-strip-on')}>
<span className="text-[13px] font-bold opacity-80">{s.label}</span>
<Ic name={s.icon} className="my-0.5 h-[22px] w-[22px] object-contain" />
<b className="font-jua text-[15px] font-normal">{s.temp}</b>
</span> </span>
))} <span className="text-right">
</div> <b className="block font-bagel text-[62px] leading-[0.9] font-normal">{d.score ?? '–'}</b>
<small className="text-[13px] font-bold opacity-75">날씨 점수</small>
</span>
</div>
))}
</div>
</Offscreen>
)
}
/** 1:1 공유용: 같은 내용을 2×2 칸으로 */
export function DayShareGrid({ days, ref }: { days: DayShare[]; ref: Ref<HTMLDivElement> }) {
return (
<Offscreen>
<div ref={ref} className="grid aspect-square grid-cols-2 grid-rows-2">
{days.map((d) => (
<div key={d.kind} className="b-hero flex flex-col justify-between p-4" data-t={d.kind}>
<span className="flex items-center justify-between">
<DayLabel d={d} size="text-[26px]" />
<span className="flex items-center gap-1 font-jua text-[20px] leading-none">
<Ic name={d.icon} className="h-7 w-7 object-contain" />
{d.temp}
</span>
</span>
<span>
<b className="block font-bagel text-[64px] leading-[0.9] font-normal">{d.score ?? '–'}</b>
<small className="text-[12px] font-bold opacity-75">날씨 점수</small>
</span>
<span className="flex min-w-0 items-center gap-1.5">
{d.gak && <Ic name={d.gak.icon} className="w-8 shrink-0" />}
<b className="truncate font-jua text-[21px] font-normal">{d.gak?.name ?? '쉬어 가요'}</b>
</span>
</div>
))}
</div> </div>
</Offscreen> </Offscreen>
) )
+4 -1
View File
@@ -1,6 +1,8 @@
import type { MyGak } from './myGakState' import type { MyGak } from './myGakState'
import type { WeatherWhyPayload } from './weatherWhy'
import { createContext, use } from 'react' import { createContext, use } from 'react'
export type SharePayload = { title: string; slides: HTMLElement[] } /** square: 1:1 비율일 때 slides 대신 찍을 틀 (없으면 slides) */
export type SharePayload = { title: string; slides: HTMLElement[]; square?: HTMLElement[] }
type CommentsState = { type: 'comments'; postId: number; draft?: string } type CommentsState = { type: 'comments'; postId: number; draft?: string }
@@ -15,6 +17,7 @@ export type SheetState =
| { type: 'region' } | { type: 'region' }
| { type: 'mix'; shared?: MyGak } | { type: 'mix'; shared?: MyGak }
| { type: 'install' } | { type: 'install' }
| { type: 'weatherWhy'; why: WeatherWhyPayload }
| null | null
export type SheetApi = { open: (s: Exclude<SheetState, null>) => void; close: () => void } export type SheetApi = { open: (s: Exclude<SheetState, null>) => void; close: () => void }
+54
View File
@@ -0,0 +1,54 @@
import type { WeatherWhy } from '../api/client/types.gen'
export type WeatherWhyPayload = { label: string; score: number; why: WeatherWhy[] }
// 조건마다 같은 색을 막대 칸과 아래 줄 점에 같이 써서 이어 보이게
const COLOR: Record<string, string> = {
기온: '#ff7a45',
비: '#4f97e3',
햇볕: '#ffb02e',
바람: '#5fb8b0',
습도: '#8e8cf0',
미세먼지: '#b59a86',
}
const colorOf = (label: string) => COLOR[label] ?? '#9aa3b8'
/** 날씨 점수 근거: 비중만큼 나눈 막대(채운 만큼 얻은 점수)와 조건별 지금 값 */
export function WeatherWhySheet({ d }: { d: WeatherWhyPayload }) {
return (
<div className="flex-1 overflow-auto overscroll-contain px-4 pt-4 pb-[18px]">
<p className="m-0 flex items-baseline gap-2">
<b className="font-bagel text-[44px] leading-none font-normal">{d.score}</b>
<span className="font-jua text-[17px] text-(--ink2)">{d.label} 날씨 점수</span>
</p>
<div className="mt-3 flex h-7 gap-[3px] overflow-hidden rounded-[10px]" role="img" aria-label={d.why.map((w) => `${w.label} 비중 ${w.weight}% 중 ${w.score}점`).join(', ')}>
{d.why.map((w) => (
<span key={w.label} className="relative h-full bg-[#eef2f8]" style={{ width: `${w.weight}%` }}>
<span className="absolute inset-y-0 left-0" style={{ width: `${w.score}%`, background: colorOf(w.label) }} />
</span>
))}
</div>
<p className="m-0 mt-1.5 text-[12.5px] font-semibold text-(--ink3)">칸 넓이는 비중, 채운 만큼이 얻은 점수예요</p>
<ul className="m-0 mt-3 flex list-none flex-col gap-1.5 p-0">
{d.why.map((w) => (
<li key={w.label} className="flex items-center gap-3 rounded-2xl bg-[#f5f8fc] px-3.5 py-2.5">
<i className="size-3 shrink-0 rounded-full" style={{ background: colorOf(w.label) }} aria-hidden="true" />
<span className="min-w-0 flex-1">
<b className="block font-jua text-[16px] leading-tight font-normal">
{w.label} <small className="font-sans text-[12px] font-bold text-(--ink3)">비중 {w.weight}%</small>
</b>
<small className="block text-[13px] font-semibold text-(--ink2)">{w.note}</small>
</span>
<b className="font-jua text-[20px] font-normal tabular-nums">{w.score}</b>
</li>
))}
</ul>
<p className="m-0 mt-3 text-[13px] leading-relaxed font-semibold text-(--ink2)">
조건마다 점수를 매겨 비중대로 합쳐요. 유난히 아쉬운 조건이 있으면 조금 더 깎고, 모든 조건이 완벽할 때만 만점이 나와요.
</p>
</div>
)
}