优惠退出BUG,首页升级检测,优化运行时间

This commit is contained in:
taoser 2021-03-17 18:02:11 +08:00
parent 73c046b051
commit f17af17419
3 changed files with 43 additions and 10 deletions

View File

@ -225,6 +225,7 @@ class Admin extends AdminController
//退出登陆
public function logout()
{
Cookie::delete('adminAuth');
Session::clear();
$res = ['code'=>0,'msg'=>'退出成功' ];

View File

@ -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();
}

View File

@ -5,6 +5,11 @@
<div class="layui-row layui-col-space15">
<div class="layui-col-md8">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header"><span style="color:red">{$versions}</span></div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-card">
<div class="layui-card-header">快捷方式</div>
@ -247,7 +252,7 @@
<td>运行时间</td>
<td>
<script type="text/html" template>
{$day}天{$hos}时{$mins}分
{$runTime}
</script>
</td>
</tr>