Files
goldenChart/frontend/src/utils/storage.ts
T
2026-05-28 14:44:19 +09:00

65 lines
1.7 KiB
TypeScript

import type { IndicatorConfig, Theme, ChartType, Timeframe, MainChartStyle } from '../types';
interface ChartState {
version: number;
symbol: string;
timeframe: Timeframe;
chartType: ChartType;
theme: Theme;
indicators: IndicatorConfig[];
watchlist: string[];
alertPrices: number[];
mainChartStyle?: MainChartStyle;
}
const CUR_VERSION = 8;
/** 기본 보조지표 없음 — 처음 로딩 시 캔들차트만 표시 */
const DEFAULT_INDICATORS: IndicatorConfig[] = [];
const DEFAULT_WATCHLIST = [
'KRW-BTC', 'KRW-ETH', 'KRW-XRP', 'KRW-SOL', 'KRW-DOGE',
'KRW-ADA', 'KRW-AVAX', 'KRW-DOT',
];
/**
* 절대적 최후 fallback 기본값.
* 우선순위: DB(gc_app_settings + gc_chart_workspace) > 이 값.
*/
const DEFAULT_STATE: ChartState = {
version: CUR_VERSION,
symbol: 'KRW-BTC',
timeframe: '1D',
chartType: 'candlestick',
theme: 'dark',
indicators: DEFAULT_INDICATORS,
watchlist: DEFAULT_WATCHLIST,
alertPrices: [],
};
/** @deprecated DB·워크스페이스 사용 — no-op */
export function saveState(_state: Partial<ChartState>): void {
/* chart state는 gc_chart_workspace·gc_app_settings로 저장 */
}
/** 초기 마운트 fallback (DB 로드 전 1회) */
export function loadState(): ChartState {
return DEFAULT_STATE;
}
/** @deprecated */
export function clearState(): void {
/* no-op */
}
export const DEFAULT_MAIN_CHART_STYLE: MainChartStyle = {
upColor: '#ff6b6b',
downColor: '#4dabf7',
borderUpColor: '#ff6b6b',
borderDownColor: '#4dabf7',
wickUpColor: '#ff6b6b',
wickDownColor: '#4dabf7',
};
export { DEFAULT_INDICATORS };