feat: 动态设置访问路径前缀

This commit is contained in:
fit2cloud-chenyw 2023-09-22 13:28:37 +08:00
parent 7565161c2d
commit 6b190e83ea
5 changed files with 14 additions and 2 deletions

View File

@ -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 增加仪表板外部参数

View File

@ -5,3 +5,5 @@ ENV = 'production'
# VUE_APP_BASE_API = 'http://localhost:8081/'
VUE_APP_BASE_API = '/'
VUE_CONTEXT_PATH = '/'

View File

@ -6,3 +6,5 @@ ENV = 'staging'
# base api
VUE_APP_BASE_API = '/de-api/'
VUE_CONTEXT_PATH = 'de-api/'

View File

@ -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
}

View File

@ -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: [