catalog-normalize.js 710 B

12345678910111213141516171819202122232425
  1. /** 作品/喜欢列表分页解包(复用 feed 模块,兼容 images 字符串 / 嵌套 data) */
  2. export { extractFeedPage as extractContentPage } from '@/features/feed/clip-normalize'
  3. /** 合辑列表分页解包 */
  4. export function extractSeriesPage(payload) {
  5. const body = payload && typeof payload === 'object' ? payload : {}
  6. const rows = Array.isArray(body)
  7. ? body
  8. : Array.isArray(body.data)
  9. ? body.data
  10. : []
  11. return {
  12. rows,
  13. currentPage: Number(body.current_page || 1),
  14. lastPage: Number(body.last_page || body.current_page || 1)
  15. }
  16. }
  17. export function stripRichText(html) {
  18. if (!html) return ''
  19. return String(html)
  20. .replace(/<[^>]+>/g, '')
  21. .replace(/&nbsp;/g, ' ')
  22. .trim()
  23. }