| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace UCore\DcatAdmin\Metrics\Examples;
- use Dcat\Admin\Admin;
- use Dcat\Admin\Widgets\Metrics\Card;
- use Dcat\Admin\Widgets\Metrics\RadialBar;
- use Dcat\Admin\Widgets\Widget;
- use Illuminate\Http\Request;
- class Reload extends Widget
- {
- protected $title = 'Reload';
- protected $view = 'admin_core.metrics.reload';
- /**
- * 刷新时间
- * @var int
- */
- protected $sRoload = 60 ;
- /**
- * 弹出提示
- *
- * @var bool
- */
- public $notice = false;
- public function __construct()
- {
- $ms = $this->sRoload * 1000;
- $script = <<<JS
- // js
- if(typeof reloadindex == 'undefined'){
- var reloads = {$this->sRoload};
- var notice = '{$this->notice}';
- var reloadindex = setInterval(function(){
- if(reloads < 0){
- window.location.reload();
- }
- reloads --;
- $('.reload_2').html(reloads);
- console.log('reloads:', reloads)
- }, 1000);
- if(notice){
- Dcat.warning('页面将在 {$this->sRoload} 秒后自动刷新', null, {
- timeOut: 5000, // 5秒后自动消失
- });
- }
- }
- JS;
- Admin::script($script);
- }
- }
|