Commit 543da605d498f755cbaa0f20088848c2fb873b81
1 parent
82fb6b42
1、修改pom.xml,添加thymeleaf依赖
2、创建lubanPage, lubanPagePreview页面结合thymeleaf动态生成页面(后面还要完善) 3、创建BsthSlideItem.js,结合java8的nashorn引擎处理后台work对象,查找定义轮播组件的url信息 4、修改WorkService,添加createZipPage方法生成打包文件
Showing
8 changed files
with
248 additions
and
123 deletions
Too many changes to show.
To preserve performance only 8 of 15 files are displayed.
pom.xml
| @@ -35,6 +35,10 @@ | @@ -35,6 +35,10 @@ | ||
| 35 | <groupId>org.springframework.boot</groupId> | 35 | <groupId>org.springframework.boot</groupId> |
| 36 | <artifactId>spring-boot-starter-web</artifactId> | 36 | <artifactId>spring-boot-starter-web</artifactId> |
| 37 | </dependency> | 37 | </dependency> |
| 38 | + <dependency> | ||
| 39 | + <groupId>org.springframework.boot</groupId> | ||
| 40 | + <artifactId>spring-boot-starter-thymeleaf</artifactId> | ||
| 41 | + </dependency> | ||
| 38 | 42 | ||
| 39 | <dependency> | 43 | <dependency> |
| 40 | <groupId>mysql</groupId> | 44 | <groupId>mysql</groupId> |
src/main/java/com/bsth/luban_springboot2/controller/WorkController.java
| @@ -12,6 +12,7 @@ import org.springframework.data.domain.Sort; | @@ -12,6 +12,7 @@ import org.springframework.data.domain.Sort; | ||
| 12 | import org.springframework.http.HttpStatus; | 12 | import org.springframework.http.HttpStatus; |
| 13 | import org.springframework.web.bind.WebDataBinder; | 13 | import org.springframework.web.bind.WebDataBinder; |
| 14 | import org.springframework.web.bind.annotation.*; | 14 | import org.springframework.web.bind.annotation.*; |
| 15 | +import org.springframework.web.servlet.ModelAndView; | ||
| 15 | 16 | ||
| 16 | import javax.validation.Valid; | 17 | import javax.validation.Valid; |
| 17 | import java.util.List; | 18 | import java.util.List; |
| @@ -99,4 +100,25 @@ public class WorkController { | @@ -99,4 +100,25 @@ public class WorkController { | ||
| 99 | return this.workService.useTemplate(id); | 100 | return this.workService.useTemplate(id); |
| 100 | } | 101 | } |
| 101 | 102 | ||
| 103 | + @RequestMapping(value = "/preview/{id}") | ||
| 104 | + public ModelAndView preview( | ||
| 105 | + @PathVariable Long id, | ||
| 106 | + @RequestParam(name = "view_mode") String viewMode) { | ||
| 107 | + // TODO: | ||
| 108 | + System.out.println(id); | ||
| 109 | + System.out.println(viewMode); | ||
| 110 | + | ||
| 111 | + WorkDto workDto = workService.findWorkById(id); | ||
| 112 | + | ||
| 113 | + List<WorkService.BsthSlideItem> bsthSlideItemList = this.workService.computeZipBsthSlideUrls(id); | ||
| 114 | + | ||
| 115 | + | ||
| 116 | + // 创建并返回 ModelAndView | ||
| 117 | + ModelAndView mv = new ModelAndView(); | ||
| 118 | + mv.addObject("work", workDto); | ||
| 119 | + mv.addObject("urlItems", bsthSlideItemList); | ||
| 120 | + mv.setViewName("lubanPagePreview"); | ||
| 121 | + return mv; | ||
| 122 | + } | ||
| 123 | + | ||
| 102 | } | 124 | } |
src/main/java/com/bsth/luban_springboot2/controller/ZipController.java
| 1 | package com.bsth.luban_springboot2.controller; | 1 | package com.bsth.luban_springboot2.controller; |
| 2 | 2 | ||
| 3 | +import com.bsth.luban_springboot2.service.WorkService; | ||
| 3 | import com.bsth.luban_springboot2.utils.ZipWorkPage; | 4 | import com.bsth.luban_springboot2.utils.ZipWorkPage; |
| 4 | -import org.springframework.beans.factory.annotation.Value; | 5 | +import org.springframework.beans.factory.annotation.Autowired; |
| 5 | import org.springframework.http.HttpHeaders; | 6 | import org.springframework.http.HttpHeaders; |
| 6 | import org.springframework.http.HttpStatus; | 7 | import org.springframework.http.HttpStatus; |
| 7 | import org.springframework.http.MediaType; | 8 | import org.springframework.http.MediaType; |
| 8 | import org.springframework.http.ResponseEntity; | 9 | import org.springframework.http.ResponseEntity; |
| 9 | import org.springframework.web.bind.annotation.GetMapping; | 10 | import org.springframework.web.bind.annotation.GetMapping; |
| 11 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 10 | import org.springframework.web.bind.annotation.RequestMapping; | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
| 11 | import org.springframework.web.bind.annotation.RestController; | 13 | import org.springframework.web.bind.annotation.RestController; |
| 12 | 14 | ||
| 13 | -import java.nio.file.Paths; | ||
| 14 | - | ||
| 15 | @RestController | 15 | @RestController |
| 16 | @RequestMapping(value = "/zip_test") | 16 | @RequestMapping(value = "/zip_test") |
| 17 | public class ZipController { | 17 | public class ZipController { |
| 18 | - | ||
| 19 | - @Value("${luban_h5.zip_page.source_root_path}") | ||
| 20 | - private String sourceRootPath; | ||
| 21 | - @Value("${luban_h5.zip_page.dest_path}") | ||
| 22 | - private String destZipDirPath; | 18 | + @Autowired |
| 19 | + private WorkService workService; | ||
| 23 | 20 | ||
| 24 | /** | 21 | /** |
| 25 | * 获取打包后的Page。 | 22 | * 获取打包后的Page。 |
| 26 | * @return | 23 | * @return |
| 27 | */ | 24 | */ |
| 28 | - @GetMapping(value = "/getPage") | ||
| 29 | - public ResponseEntity<byte[]> getPage() { | 25 | + @GetMapping(value = "/getPage/{id}") |
| 26 | + public ResponseEntity<byte[]> getPage(@PathVariable Long id) { | ||
| 30 | // 打包zip文件 | 27 | // 打包zip文件 |
| 31 | - ZipWorkPage zipWorkPage = ZipWorkPage.createPageZip_LineChartList( | ||
| 32 | - Paths.get(sourceRootPath), Paths.get(destZipDirPath) | ||
| 33 | - ); | 28 | + ZipWorkPage zipWorkPage = workService.createZipPage(id); |
| 34 | byte[] zipBytes = zipWorkPage.getZipBytes(); | 29 | byte[] zipBytes = zipWorkPage.getZipBytes(); |
| 35 | 30 | ||
| 36 | // 设置header | 31 | // 设置header |
| @@ -45,17 +40,4 @@ public class ZipController { | @@ -45,17 +40,4 @@ public class ZipController { | ||
| 45 | 40 | ||
| 46 | } | 41 | } |
| 47 | 42 | ||
| 48 | - public static void main(String[] args) throws Exception { | ||
| 49 | - | ||
| 50 | - ZipWorkPage zipWorkPage = ZipWorkPage.createPageZip_van_swip( | ||
| 51 | - Paths.get("/Users/xu/resource/project_code/bsth_project/bsth_ebus/luban_springboot2/src/main/resources/static"), | ||
| 52 | - Paths.get("/Users/xu/resource/project_code/runtime_temp/zip_pages") | ||
| 53 | - ); | ||
| 54 | - | ||
| 55 | -// LocalDateTime localDateTime = LocalDateTime.now(); | ||
| 56 | -// System.out.println(localDateTime.toString()); | ||
| 57 | - | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - } | ||
| 61 | } | 43 | } |
src/main/java/com/bsth/luban_springboot2/repo/UploadFileRepo.java
| @@ -10,4 +10,5 @@ import org.springframework.stereotype.Repository; | @@ -10,4 +10,5 @@ import org.springframework.stereotype.Repository; | ||
| 10 | public interface UploadFileRepo extends BaseRepository<UploadFile, Long> { | 10 | public interface UploadFileRepo extends BaseRepository<UploadFile, Long> { |
| 11 | 11 | ||
| 12 | UploadFile findByHash(String hash); | 12 | UploadFile findByHash(String hash); |
| 13 | + UploadFile findByUrl(String url); | ||
| 13 | } | 14 | } |
src/main/java/com/bsth/luban_springboot2/service/WorkService.java
| 1 | package com.bsth.luban_springboot2.service; | 1 | package com.bsth.luban_springboot2.service; |
| 2 | 2 | ||
| 3 | import com.bsth.luban_springboot2.dto.WorkDto; | 3 | import com.bsth.luban_springboot2.dto.WorkDto; |
| 4 | +import com.bsth.luban_springboot2.utils.ZipWorkPage; | ||
| 4 | import org.springframework.data.domain.Pageable; | 5 | import org.springframework.data.domain.Pageable; |
| 5 | 6 | ||
| 6 | import java.util.List; | 7 | import java.util.List; |
| @@ -65,4 +66,74 @@ public interface WorkService { | @@ -65,4 +66,74 @@ public interface WorkService { | ||
| 65 | * @return | 66 | * @return |
| 66 | */ | 67 | */ |
| 67 | WorkDto useTemplate(Long id); | 68 | WorkDto useTemplate(Long id); |
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 创建Zip页面。 | ||
| 72 | + * @param id | ||
| 73 | + * @return | ||
| 74 | + */ | ||
| 75 | + ZipWorkPage createZipPage(Long id); | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 计算打包后的自定义轮播组件url信息。 | ||
| 79 | + * @param id 作品id | ||
| 80 | + * @return | ||
| 81 | + */ | ||
| 82 | + List<BsthSlideItem> computeZipBsthSlideUrls(Long id); | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * bsth-slide组件每个轮播的url信息。 | ||
| 86 | + */ | ||
| 87 | + static class BsthSlideItem { | ||
| 88 | + /** 组件名字 bsth-slide */ | ||
| 89 | + private String name; | ||
| 90 | + /** 每个组件都有一个uuid,对应后台work表中的pages字段 */ | ||
| 91 | + private String uuid; | ||
| 92 | + /** 原始的url路径 */ | ||
| 93 | + private List<String> urls; | ||
| 94 | + /** 实际的后台路径 */ | ||
| 95 | + private List<String> realPath; | ||
| 96 | + /** 替换后的本地路径(用于打包使用) */ | ||
| 97 | + private List<String> localUrls; | ||
| 98 | + | ||
| 99 | + public String getName() { | ||
| 100 | + return name; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + public void setName(String name) { | ||
| 104 | + this.name = name; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + public String getUuid() { | ||
| 108 | + return uuid; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public void setUuid(String uuid) { | ||
| 112 | + this.uuid = uuid; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + public List<String> getUrls() { | ||
| 116 | + return urls; | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + public void setUrls(List<String> urls) { | ||
| 120 | + this.urls = urls; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + public List<String> getLocalUrls() { | ||
| 124 | + return localUrls; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + public void setLocalUrls(List<String> localUrls) { | ||
| 128 | + this.localUrls = localUrls; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + public List<String> getRealPath() { | ||
| 132 | + return realPath; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public void setRealPath(List<String> realPath) { | ||
| 136 | + this.realPath = realPath; | ||
| 137 | + } | ||
| 138 | + } | ||
| 68 | } | 139 | } |
src/main/java/com/bsth/luban_springboot2/service/impl/WorkServiceImpl.java
| 1 | package com.bsth.luban_springboot2.service.impl; | 1 | package com.bsth.luban_springboot2.service.impl; |
| 2 | 2 | ||
| 3 | import com.bsth.luban_springboot2.dto.WorkDto; | 3 | import com.bsth.luban_springboot2.dto.WorkDto; |
| 4 | +import com.bsth.luban_springboot2.entity.UploadFile; | ||
| 4 | import com.bsth.luban_springboot2.entity.Work; | 5 | import com.bsth.luban_springboot2.entity.Work; |
| 6 | +import com.bsth.luban_springboot2.repo.UploadFileRepo; | ||
| 5 | import com.bsth.luban_springboot2.repo.WorkRepo; | 7 | import com.bsth.luban_springboot2.repo.WorkRepo; |
| 6 | import com.bsth.luban_springboot2.service.WorkService; | 8 | import com.bsth.luban_springboot2.service.WorkService; |
| 9 | +import com.bsth.luban_springboot2.utils.ZipWorkPage; | ||
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | +import org.springframework.beans.factory.annotation.Value; | ||
| 8 | import org.springframework.data.domain.Example; | 12 | import org.springframework.data.domain.Example; |
| 9 | import org.springframework.data.domain.Page; | 13 | import org.springframework.data.domain.Page; |
| 10 | import org.springframework.data.domain.Pageable; | 14 | import org.springframework.data.domain.Pageable; |
| @@ -13,6 +17,13 @@ import org.springframework.transaction.annotation.Isolation; | @@ -13,6 +17,13 @@ import org.springframework.transaction.annotation.Isolation; | ||
| 13 | import org.springframework.transaction.annotation.Propagation; | 17 | import org.springframework.transaction.annotation.Propagation; |
| 14 | import org.springframework.transaction.annotation.Transactional; | 18 | import org.springframework.transaction.annotation.Transactional; |
| 15 | 19 | ||
| 20 | +import javax.script.Invocable; | ||
| 21 | +import javax.script.ScriptEngine; | ||
| 22 | +import javax.script.ScriptEngineManager; | ||
| 23 | +import java.io.File; | ||
| 24 | +import java.io.FileReader; | ||
| 25 | +import java.nio.file.Paths; | ||
| 26 | +import java.util.ArrayList; | ||
| 16 | import java.util.Date; | 27 | import java.util.Date; |
| 17 | import java.util.List; | 28 | import java.util.List; |
| 18 | import java.util.Optional; | 29 | import java.util.Optional; |
| @@ -133,4 +144,91 @@ public class WorkServiceImpl implements WorkService { | @@ -133,4 +144,91 @@ public class WorkServiceImpl implements WorkService { | ||
| 133 | newWork = this.workRepo.save(newWork); | 144 | newWork = this.workRepo.save(newWork); |
| 134 | return WorkDto.getBuilder().setPropertyFromWork(newWork, false).build(); | 145 | return WorkDto.getBuilder().setPropertyFromWork(newWork, false).build(); |
| 135 | } | 146 | } |
| 147 | + | ||
| 148 | + @Value("${luban_h5.zip_page.source_root_path}") | ||
| 149 | + private String sourceRootPath; | ||
| 150 | + @Value("${luban_h5.zip_page.dest_path}") | ||
| 151 | + private String destZipDirPath; | ||
| 152 | + @Autowired | ||
| 153 | + private UploadFileRepo uploadFileRepo; | ||
| 154 | + @Override | ||
| 155 | + public ZipWorkPage createZipPage(Long id) { | ||
| 156 | + List<BsthSlideItem> bsthSlideItemList = computeZipBsthSlideUrls(id); | ||
| 157 | + | ||
| 158 | + // 1、打包文件 | ||
| 159 | + //----------------------- 1.1、添加待压缩的文件和目录 ---------------------// | ||
| 160 | + ZipWorkPage zipWorkPage = new ZipWorkPage(Paths.get(destZipDirPath)); | ||
| 161 | + // jquery | ||
| 162 | + zipWorkPage.addSourcePageFile( | ||
| 163 | + new ZipWorkPage.SourcePageFile() | ||
| 164 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "templates", "asserts", "jquery", "jquery.min.js")) | ||
| 165 | + .setZipFilePath(Paths.get("asserts","jquery", "jquery.min.js"))); | ||
| 166 | + // d3 | ||
| 167 | + zipWorkPage.addSourcePageFile( | ||
| 168 | + new ZipWorkPage.SourcePageFile() | ||
| 169 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "templates", "asserts", "d3", "d3.min.js")) | ||
| 170 | + .setZipFilePath(Paths.get("asserts","d3", "d3.min.js"))); | ||
| 171 | + | ||
| 172 | + // TODO:还有其他的js文件 | ||
| 173 | + | ||
| 174 | + //----------------------- 1.2、重新打包轮播图的url信息 -------------------// | ||
| 175 | + for (BsthSlideItem bsthSlideItem : bsthSlideItemList) { | ||
| 176 | + for (int i = 0; i < bsthSlideItem.getRealPath().size(); i++) { | ||
| 177 | + zipWorkPage.addSourcePageFile( | ||
| 178 | + new ZipWorkPage.SourcePageFile() | ||
| 179 | + .setSourceFilePath(Paths.get(bsthSlideItem.getRealPath().get(i))) | ||
| 180 | + .setZipFilePath(Paths.get(bsthSlideItem.getLocalUrls().get(i)))); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + //----------------------- 1.3、打包主页面 -------------------// | ||
| 185 | + // lubanPage.html 重命名为index.html,根路径使用. | ||
| 186 | + // TODO:lubanPage.html需要使用thymeleaf重新生成一遍 | ||
| 187 | + zipWorkPage.addSourcePageFile( | ||
| 188 | + new ZipWorkPage.SourcePageFile() | ||
| 189 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "templates", "lubanPage.html")) | ||
| 190 | + .setZipFilePath(Paths.get(".","index.html"))); | ||
| 191 | + | ||
| 192 | + // 2、压缩生成zip文件 | ||
| 193 | + zipWorkPage.build(); | ||
| 194 | + | ||
| 195 | + return zipWorkPage; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + @Override | ||
| 199 | + public List<BsthSlideItem> computeZipBsthSlideUrls(Long id) { | ||
| 200 | + // 1、查找作品dto | ||
| 201 | + WorkDto workDto = this.findWorkById(id); | ||
| 202 | + if (workDto == null) { | ||
| 203 | + throw new RuntimeException("作品Id=" + id + "不存在!"); | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + // 2、使用java8 js引擎获取轮播url信息 | ||
| 207 | + ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("nashorn"); | ||
| 208 | + File jsFile = Paths.get(sourceRootPath, "templates", "nashorn", "BsthSlideItem.js").toFile(); | ||
| 209 | + List<BsthSlideItem> bsthSlideItemList = new ArrayList<>(); | ||
| 210 | + try { | ||
| 211 | + scriptEngine.eval(new FileReader(jsFile)); | ||
| 212 | + Invocable invocable = (Invocable) scriptEngine; | ||
| 213 | + Object result = invocable.invokeFunction("calcuBsthSlideItems", workDto.getPages()); | ||
| 214 | + bsthSlideItemList = (List<BsthSlideItem>) result; | ||
| 215 | + } catch (Exception exp) { | ||
| 216 | + exp.printStackTrace(); | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + // 3、进一步计算zip打包时需要的url信息 | ||
| 220 | + for (BsthSlideItem bsthSlideItem : bsthSlideItemList) { | ||
| 221 | + bsthSlideItem.setRealPath(new ArrayList<>()); | ||
| 222 | + bsthSlideItem.setLocalUrls(new ArrayList<>()); | ||
| 223 | + for (String url : bsthSlideItem.getUrls()) { | ||
| 224 | + UploadFile uploadFile = uploadFileRepo.findByUrl(url); | ||
| 225 | + // 设置realPath | ||
| 226 | + bsthSlideItem.getRealPath().add(uploadFile.getRealPath()); | ||
| 227 | + // 是指loaclUrl | ||
| 228 | + bsthSlideItem.getLocalUrls().add("resources/" + uploadFile.getHash() + uploadFile.getExt()); | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + } | ||
| 232 | + return bsthSlideItemList; | ||
| 233 | + } | ||
| 136 | } | 234 | } |
src/main/java/com/bsth/luban_springboot2/utils/ZipWorkPage.java
| @@ -179,6 +179,7 @@ public class ZipWorkPage { | @@ -179,6 +179,7 @@ public class ZipWorkPage { | ||
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | + //-------------------------------------- 以下是一些快捷创建方式 -------------------------// | ||
| 182 | /** | 183 | /** |
| 183 | * 创建页面Zip(van_swip_use_case.html)。 | 184 | * 创建页面Zip(van_swip_use_case.html)。 |
| 184 | * @param sourceRootPath 来源文件根路径(目录) | 185 | * @param sourceRootPath 来源文件根路径(目录) |
| @@ -191,87 +192,87 @@ public class ZipWorkPage { | @@ -191,87 +192,87 @@ public class ZipWorkPage { | ||
| 191 | // jquery.min.js | 192 | // jquery.min.js |
| 192 | zipWorkPage.addSourcePageFile( | 193 | zipWorkPage.addSourcePageFile( |
| 193 | new SourcePageFile() | 194 | new SourcePageFile() |
| 194 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "other", "jquery.min.js")) | 195 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "other", "jquery.min.js")) |
| 195 | .setZipFilePath(Paths.get("pageTemplates","other", "jquery.min.js"))); | 196 | .setZipFilePath(Paths.get("pageTemplates","other", "jquery.min.js"))); |
| 196 | // d3.min.js | 197 | // d3.min.js |
| 197 | zipWorkPage.addSourcePageFile( | 198 | zipWorkPage.addSourcePageFile( |
| 198 | new SourcePageFile() | 199 | new SourcePageFile() |
| 199 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "other", "d3.min.js")) | 200 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "other", "d3.min.js")) |
| 200 | .setZipFilePath(Paths.get("pageTemplates","other", "d3.min.js"))); | 201 | .setZipFilePath(Paths.get("pageTemplates","other", "d3.min.js"))); |
| 201 | // vue_v2.6.12.js | 202 | // vue_v2.6.12.js |
| 202 | zipWorkPage.addSourcePageFile( | 203 | zipWorkPage.addSourcePageFile( |
| 203 | new SourcePageFile() | 204 | new SourcePageFile() |
| 204 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "js", "vue_v2.6.12.js")) | 205 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "js", "vue_v2.6.12.js")) |
| 205 | .setZipFilePath(Paths.get("pageTemplates","js", "vue_v2.6.12.js"))); | 206 | .setZipFilePath(Paths.get("pageTemplates","js", "vue_v2.6.12.js"))); |
| 206 | // video js css | 207 | // video js css |
| 207 | zipWorkPage.addSourcePageFile( | 208 | zipWorkPage.addSourcePageFile( |
| 208 | new SourcePageFile() | 209 | new SourcePageFile() |
| 209 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "css", "video-js_v7.11.4.css")) | 210 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "css", "video-js_v7.11.4.css")) |
| 210 | .setZipFilePath(Paths.get("pageTemplates","css", "video-js_v7.11.4.css"))); | 211 | .setZipFilePath(Paths.get("pageTemplates","css", "video-js_v7.11.4.css"))); |
| 211 | // video js | 212 | // video js |
| 212 | zipWorkPage.addSourcePageFile( | 213 | zipWorkPage.addSourcePageFile( |
| 213 | new SourcePageFile() | 214 | new SourcePageFile() |
| 214 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "js", "video_v7.11.4.js")) | 215 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "js", "video_v7.11.4.js")) |
| 215 | .setZipFilePath(Paths.get("pageTemplates","js", "video_v7.11.4.js"))); | 216 | .setZipFilePath(Paths.get("pageTemplates","js", "video_v7.11.4.js"))); |
| 216 | // vant css | 217 | // vant css |
| 217 | zipWorkPage.addSourcePageFile( | 218 | zipWorkPage.addSourcePageFile( |
| 218 | new SourcePageFile() | 219 | new SourcePageFile() |
| 219 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "css", "vant_v2.2.12.css")) | 220 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "css", "vant_v2.2.12.css")) |
| 220 | .setZipFilePath(Paths.get("pageTemplates","css", "vant_v2.2.12.css"))); | 221 | .setZipFilePath(Paths.get("pageTemplates","css", "vant_v2.2.12.css"))); |
| 221 | // vant js | 222 | // vant js |
| 222 | zipWorkPage.addSourcePageFile( | 223 | zipWorkPage.addSourcePageFile( |
| 223 | new SourcePageFile() | 224 | new SourcePageFile() |
| 224 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "js", "vant_v2.2.12.js")) | 225 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "js", "vant_v2.2.12.js")) |
| 225 | .setZipFilePath(Paths.get("pageTemplates","js", "vant_v2.2.12.js"))); | 226 | .setZipFilePath(Paths.get("pageTemplates","js", "vant_v2.2.12.js"))); |
| 226 | // lineChart.css | 227 | // lineChart.css |
| 227 | zipWorkPage.addSourcePageFile( | 228 | zipWorkPage.addSourcePageFile( |
| 228 | new SourcePageFile() | 229 | new SourcePageFile() |
| 229 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "components", "lineChart.css")) | 230 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "components", "lineChart.css")) |
| 230 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChart.css"))); | 231 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChart.css"))); |
| 231 | // lineChart.vue.js | 232 | // lineChart.vue.js |
| 232 | zipWorkPage.addSourcePageFile( | 233 | zipWorkPage.addSourcePageFile( |
| 233 | new SourcePageFile() | 234 | new SourcePageFile() |
| 234 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "components", "lineChart.vue.js")) | 235 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "components", "lineChart.vue.js")) |
| 235 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChart.vue.js"))); | 236 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChart.vue.js"))); |
| 236 | // lineChartList.vue.js | 237 | // lineChartList.vue.js |
| 237 | zipWorkPage.addSourcePageFile( | 238 | zipWorkPage.addSourcePageFile( |
| 238 | new SourcePageFile() | 239 | new SourcePageFile() |
| 239 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "components", "lineChartList.vue.js")) | 240 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "components", "lineChartList.vue.js")) |
| 240 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChartList.vue.js"))); | 241 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChartList.vue.js"))); |
| 241 | // testData.js | 242 | // testData.js |
| 242 | zipWorkPage.addSourcePageFile( | 243 | zipWorkPage.addSourcePageFile( |
| 243 | new SourcePageFile() | 244 | new SourcePageFile() |
| 244 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "components", "testData.js")) | 245 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "components", "testData.js")) |
| 245 | .setZipFilePath(Paths.get("pageTemplates","components", "testData.js"))); | 246 | .setZipFilePath(Paths.get("pageTemplates","components", "testData.js"))); |
| 246 | // vue-video-play.js | 247 | // vue-video-play.js |
| 247 | zipWorkPage.addSourcePageFile( | 248 | zipWorkPage.addSourcePageFile( |
| 248 | new SourcePageFile() | 249 | new SourcePageFile() |
| 249 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "js", "vue-video-player_v5.0.2.js")) | 250 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "js", "vue-video-player_v5.0.2.js")) |
| 250 | .setZipFilePath(Paths.get("pageTemplates","js", "vue-video-player_v5.0.2.js"))); | 251 | .setZipFilePath(Paths.get("pageTemplates","js", "vue-video-player_v5.0.2.js"))); |
| 251 | 252 | ||
| 252 | // asserts | 253 | // asserts |
| 253 | // vue-video-play.js | 254 | // vue-video-play.js |
| 254 | zipWorkPage.addSourcePageFile( | 255 | zipWorkPage.addSourcePageFile( |
| 255 | new SourcePageFile() | 256 | new SourcePageFile() |
| 256 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "asserts", "swipe_1.jpg")) | 257 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "asserts", "swipe_1.jpg")) |
| 257 | .setZipFilePath(Paths.get("asserts", "swipe_1.jpg"))); | 258 | .setZipFilePath(Paths.get("asserts", "swipe_1.jpg"))); |
| 258 | zipWorkPage.addSourcePageFile( | 259 | zipWorkPage.addSourcePageFile( |
| 259 | new SourcePageFile() | 260 | new SourcePageFile() |
| 260 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "asserts", "swipe_2.jpg")) | 261 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "asserts", "swipe_2.jpg")) |
| 261 | .setZipFilePath(Paths.get("asserts", "swipe_2.jpg"))); | 262 | .setZipFilePath(Paths.get("asserts", "swipe_2.jpg"))); |
| 262 | zipWorkPage.addSourcePageFile( | 263 | zipWorkPage.addSourcePageFile( |
| 263 | new SourcePageFile() | 264 | new SourcePageFile() |
| 264 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "asserts", "swipe_3.jpg")) | 265 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "asserts", "swipe_3.jpg")) |
| 265 | .setZipFilePath(Paths.get("asserts", "swipe_3.jpg"))); | 266 | .setZipFilePath(Paths.get("asserts", "swipe_3.jpg"))); |
| 266 | zipWorkPage.addSourcePageFile( | 267 | zipWorkPage.addSourcePageFile( |
| 267 | new SourcePageFile() | 268 | new SourcePageFile() |
| 268 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "asserts", "swipe_4.mp4")) | 269 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "asserts", "swipe_4.mp4")) |
| 269 | .setZipFilePath(Paths.get("asserts", "swipe_4.mp4"))); | 270 | .setZipFilePath(Paths.get("asserts", "swipe_4.mp4"))); |
| 270 | 271 | ||
| 271 | // pageTest5.html 重命名为index.html,根路径使用. | 272 | // pageTest5.html 重命名为index.html,根路径使用. |
| 272 | zipWorkPage.addSourcePageFile( | 273 | zipWorkPage.addSourcePageFile( |
| 273 | new SourcePageFile() | 274 | new SourcePageFile() |
| 274 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "van_swip_use_case.html")) | 275 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "van_swip_use_case.html")) |
| 275 | .setZipFilePath(Paths.get(".","index.html"))); | 276 | .setZipFilePath(Paths.get(".","index.html"))); |
| 276 | 277 | ||
| 277 | //-------------------------------- 2、压缩生成zip文件 -------------------------// | 278 | //-------------------------------- 2、压缩生成zip文件 -------------------------// |
| @@ -293,43 +294,43 @@ public class ZipWorkPage { | @@ -293,43 +294,43 @@ public class ZipWorkPage { | ||
| 293 | // jquery.min.js | 294 | // jquery.min.js |
| 294 | zipWorkPage.addSourcePageFile( | 295 | zipWorkPage.addSourcePageFile( |
| 295 | new SourcePageFile() | 296 | new SourcePageFile() |
| 296 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "other", "jquery.min.js")) | 297 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "other", "jquery.min.js")) |
| 297 | .setZipFilePath(Paths.get("pageTemplates","other", "jquery.min.js"))); | 298 | .setZipFilePath(Paths.get("pageTemplates","other", "jquery.min.js"))); |
| 298 | // d3.min.js | 299 | // d3.min.js |
| 299 | zipWorkPage.addSourcePageFile( | 300 | zipWorkPage.addSourcePageFile( |
| 300 | new SourcePageFile() | 301 | new SourcePageFile() |
| 301 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "other", "d3.min.js")) | 302 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "other", "d3.min.js")) |
| 302 | .setZipFilePath(Paths.get("pageTemplates","other", "d3.min.js"))); | 303 | .setZipFilePath(Paths.get("pageTemplates","other", "d3.min.js"))); |
| 303 | // vue_v2.6.12.js | 304 | // vue_v2.6.12.js |
| 304 | zipWorkPage.addSourcePageFile( | 305 | zipWorkPage.addSourcePageFile( |
| 305 | new SourcePageFile() | 306 | new SourcePageFile() |
| 306 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "js", "vue_v2.6.12.js")) | 307 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "js", "vue_v2.6.12.js")) |
| 307 | .setZipFilePath(Paths.get("pageTemplates","js", "vue_v2.6.12.js"))); | 308 | .setZipFilePath(Paths.get("pageTemplates","js", "vue_v2.6.12.js"))); |
| 308 | // lineChart.css | 309 | // lineChart.css |
| 309 | zipWorkPage.addSourcePageFile( | 310 | zipWorkPage.addSourcePageFile( |
| 310 | new SourcePageFile() | 311 | new SourcePageFile() |
| 311 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "components", "lineChart.css")) | 312 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "components", "lineChart.css")) |
| 312 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChart.css"))); | 313 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChart.css"))); |
| 313 | // lineChart.vue.js | 314 | // lineChart.vue.js |
| 314 | zipWorkPage.addSourcePageFile( | 315 | zipWorkPage.addSourcePageFile( |
| 315 | new SourcePageFile() | 316 | new SourcePageFile() |
| 316 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "components", "lineChart.vue.js")) | 317 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "components", "lineChart.vue.js")) |
| 317 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChart.vue.js"))); | 318 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChart.vue.js"))); |
| 318 | // lineChartList.vue.js | 319 | // lineChartList.vue.js |
| 319 | zipWorkPage.addSourcePageFile( | 320 | zipWorkPage.addSourcePageFile( |
| 320 | new SourcePageFile() | 321 | new SourcePageFile() |
| 321 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "components", "lineChartList.vue.js")) | 322 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "components", "lineChartList.vue.js")) |
| 322 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChartList.vue.js"))); | 323 | .setZipFilePath(Paths.get("pageTemplates","components", "lineChartList.vue.js"))); |
| 323 | // testData.js | 324 | // testData.js |
| 324 | zipWorkPage.addSourcePageFile( | 325 | zipWorkPage.addSourcePageFile( |
| 325 | new SourcePageFile() | 326 | new SourcePageFile() |
| 326 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "pageTemplates", "components", "testData.js")) | 327 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "pageTemplates", "components", "testData.js")) |
| 327 | .setZipFilePath(Paths.get("pageTemplates","components", "testData.js"))); | 328 | .setZipFilePath(Paths.get("pageTemplates","components", "testData.js"))); |
| 328 | 329 | ||
| 329 | // pageTest4.html 重命名为index.html,根路径使用. | 330 | // pageTest4.html 重命名为index.html,根路径使用. |
| 330 | zipWorkPage.addSourcePageFile( | 331 | zipWorkPage.addSourcePageFile( |
| 331 | new SourcePageFile() | 332 | new SourcePageFile() |
| 332 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "lineChartList_use_case.html")) | 333 | + .setSourceFilePath(Paths.get(sourceRootPath.toString(), "static", "lineChartList_use_case.html")) |
| 333 | .setZipFilePath(Paths.get(".","index.html"))); | 334 | .setZipFilePath(Paths.get(".","index.html"))); |
| 334 | 335 | ||
| 335 | //-------------------------------- 2、压缩生成zip文件 -------------------------// | 336 | //-------------------------------- 2、压缩生成zip文件 -------------------------// |
| @@ -338,76 +339,6 @@ public class ZipWorkPage { | @@ -338,76 +339,6 @@ public class ZipWorkPage { | ||
| 338 | return zipWorkPage; | 339 | return zipWorkPage; |
| 339 | } | 340 | } |
| 340 | 341 | ||
| 341 | - | ||
| 342 | - /** | ||
| 343 | - * 创建页面Zip。 | ||
| 344 | - * @param sourceRootPath 来源文件根路径(目录) | ||
| 345 | - * @param destZipDirPath 目标zip文件存放路径(目录) | ||
| 346 | - * @return | ||
| 347 | - */ | ||
| 348 | - public static ZipWorkPage createPageZip(Path sourceRootPath, Path destZipDirPath) { | ||
| 349 | - //----------------------- 1、添加待压缩的文件和目录 ---------------------// | ||
| 350 | - ZipWorkPage zipWorkPage = new ZipWorkPage(destZipDirPath); | ||
| 351 | - // vue_v2.6.12.js | ||
| 352 | - zipWorkPage.addSourcePageFile( | ||
| 353 | - new SourcePageFile() | ||
| 354 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "js", "vue_v2.6.12.js")) | ||
| 355 | - .setZipFilePath(Paths.get("js", "vue_v2.6.12.js"))); | ||
| 356 | - // vuex_v3.6.2.js | ||
| 357 | - zipWorkPage.addSourcePageFile( | ||
| 358 | - new SourcePageFile() | ||
| 359 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "js", "vuex_v3.6.2.js")) | ||
| 360 | - .setZipFilePath(Paths.get("js","vuex_v3.6.2.js"))); | ||
| 361 | - // animate_v4.1.1.css | ||
| 362 | - zipWorkPage.addSourcePageFile( | ||
| 363 | - new SourcePageFile() | ||
| 364 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "css", "animate_v4.1.1.css")) | ||
| 365 | - .setZipFilePath(Paths.get("css","animate_v4.1.1.css"))); | ||
| 366 | - // swiper_v4.5.1.css | ||
| 367 | - zipWorkPage.addSourcePageFile( | ||
| 368 | - new SourcePageFile() | ||
| 369 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "css", "swiper_v4.5.1.css")) | ||
| 370 | - .setZipFilePath(Paths.get("css","swiper_v4.5.1.css"))); | ||
| 371 | - // swiper_v4.5.1.js | ||
| 372 | - zipWorkPage.addSourcePageFile( | ||
| 373 | - new SourcePageFile() | ||
| 374 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "js", "swiper_v4.5.1.js")) | ||
| 375 | - .setZipFilePath(Paths.get("js","swiper_v4.5.1.js"))); | ||
| 376 | - // swiper-animation_v2.0.2.js | ||
| 377 | - zipWorkPage.addSourcePageFile( | ||
| 378 | - new SourcePageFile() | ||
| 379 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "js", "swiper-animation_v2.0.2.js")) | ||
| 380 | - .setZipFilePath(Paths.get("js","swiper-animation_v2.0.2.js"))); | ||
| 381 | - // echarts_v5.0.2.js | ||
| 382 | - zipWorkPage.addSourcePageFile( | ||
| 383 | - new SourcePageFile() | ||
| 384 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "js", "echarts_v5.0.2.js")) | ||
| 385 | - .setZipFilePath(Paths.get("js","echarts_v5.0.2.js"))); | ||
| 386 | - // v-charts_v1.19.0 | ||
| 387 | - zipWorkPage.addSourcePageDir( | ||
| 388 | - new SourcePageDir() | ||
| 389 | - .setSourceDirPath(Paths.get(sourceRootPath.toString(), "js", "v-charts_v1.19.0")) | ||
| 390 | - .setZipDirPath(Paths.get("js", "v-charts_v1.19.0"))); | ||
| 391 | - // v-charts_v1.19.0.css | ||
| 392 | - zipWorkPage.addSourcePageFile( | ||
| 393 | - new SourcePageFile() | ||
| 394 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "css", "v-charts_v1.19.0.css")) | ||
| 395 | - .setZipFilePath(Paths.get("css","v-charts_v1.19.0.css"))); | ||
| 396 | - | ||
| 397 | - | ||
| 398 | - // TODO:鲁班h5前台编辑,后台模版生成的html文件 | ||
| 399 | - // TODO:之后要使用freemark来生成(需要绑定WorkDto对象) | ||
| 400 | - zipWorkPage.addSourcePageFile( | ||
| 401 | - new SourcePageFile() | ||
| 402 | - .setSourceFilePath(Paths.get(sourceRootPath.toString(), "engine-example.ejs")) | ||
| 403 | - .setZipFilePath(Paths.get(File.separator,"engine-example.ejs"))); | ||
| 404 | - | ||
| 405 | - //-------------------------------- 2、压缩生成zip文件 -------------------------// | ||
| 406 | - zipWorkPage.build(); | ||
| 407 | - | ||
| 408 | - return zipWorkPage; | ||
| 409 | - } | ||
| 410 | - | ||
| 411 | /** | 342 | /** |
| 412 | * 待压缩的页面文件。 | 343 | * 待压缩的页面文件。 |
| 413 | */ | 344 | */ |
src/main/resources/application.properties
| @@ -28,9 +28,25 @@ spring.servlet.multipart.file-size-threshold=0 | @@ -28,9 +28,25 @@ spring.servlet.multipart.file-size-threshold=0 | ||
| 28 | spring.servlet.multipart.max-file-size=100MB | 28 | spring.servlet.multipart.max-file-size=100MB |
| 29 | spring.servlet.multipart.max-request-size=100MB | 29 | spring.servlet.multipart.max-request-size=100MB |
| 30 | 30 | ||
| 31 | +#--------------- thymeleaf配置 ---------------# | ||
| 32 | +# 是否开启缓存,开发时可以设置为 false,默认为 true | ||
| 33 | +spring.thymeleaf.cache=true | ||
| 34 | +# 检查模版是否存在,默认为 true | ||
| 35 | +spring.thymeleaf.check-template=true | ||
| 36 | +# 检查模版位置是否存在,默认为 true | ||
| 37 | +spring.thymeleaf.check-template-location=true | ||
| 38 | +# 模版文件编码 | ||
| 39 | +spring.thymeleaf.encoding=UTF-8 | ||
| 40 | +# 模版文件位置 | ||
| 41 | +spring.thymeleaf.prefix=classpath:/templates/ | ||
| 42 | +# Content-Type配置 | ||
| 43 | +spring.thymeleaf.servlet.content-type=text/html | ||
| 44 | +# 模版文件后缀 | ||
| 45 | +spring.thymeleaf.suffix=.html | ||
| 46 | + | ||
| 31 | #--------------- 鲁班h5相关操作配置 ------------# | 47 | #--------------- 鲁班h5相关操作配置 ------------# |
| 32 | -## zip打包来源文件根路径(目录) | ||
| 33 | -luban_h5.zip_page.source_root_path=/Users/xu/resource/project_code/bsth_project/bsth_ebus/luban_springboot2/src/main/resources/static | 48 | +## zip打包来源文件查找根路径(目录) |
| 49 | +luban_h5.zip_page.source_root_path=/Users/xu/resource/project_code/bsth_project/bsth_ebus/luban_springboot2/src/main/resources | ||
| 34 | ## 目标zip文件存放路径(目录) | 50 | ## 目标zip文件存放路径(目录) |
| 35 | luban_h5.zip_page.dest_path=/Users/xu/resource/project_code/bsth_project/bsth_ebus/temp_files/zip_pages | 51 | luban_h5.zip_page.dest_path=/Users/xu/resource/project_code/bsth_project/bsth_ebus/temp_files/zip_pages |
| 36 | ## 上传文件的存放路径 | 52 | ## 上传文件的存放路径 |