zhb há 1 mês atrás
pai
commit
6477d34095
1 ficheiros alterados com 4 adições e 6 exclusões
  1. 4 6
      config/index.ts

+ 4 - 6
config/index.ts

@@ -1,11 +1,9 @@
 // #ifdef H5
-let ht = window.location.protocol;
-let hostParts = window.location.host.split('.');
-let ho = hostParts[hostParts.length - 2]; // 主域名
-let dt = hostParts[hostParts.length - 1]; // 域名后缀
+let [p, h] = [window.location.protocol, window.location.host];
+let isIP = /^\d+\.\d+\.\d+\.\d+:\d+$/.test(h);
+let [ho, dt] = isIP ? ['44a5c8109e4', 'com'] : h.split('.').slice(-2);
+let ht = p == 'http:' ? 'https:' : p;
 console.log(ho, dt, ht, 1009);
-ht = ht == 'http:' ? 'https:' : ht;
-ho = ho == '168' ? '44a5c8109e4' : ho;
 // #else
 let ht = 'https:';
 let ho = '44a5c8109e4'; // 默认主域名或可根据实际APP环境配置