가상투자 종목카드박스 레이아웃 수정
This commit is contained in:
@@ -37,6 +37,8 @@ export const DEFAULT_AUXILIARY_ITEMS: Omit<PaletteItem, 'id' | 'kind'>[] = [
|
||||
{ value: 'PSYCHOLOGICAL', label: '심리도', desc: 'Psychological', builtIn: true },
|
||||
{ value: 'INVEST_PSYCHOLOGICAL', label: '투자심리도', desc: 'Invest PSY', builtIn: true },
|
||||
{ value: 'VOLUME', label: '거래량', desc: 'Volume', builtIn: true },
|
||||
{ value: 'NEW_HIGH', label: '신고가', desc: '직전 N봉 최고가 돌파 — 종가/고가 vs N일 신고가선 (9·20일)', builtIn: true, period: 9 },
|
||||
{ value: 'NEW_LOW', label: '신저가', desc: '직전 N봉 최저가 이탈 — 종가/저가 vs N일 신저가선 (9·20일)', builtIn: true, period: 9 },
|
||||
];
|
||||
|
||||
export const DEFAULT_COMPOSITE_ITEMS: Omit<PaletteItem, 'id' | 'kind'>[] =
|
||||
@@ -85,13 +87,36 @@ function parseStored(raw: string | null): PaletteItem[] | null {
|
||||
}
|
||||
}
|
||||
|
||||
/** 복합지표 팔레트에서 단일 지표로 이전된 항목 제거 */
|
||||
const DEPRECATED_COMPOSITE_VALUES = new Set(['NEW_HIGH', 'NEW_LOW']);
|
||||
|
||||
function mergeMissingBuiltIns(
|
||||
stored: PaletteItem[],
|
||||
kind: PaletteItemKind,
|
||||
defaults: Omit<PaletteItem, 'id' | 'kind'>[],
|
||||
): PaletteItem[] {
|
||||
let base = stored;
|
||||
if (kind === 'composite') {
|
||||
base = stored.filter(i => !DEPRECATED_COMPOSITE_VALUES.has(i.value));
|
||||
}
|
||||
const existing = new Set(base.map(i => i.value));
|
||||
const added = defaults
|
||||
.filter(d => !existing.has(d.value))
|
||||
.map(d => ({
|
||||
...d,
|
||||
id: builtinId(kind, d.value),
|
||||
kind,
|
||||
}));
|
||||
return added.length > 0 ? [...base, ...added] : base;
|
||||
}
|
||||
|
||||
export function loadPaletteItems(kind: PaletteItemKind): PaletteItem[] {
|
||||
const key = kind === 'auxiliary' ? STORAGE_AUX : STORAGE_COMP;
|
||||
const defaults = kind === 'auxiliary' ? DEFAULT_AUXILIARY_ITEMS : DEFAULT_COMPOSITE_ITEMS;
|
||||
try {
|
||||
const stored = parseStored(localStorage.getItem(key));
|
||||
if (stored && stored.length > 0) {
|
||||
return stored.map(i => ({ ...i, kind }));
|
||||
return mergeMissingBuiltIns(stored.map(i => ({ ...i, kind })), kind, defaults);
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return seedItems(kind, defaults);
|
||||
|
||||
Reference in New Issue
Block a user