mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 09:30:10 +08:00
[update] Version compatible
This commit is contained in:
parent
b5e75eb1eb
commit
534b20d389
@ -14,7 +14,7 @@ filter_words =
|
|||||||
|
|
||||||
**钉钉**
|
**钉钉**
|
||||||
|
|
||||||
> 文档: https://developers.dingtalk.com/文档ument/robots/custom-robot-access
|
> 文档: https://developers.dingtalk.com/document/robots/custom-robot-access
|
||||||
> 说明: 钉钉推送的密钥
|
> 说明: 钉钉推送的密钥
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
|
|||||||
@ -5,7 +5,10 @@
|
|||||||
"source": "https://github.com/lkeme/BiliHelper-personal",
|
"source": "https://github.com/lkeme/BiliHelper-personal",
|
||||||
"raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json",
|
"raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json",
|
||||||
"purge_url": "https://purge.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json",
|
"purge_url": "https://purge.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json",
|
||||||
"version": "1.0.2.211115",
|
"version": "1.0.2.211114",
|
||||||
"des": "程序有更新,请及时线上查看更新哦~",
|
"des": "程序有更新,请及时线上查看更新哦~",
|
||||||
"time": "2021年11月15日15:40:35"
|
"time": "2021年11月15日15:40:35",
|
||||||
|
"ini_version": "0.0.1",
|
||||||
|
"ini_des": "配置有更新,请及时线上查看更新哦~",
|
||||||
|
"ini_time": "2021年11月15日15:40:35"
|
||||||
}
|
}
|
||||||
@ -40,11 +40,12 @@ function setConf($name, $value, int|string $section = 0, $key = null)
|
|||||||
/**
|
/**
|
||||||
* @use 开关
|
* @use 开关
|
||||||
* @param string $plugin
|
* @param string $plugin
|
||||||
|
* @param bool $default
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function getEnable(string $plugin): bool
|
function getEnable(string $plugin, bool $default = false): bool
|
||||||
{
|
{
|
||||||
return getConf('enable', $plugin);
|
return getConf('enable', $plugin) ?: $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class AloneTcpClient
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private static function unPackMsg($value, string $fmt = "N"):mixed
|
private static function unPackMsg($value, string $fmt = "N"): mixed
|
||||||
{
|
{
|
||||||
return unpack($fmt, $value)[1];
|
return unpack($fmt, $value)[1];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,15 +43,28 @@ class CheckUpdate
|
|||||||
self::loadJsonData();
|
self::loadJsonData();
|
||||||
Log::info('拉取线上最新配置');
|
Log::info('拉取线上最新配置');
|
||||||
self::fetchLatest();
|
self::fetchLatest();
|
||||||
|
// 检测项目版本
|
||||||
if (!self::compareVersion()) {
|
if (!self::compareVersion()) {
|
||||||
Log::info('项目已是最新版本');
|
Log::info('程序已是最新版本');
|
||||||
} else {
|
} else {
|
||||||
Log::notice('项目有更新');
|
|
||||||
// Todo 完善提示信息
|
// Todo 完善提示信息
|
||||||
$time = self::$latest_conf->get('time');
|
$time = self::$latest_conf->get('time');
|
||||||
$version = self::$latest_conf->get('version');
|
$version = self::$latest_conf->get('version');
|
||||||
$des = self::$latest_conf->get('des');
|
$des = self::$latest_conf->get('des');
|
||||||
$info = "最新版本-$version, $des";
|
$info = "请注意程序有版本更新变动哦~\n\n版本号: $version\n\n更新日志: $des\n\n更新时间: $time\n\n";
|
||||||
|
Log::notice($info);
|
||||||
|
Notice::push('update', $info);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测配置版本
|
||||||
|
if (!self::compareINIVersion()) {
|
||||||
|
Log::info('配置已是最新版本');
|
||||||
|
} else {
|
||||||
|
$time = self::$latest_conf->get('ini_time');
|
||||||
|
$version = self::$latest_conf->get('ini_version');
|
||||||
|
$des = self::$latest_conf->get('ini_des');
|
||||||
|
$info = "请注意配置有版本变动更新哦~\n\n版本号: $version\n\n更新日志: $des\n\n更新时间: $time\n\n";
|
||||||
|
Log::notice($info);
|
||||||
Notice::push('update', $info);
|
Notice::push('update', $info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,4 +100,16 @@ class CheckUpdate
|
|||||||
return !($current_version == $latest_version);
|
return !($current_version == $latest_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 比较INI版本号
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function compareINIVersion(): bool
|
||||||
|
{
|
||||||
|
$current_version = self::$current_conf->get('ini_version');
|
||||||
|
$latest_version = self::$latest_conf->get('ini_version');
|
||||||
|
// true 有更新 false 无更新
|
||||||
|
return !($current_version == $latest_version);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ class Notice
|
|||||||
$now_time = date('Y-m-d H:i:s');
|
$now_time = date('Y-m-d H:i:s');
|
||||||
$info = match ($type) {
|
$info = match ($type) {
|
||||||
'update' => [
|
'update' => [
|
||||||
'title' => '程序更新通知',
|
'title' => '版本更新通知',
|
||||||
'content' => "[$now_time] 用户: $uname 程序更新通知: $result"
|
'content' => "[$now_time] 用户: $uname 程序更新通知: $result"
|
||||||
],
|
],
|
||||||
'anchor' => [
|
'anchor' => [
|
||||||
@ -127,6 +127,9 @@ class Notice
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 添加前缀
|
||||||
|
$info['title'] = "【BHP】" . $info['title'];
|
||||||
|
|
||||||
self::sendLog($info);
|
self::sendLog($info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user