企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
一、路径:dashboard\controller\Index.php,通过smarty模版引擎,赋值并渲染视图页面: ``` function lockData() { global $CONF; $tpl = new Smarty; $tpl->caching = true; $tpl->cache_lifetime = 120; //$tpl->debugging = true; $pagestpl = './' . DASH_BOARD . '/view/lockdata.html'; if (!$tpl->isCached($pagestpl)) { //判断当前的缓存有效,如果有效,则无需使用模型取数据; $tpl->assign('title', $CONF['sys_name']); $tpl->assign('description', '漏刻有时(LOCKDATA),智能化数据展示解决方案服务商,让更多的人看到数据可视化的魅力,促进前沿技术与产业融合,帮助非专业的工程师通过图形化的界面轻松搭建专业水准的可视化应用,满足会议展览、业务监控、风险预警、地理信息分析等多种业务的展示需求。'); $tpl->assign('author', 'Poleung'); $tpl->assign('STATIC', 'static/lockdata/'); $tpl->assign('loading', 'Loading...'); $tpl->assign('retreat', '开启/退出全屏'); $tpl->assign('subtitle1', '任务进程分布'); …… } $tpl->display($pagestpl); } ``` 二、视图呈现,路径:dashboard\view\lockdata.html ``` <!doctype html> <html style="overflow-x: hidden; overflow-y: auto;"> <head> <meta charset="utf-8"> <title>{$title}</title> <meta name="description" content="{$description}"> <meta name="author" content="{$author}"> <script type="text/javascript" src="{$STATIC}js/jquery.js"></script> <script type="text/javascript" src="{$STATIC}js/echarts.min.js"></script> <script type="text/javascript" src="{$STATIC}js/visual.js"></script> <script type="text/javascript" src="{$STATIC}js/times.js"></script> <script type="text/javascript" src="{$STATIC}js/jquery.liMarquee.js"></script> <script type="text/javascript" src="{$STATIC}js/jquery.cxselect.min.js"></script> <link rel="stylesheet" href="{$STATIC}css/common.css"> </head> <body> 内容展示区 </body> </html> ``` 三、ECHARTS图标核心代码,路径:static\lockdata\js\visual.js * [ ] 前台调用函数; ``` //调用Echarts; $(function () { echarts_1(); echarts_2(); echarts_3(); echarts_4(); echarts_5(); zb1(); zb2(); zb3(); ``` * [ ] 通过api/api.php接口进行数据调用,并且自动刷新数据; ``` function showtotal() { $.ajax({ type: "post", async: false, url: "../api/api.php?act=summary&token=3cab7ce4142608c0f40c785b5ab5ca24", data: {}, dataType: "json", success: function (result) { $('.cnum').text(result.data.totaldata); }, error: function (errmsg) { $('.cnum').text("Ajax err!" + errmsg); } }); } //自动刷新; var interval; showtotal(); clearInterval(interval); interval = setInterval(function () { showtotal() }, 6 * 1000); ```