预留在线升级功能
This commit is contained in:
+24
-1
@@ -1 +1,24 @@
|
|||||||
APP_DEBUG = false
|
APP_DEBUG = false
|
||||||
|
VERSION = 4.0.2
|
||||||
|
|
||||||
|
rootuid = 1
|
||||||
|
|
||||||
|
[APP]
|
||||||
|
DEFAULT_TIMEZONE = Asia/Shanghai
|
||||||
|
|
||||||
|
[DATABASE]
|
||||||
|
TYPE = {type}
|
||||||
|
HOSTNAME = {hostname}
|
||||||
|
DATABASE = {database}
|
||||||
|
USERNAME = {username}
|
||||||
|
PASSWORD = {password}
|
||||||
|
HOSTPORT = {hostport}
|
||||||
|
CHARSET = utf8
|
||||||
|
PREFIX = {prefix}
|
||||||
|
DEBUG = false
|
||||||
|
|
||||||
|
[LANG]
|
||||||
|
default_lang = zh-cn
|
||||||
|
|
||||||
|
[JWT]
|
||||||
|
SECRET={secret}
|
||||||
@@ -30,6 +30,18 @@ class Index extends Base {
|
|||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 系统更新
|
||||||
|
*/
|
||||||
|
public function update(){
|
||||||
|
$version = new \com\Version();
|
||||||
|
|
||||||
|
$info = $version->check();
|
||||||
|
|
||||||
|
$this->data['info'] = $info;
|
||||||
|
return $this->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 用户登录
|
* @title 用户登录
|
||||||
* @return html
|
* @return html
|
||||||
|
|||||||
+37
-3
@@ -9,6 +9,7 @@
|
|||||||
namespace com;
|
namespace com;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 版本管理
|
* @title 版本管理
|
||||||
@@ -16,8 +17,41 @@ use GuzzleHttp\Client;
|
|||||||
*/
|
*/
|
||||||
class Version{
|
class Version{
|
||||||
|
|
||||||
public static function check(){
|
public $client = "";
|
||||||
$client = new Client();
|
public $headers = "";
|
||||||
$res = $client->request('POST', 'http://www.tensent.cn/api/version/index');
|
|
||||||
|
public function __construct(){
|
||||||
|
$this->headers = [
|
||||||
|
// 'Content-Type' => 'application/json',
|
||||||
|
// 'Authorization' => 'Bearer ' . Env::get('test.token'),
|
||||||
|
];
|
||||||
|
$this->client = new Client([
|
||||||
|
'base_uri' => 'http://www.tensent.cn/',
|
||||||
|
'timeout' => 2.0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check(){
|
||||||
|
$param = [
|
||||||
|
'client_url' => 'https://www.com',
|
||||||
|
'dd' => 'dd'
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
$response = $this->client->post('api/version/index', [
|
||||||
|
'form_params' => $param,
|
||||||
|
'headers' => $this->headers,
|
||||||
|
]);
|
||||||
|
$ret = \GuzzleHttp\json_decode($response->getBody()->getContents(), true);
|
||||||
|
if($ret['code'] == 1){
|
||||||
|
$version = Env::get('version');
|
||||||
|
$data = $ret['data'];
|
||||||
|
if(version_compare($version, $data['version'], '<')){
|
||||||
|
$data['update'] = 1;
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
//throw $th;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{extend name="admin/public/base" /}
|
||||||
|
{block name="body"}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="callout callout-info">
|
||||||
|
<h4>当前版本:{$version}</h4>
|
||||||
|
<h4>最新版本:{$info['version']}</h4>
|
||||||
|
{if isset($info['update']) && $info['update'] == 1}
|
||||||
|
<p>
|
||||||
|
<a href="{$info['file']}" class="btn btn-success" target="_blank">下载手动升级</a>
|
||||||
|
<button class="btn btn-success">在线升级</button>
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="callout callout-success">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/block}
|
||||||
Reference in New Issue
Block a user