33 lines
921 B
TypeScript
33 lines
921 B
TypeScript
import type { SuixinBaseThemeId, UserProfileScoring } from '@/src/storage/appStorage';
|
||
|
||
const ALL_NEED_THEME_IDS: ReadonlySet<string> = new Set([
|
||
'emotional_support',
|
||
'parenting_pressure',
|
||
'self_worth',
|
||
'anxiety_relief',
|
||
'rest_balance',
|
||
]);
|
||
|
||
/**
|
||
* Base Theme 选择(Theme Picking)
|
||
*
|
||
* Hard Rules(对齐设计文档):
|
||
* - mom_stage = unknown → 强制 Neutral
|
||
* - need 跳过/缺失 → Neutral
|
||
*/
|
||
export function pickSuixinBaseThemeId(profile: UserProfileScoring | null | undefined): SuixinBaseThemeId {
|
||
if (!profile) return 'neutral';
|
||
|
||
// Hard Rule:unknown → Neutral
|
||
if (profile.stage?.unknown === 1) return 'neutral';
|
||
|
||
const needObj = profile.need ?? {};
|
||
const keys = Object.keys(needObj);
|
||
if (keys.length === 0) return 'neutral';
|
||
|
||
const needId = keys[0];
|
||
if (!ALL_NEED_THEME_IDS.has(needId)) return 'neutral';
|
||
return needId as Exclude<SuixinBaseThemeId, 'neutral'>;
|
||
}
|
||
|