goldenChat base source add
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 업비트 마켓 코드 ↔ 한글명 캐시
|
||||
* MarketSearchPanel 에서 market/all API 결과를 저장하고
|
||||
* Toolbar 등에서 getKoreanName() 으로 조회합니다.
|
||||
*/
|
||||
|
||||
const CACHE_KEY = 'upbit_market_names_v1';
|
||||
|
||||
// 앱 시작 시 localStorage에서 복원
|
||||
let _cache: Record<string, string> = {};
|
||||
try {
|
||||
_cache = JSON.parse(localStorage.getItem(CACHE_KEY) ?? '{}');
|
||||
} catch { /* ignore */ }
|
||||
|
||||
/** market/all 로드 후 한꺼번에 저장 */
|
||||
export function setMarketNames(map: Record<string, string>): void {
|
||||
_cache = { ..._cache, ...map };
|
||||
try { localStorage.setItem(CACHE_KEY, JSON.stringify(_cache)); } catch { /* ignore */ }
|
||||
}
|
||||
|
||||
/**
|
||||
* 마켓 코드 → 한글명
|
||||
* 캐시에 없으면 "BTC" 형식 fallback
|
||||
*/
|
||||
export function getKoreanName(market: string): string {
|
||||
return _cache[market] ?? market.replace(/^KRW-/, '');
|
||||
}
|
||||
Reference in New Issue
Block a user