diff --git a/application/wechat/controller/Config.php b/application/wechat/controller/Config.php index 333604aea..48de3aae8 100644 --- a/application/wechat/controller/Config.php +++ b/application/wechat/controller/Config.php @@ -17,6 +17,7 @@ namespace app\wechat\controller; use controller\BasicAdmin; use service\LogService; use service\WechatService; +use think\Exception; /** * 微信配置管理 @@ -44,13 +45,18 @@ class Config extends BasicAdmin { if ($this->request->isGet()) { $code = encode(url('@admin', '', true, true) . '#' . $this->request->url()); + try { + $info = WechatService::instance('config')->getConfig(); + } catch (Exception $e) { + $info = []; + } return $this->fetch('', [ 'title' => '微信接口配置', 'appuri' => url("@wechat/api.push", '', true, true), 'appid' => $this->request->get('appid', sysconf('wechat_thr_appid')), 'appkey' => $this->request->get('appkey', sysconf('wechat_thr_appkey')), 'authurl' => "http://wm.cuci.cc/wechat/api.push/auth/{$code}.html", - 'wechat' => WechatService::instance('config')->getConfig(), + 'wechat' => $info, ]); } try { diff --git a/extend/service/WechatService.php b/extend/service/WechatService.php index a0a187530..40404007c 100644 --- a/extend/service/WechatService.php +++ b/extend/service/WechatService.php @@ -69,9 +69,6 @@ class WechatService 'ssl_key' => sysconf('wechat_cert_key'), 'cachepath' => env('cache_path') . 'wechat' . DIRECTORY_SEPARATOR, ]; - if (in_array(strtolower($name), ['wechat', 'config'])) { - $name = 'user'; - } $type = '\\WeChat\\' . ucfirst(strtolower($name)); return new $type($config); case 'thr':