forked from github/dataease
fix: nginx前后分离部署
This commit is contained in:
parent
abe6f072c9
commit
995fe08298
104
backend/pom.xml
104
backend/pom.xml
@ -407,48 +407,74 @@
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<?m2e execute onConfiguration?>
|
||||
<id>main-class-placement</id>
|
||||
<phase>generate-resources</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<move todir="src/main/resources/static">
|
||||
<fileset dir="../frontend/dist">
|
||||
<exclude name="*.html"/>
|
||||
</fileset>
|
||||
</move>
|
||||
<move todir="src/main/resources/templates">
|
||||
<fileset dir="../frontend/dist">
|
||||
<include name="*.html"/>
|
||||
</fileset>
|
||||
</move>
|
||||
|
||||
<copy todir="src/main/resources/static/de-app">
|
||||
<fileset dir="../mobile/dist">
|
||||
<exclude name="*.html"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
|
||||
<copy file="../mobile/dist/index.html" tofile="src/main/resources/templates/app.html" />
|
||||
|
||||
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>whole</id>
|
||||
<properties>
|
||||
<profiles.active>whole</profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<?m2e execute onConfiguration?>
|
||||
<id>main-class-placement</id>
|
||||
<phase>generate-resources</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<move todir="src/main/resources/static">
|
||||
<fileset dir="../frontend/dist">
|
||||
<exclude name="*.html"/>
|
||||
</fileset>
|
||||
</move>
|
||||
<move todir="src/main/resources/templates">
|
||||
<fileset dir="../frontend/dist">
|
||||
<include name="*.html"/>
|
||||
</fileset>
|
||||
</move>
|
||||
|
||||
<copy todir="src/main/resources/static/de-app">
|
||||
<fileset dir="../mobile/dist">
|
||||
<exclude name="*.html"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
|
||||
<copy file="../mobile/dist/index.html" tofile="src/main/resources/templates/app.html" />
|
||||
|
||||
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>stage</id>
|
||||
<properties>
|
||||
<profiles.active>stage</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>pentaho-public</id>
|
||||
|
@ -53,7 +53,7 @@ public class IndexController {
|
||||
String url;
|
||||
if (CodingUtil.isNumeric(index)) {
|
||||
url = panelLinkService.getUrlByIndex(Long.parseLong(index));
|
||||
}else {
|
||||
} else {
|
||||
url = panelLinkService.getUrlByUuid(index);
|
||||
}
|
||||
HttpServletResponse response = ServletUtils.response();
|
||||
@ -65,8 +65,6 @@ public class IndexController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/tempMobileLink/{id}/{token}")
|
||||
public void tempMobileLink(@PathVariable("id") String id, @PathVariable("token") String token) {
|
||||
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.PanelLinkMappingMapper;
|
||||
import io.dataease.base.mapper.ext.ExtPanelLinkMapper;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
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.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -27,7 +27,6 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class PanelLinkService {
|
||||
@ -36,6 +35,9 @@ public class PanelLinkService {
|
||||
private static final String USERPARAM = "&user=";
|
||||
private static final String SHORT_URL_PREFIX = "/link/";
|
||||
|
||||
@Value("${server.servlet.context-path}")
|
||||
private String contextPath;
|
||||
|
||||
@Resource
|
||||
private PanelLinkMapper mapper;
|
||||
@Resource
|
||||
@ -60,7 +62,7 @@ public class PanelLinkService {
|
||||
panelLinkMappingMapper.updateByExampleSelective(mapping, example);
|
||||
}
|
||||
|
||||
private PanelLinkExample example(String panelLinkId, Long userId){
|
||||
private PanelLinkExample example(String panelLinkId, Long userId) {
|
||||
PanelLinkExample example = new PanelLinkExample();
|
||||
example.createCriteria().andResourceIdEqualTo(panelLinkId).andUserIdEqualTo(userId);
|
||||
return example;
|
||||
@ -88,18 +90,18 @@ public class PanelLinkService {
|
||||
private PanelLink findOne(String resourceId) {
|
||||
PanelLinkExample example = new PanelLinkExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andUserIdIsNull();
|
||||
List<PanelLink> list = mapper.selectByExample(example);
|
||||
List<PanelLink> list = mapper.selectByExample(example);
|
||||
return CollectionUtils.isNotEmpty(list) ? list.get(0) : null;
|
||||
}
|
||||
|
||||
public PanelLink findOne(String resourceId, Long userId) {
|
||||
if(userId == null){
|
||||
if (userId == null) {
|
||||
return findOne(resourceId);
|
||||
}
|
||||
List<PanelLink> panelLinks = mapper.selectByExample(example(resourceId, userId));
|
||||
if(CollectionUtils.isNotEmpty(panelLinks)){
|
||||
if (CollectionUtils.isNotEmpty(panelLinks)) {
|
||||
return panelLinks.get(0);
|
||||
}else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -152,8 +154,8 @@ public class PanelLinkService {
|
||||
|
||||
private String buildLinkParam(PanelLink link) {
|
||||
String linkParam = encrypt(link.getResourceId());
|
||||
if(link.getUserId() != null){
|
||||
linkParam = linkParam+ USERPARAM + link.getUserId().toString();
|
||||
if (link.getUserId() != null) {
|
||||
linkParam = linkParam + USERPARAM + link.getUserId().toString();
|
||||
}
|
||||
return linkParam;
|
||||
}
|
||||
@ -172,7 +174,8 @@ public class PanelLinkService {
|
||||
public Boolean validateHeads(PanelLink panelLink) throws Exception {
|
||||
HttpServletRequest request = ServletUtils.request();
|
||||
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 pwd = "dataease";
|
||||
String tk = JWTUtils.signLink(resourceId, panelLink.getUserId(), pwd);
|
||||
@ -181,7 +184,8 @@ public class PanelLinkService {
|
||||
httpServletResponse.setHeader("LINK-PWD-TOKEN", tk);
|
||||
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());
|
||||
}
|
||||
|
||||
@ -218,7 +222,7 @@ public class PanelLinkService {
|
||||
List<PanelLinkMapping> mappings = panelLinkMappingMapper.selectByExample(example);
|
||||
PanelLinkMapping mapping = mappings.get(0);
|
||||
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) {
|
||||
|
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
|
||||
|
||||
server.port=8081
|
||||
|
@ -4,5 +4,5 @@ NODE_ENV = production
|
||||
ENV = 'staging'
|
||||
|
||||
# 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 = () => {
|
||||
let time = 10
|
||||
const url = '/system/requestTimeOut'
|
||||
const url = process.env.VUE_APP_BASE_API + 'system/requestTimeOut'
|
||||
const xhr = new XMLHttpRequest()
|
||||
xhr.onreadystatechange = () => {
|
||||
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": {
|
||||
"serve": "npm run dev: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: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",
|
||||
|
Loading…
Reference in New Issue
Block a user