You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
3 years ago
|
<?php
|
||
3 years ago
|
/*
|
||
|
* @Author: witersen
|
||
|
* @Date: 2022-04-24 23:37:05
|
||
|
* @LastEditors: witersen
|
||
3 years ago
|
* @LastEditTime: 2022-05-07 14:25:15
|
||
3 years ago
|
* @Description: QQ:1801168257
|
||
|
*/
|
||
3 years ago
|
|
||
3 years ago
|
namespace app\service;
|
||
3 years ago
|
|
||
3 years ago
|
class Update extends Base
|
||
|
{
|
||
|
function __construct()
|
||
|
{
|
||
|
parent::__construct();
|
||
|
}
|
||
3 years ago
|
|
||
|
/**
|
||
|
* 获取当前版本信息
|
||
|
*/
|
||
3 years ago
|
public function GetVersion()
|
||
3 years ago
|
{
|
||
3 years ago
|
return message(200, 1, '成功', [
|
||
3 years ago
|
'current_verson' => $this->config_version['version'],
|
||
3 years ago
|
'github' => 'https://github.com/witersen/svnAdminV2.0',
|
||
|
'gitee' => 'https://gitee.com/witersen/SvnAdminV2.0',
|
||
|
'author' => 'https://www.witersen.com'
|
||
|
]);
|
||
3 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* 检测新版本
|
||
|
*/
|
||
3 years ago
|
public function CheckUpdate($payload)
|
||
3 years ago
|
{
|
||
3 years ago
|
foreach ($this->config_update['update_server'] as $key => $value) {
|
||
3 years ago
|
$versionInfo = FunCurlRequest($value);
|
||
3 years ago
|
if ($versionInfo != null) {
|
||
|
$versionInfo = json_decode($versionInfo, true);
|
||
|
$latestVersion = $versionInfo['latestVersion'];
|
||
3 years ago
|
if ($latestVersion == $this->config_version['version']) {
|
||
|
return message(200, 1, '当前版本为最新版');
|
||
|
} else if ($latestVersion > $this->config_version['version']) {
|
||
|
return message(200, 1, '有更新', [
|
||
3 years ago
|
'latestVersion' => $versionInfo['latestVersion'],
|
||
|
'fixedContent' => implode('<br>', $versionInfo['fixedContent']) == '' ? '暂无内容' : implode('<br>', $versionInfo['fixedContent']),
|
||
|
'newContent' => implode('<br>', $versionInfo['newContent']) == '' ? '暂无内容' : implode('<br>', $versionInfo['newContent']),
|
||
|
'updateType' => $versionInfo['updateType'],
|
||
|
'updateStep' => $versionInfo['updateStep']
|
||
3 years ago
|
]);
|
||
|
} else if ($latestVersion < $this->config_version['version']) {
|
||
|
return message(200, 0, '系统版本错误');
|
||
3 years ago
|
}
|
||
|
}
|
||
|
}
|
||
3 years ago
|
return message(200, 0, '检测更新超时');
|
||
3 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* 确认更新
|
||
|
*/
|
||
3 years ago
|
public function StartUpdate($payload)
|
||
3 years ago
|
{
|
||
|
}
|
||
|
}
|