From a325868e08e13841b4a5967016ee5292baf1b2fe Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 5 Jun 2022 13:31:44 +0800 Subject: [PATCH] =?UTF-8?q?makeServerUrl(...)=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20servXxx=20=E5=8F=98=E9=87=8F=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E7=8E=AF=E5=A2=83=E6=9D=A5=E8=AE=BE=E7=BD=AE=20servXx?= =?UTF-8?q?x=EF=BC=8C=E4=B8=8D=E5=86=8D=E4=BD=BF=E7=94=A8=20servXxxDev=20?= =?UTF-8?q?=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usertool.js | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/usertool.js b/usertool.js index 761874e..f2925c6 100644 --- a/usertool.js +++ b/usertool.js @@ -70,8 +70,7 @@ export default { }) // #ifdef H5 - document.title = - windowTitle || wo?.envar?.Sys_Brand_Name?.[mylang] || pagesJson?.appInfo?.i18nText?.[mylang] || pagesJson?.globalStyle?.navigationBarTitleText // 必须放在 setNavigationBarTitle 之后,否则会被其覆盖掉。 + document.title = windowTitle || wo?.envar?.callname?.[mylang] || pagesJson?.appInfo?.i18nText?.[mylang] || pagesJson?.globalStyle?.navigationBarTitleText // 必须放在 setNavigationBarTitle 之后,否则会被其覆盖掉。 // #endif // 必须要在有 tab 的页面里 setTabBarItem 才有效果 @@ -119,26 +118,18 @@ export default { return route } - let protocol, hostname, port - - if (process.env.NODE_ENV === 'production') { - protocol = envar.servProtocol || 'https' - hostname = envar.servHostname - port = envar.servPort - } else { - protocol = envar.servProtocolDev || 'http' - hostname = - envar.servHostnameDev || - // #ifdef H5 - window.location.hostname - // #endif - port = - envar.servPortDev || - envar.servPort || - // #ifdef H5 - window.location.port.replace(':', '') - // #endif + const protocol = envar.servProtocol || (process.env.NODE_ENV === 'production' ? 'https' : 'http') + let hostname = envar.servHostname + let port = envar.servPort + // #ifdef H5 + if (!hostname) { + hostname = window?.location?.hostname } + if (!port) { + port = window?.location?.port?.replace(':', '') + } + // #endif + return `${protocol}://${hostname}:${port}/${route.replace(/^\//, '')}` },