From 1d20ecbf6a214b2a9f3604a599af90d2ff6e41a2 Mon Sep 17 00:00:00 2001 From: bwcx_jzy Date: Wed, 4 Aug 2021 11:53:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88=E6=9C=AC=20UI=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=B7=BB=E5=8A=A0=20common.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 19 +++-- .../interceptor/BaseJpomInterceptor.java | 20 +++--- .../common/interceptor/LoginInterceptor.java | 70 +++++++++---------- .../java/io/jpom/controller/IndexControl.java | 15 +++- web-vue/public/index.html | 25 +++---- 5 files changed, 78 insertions(+), 71 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1307d20e..b35752bf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ 7. 【server】节点升级上传新包成功后删除历史包 8. 【server】新版本 UI 菜单系统管理、节点升级只有系统管理员可见 9. 【server】新版本 UI 脚本模板同步添加执行参数(感谢@轻描淡写 [Gitee issues I43G4B](https://gitee.com/dromara/Jpom/issues/I43G4B) ) +10. 【server】新版本 UI 同步添加 common.js ### 解决BUG、优化功能 @@ -77,8 +78,7 @@ 11. 【server】项目控制台新增心跳消息,避免超过一定时间后无法操作的情况 12. 【server】ssh 新增心跳消息,避免超过一定时间后无法操作的情况 13. 【server】系统缓存中的文件占用空间大小调整为定时更新(10分钟) -14. 【server】修复 bug:分发列表页面点击【创建分发项目】按钮之后不能正常显示【分发节点】感谢 - @xingenhi [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/bd38528fbd3067d220b7569f08449d7796e07c74) [@Hotstrip](https://gitee.com/hotstrip) +14. 【server】修复 bug:分发列表页面点击【创建分发项目】按钮之后不能正常显示【分发节点】感谢 @xingenhi [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/bd38528fbd3067d220b7569f08449d7796e07c74) [@Hotstrip](https://gitee.com/hotstrip) 15. 【server】fix: 编辑管理员时用户名不可修改 16. 【server】折叠显示部分列表操作按钮(减少误操作) @@ -104,12 +104,9 @@ 项目监控页面,线程数据加载失败问题 [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/b11c5443db6468a2bf7f6a9fa933f8d965899624) [@Hotstrip](https://gitee.com/hotstrip) 3. 【server】fix bug: 修复低版本浏览器不支持 `.replaceAll()` 方法 [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/0fb475963153b76546409ac3065a0efe9e647541) [@杨巍](https://gitee.com/fat_magpie_beijing_tony) -4. 【server】update: 更新分发列表 -- - 关联分发项目页面操作逻辑(跟老版本操作逻辑一致)[点击查看提交记录](https://gitee.com/dromara/Jpom/commit/cd6e4ae89f833e5e7ef11bd12c324a487de27b1a) [@李道甫](https://gitee.com/koushare_dfli) -5. 【server】update: 优化项目文件管理页面,加载目录树时会多次显示 loading - 层 [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/71b3779bffb36259e0980ce25d4e4082a9d7c2e6) [@Hotstrip](https://gitee.com/hotstrip) -6. 【server】fix bug: 修复节点请求超时可能导致节点项目列表为空 - bug [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/e3182dfa04c27e63a29d67b292a7bfef834f875e) [@Hotstrip](https://gitee.com/hotstrip) +4. 【server】update: 更新分发列表 -- 关联分发项目页面操作逻辑(跟老版本操作逻辑一致)[点击查看提交记录](https://gitee.com/dromara/Jpom/commit/cd6e4ae89f833e5e7ef11bd12c324a487de27b1a) [@李道甫](https://gitee.com/koushare_dfli) +5. 【server】update: 优化项目文件管理页面,加载目录树时会多次显示 loading 层 [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/71b3779bffb36259e0980ce25d4e4082a9d7c2e6) [@Hotstrip](https://gitee.com/hotstrip) +6. 【server】fix bug: 修复节点请求超时可能导致节点项目列表为空 bug [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/e3182dfa04c27e63a29d67b292a7bfef834f875e) [@Hotstrip](https://gitee.com/hotstrip) 7. 【agent】 fix bug: index 获取进程列表 NPE (感谢@夏末秋初) 8. 【server】fix bug: 修复上传项目压缩文件创建项目目录异常[点击这里查看对应 issue](https://gitee.com/dromara/Jpom/issues/I29FRJ) 9. 【server】fix bug:创建构建时,如果选择 @@ -118,9 +115,9 @@ 11. 【server】update 构建初始化仓库拉取指定分支,不先拉取主分支再切换到指定分支(感谢@大灰灰) 12. 【server】程序关闭时候自动关闭 h2 数据连接池,避免数据库文件被损坏 13. 【server】style: - 优化logo,登录页面,初始化页面 [点击查看对应提交记录](https://gitee.com/dromara/Jpom/commit/5d4783f0be7d44bb04275b059ccd1509620c5828) [@长得丑活得久i](https://gitee.com/zsf_008) + 优化logo,登录页面,初始化页面 [点击查看对应提交记录](https://gitee.com/dromara/Jpom/commit/5d4783f0be7d44bb04275b059ccd1509620c5828) [@长得丑活得久i](https://gitee.com/zsf_008) 14. 【server】fix bug: - 修复在没有配置nginx白名单时访问nginx列表数据一直加载中问题[点击这里查看对应 issue](https://github.com/dromara/Jpom/issues/5) [@长得丑活得久i](https://gitee.com/zsf_008) + 修复在没有配置nginx白名单时访问nginx列表数据一直加载中问题[点击这里查看对应 issue](https://github.com/dromara/Jpom/issues/5) [@长得丑活得久i](https://gitee.com/zsf_008) 15. 新增 .gitattributes 文件控制命令文件的编码格式以及换行符(感谢@ℳ๓₯㎕斌) ------ @@ -155,7 +152,7 @@ 13. 【Agent】解决控制台输出 `Failed to check connection: java.net.ConnectException: Connection refused: connect`,因为没有关闭对应的 jmx 14. 【Agent】解决首页控制台 java 进程列表慢的问题(采用定时拉取并缓存) 15. 【server】fix bug: - 节点列表页面,展开某个节点之后点击操作按钮会出现新的一行无效数据。 [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/b9ecdfa649d27c46bca696e6df088a0908056ff6) + 节点列表页面,展开某个节点之后点击操作按钮会出现新的一行无效数据。 [点击查看提交记录](https://gitee.com/dromara/Jpom/commit/b9ecdfa649d27c46bca696e6df088a0908056ff6) 16. 【server】fix bug: 节点列表页面,在没有安装节点的情况下,点击终端按钮会在控制台报错。[点击这里查看对应 issue](https://gitee.com/dromara/Jpom/issues/I3J4UI) 17. 【server】fix bug: 节点管理里面的 Nginx 管理,关闭服务的接口参数传递错了。[点击这里查看对应 issue](https://gitee.com/dromara/Jpom/issues/I3IFZY) 18. 【server】优化系统配置页面的样式,在小屏幕设备上会出现多个竖方向上的滚动条,甚至有时候会遮住底部的操作按钮 diff --git a/modules/server/src/main/java/io/jpom/common/interceptor/BaseJpomInterceptor.java b/modules/server/src/main/java/io/jpom/common/interceptor/BaseJpomInterceptor.java index cee1a83aa..b8f04d844 100644 --- a/modules/server/src/main/java/io/jpom/common/interceptor/BaseJpomInterceptor.java +++ b/modules/server/src/main/java/io/jpom/common/interceptor/BaseJpomInterceptor.java @@ -28,16 +28,16 @@ public abstract class BaseJpomInterceptor extends BaseInterceptor { // return false; // } - public static void sendRedirects(HttpServletRequest request, HttpServletResponse response, String url) throws IOException { - String newUrl = UrlRedirectUtil.getHeaderProxyPath(request, PROXY_PATH) + url; - UrlRedirectUtil.sendRedirect(request, response, newUrl); - } - - public static String getRedirect(HttpServletRequest request, String url) { - String newUrl = UrlRedirectUtil.getHeaderProxyPath(request, PROXY_PATH) + url; - String redirect = UrlRedirectUtil.getRedirect(request, newUrl); - return String.format("redirect:%s", redirect); - } +// public static void sendRedirects(HttpServletRequest request, HttpServletResponse response, String url) throws IOException { +// String newUrl = UrlRedirectUtil.getHeaderProxyPath(request, PROXY_PATH) + url; +// UrlRedirectUtil.sendRedirect(request, response, newUrl); +// } +// +// public static String getRedirect(HttpServletRequest request, String url) { +// String newUrl = UrlRedirectUtil.getHeaderProxyPath(request, PROXY_PATH) + url; +// String redirect = UrlRedirectUtil.getRedirect(request, newUrl); +// return String.format("redirect:%s", redirect); +// } public static String getHeaderProxyPath(HttpServletRequest request) { String proxyPath = ServletUtil.getHeaderIgnoreCase(request, PROXY_PATH); diff --git a/modules/server/src/main/java/io/jpom/common/interceptor/LoginInterceptor.java b/modules/server/src/main/java/io/jpom/common/interceptor/LoginInterceptor.java index a7cfddd27..015c6e406 100644 --- a/modules/server/src/main/java/io/jpom/common/interceptor/LoginInterceptor.java +++ b/modules/server/src/main/java/io/jpom/common/interceptor/LoginInterceptor.java @@ -171,41 +171,41 @@ public class LoginInterceptor extends BaseJpomInterceptor { } - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { - super.postHandle(request, response, handler, modelAndView); - HttpSession session; - try { - session = getSession(); - } catch (Exception ignored) { - return; - } - try { - // 静态资源地址参数 - session.setAttribute("staticCacheTime", DateUtil.currentSeconds()); - // 代理二级路径 - Object jpomProxyPath = session.getAttribute("jpomProxyPath"); - if (jpomProxyPath == null) { - String path = getHeaderProxyPath(request); - session.setAttribute("jpomProxyPath", path); - } - } catch (Exception ignored) { - } - try { - // 统一的js 注入 - String jsCommonContext = (String) session.getAttribute("jsCommonContext"); - if (jsCommonContext == null) { - String path = ExtConfigBean.getInstance().getPath(); - File file = FileUtil.file(String.format("%s/script/common.js", path)); - if (file.exists()) { - jsCommonContext = FileUtil.readString(file, CharsetUtil.CHARSET_UTF_8); - jsCommonContext = URLEncoder.DEFAULT.encode(jsCommonContext, CharsetUtil.CHARSET_UTF_8); - } - session.setAttribute("jsCommonContext", jsCommonContext); - } - } catch (IllegalStateException ignored) { - } - } +// @Override +// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { +// super.postHandle(request, response, handler, modelAndView); +// HttpSession session; +// try { +// session = getSession(); +// } catch (Exception ignored) { +// return; +// } +// try { +// // 静态资源地址参数 +// session.setAttribute("staticCacheTime", DateUtil.currentSeconds()); +// // 代理二级路径 +// Object jpomProxyPath = session.getAttribute("jpomProxyPath"); +// if (jpomProxyPath == null) { +// String path = getHeaderProxyPath(request); +// session.setAttribute("jpomProxyPath", path); +// } +// } catch (Exception ignored) { +// } +// try { +// // 统一的js 注入 +// String jsCommonContext = (String) session.getAttribute("jsCommonContext"); +// if (jsCommonContext == null) { +// String path = ExtConfigBean.getInstance().getPath(); +// File file = FileUtil.file(String.format("%s/script/common.js", path)); +// if (file.exists()) { +// jsCommonContext = FileUtil.readString(file, CharsetUtil.CHARSET_UTF_8); +// jsCommonContext = URLEncoder.DEFAULT.encode(jsCommonContext, CharsetUtil.CHARSET_UTF_8); +// } +// session.setAttribute("jsCommonContext", jsCommonContext); +// } +// } catch (IllegalStateException ignored) { +// } +// } @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { diff --git a/modules/server/src/main/java/io/jpom/controller/IndexControl.java b/modules/server/src/main/java/io/jpom/controller/IndexControl.java index d5e1913c5..0cdc0e951 100644 --- a/modules/server/src/main/java/io/jpom/controller/IndexControl.java +++ b/modules/server/src/main/java/io/jpom/controller/IndexControl.java @@ -3,6 +3,7 @@ package io.jpom.controller; import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.resource.ResourceUtil; +import cn.hutool.core.net.URLEncoder; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.servlet.ServletUtil; @@ -18,6 +19,7 @@ import io.jpom.model.data.UserModel; import io.jpom.permission.CacheControllerFeature; import io.jpom.service.user.RoleService; import io.jpom.service.user.UserService; +import io.jpom.system.ExtConfigBean; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.List; @@ -50,8 +53,6 @@ public class IndexControl extends BaseServerController { /** * 加载首页 - * - * @return page */ @GetMapping(value = {"index", "", "/"}, produces = MediaType.TEXT_HTML_VALUE) @NotLogin @@ -59,12 +60,20 @@ public class IndexControl extends BaseServerController { public void index(HttpServletResponse response) throws IOException { InputStream inputStream = ResourceUtil.getStream("classpath:/dist/index.html"); String html = IoUtil.read(inputStream, CharsetUtil.CHARSET_UTF_8); + //
+ String path = ExtConfigBean.getInstance().getPath(); + File file = FileUtil.file(String.format("%s/script/common.js", path)); + String jsCommonContext = StrUtil.EMPTY; + if (file.exists()) { + jsCommonContext = FileUtil.readString(file, CharsetUtil.CHARSET_UTF_8); + } + html = StrUtil.replace(html, "
", jsCommonContext); ServletUtil.write(response, html, ContentType.TEXT_HTML.getValue()); } /** - * @return + * @return json * @author Hotstrip * 检查是否需要初始化系统 * check if need to init system diff --git a/web-vue/public/index.html b/web-vue/public/index.html index fd5a63681..ed81350f4 100644 --- a/web-vue/public/index.html +++ b/web-vue/public/index.html @@ -1,25 +1,26 @@ - - - - - - - - - - <%= htmlWebpackPlugin.options.title %> + + + + + + + + + + <%= htmlWebpackPlugin.options.title %>
+