Pārlūkot izejas kodu

refactor(admin): 重构管理员界面并优化用户体验

- 移除了 CommonDataInterceptor 中的 cookieMap逻辑
- 更新了 common.1.js,增加了菜单状态和滚动条功能
- 修改了多个模板文件,统一了页面结构和样式- 优化了登录页面的样式导入
- 调整了侧边栏菜单的展开/收起逻辑
xuxueli 4 mēneši atpakaļ
vecāks
revīzija
bfe7687cbd

+ 1 - 1
doc/XXL-JOB官方文档.md

@@ -2543,7 +2543,7 @@ public void execute() {
 - 4、【升级】多个项目依赖升级至较新稳定版本,涉及 netty、spring/springboot、groovy 等;
 
 
-### 7.40 版本 v3.2.0 Release Notes[规划中]
+### 7.40 版本 v3.2.0 Release Notes[2025-06-24]
 - 1、【强化】AI任务(ollamaJobHandler)优化:针对 “model” 模型配置信息,从执行器侧文件类配置调整至调度中心“任务参数”动态配置,支持集成多模型、并结合任务动态配置切换。
 - 2、【安全】登录认证重构:密码加密算法从Md5改为Sha256;登录态改为登录后动态随机生成;提升系统安全性;(需要针对用户表进行字段调整,同时需要重新初始化密码信息;相关SQL脚本如下)
 ```

+ 0 - 13
xxl-job-admin/src/main/java/com/xxl/job/admin/web/interceptor/CommonDataInterceptor.java

@@ -2,18 +2,14 @@ package com.xxl.job.admin.web.interceptor;
 
 import com.xxl.job.admin.util.I18nUtil;
 import com.xxl.tool.freemarker.FtlTool;
-import jakarta.servlet.http.Cookie;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.stereotype.Component;
 import org.springframework.web.servlet.AsyncHandlerInterceptor;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import java.util.HashMap;
-
 /**
  * push cookies to model as cookieMap
  *
@@ -31,15 +27,6 @@ public class CommonDataInterceptor implements WebMvcConfigurer {
 								   Object handler,
 								   ModelAndView modelAndView) throws Exception {
 
-				// cookie
-				if (modelAndView!=null && request.getCookies()!=null && request.getCookies().length>0) {
-					HashMap<String, Cookie> cookieMap = new HashMap<String, Cookie>();
-					for (Cookie ck : request.getCookies()) {
-						cookieMap.put(ck.getName(), ck);
-					}
-					modelAndView.addObject("cookieMap", cookieMap);
-				}
-
 				// static method
 				if (modelAndView != null) {
 					modelAndView.addObject("I18nUtil", FtlTool.generateStaticModel(I18nUtil.class.getName()));

+ 53 - 63
xxl-job-admin/src/main/resources/static/js/common.1.js

@@ -28,68 +28,6 @@ $(function(){
 
 	});
 
-	// slideToTop
-	var slideToTop = $("<div />");
-	slideToTop.html('<i class="fa fa-chevron-up"></i>');
-	slideToTop.css({
-		position: 'fixed',
-		bottom: '20px',
-		right: '25px',
-		width: '40px',
-		height: '40px',
-		color: '#eee',
-		'font-size': '',
-		'line-height': '40px',
-		'text-align': 'center',
-		'background-color': '#222d32',
-		cursor: 'pointer',
-		'border-radius': '5px',
-		'z-index': '99999',
-		opacity: '.7',
-		'display': 'none'
-	});
-	slideToTop.on('mouseenter', function () {
-		$(this).css('opacity', '1');
-	});
-	slideToTop.on('mouseout', function () {
-		$(this).css('opacity', '.7');
-	});
-	$('.wrapper').append(slideToTop);
-	$(window).scroll(function () {
-		if ($(window).scrollTop() >= 150) {
-			if (!$(slideToTop).is(':visible')) {
-				$(slideToTop).fadeIn(500);
-			}
-		} else {
-			$(slideToTop).fadeOut(500);
-		}
-	});
-	$(slideToTop).click(function () {
-		$("html,body").animate({		// firefox ie not support body, chrome support body. but found that new version chrome not support body too.
-			scrollTop: 0
-		}, 100);
-	});
-
-	// left menu status v: js + server + cookie
-	$('.sidebar-toggle').click(function(){
-		var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings');	// on=open,off=close
-		if ('off' == xxljob_adminlte_settings) {
-            xxljob_adminlte_settings = 'on';
-		} else {
-            xxljob_adminlte_settings = 'off';
-		}
-		$.cookie('xxljob_adminlte_settings', xxljob_adminlte_settings, { expires: 7 });	//$.cookie('the_cookie', '', { expires: -1 });
-	});
-
-	// left menu status v1: js + cookie
-	/*
-	 var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings');
-	 if (xxljob_adminlte_settings == 'off') {
-	 	$('body').addClass('sidebar-collapse');
-	 }
-	 */
-
-
     // update pwd
     $('#updatePwd').on('click', function(){
         $('#updatePwdModal').modal({backdrop: false, keyboard: false}).modal('show');
@@ -160,5 +98,57 @@ $(function(){
         updatePwdModalValidate.resetForm();
         $("#updatePwdModal .form .form-group").removeClass("has-error");
     });
-	
+
+	// slideToTop
+	var slideToTop = $("<div />");
+	slideToTop.html('<i class="fa fa-chevron-up"></i>');
+	slideToTop.css({
+		position: 'fixed',
+		bottom: '20px',
+		right: '25px',
+		width: '40px',
+		height: '40px',
+		color: '#eee',
+		'font-size': '',
+		'line-height': '40px',
+		'text-align': 'center',
+		'background-color': '#222d32',
+		cursor: 'pointer',
+		'border-radius': '5px',
+		'z-index': '99999',
+		opacity: '.7',
+		'display': 'none'
+	});
+	slideToTop.on('mouseenter', function () {
+		$(this).css('opacity', '1');
+	});
+	slideToTop.on('mouseout', function () {
+		$(this).css('opacity', '.7');
+	});
+	$('.wrapper').append(slideToTop);
+	$(window).scroll(function () {
+		if ($(window).scrollTop() >= 150) {
+			if (!$(slideToTop).is(':visible')) {
+				$(slideToTop).fadeIn(500);
+			}
+		} else {
+			$(slideToTop).fadeOut(500);
+		}
+	});
+	$(slideToTop).click(function () {
+		$("html,body").animate({		// firefox ie not support body, chrome support body. but found that new version chrome not support body too.
+			scrollTop: 0
+		}, 100);
+	});
+
+
+    // change menu status
+    $('.sidebar-toggle').click(function(){
+        if ( 'close' == $.cookie('sidebar_status') ) {
+            $.cookie('sidebar_status', 'open', { expires: 7 });
+        } else {
+            $.cookie('sidebar_status', 'close', { expires: 7 });	//$.cookie('the_cookie', '', { expires: -1 });
+        }
+    });
+
 });

+ 31 - 13
xxl-job-admin/src/main/resources/templates/common/common.macro.ftl

@@ -1,12 +1,20 @@
+<#-- page import (style + script) -->
 <#macro commonStyle>
 
-	<#-- favicon -->
+	<#-- i18n -->
+	<#global I18n = I18nUtil.getMultString()?eval />
+
+	<#-- favicon、logo -->
+	<title>${I18n.admin_name}</title>
 	<link rel="icon" href="${request.contextPath}/static/favicon.ico" />
 
+	<#-- meta -->
 	<meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <!-- Tell the browser to be responsive to screen width -->
     <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
+
+	<#-- link style -->
     <!-- Bootstrap -->
     <link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/bootstrap/css/bootstrap.min.css">
     <!-- Font Awesome -->
@@ -28,9 +36,6 @@
 	<!-- pace -->
 	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/PACE/themes/blue/pace-theme-flash.css">
 
-	<#-- i18n -->
-	<#global I18n = I18nUtil.getMultString()?eval />
-
 </#macro>
 
 <#macro commonScript>
@@ -38,30 +43,43 @@
 	<script src="${request.contextPath}/static/adminlte/bower_components/jquery/jquery.min.js"></script>
 	<!-- Bootstrap -->
 	<script src="${request.contextPath}/static/adminlte/bower_components/bootstrap/js/bootstrap.min.js"></script>
-	<!-- FastClick -->
-	<script src="${request.contextPath}/static/adminlte/bower_components/fastclick/fastclick.js"></script>
-	<!-- AdminLTE App -->
-	<script src="${request.contextPath}/static/adminlte/dist/js/adminlte.min.js"></script>
+	<!-- PACE -->
+	<script src="${request.contextPath}/static/adminlte/bower_components/PACE/pace.min.js"></script>
 	<!-- jquery.slimscroll -->
 	<script src="${request.contextPath}/static/adminlte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
+	<!-- FastClick -->
+	<script src="${request.contextPath}/static/adminlte/bower_components/fastclick/fastclick.js"></script>
 
-    <!-- pace -->
-    <script src="${request.contextPath}/static/adminlte/bower_components/PACE/pace.min.js"></script>
     <#-- jquery cookie -->
 	<script src="${request.contextPath}/static/plugins/jquery/jquery.cookie.js"></script>
 	<#-- jquery.validate -->
 	<script src="${request.contextPath}/static/plugins/jquery/jquery.validate.min.js"></script>
-
 	<#-- layer -->
 	<script src="${request.contextPath}/static/plugins/layer/layer.js"></script>
 
-	<#-- common -->
-    <script src="${request.contextPath}/static/js/common.1.js"></script>
+	<!-- base config -->
     <script>
 		var base_url = '${request.contextPath}';
         var I18n = ${I18nUtil.getMultString()};
+
+		// init menu status
+		if ( 'close' == $.cookie('sidebar_status') ) {
+			$('body').addClass('sidebar-collapse');
+		} else {
+			$('body').removeClass('sidebar-collapse');
+		}
+		// init body fixed
+		$('body').addClass('fixed');
+		// init menu speed
+		$('.sidebar-menu').attr('data-animation-speed', 1);
 	</script>
 
+	<!-- AdminLTE App -->
+	<script src="${request.contextPath}/static/adminlte/dist/js/adminlte.min.js"></script>
+
+	<#-- common js -->
+	<script src="${request.contextPath}/static/js/common.1.js"></script>
+
 </#macro>
 
 <#macro commonHeader>

+ 1 - 1
xxl-job-admin/src/main/resources/templates/help.ftl

@@ -5,7 +5,7 @@
 	<@netCommon.commonStyle />
 	<title>${I18n.admin_name}</title>
 </head>
-<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
+<body class="hold-transition skin-blue sidebar-mini">
 <div class="wrapper">
 	<!-- header -->
 	<@netCommon.commonHeader />

+ 1 - 1
xxl-job-admin/src/main/resources/templates/index.ftl

@@ -7,7 +7,7 @@
     <link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/bootstrap-daterangepicker/daterangepicker.css">
     <title>${I18n.admin_name}</title>
 </head>
-<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
+<body class="hold-transition skin-blue sidebar-mini">
 <div class="wrapper">
 	<!-- header -->
 	<@netCommon.commonHeader />

+ 1 - 1
xxl-job-admin/src/main/resources/templates/jobgroup/jobgroup.index.ftl

@@ -7,7 +7,7 @@
   	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
     <title>${I18n.admin_name}</title>
 </head>
-<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
+<body class="hold-transition skin-blue sidebar-mini">
 <div class="wrapper">
 	<!-- header -->
 	<@netCommon.commonHeader />

+ 1 - 1
xxl-job-admin/src/main/resources/templates/jobinfo/jobinfo.index.ftl

@@ -7,7 +7,7 @@
   	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
     <title>${I18n.admin_name}</title>
 </head>
-<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if>">
+<body class="hold-transition skin-blue sidebar-mini">
 <div class="wrapper">
 	<!-- header -->
 	<@netCommon.commonHeader />

+ 1 - 2
xxl-job-admin/src/main/resources/templates/joblog/joblog.detail.ftl

@@ -5,8 +5,7 @@
     <@netCommon.commonStyle />
     <title>${I18n.admin_name}</title>
 </head>
-<body class="hold-transition skin-blue layout-top-nav">
-
+<body class="hold-transition skin-blue sidebar-mini">
 <div class="wrapper">
 
     <header class="main-header">

+ 1 - 1
xxl-job-admin/src/main/resources/templates/joblog/joblog.index.ftl

@@ -9,7 +9,7 @@
   	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/bootstrap-daterangepicker/daterangepicker.css">
     <title>${I18n.admin_name}</title>
 </head>
-<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
+<body class="hold-transition skin-blue sidebar-mini">
 <div class="wrapper">
 	<!-- header -->
 	<@netCommon.commonHeader />

+ 4 - 1
xxl-job-admin/src/main/resources/templates/login.ftl

@@ -1,10 +1,13 @@
 <!DOCTYPE html>
 <html>
 <head>
+	<#-- import macro -->
   	<#import "./common/common.macro.ftl" as netCommon>
+
+	<#-- commonStyle -->
 	<@netCommon.commonStyle />
+	<!-- iCheck -->
     <link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/iCheck/square/blue.css">
-	<title>${I18n.admin_name}</title>
 </head>
 <body class="hold-transition login-page">
 	<div class="login-box">

+ 1 - 1
xxl-job-admin/src/main/resources/templates/user/user.index.ftl

@@ -7,7 +7,7 @@
   	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
     <title>${I18n.admin_name}</title>
 </head>
-<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if>">
+<body class="hold-transition skin-blue sidebar-mini">
 <div class="wrapper">
 	<!-- header -->
 	<@netCommon.commonHeader />