Function
extractText
(text: string | Array<string | { type: string; text: string }>)
Source from the content-addressed store, hash-verified
| 68 | * text 可以是字符串或 mixed 数组 |
| 69 | */ |
| 70 | export function extractText(text: string | Array<string | { type: string; text: string }>): string { |
| 71 | if (typeof text === 'string') return text |
| 72 | if (!Array.isArray(text)) return '' |
| 73 | |
| 74 | return text |
| 75 | .map((part) => { |
| 76 | if (typeof part === 'string') return part |
| 77 | if (part && typeof part === 'object' && 'text' in part) return part.text |
| 78 | return '' |
| 79 | }) |
| 80 | .join('') |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * 从 from_id 提取平台 ID |
Tested by
no test coverage detected