From aca1a4d34c22ae596481a2647cb1ac2bcf402795 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 14 Jan 2022 16:56:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ws=E8=BF=94=E5=9B=9E=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Module/Base.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/Module/Base.php b/app/Module/Base.php index d246835c..9673b351 100755 --- a/app/Module/Base.php +++ b/app/Module/Base.php @@ -756,7 +756,11 @@ class Base ) { return $str; } else { - return Base::leftDelete(url($str), "http://localhost"); + $url = url($str); + if (str_starts_with($url, "http://localhost/")) { + $url = self::localhostAndPort() . substr($url, 17); + } + return $url; } } @@ -773,8 +777,16 @@ class Base } return $str; } - $find = url(''); - return Base::leftDelete($str, $find . '/'); + $str = Base::leftDelete($str, url('') . '/'); + return Base::leftDelete($str, self::localhostAndPort()); + } + + /** + * 获取localhost和端口,如:http://localhost:8888/ + * @return string + */ + public static function localhostAndPort() { + return "http://localhost:" . env("APP_PORT", "80") . "/"; } /**