菜单栏增加角标方法
1、修改文件 \public\assets\js\index.js
//定时加载新消息
setInterval(function (){
$.post("order/index/orderCount",function(data){
Backend.api.sidebar({
'order/index': data,
'category':['456','red', 'badge'],//圆角
});
if(data>'0'){
const audio = new Audio('http://a.adichuxing.top/order.mp4');
audio.play();
}
},"json");
}, 10000);//1000=1秒
2、在对应控制器增加查询代码
/**
* 新订单数量
*/
public function orderCount(){
$count=db::name("order")->where(['status'=>'0','is_see'=>'0'])->update(array("is_see"=>'1'));
return $count;
}
定时修改方法
1、修改文件 \public\assets\js\require-backend.js
添加一行
'bootstrap-table-auto-refresh': '../libs/bootstrap-table/dist/extensions/auto-refresh/bootstrap-table-auto-refresh',
添加一行
'bootstrap-table-auto-refresh': {
deps: ['bootstrap-table'],
exports: '$.fn.bootstrapTable.defaults'
},
2,修改文件 public\assets\js\require-table.js
添加一个属性
'bootstrap-table-auto-refresh'
最后在一键生成的curd的js文件里加入
autoRefresh:false,//true=开启
autoRefreshInterval:10
最后在终端重新打包一下框架js、css
php think min -m backend -r all