diff --git a/NOTIFY.md b/NOTIFY.md index 5a84ed5..c86cc33 100644 --- a/NOTIFY.md +++ b/NOTIFY.md @@ -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 diff --git a/data/latest_version.json b/data/latest_version.json index 1350ba1..84c8de1 100644 --- a/data/latest_version.json +++ b/data/latest_version.json @@ -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" } \ No newline at end of file diff --git a/src/core/Helpers.php b/src/core/Helpers.php index f3128dd..28a99dd 100644 --- a/src/core/Helpers.php +++ b/src/core/Helpers.php @@ -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; } /** diff --git a/src/plugin/AloneTcpClient.php b/src/plugin/AloneTcpClient.php index 2882472..094d814 100644 --- a/src/plugin/AloneTcpClient.php +++ b/src/plugin/AloneTcpClient.php @@ -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]; } diff --git a/src/plugin/CheckUpdate.php b/src/plugin/CheckUpdate.php index 813ece4..fe2ba23 100644 --- a/src/plugin/CheckUpdate.php +++ b/src/plugin/CheckUpdate.php @@ -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); + } + } \ No newline at end of file diff --git a/src/plugin/Notice.php b/src/plugin/Notice.php index 691f512..4c60b1a 100644 --- a/src/plugin/Notice.php +++ b/src/plugin/Notice.php @@ -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; }