💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
> 插件说明:用于会员对cms的内容进行收藏 ***** >[tip] 安装前,请先安装【cms插件】 ***** ### 效果如下: ![](https://img.kancloud.cn/e3/95/e395e85a00d226e370f25f2134cbdfbe_295x164.png) ### 1.在需要收藏按钮的模板页面加下以下html代码(具体样式自行调整) ``` <link rel="stylesheet" href="__CDN__/assets/fonts/iconfont/iconfont.css"> <style type="text/css"> .favorite-box{text-align: center;} .favorite-box span{font-size: 14px;line-height: 20px;display: block;} .favorite-btn{width: 60px;height: 55px;position: relative;padding: 0;background-color: #f0f3f8;display: inline-block;font-weight: 400;color: #212529;text-align: center;vertical-align: middle;user-select: none;font-size: 14px;line-height: 1.5;margin: 0 5px;padding-top: 5px;} .favorite-num{background: #f00; position: absolute;font-size: 12px;font-weight: 300;top: -5px;right: -5px;padding: 0px 6px;color: #fff;text-shadow: none;border-width: 0;border-style: solid;border-radius: 12px;box-shadow: none;} </style> <div class="favorite-box"> <a href="javascript:;" class="favorite-btn" data-catid="{$catid}" data-id={$id}> <i class="iconfont icon-heart-line"></i> <span>收藏</span> <small class="favorite-num">{$favorite|default=0}</small> </a> </div> <script> $(function() { //收藏 $(document).on("click", ".favorite-btn", function () { var that = this; $.ajax({ url: "{:url('index/favorite/post')}", type: 'get', dataType: 'json', data: {catid: $(that).data("catid"),id: $(that).data("id")}, success(data){ if(data.code==1){ $('.favorite-num').text(data.data.num); alert(data.msg); }else{ alert(data.msg); } } }); return false; }); }); </script> ``` ***** ### 2.必须对需要的模型增加favorite字段,如文章模型需要用到收藏,则对文章模型增加字段如下 ![](https://img.kancloud.cn/71/e4/71e4f5fb4b7b16e8cfa6c41b94a0a5b7_847x674.png)