Quellcode durchsuchen

长链接端口设置

evoxwht vor 4 Jahren
Ursprung
Commit
f0682531ca

+ 13 - 0
crmeb/app/adminapi/controller/v1/setting/SystemConfig.php

@@ -292,6 +292,19 @@ class SystemConfig extends AuthController
             $to = public_path() . explode('/', $post['weixin_ckeck_file'])[2];
             @copy($from, $to);
         }
+        if (isset($post['admin_port'])) {
+            $res = include(config_path() . 'workerman.php');
+            $old_admin_port = $res['admin']['port'];
+            $old_channel_port = $res['channel']['port'];
+            $admin_port = substr($post['admin_port'], strrpos($post['admin_port'], ":") + 1);
+            $channel_port = substr($post['channel_port'], strrpos($post['channel_port'], ":") + 1);
+            if ($admin_port == '') $admin_port = 999999;
+            if ($channel_port == '') $channel_port = 999999;
+            $info = file_get_contents(config_path() . 'workerman.php');
+            $info = str_replace($old_admin_port, $admin_port, $info);
+            $info = str_replace($old_channel_port, $channel_port, $info);
+            file_put_contents(config_path() . 'workerman.php', $info);
+        }
         \crmeb\services\CacheService::clear();
         return app('json')->success('修改成功');
 

+ 4 - 6
crmeb/app/common.php

@@ -24,12 +24,10 @@ if (!function_exists('getWorkerManUrl')) {
      */
     function getWorkerManUrl()
     {
-        $res = Config::get('workerman');
-        $ws = sys_config('wss_open', 0) ? 'wss' : 'ws';
-        $site_url = sys_config('site_url');
-        $site = substr($site_url, strpos($site_url, ':'));
-        $data['chat'] = $ws . $site . ':' . $res['chat']['port'];
-        $data['admin'] = $ws . $site . ':' . $res['admin']['port'];
+        $ws = sys_config('wss_open', 0) ? 'wss://' : 'ws://';
+        $data['chat'] = $ws . sys_config('chat_port', '');
+        $data['admin'] = $ws . sys_config('admin_port', '');
+        $data['channel'] = $ws . sys_config('channel_port', '');
         return $data;
     }
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 6 - 2
crmeb/public/install/crmeb.sql