From 6b190e83ea3880444b66f5d88381596872abe4b4 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 22 Sep 2023 13:28:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=A8=E6=80=81=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E8=B7=AF=E5=BE=84=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/dataease/controller/IndexController.java | 7 +++++++ core/frontend/.env.production | 2 ++ core/frontend/.env.staging | 2 ++ core/frontend/public/link.html | 3 ++- core/frontend/vue.config.js | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/backend/src/main/java/io/dataease/controller/IndexController.java b/core/backend/src/main/java/io/dataease/controller/IndexController.java index 857ab7eadc..baae2b4468 100644 --- a/core/backend/src/main/java/io/dataease/controller/IndexController.java +++ b/core/backend/src/main/java/io/dataease/controller/IndexController.java @@ -7,6 +7,7 @@ import io.dataease.commons.utils.LogUtil; import io.dataease.commons.utils.ServletUtils; import io.dataease.service.panel.PanelLinkService; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -29,6 +30,9 @@ public class IndexController { @Resource private PanelLinkService panelLinkService; + @Value("${server.servlet.context-path:#{null}}") + private String contextPath; + @GetMapping(value = "/") public String index() { return "index.html"; @@ -52,6 +56,9 @@ public class IndexController { } else { url = panelLinkService.getUrlByUuid(index); } + if (StringUtils.isNotBlank(contextPath)) { + url = contextPath + url; + } HttpServletResponse response = ServletUtils.response(); try { // TODO 增加仪表板外部参数 diff --git a/core/frontend/.env.production b/core/frontend/.env.production index d24a4671c1..ad684689e8 100644 --- a/core/frontend/.env.production +++ b/core/frontend/.env.production @@ -5,3 +5,5 @@ ENV = 'production' # VUE_APP_BASE_API = 'http://localhost:8081/' VUE_APP_BASE_API = '/' +VUE_CONTEXT_PATH = '/' + diff --git a/core/frontend/.env.staging b/core/frontend/.env.staging index 44c8f6dec2..cf0eaefd52 100644 --- a/core/frontend/.env.staging +++ b/core/frontend/.env.staging @@ -6,3 +6,5 @@ ENV = 'staging' # base api VUE_APP_BASE_API = '/de-api/' +VUE_CONTEXT_PATH = 'de-api/' + diff --git a/core/frontend/public/link.html b/core/frontend/public/link.html index d7bae4999a..38887b0b69 100644 --- a/core/frontend/public/link.html +++ b/core/frontend/public/link.html @@ -33,7 +33,8 @@ const user = getQueryVariable('user') const terminal = getQueryVariable('terminal') const attachParams = getQueryVariable('attachParams') - let url = "/#/delink?link=" + encodeURIComponent(link) + const baseUrl = window.location.pathname.replace('link.html', '') + let url = baseUrl + "#/delink?link=" + encodeURIComponent(link) if (terminal) { url += '&terminal=' + terminal } diff --git a/core/frontend/vue.config.js b/core/frontend/vue.config.js index 7d261bfdf8..dc0d168899 100644 --- a/core/frontend/vue.config.js +++ b/core/frontend/vue.config.js @@ -18,6 +18,7 @@ const port = process.env.port || process.env.npm_config_port || 9528 // dev port const parallel = process.env.NODE_ENV === 'development' module.exports = { productionSourceMap: false, + publicPath: process.env.VUE_CONTEXT_PATH, parallel, // 使用mock-server devServer: { @@ -52,7 +53,6 @@ module.exports = { }, output: process.env.NODE_ENV === 'development' ? {} : { filename: `js/[name].[contenthash:8].${pkg.version}.js`, - publicPath: '/', chunkFilename: `js/[name].[contenthash:8].${pkg.version}.js` }, plugins: [