企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
~~~ class KeywordModel{ getHistory(){ const words = wx.getStorageSync('q'); if(words){ return words }else{ return [] } } getHot(){ } addToHistory(keyword){ /* 将搜索的历史词汇添加到缓存中,如果缓存中存在则不添加 */ let words = this.getHistory(); const has = words.includes(keyword); if(!has){ /* 如果数组的长度大于10,则删除末尾的值*/ const length = words.length; if(length>10){ words.pop(); } words.unshift(keyword); wx.setStorageSync('q', words); } } } export {KeywordModel};