💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] #### cubeUI 索引列表 * [ ] 数据结构 ![](https://box.kancloud.cn/95fb07c4fdee6823c36b94e23d548753_574x628.png) ***** * [ ] 格式化数据结构,成为符合 cubeUi 结构的数据 ~~~ _normalizeSinger (list) { let map = { hot: { title: HOT_NAME, items: [] } } list.forEach((item, index) => { // 取前10条作为热门数据 if (index < HOT_SINGER_LEN) { map.hot.items.push(new Singer({ name: item.Fsinger_name, id: item.Fsinger_mid })) } // 定义数据结构 const key = item.Findex if (!map[key]) { map[key] = { title: key, items: [] } } map[key].items.push(new Singer({ name: item.Fsinger_name, id: item.Fsinger_mid })) }) // 为了得到有序列表,我们需要处理 map let ret = [] let hot = [] for (let key in map) { let val = map[key] if (val.title.match(/[a-zA-Z]/)) { ret.push(val) } else if (val.title === HOT_NAME) { hot.push(val) } } // 数据排序 ret.sort((a, b) => { return a.title.charCodeAt(0) - b.title.charCodeAt(0) }) return hot.concat(ret) }, ~~~