IOS小组件/文案
This commit is contained in:
32
client/src/features/suixinTheme/pickTheme.ts
Normal file
32
client/src/features/suixinTheme/pickTheme.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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'>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user