From f17af174193d28de8959828d5d113c5bf2331017 Mon Sep 17 00:00:00 2001 From: taoser Date: Wed, 17 Mar 2021 18:02:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E9=80=80=E5=87=BABUG?= =?UTF-8?q?=EF=BC=8C=E9=A6=96=E9=A1=B5=E5=8D=87=E7=BA=A7=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E8=BF=90=E8=A1=8C=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Admin.php | 1 + app/admin/controller/Index.php | 45 +++++++++++++++++++++++++++------- app/admin/view/index/home.html | 7 +++++- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php index ffb248e..fc4e0e1 100644 --- a/app/admin/controller/Admin.php +++ b/app/admin/controller/Admin.php @@ -225,6 +225,7 @@ class Admin extends AdminController //退出登陆 public function logout() { + Cookie::delete('adminAuth'); Session::clear(); $res = ['code'=>0,'msg'=>'退出成功' ]; diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 67c6e0f..c09e900 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -15,17 +15,27 @@ use taoler\com\Api; class Index extends AdminController { - +/* protected function initialize() { parent::initialize(); - $this->domain = Request::scheme().'://www.'.Request::rootDomain(); - $this->api = Db::name('system')->where('id',1)->value('api_url'); + } +*/ + public function __construct() + { + $this->sys_version = Config::get('taoler.version'); + $this->sys = Db::name('system')->where('id',1)->find(); + + $this->domain = Request::scheme().'://'.$this->sys['domain']; + $this->api = $this->sys['api_url']; if(empty($this->api)){ - $baseUrl = Db::name('system')->where('id',1)->value('base_url'); + $baseUrl = $this->sys['base_url']; $this->api = strstr($baseUrl,'/v',true); } - } + // 控制器初始化显示左侧导航菜单 + parent::initialize(); + } + public function index() { @@ -43,14 +53,31 @@ class Index extends AdminController return view(); } - public function home(){ - $sys = Db::name('system')->find(1); + public function home() + { + //版本检测 + $url = $this->sys['upcheck_url'].'?ver='.$this->sys_version; + $versions = Api::urlGet($url); + if($versions->code == 1){ + if($versions->up_num > 0){ + $versions = "当前有{$versions->up_num}个版本需更新,当前可更新至{$versions->version}"; + } + } else { + $versions ='当前无可更新版本'; + } + //运行时间 $now = time(); - $count = $now-$sys['create_time']; + $count = $now-$this->sys['create_time']; $days = floor($count/86400); $hos = floor(($count%86400)/3600); $mins = floor(($count%3600)/60); - View::assign(['sys'=>$sys,'day'=>$days,'hos'=>$hos,'mins'=>$mins]); + $years = floor($days/365); + if($years >= 1){ + $days = floor($days%365); + } + $runTime = $years ? "{$years}年{$days}天{$hos}时{$mins}分" : "{$days}天{$hos}时{$mins}分"; + + View::assign(['runTime'=>$runTime,'versions'=>$versions]); return View::fetch(); } diff --git a/app/admin/view/index/home.html b/app/admin/view/index/home.html index b9c706f..0397bc2 100644 --- a/app/admin/view/index/home.html +++ b/app/admin/view/index/home.html @@ -5,6 +5,11 @@
+
+
+
{$versions}
+
+
快捷方式
@@ -247,7 +252,7 @@ 运行时间