forked from github/dataease
fix: nginx前后分离部署
This commit is contained in:
parent
abe6f072c9
commit
995fe08298
@ -407,6 +407,22 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>whole</id>
|
||||||
|
<properties>
|
||||||
|
<profiles.active>whole</profiles.active>
|
||||||
|
</properties>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
@ -448,6 +464,16 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>stage</id>
|
||||||
|
<properties>
|
||||||
|
<profiles.active>stage</profiles.active>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
|
@ -53,7 +53,7 @@ public class IndexController {
|
|||||||
String url;
|
String url;
|
||||||
if (CodingUtil.isNumeric(index)) {
|
if (CodingUtil.isNumeric(index)) {
|
||||||
url = panelLinkService.getUrlByIndex(Long.parseLong(index));
|
url = panelLinkService.getUrlByIndex(Long.parseLong(index));
|
||||||
}else {
|
} else {
|
||||||
url = panelLinkService.getUrlByUuid(index);
|
url = panelLinkService.getUrlByUuid(index);
|
||||||
}
|
}
|
||||||
HttpServletResponse response = ServletUtils.response();
|
HttpServletResponse response = ServletUtils.response();
|
||||||
@ -65,8 +65,6 @@ public class IndexController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/tempMobileLink/{id}/{token}")
|
@GetMapping("/tempMobileLink/{id}/{token}")
|
||||||
public void tempMobileLink(@PathVariable("id") String id, @PathVariable("token") String token) {
|
public void tempMobileLink(@PathVariable("id") String id, @PathVariable("token") String token) {
|
||||||
String url = "/#preview/" + id;
|
String url = "/#preview/" + id;
|
||||||
|
@ -8,7 +8,6 @@ import io.dataease.base.mapper.PanelGroupMapper;
|
|||||||
import io.dataease.base.mapper.PanelLinkMapper;
|
import io.dataease.base.mapper.PanelLinkMapper;
|
||||||
import io.dataease.base.mapper.PanelLinkMappingMapper;
|
import io.dataease.base.mapper.PanelLinkMappingMapper;
|
||||||
import io.dataease.base.mapper.ext.ExtPanelLinkMapper;
|
import io.dataease.base.mapper.ext.ExtPanelLinkMapper;
|
||||||
import io.dataease.commons.exception.DEException;
|
|
||||||
import io.dataease.commons.utils.AuthUtils;
|
import io.dataease.commons.utils.AuthUtils;
|
||||||
import io.dataease.commons.utils.CodingUtil;
|
import io.dataease.commons.utils.CodingUtil;
|
||||||
import io.dataease.commons.utils.ServletUtils;
|
import io.dataease.commons.utils.ServletUtils;
|
||||||
@ -20,6 +19,7 @@ import io.dataease.dto.panel.link.GenerateDto;
|
|||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -27,7 +27,6 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PanelLinkService {
|
public class PanelLinkService {
|
||||||
@ -36,6 +35,9 @@ public class PanelLinkService {
|
|||||||
private static final String USERPARAM = "&user=";
|
private static final String USERPARAM = "&user=";
|
||||||
private static final String SHORT_URL_PREFIX = "/link/";
|
private static final String SHORT_URL_PREFIX = "/link/";
|
||||||
|
|
||||||
|
@Value("${server.servlet.context-path}")
|
||||||
|
private String contextPath;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PanelLinkMapper mapper;
|
private PanelLinkMapper mapper;
|
||||||
@Resource
|
@Resource
|
||||||
@ -60,7 +62,7 @@ public class PanelLinkService {
|
|||||||
panelLinkMappingMapper.updateByExampleSelective(mapping, example);
|
panelLinkMappingMapper.updateByExampleSelective(mapping, example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PanelLinkExample example(String panelLinkId, Long userId){
|
private PanelLinkExample example(String panelLinkId, Long userId) {
|
||||||
PanelLinkExample example = new PanelLinkExample();
|
PanelLinkExample example = new PanelLinkExample();
|
||||||
example.createCriteria().andResourceIdEqualTo(panelLinkId).andUserIdEqualTo(userId);
|
example.createCriteria().andResourceIdEqualTo(panelLinkId).andUserIdEqualTo(userId);
|
||||||
return example;
|
return example;
|
||||||
@ -93,13 +95,13 @@ public class PanelLinkService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PanelLink findOne(String resourceId, Long userId) {
|
public PanelLink findOne(String resourceId, Long userId) {
|
||||||
if(userId == null){
|
if (userId == null) {
|
||||||
return findOne(resourceId);
|
return findOne(resourceId);
|
||||||
}
|
}
|
||||||
List<PanelLink> panelLinks = mapper.selectByExample(example(resourceId, userId));
|
List<PanelLink> panelLinks = mapper.selectByExample(example(resourceId, userId));
|
||||||
if(CollectionUtils.isNotEmpty(panelLinks)){
|
if (CollectionUtils.isNotEmpty(panelLinks)) {
|
||||||
return panelLinks.get(0);
|
return panelLinks.get(0);
|
||||||
}else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,8 +154,8 @@ public class PanelLinkService {
|
|||||||
|
|
||||||
private String buildLinkParam(PanelLink link) {
|
private String buildLinkParam(PanelLink link) {
|
||||||
String linkParam = encrypt(link.getResourceId());
|
String linkParam = encrypt(link.getResourceId());
|
||||||
if(link.getUserId() != null){
|
if (link.getUserId() != null) {
|
||||||
linkParam = linkParam+ USERPARAM + link.getUserId().toString();
|
linkParam = linkParam + USERPARAM + link.getUserId().toString();
|
||||||
}
|
}
|
||||||
return linkParam;
|
return linkParam;
|
||||||
}
|
}
|
||||||
@ -172,7 +174,8 @@ public class PanelLinkService {
|
|||||||
public Boolean validateHeads(PanelLink panelLink) throws Exception {
|
public Boolean validateHeads(PanelLink panelLink) throws Exception {
|
||||||
HttpServletRequest request = ServletUtils.request();
|
HttpServletRequest request = ServletUtils.request();
|
||||||
String token = request.getHeader("LINK-PWD-TOKEN");
|
String token = request.getHeader("LINK-PWD-TOKEN");
|
||||||
if (!panelLink.getEnablePwd() || StringUtils.isEmpty(token) || StringUtils.equals("undefined", token) || StringUtils.equals("null", token)) {
|
if (!panelLink.getEnablePwd() || StringUtils.isEmpty(token) || StringUtils.equals("undefined", token)
|
||||||
|
|| StringUtils.equals("null", token)) {
|
||||||
String resourceId = panelLink.getResourceId();
|
String resourceId = panelLink.getResourceId();
|
||||||
String pwd = "dataease";
|
String pwd = "dataease";
|
||||||
String tk = JWTUtils.signLink(resourceId, panelLink.getUserId(), pwd);
|
String tk = JWTUtils.signLink(resourceId, panelLink.getUserId(), pwd);
|
||||||
@ -181,7 +184,8 @@ public class PanelLinkService {
|
|||||||
httpServletResponse.setHeader("LINK-PWD-TOKEN", tk);
|
httpServletResponse.setHeader("LINK-PWD-TOKEN", tk);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(panelLink.getPwd())) return false;
|
if (StringUtils.isEmpty(panelLink.getPwd()))
|
||||||
|
return false;
|
||||||
return JWTUtils.verifyLink(token, panelLink.getResourceId(), panelLink.getUserId(), panelLink.getPwd());
|
return JWTUtils.verifyLink(token, panelLink.getResourceId(), panelLink.getUserId(), panelLink.getPwd());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +222,7 @@ public class PanelLinkService {
|
|||||||
List<PanelLinkMapping> mappings = panelLinkMappingMapper.selectByExample(example);
|
List<PanelLinkMapping> mappings = panelLinkMappingMapper.selectByExample(example);
|
||||||
PanelLinkMapping mapping = mappings.get(0);
|
PanelLinkMapping mapping = mappings.get(0);
|
||||||
String uuid = mapping.getUuid();
|
String uuid = mapping.getUuid();
|
||||||
return SHORT_URL_PREFIX + (StringUtils.isBlank(uuid) ? mapping.getId() : uuid);
|
return contextPath + SHORT_URL_PREFIX + (StringUtils.isBlank(uuid) ? mapping.getId() : uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrlByIndex(Long index) {
|
public String getUrlByIndex(Long index) {
|
||||||
|
1
backend/src/main/resources/application-stage.properties
Normal file
1
backend/src/main/resources/application-stage.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
server.servlet.context-path=/de-api
|
1
backend/src/main/resources/application-whole.properties
Normal file
1
backend/src/main/resources/application-whole.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
server.servlet.context-path=
|
@ -1,3 +1,4 @@
|
|||||||
|
spring.profiles.active=@profiles.active@
|
||||||
spring.application.name=dataease
|
spring.application.name=dataease
|
||||||
|
|
||||||
server.port=8081
|
server.port=8081
|
||||||
|
@ -4,5 +4,5 @@ NODE_ENV = production
|
|||||||
ENV = 'staging'
|
ENV = 'staging'
|
||||||
|
|
||||||
# base api
|
# base api
|
||||||
VUE_APP_BASE_API = '/stage-api'
|
VUE_APP_BASE_API = '/de-api/'
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import Cookies from 'js-cookie'
|
|||||||
|
|
||||||
const getTimeOut = () => {
|
const getTimeOut = () => {
|
||||||
let time = 10
|
let time = 10
|
||||||
const url = '/system/requestTimeOut'
|
const url = process.env.VUE_APP_BASE_API + 'system/requestTimeOut'
|
||||||
const xhr = new XMLHttpRequest()
|
const xhr = new XMLHttpRequest()
|
||||||
xhr.onreadystatechange = () => {
|
xhr.onreadystatechange = () => {
|
||||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||||
|
8
mobile/.env.staging
Normal file
8
mobile/.env.staging
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
NODE_ENV = production
|
||||||
|
|
||||||
|
# just a flag
|
||||||
|
ENV = 'staging'
|
||||||
|
|
||||||
|
# base api
|
||||||
|
VUE_APP_BASE_API = '/de-api/'
|
||||||
|
|
@ -5,6 +5,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "npm run dev:h5",
|
"serve": "npm run dev:h5",
|
||||||
"build": "npm run build:h5",
|
"build": "npm run build:h5",
|
||||||
|
"build:stage": "npm run build:h5:stage",
|
||||||
|
"build:h5:stage": "cross-env NODE_ENV=production UNI_PLATFORM=h5 UNI_OUTPUT_DIR=dist vue-cli-service uni-build --mode staging",
|
||||||
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
|
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
|
||||||
"build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
|
"build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
|
||||||
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 UNI_OUTPUT_DIR=dist vue-cli-service uni-build",
|
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 UNI_OUTPUT_DIR=dist vue-cli-service uni-build",
|
||||||
|
Loading…
Reference in New Issue
Block a user