/** * 栏目标题(CommonSectionTitle)统一读取器 * * 用法: * const st = await useSectionTitles() * * * st(path, fallback, field = 'title') 三个参数都是字符串。 * field 可选 'title' | 'subtitle' | 'label'。 */ export async function useSectionTitles() { const { data } = await usePublicApi('section-titles') return (path, fallback = '', field = 'title') => { const parts = (path || '').split('.') let cursor = data.value for (const p of parts) { if (cursor && typeof cursor === 'object' && p in cursor) { cursor = cursor[p] } else { return fallback } } if (cursor && typeof cursor === 'object') { return cursor[field] || fallback } return fallback } }