mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 01:20:08 +08:00
[update] Version compatible
This commit is contained in:
parent
3b015424a7
commit
1c19204456
@ -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
|
||||
|
||||
@ -5,7 +5,10 @@
|
||||
"source": "https://github.com/lkeme/BiliHelper-personal",
|
||||
"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",
|
||||
"version": "1.0.2.211115",
|
||||
"version": "1.0.2.211114",
|
||||
"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 开关
|
||||
* @param string $plugin
|
||||
* @param bool $default
|
||||
* @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
|
||||
* @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];
|
||||
}
|
||||
|
||||
@ -43,15 +43,28 @@ class CheckUpdate
|
||||
self::loadJsonData();
|
||||
Log::info('拉取线上最新配置');
|
||||
self::fetchLatest();
|
||||
// 检测项目版本
|
||||
if (!self::compareVersion()) {
|
||||
Log::info('项目已是最新版本');
|
||||
Log::info('程序已是最新版本');
|
||||
} else {
|
||||
Log::notice('项目有更新');
|
||||
// Todo 完善提示信息
|
||||
$time = self::$latest_conf->get('time');
|
||||
$version = self::$latest_conf->get('version');
|
||||
$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);
|
||||
}
|
||||
}
|
||||
@ -87,4 +100,16 @@ class CheckUpdate
|
||||
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');
|
||||
$info = match ($type) {
|
||||
'update' => [
|
||||
'title' => '程序更新通知',
|
||||
'title' => '版本更新通知',
|
||||
'content' => "[$now_time] 用户: $uname 程序更新通知: $result"
|
||||
],
|
||||
'anchor' => [
|
||||
@ -127,6 +127,9 @@ class Notice
|
||||
],
|
||||
};
|
||||
|
||||
// 添加前缀
|
||||
$info['title'] = "【BHP】" . $info['title'];
|
||||
|
||||
self::sendLog($info);
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user