From ec0420fb511804f40321aab88a9025e147cf54f4 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Mon, 21 Nov 2022 14:24:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=9B=B4=E6=96=B0=E5=BF=85?= =?UTF-8?q?=E9=A1=BB=E5=85=88=E6=9B=B4=E6=96=B0=E5=BE=85=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/PluginsService.php | 45 +++++++++++++++++++++++++++- app/service/SystemUpgradeService.php | 9 ++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/app/service/PluginsService.php b/app/service/PluginsService.php index 630885246..fcb421513 100755 --- a/app/service/PluginsService.php +++ b/app/service/PluginsService.php @@ -523,7 +523,7 @@ class PluginsService $time = 3600; $key = 'plugins_upgrade_check_info'; $res = MyCache($key); - if(empty($res)) + if(empty($res) || (isset($params['is_force_new']) && $params['is_force_new'] == 1)) { if(!empty($params) && !empty($params['db_data']) && is_array($params['db_data'])) { @@ -587,5 +587,48 @@ class PluginsService $data = Db::name('Plugins')->field('id,name,plugins')->where(['is_enable'=>1])->order(PluginsAdminService::$plugins_order_by)->select()->toArray(); return empty($data) ? [] : $data; } + + /** + * 插件新版本检查 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2022-11-21 + * @desc description + * @param [string] $plugins [插件标识、空则全部] + */ + public static function PluginsNewVersionCheck($plugins = '') + { + // 是否存在插件未更新的情况 + $where = empty($plugins) ? [] : ['plugins'=>$plugins]; + $plugins_list = Db::name('Plugins')->where($where)->column('plugins'); + if(!empty($plugins_list)) + { + $data = []; + foreach($plugins_list as $plugins) + { + $config = PluginsAdminService::GetPluginsConfig($plugins); + if(!empty($config['base'])) + { + $data[$plugins] = $config['base']; + } + } + if(!empty($data)) + { + $check = self::PluginsUpgradeInfo(['db_data'=>$data, 'is_force_new'=>1]); + if(isset($check['code']) && $check['code'] == 0 && !empty($check['data'])) + { + foreach($check['data'] as $v) + { + if(isset($data[$v['plugins']])) + { + return DataReturn('('.$data[$v['plugins']]['name'].' v'.$v['version_new'].')插件有新版本待更新', -1); + } + } + } + } + } + return DataReturn('无需要更新的插件', 0); + } } ?> \ No newline at end of file diff --git a/app/service/SystemUpgradeService.php b/app/service/SystemUpgradeService.php index 0097ee7f6..0824b960d 100644 --- a/app/service/SystemUpgradeService.php +++ b/app/service/SystemUpgradeService.php @@ -11,6 +11,7 @@ namespace app\service; use app\service\SqlConsoleService; +use app\service\PluginsService; /** * 系统更新服务层 @@ -41,6 +42,14 @@ class SystemUpgradeService */ public static function Run($params = []) { + // 是否存在插件未更新的情况 + $plugins_check = PluginsService::PluginsNewVersionCheck(); + if($plugins_check['code'] != 0) + { + return $plugins_check; + } + return DataReturn('test', -1); + // 参数校验 $ret = self::ParamsCheck($params); if($ret['code'] != 0)