diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java index 8ac4fba1..e96a3ddc 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java @@ -669,7 +669,7 @@ public class SpringBootCallable implements Callable { } {//js文件 - freeMarkerManager.outputTemp(new File(js.getAbsolutePath(), "ajax.js"), option + "/resources/static/js/ajax.ftl", ctx); + freeMarkerManager.outputTemp(new File(js.getAbsolutePath(), "ajax.js"), option + "/resources/static/js/ajax.js", ctx); } {//img Tool.outputResource(option + "/resources/static/img/logo.png", new File(img.getAbsolutePath(), "logo.png")); diff --git a/src/main/resources/modules/SpringBoot/java/config/WebMvcConfig.java b/src/main/resources/modules/SpringBoot/java/config/WebMvcConfig.java index eb340964..e0121427 100644 --- a/src/main/resources/modules/SpringBoot/java/config/WebMvcConfig.java +++ b/src/main/resources/modules/SpringBoot/java/config/WebMvcConfig.java @@ -1,44 +1,22 @@ package ${basePackage}.config; -import ${basePackage}.frame.springmvc.GlobalHandlerInterceptor; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import org.apache.catalina.connector.Connector; -import org.apache.coyote.http11.Http11NioProtocol; +import ${basePackage}.frame.springmvc.GlobalHandlerInterceptor; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.system.ApplicationHome; -import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.boot.web.servlet.server.ServletWebServerFactory; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.core.io.ClassPathResource; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import ${basePackage}.frame.springmvc.GlobalHandlerInterceptor; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; import java.util.List; @Configuration public class WebMvcConfig implements WebMvcConfigurer { - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - //将资源Order设为 -1 权重大于 Mapping,保证资源优先级高于Mapping("**") - registry.setOrder(-1); - } - @Autowired private GlobalHandlerInterceptor globalHandlerInterceptor; @@ -61,19 +39,15 @@ public class WebMvcConfig implements WebMvcConfigurer { */ @Override public void extendMessageConverters(List> converters) { - MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); - ObjectMapper objectMapper = jackson2HttpMessageConverter.getObjectMapper(); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - SimpleModule simpleModule = new SimpleModule(); - simpleModule.addSerializer(Long.class, ToStringSerializer.instance); - simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); - objectMapper.registerModule(simpleModule); - jackson2HttpMessageConverter.setObjectMapper(objectMapper); - - // 将转化器注册到首个 - converters.add(0, jackson2HttpMessageConverter); + for (HttpMessageConverter converter : converters) { + if (converter instanceof MappingJackson2HttpMessageConverter){ + ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter)converter).getObjectMapper(); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + } + } } // @Bean diff --git a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl index e5a64dbe..a036b114 100644 --- a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl +++ b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl @@ -47,6 +47,12 @@ pagehelper.autoRuntimeDialect=true pagehelper.reasonable=false pagehelper.supportMethodsArguments=true pagehelper.params=count=countSql +# jackson 相关配置 +spring.jackson.date-format=yyyy-MM-dd HH:mm:ss +spring.jackson.time-zone=GMT+8 +spring.jackson.default-property-inclusion=use_defaults +spring.jackson.mapper.sort-properties-alphabetically=true +spring.jackson.deserialization.fail-on-unknown-properties=false # freemarker spring.freemarker.enabled=true spring.freemarker.allow-request-override=false diff --git a/src/main/resources/modules/SpringBoot/resources/application-prod.ftl b/src/main/resources/modules/SpringBoot/resources/application-prod.ftl index dbd64913..8e6eeee5 100644 --- a/src/main/resources/modules/SpringBoot/resources/application-prod.ftl +++ b/src/main/resources/modules/SpringBoot/resources/application-prod.ftl @@ -46,6 +46,12 @@ pagehelper.autoRuntimeDialect=true pagehelper.reasonable=false pagehelper.supportMethodsArguments=true pagehelper.params=count=countSql +# jackson 相关配置 +spring.jackson.date-format=yyyy-MM-dd HH:mm:ss +spring.jackson.time-zone=GMT+8 +spring.jackson.default-property-inclusion=use_defaults +spring.jackson.mapper.sort-properties-alphabetically=true +spring.jackson.deserialization.fail-on-unknown-properties=false # freemarker spring.freemarker.enabled=true spring.freemarker.allow-request-override=false diff --git a/src/main/resources/modules/SpringBoot/resources/static/dist/fonts/element-icons.woff b/src/main/resources/modules/SpringBoot/resources/static/dist/fonts/element-icons.woff index 28da65d4..02b9a253 100644 Binary files a/src/main/resources/modules/SpringBoot/resources/static/dist/fonts/element-icons.woff and b/src/main/resources/modules/SpringBoot/resources/static/dist/fonts/element-icons.woff differ diff --git a/src/main/resources/modules/SpringBoot/resources/static/js/ajax.ftl b/src/main/resources/modules/SpringBoot/resources/static/js/ajax.js similarity index 91% rename from src/main/resources/modules/SpringBoot/resources/static/js/ajax.ftl rename to src/main/resources/modules/SpringBoot/resources/static/js/ajax.js index 274b4c72..ea1f4142 100644 --- a/src/main/resources/modules/SpringBoot/resources/static/js/ajax.ftl +++ b/src/main/resources/modules/SpringBoot/resources/static/js/ajax.js @@ -23,10 +23,18 @@ instance.interceptors.request.use(function (config) { instance.interceptors.response.use(function (response) { // 对响应数据做点什么 nav.tip.close(); - nav.bar.finish(); + try {//确保服务器正确返回Json + if(response.data.errors.length > 0){ + console.error(response.data.errors) + } + nav.bar.finish(); + }catch (e){ + nav.bar.error(); + response.data = {errors: [{message: '服务器错误'}]}; + } return response; }, function (error) { - // 对响应错误做点什么 + // 对响应错误做点什么,保准化返回结果 nav.tip.close(); nav.bar.error(); const rsp = {errors: []}; @@ -64,7 +72,7 @@ jsonRequest = function (config) { params: { method: config.method }, - url: "${contextPath?default("")}/ajax", + url: '${contextPath?default("")}/ajax', headers: {'Content-Type': 'text/plain'}, data: config.data }).then(function (response) { @@ -75,7 +83,7 @@ jsonRequest = function (config) { }; fileRequest = function (config) { return instance.request({ - url: "${contextPath?default("")}/upload", + url: '${contextPath?default("")}/upload', data: config.data, headers: {'Content-Type': 'multipart/form-data'}, onUploadProgress: function (progressEvent) { diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl index a3642ef2..8098e136 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl @@ -1,19 +1,130 @@
- - -

介绍说明

- -

Freemarker 是一款模板引擎,是一种基于模版生成静态文件的通用 - 工具,它是为Java程序员提供的一个开发包,或者说是一个类库,它不是面向最终用户的,而是为程序员提供了一款可以嵌入他们开发产品的应用程序。

- -

Freemarker 是使用纯java编写的,为了提高页面的访问速度,需要把页面静态化, 那么Freemarker就是被用来生成html页面。

- -

前提条件

- -

本工程使用的Freemarker整合了Spring MVC, 与你需要了解或熟悉Spring MVC框架。如果你熟悉EL表达,将有助于该工程Freemarker的使用。

+ + + +
+ 主要颜色 +
+ + +
Success +
#67C23A
+
+
+ +
Warning +
#E6A23C
+
+
+ +
Danger +
#F56C6C
+
+
+ +
Info +
#909399
+
+
+
+
+ +
+ 中性色 +
+ + +
+
+ 主要文字 +
#303133
+
+
+ 常规文字 +
#606266
+
+
+ 次要文字 +
#909399
+
+
+ 占位文字 +
#C0C4CC
+
+
+
+ +
+
+ +
+
一级边框 +
#DCDFE6
+
+
二级边框 +
#E4E7ED
+
+
三级边框 +
#EBEEF5
+
+
四级边框 +
#F2F6FC
+
+
+
+
+
+
+ + +

主要框架

+ +
    +
  1. + SpringBoot v2.1.2.RELEASE +
  2. +
  3. + Freemarker v2.1.2.RELEASE Html模板引擎 +
  4. +
  5. + pagehelper v1.2.5 分页插件、提供便捷的分页功能 +
  6. +
  7. + dozer v5.5.1 对象复制拷贝 +
  8. +
  9. + logback v1.2.3 日志框架 +
  10. +
  11. + jQuery v3.2.1 前端JavaScript框架(保留),打包进base.min.js,但请尽量勿使用jQuery直接操作Dom +
  12. +
  13. + Vue v2.5.17 DOM渲染引擎 +
  14. +
  15. + ElementUI v2.8.2 前端UI框架,提供统一风格控件 +
  16. +
  17. + Maven 后端构建管理工具 +
  18. +
  19. + JDK 8+ SpringBoot2.x开始不再支持JDK 7及以下,所以请将JDk升级到8+ +
  20. +
+ +

- + + @@ -37,6 +148,7 @@ + 普通消息 @@ -56,6 +168,7 @@ 失败 + @@ -116,84 +229,524 @@ + + +
+

1、表单控件集合及验证

+
+ + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + 立即创建 + 重置 + + - +
- 主要颜色 +

2、表格数据

- - -
Success -
#67C23A
-
-
- -
Warning -
#E6A23C
-
-
- -
Danger -
#F56C6C
-
-
- -
Info -
#909399
-
-
+ + + + + + + + + + + + + + + + +
+ + +
+

3、分页

+
+ + + + +
+ + +
+

4、按钮

+
+ + + 默认按钮 + 主要按钮 + 成功按钮 + 信息按钮 + 警告按钮 + 危险按钮 + + + + 朴素按钮 + 主要按钮 + 成功按钮 + 信息按钮 + 警告按钮 + 危险按钮 + + + + 圆角按钮 + 主要按钮 + 成功按钮 + 信息按钮 + 警告按钮 + + + + 危险按钮 + 加载中 + + + + + + + + + + 默认按钮 + 主要按钮 + 成功按钮 + 信息按钮 + 警告按钮 + 危险按钮 + + + + 朴素按钮 + 主要按钮 + 成功按钮 + 信息按钮 + 警告按钮 + 危险按钮 + + + 文字按钮 + 文字按钮 + + + + + + 搜索 + 上传 + + + + 上一页 + 下一页 + + + + + + + + + + 默认按钮 + 中等按钮 + 小型按钮 + 超小按钮 + + + 默认按钮 + 中等按钮 + 小型按钮 + 超小按钮 + +
- 中性色 +

5、Link 文字链接

+ + + 默认链接 + 主要链接 + 成功链接 + 警告链接 + 危险链接 + 信息链接 + + + + 默认链接 + 主要链接 + 成功链接 + 警告链接 + 危险链接 + 信息链接 + + + + 无下划线 + 有下划线 + 编辑 + 查看 + + +
+ +
+

6、Tabs 标签页

+
+ + + 用户管理 + 配置管理 + 角色管理 + 定时任务补偿 + + +

+ Tabs位置共有4个位置分别为: + + top + + right + + bottom + + left + +

+
+ +
+

7、弹框、对话框、通知

+
+ + + + 通知 + + + 消息Box + + + 消息确认Box + + + + hover 激活 + + + - -
-
主要文字 -
#303133
-
-
常规文字 -
#606266
-
-
次要文字 -
#909399
-
-
占位文字 -
#C0C4CC
-
-
-
- -
-
- -
-
一级边框 -
#DCDFE6
-
-
二级边框 -
#E4E7ED
-
-
三级边框 -
#EBEEF5
-
-
四级边框 -
#F2F6FC
-
-
-
+ 对话框Dialog + + + 这是一段信息 + + 取 消 + 确 定 + + +
+
-
+ +
+

6、其他小控件

+
+ + + + + + + + + + + + + 标签一 + 标签二 + 标签三 + 标签四 + 标签五 + + + + 标签一 + 标签二 + 标签三 + 标签四 + 标签五 + + + + 默认标签 + 中等标签 + 小型标签 + 超小标签 + + + + + 评论 + + + 回复 + + + 评论 + + + 回复 + + + 数据查询 + + + + + + + + 评论(最大值) + + + 回复(最大值) + + + + 评论 + + + 回复 + + + + + + + + + + + + + + + + + + 首页 + 活动管理 + 活动列表 + 活动详情 + + + + + + 下拉菜单 + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + + + + + 默认尺寸 + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + + + + + 中等尺寸 + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + + + + + 小型尺寸 + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + + + + + 超小尺寸 + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + + + + + 头上一片晴天,心中一个想念 + 少年包青天 + 饿了别叫妈, 叫饿了么 + + 为了无法计算的价值 + 阿里云 + - + + 雨纷纷 + + 旧故里 + + 草木深 + + +
+ +
+ +
- 1、页面初始化前闪现源代码 +

1、页面初始化前闪现源代码

${'