From ebc386133f001c0baa4c653e89309533b5f27bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E5=90=AF=E9=BE=99?= Date: Sun, 1 Sep 2024 15:40:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20iframe=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/utils/url.ts | 11 +++++++---- webs/log-web/src/views/iframe.vue | 6 +++--- webs/oms-web/src/views/iframe.vue | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/common/utils/url.ts b/packages/common/utils/url.ts index 7e723ac..20c0fae 100644 --- a/packages/common/utils/url.ts +++ b/packages/common/utils/url.ts @@ -9,10 +9,13 @@ export function appendParamsToUrl(url: string, pathname: string, params: Record< for (const key in params) { searchParams.append(key, params[key]) } - // 设置URL的查询参数 - urlObject.search = searchParams.toString() - + let result = urlObject.toString() + if (result.endsWith('?')) { + result += searchParams.toString() + } else { + result += '?' + searchParams.toString() + } // 返回处理后的URL字符串 - return urlObject.toString() + return result } diff --git a/webs/log-web/src/views/iframe.vue b/webs/log-web/src/views/iframe.vue index c754949..51a4303 100644 --- a/webs/log-web/src/views/iframe.vue +++ b/webs/log-web/src/views/iframe.vue @@ -26,9 +26,9 @@ export default { token: getToken(), ...(this.$route.query || {}) } - const url = appendParamsToUrl(this.url, this.$route.path, params) - console.log('iframeUrl: ', url.toString()) - return url.toString() + const url = appendParamsToUrl(this.url, this.$route.path + this.$route.meta?.pathname, params) + console.log('iframeUrl: ', url) + return url } }, methods: { diff --git a/webs/oms-web/src/views/iframe.vue b/webs/oms-web/src/views/iframe.vue index 9f8c10a..13f9487 100644 --- a/webs/oms-web/src/views/iframe.vue +++ b/webs/oms-web/src/views/iframe.vue @@ -26,9 +26,9 @@ export default { token: getToken(), ...(this.$route.query || {}) } - const url = appendParamsToUrl(this.url, this.$route.path, params) - console.log('iframeUrl: ', url.toString()) - return url.toString() + const url = appendParamsToUrl(this.url, this.$route.path + this.$route.meta?.pathname, params) + console.log('iframeUrl: ', url) + return url } }, methods: {