Browse Source

调整信工模板移动端三横线导航

移动端搜索栏右侧新增三条横线菜单,隐藏原横向导航,使用右侧抽屉展示一级、二级栏目;支持遮罩、关闭按钮、Esc、链接点击关闭、视口切换复位和 ARIA 状态。同步更新信工模板静态资源版本号。

Validation: 390px 下搜索框与菜单按钮同一行且无横向溢出;抽屉可打开 42 个导航链接并正常关闭。
非繁 1 tháng trước cách đây
mục cha
commit
2c3ab3371d

+ 36 - 0
WebRoot/main/ffkj-portal/xingong-blue.css

@@ -455,3 +455,39 @@ ul.list li .ds{font-size:12.5px;color:var(--ink-3);margin-top:4px;line-height:1.
   .article-media-grid,.catalog-grid{grid-template-columns:minmax(0,1fr)}
   .article-media-grid,.catalog-grid{grid-template-columns:minmax(0,1fr)}
   .footer .qr{justify-content:flex-start}
   .footer .qr{justify-content:flex-start}
 }
 }
+
+/* 移动端:搜索栏右侧三条横线菜单 */
+.xg-mobile-menu{display:none}
+.xg-drawer-layer[hidden]{display:none!important}
+@media (max-width:980px){
+  .nav{display:none}
+  .header{height:auto;padding:14px 0}
+  .header .wrap{display:grid;grid-template-columns:minmax(0,1fr) 46px;grid-template-rows:auto auto;gap:10px 8px}
+  .brand{grid-column:1/-1;grid-row:1;min-width:0}
+  .brand-logo-image{height:56px;max-width:100%}
+  .search{grid-column:1;grid-row:2;width:100%;min-width:0;height:40px}
+  .xg-mobile-menu{grid-column:2;grid-row:2;display:flex;width:46px;height:40px;padding:8px 10px;flex-direction:column;align-items:center;justify-content:center;gap:5px;border:1px solid rgba(255,255,255,.55);border-radius:3px;background:rgba(0,35,95,.18);cursor:pointer}
+  .xg-mobile-menu span{display:block;width:24px;height:2px;border-radius:2px;background:#fff;transition:transform .2s ease,opacity .2s ease}
+  .xg-mobile-menu.is-open span:nth-child(1){transform:translateY(7px) rotate(45deg)}
+  .xg-mobile-menu.is-open span:nth-child(2){opacity:0}
+  .xg-mobile-menu.is-open span:nth-child(3){transform:translateY(-7px) rotate(-45deg)}
+  body.xg-drawer-open{overflow:hidden}
+  .xg-drawer-layer{position:fixed;inset:0;z-index:300;background:rgba(0,0,0,.38);opacity:0;transition:opacity .2s ease}
+  .xg-drawer-layer.is-open{opacity:1}
+  .xg-drawer-mask{position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;cursor:pointer}
+  .xg-drawer{position:absolute;top:0;right:0;bottom:0;width:min(84vw,340px);background:#fff;box-shadow:-14px 0 34px rgba(0,25,70,.25);transform:translateX(100%);transition:transform .24s ease;overflow-y:auto}
+  .xg-drawer-layer.is-open .xg-drawer{transform:translateX(0)}
+  .xg-drawer-head{display:flex;align-items:center;justify-content:space-between;min-height:64px;padding:0 18px;background:var(--brand);color:#fff}
+  .xg-drawer-head strong{font-size:18px;letter-spacing:1px}
+  .xg-drawer-head button{width:38px;height:38px;border:0;background:transparent;color:#fff;font-size:30px;line-height:1;cursor:pointer}
+  .xg-drawer-nav{padding:4px 0 24px}
+  .xg-drawer-nav>a,.xg-drawer-children a{display:flex;align-items:center;min-height:50px;padding:11px 20px;border-bottom:1px solid #edf0f4;color:var(--ink);font-size:15px}
+  .xg-drawer-nav>a:hover,.xg-drawer-nav>a:focus-visible,.xg-drawer-children a:hover,.xg-drawer-children a:focus-visible{background:var(--brand-l);color:var(--brand)}
+  .xg-drawer-children{margin:0 16px 8px 28px;border-left:2px solid var(--brand-l)}
+  .xg-drawer-children a{min-height:42px;padding:8px 14px;font-size:13.5px;border-bottom-color:#f1f3f6}
+}
+@media (max-width:640px){
+  .brand-logo-image{height:48px}
+  .header .wrap{gap:8px}
+  .search{height:40px}
+}

+ 53 - 0
WebRoot/main/ffkj-portal/xingong-blue.js

@@ -42,3 +42,56 @@
     });
     });
   });
   });
 })();
 })();
+
+(function () {
+  'use strict';
+
+  var menuButton = document.querySelector('.xg-mobile-menu');
+  var drawerLayer = document.querySelector('.xg-drawer-layer');
+  if (!menuButton || !drawerLayer) return;
+
+  var closeButtons = drawerLayer.querySelectorAll('.xg-drawer-mask, .xg-drawer-head button');
+  var mobileQuery = window.matchMedia('(max-width: 980px)');
+
+  function setDrawerOpen(open) {
+    menuButton.setAttribute('aria-expanded', open ? 'true' : 'false');
+    menuButton.setAttribute('aria-label', open ? '关闭导航' : '打开导航');
+    menuButton.classList.toggle('is-open', open);
+    document.body.classList.toggle('xg-drawer-open', open);
+    if (open) {
+      drawerLayer.hidden = false;
+      window.requestAnimationFrame(function () {
+        drawerLayer.classList.add('is-open');
+      });
+    } else {
+      drawerLayer.classList.remove('is-open');
+      drawerLayer.hidden = true;
+    }
+  }
+
+  menuButton.addEventListener('click', function () {
+    setDrawerOpen(menuButton.getAttribute('aria-expanded') !== 'true');
+  });
+  Array.prototype.forEach.call(closeButtons, function (button) {
+    button.addEventListener('click', function () {
+      setDrawerOpen(false);
+      menuButton.focus();
+    });
+  });
+  Array.prototype.forEach.call(drawerLayer.querySelectorAll('a'), function (link) {
+    link.addEventListener('click', function () {
+      setDrawerOpen(false);
+    });
+  });
+  document.addEventListener('keydown', function (event) {
+    if (event.key === 'Escape' && !drawerLayer.hidden) {
+      setDrawerOpen(false);
+      menuButton.focus();
+    }
+  });
+  function handleViewportChange(event) {
+    if (!event.matches && !drawerLayer.hidden) setDrawerOpen(false);
+  }
+  if (mobileQuery.addEventListener) mobileQuery.addEventListener('change', handleViewportChange);
+  else if (mobileQuery.addListener) mobileQuery.addListener(handleViewportChange);
+})();

+ 2 - 2
WebRoot/web/upload/ffkj-template/xingong-catalog.jsp

@@ -8,7 +8,7 @@
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="description" content="${navigation.desc}">
   <meta name="description" content="${navigation.desc}">
   <title>${navigation.name}_${website.seoTitle}</title>
   <title>${navigation.name}_${website.seoTitle}</title>
-  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261025-sidebar-1">
+  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261025-mobile-1">
   <%@ include file="school-schema-jsonld-include.jsp"%>
   <%@ include file="school-schema-jsonld-include.jsp"%>
 </head>
 </head>
 <body>
 <body>
@@ -27,7 +27,7 @@
     </div></section>
     </div></section>
   </main>
   </main>
   <%@ include file="xingong-footer.jsp"%>
   <%@ include file="xingong-footer.jsp"%>
-  <script src="/main/ffkj-portal/xingong-blue.js?v=20261023-xingong2"></script>
+  <script src="/main/ffkj-portal/xingong-blue.js?v=20261025-mobile-1"></script>
   <%@ include file="website-guest-gate-include.jsp"%>
   <%@ include file="website-guest-gate-include.jsp"%>
 </body>
 </body>
 </html>
 </html>

+ 2 - 2
WebRoot/web/upload/ffkj-template/xingong-details.jsp

@@ -7,7 +7,7 @@
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="description" content="${articleDescription}">
   <meta name="description" content="${articleDescription}">
   <title>${articleTitle}_${navigation.name}_${website.seoTitle}</title>
   <title>${articleTitle}_${navigation.name}_${website.seoTitle}</title>
-  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261025-details-1">
+  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261025-mobile-1">
   <%@ include file="school-schema-jsonld-include.jsp"%>
   <%@ include file="school-schema-jsonld-include.jsp"%>
 </head>
 </head>
 <body>
 <body>
@@ -25,7 +25,7 @@
     </div></section>
     </div></section>
   </main>
   </main>
   <%@ include file="xingong-footer.jsp"%>
   <%@ include file="xingong-footer.jsp"%>
-  <script src="/main/ffkj-portal/xingong-blue.js?v=20261023-xingong2"></script>
+  <script src="/main/ffkj-portal/xingong-blue.js?v=20261025-mobile-1"></script>
   <script src="/apps/space/js/secure-pdf.js?v=20260709-pdf-secure9"></script>
   <script src="/apps/space/js/secure-pdf.js?v=20260709-pdf-secure9"></script>
   <%@ include file="website-guest-gate-include.jsp"%>
   <%@ include file="website-guest-gate-include.jsp"%>
 </body>
 </body>

+ 21 - 0
WebRoot/web/upload/ffkj-template/xingong-header.jsp

@@ -1,6 +1,7 @@
 <%@ page pageEncoding="UTF-8"%>
 <%@ page pageEncoding="UTF-8"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
+<c:set var="xgDisplayTitle" value="${empty website.seoTitle ? website.name : website.seoTitle}"/>
 <header class="header">
 <header class="header">
   <div class="wm" aria-hidden="true">
   <div class="wm" aria-hidden="true">
     <svg class="l" viewBox="0 0 300 118" fill="none" stroke="#fff" stroke-width="1.4">
     <svg class="l" viewBox="0 0 300 118" fill="none" stroke="#fff" stroke-width="1.4">
@@ -28,6 +29,7 @@
         <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2.4" stroke-linecap="round"><circle cx="10.5" cy="10.5" r="7"/><path d="M20 20 l-4.6-4.6"/></svg>
         <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2.4" stroke-linecap="round"><circle cx="10.5" cy="10.5" r="7"/><path d="M20 20 l-4.6-4.6"/></svg>
       </button>
       </button>
     </form>
     </form>
+    <button class="xg-mobile-menu" type="button" aria-label="打开导航" aria-controls="xg-mobile-drawer" aria-expanded="false"><span></span><span></span><span></span></button>
   </div>
   </div>
 </header>
 </header>
 <nav class="nav" aria-label="主导航">
 <nav class="nav" aria-label="主导航">
@@ -48,3 +50,22 @@
     </c:forEach>
     </c:forEach>
   </ul>
   </ul>
 </nav>
 </nav>
+<div class="xg-drawer-layer" id="xg-mobile-drawer" hidden>
+  <button class="xg-drawer-mask" type="button" aria-label="关闭导航"></button>
+  <aside class="xg-drawer" aria-label="移动端导航">
+    <div class="xg-drawer-head"><strong>${xgDisplayTitle}</strong><button type="button" aria-label="关闭导航">×</button></div>
+    <nav class="xg-drawer-nav">
+      <a href="/">首页</a>
+      <c:forEach items="${navList}" var="item">
+        <c:if test="${item.name ne '首页子栏目'}">
+          <a href="${item.href}" target="${item.target}">${item.name}</a>
+          <c:if test="${not empty item.children}">
+            <div class="xg-drawer-children">
+              <c:forEach items="${item.children}" var="child"><a href="${child.href}" target="${child.target}">${child.name}</a></c:forEach>
+            </div>
+          </c:if>
+        </c:if>
+      </c:forEach>
+    </nav>
+  </aside>
+</div>

+ 2 - 2
WebRoot/web/upload/ffkj-template/xingong-index.jsp

@@ -10,7 +10,7 @@
   <meta name="keywords" content="${website.seoKeywords}">
   <meta name="keywords" content="${website.seoKeywords}">
   <meta name="description" content="${website.seoDescription}">
   <meta name="description" content="${website.seoDescription}">
   <title>${website.seoTitle}</title>
   <title>${website.seoTitle}</title>
-  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261023-xingong2">
+  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261025-mobile-1">
   <%@ include file="school-schema-jsonld-include.jsp"%>
   <%@ include file="school-schema-jsonld-include.jsp"%>
 </head>
 </head>
 <body>
 <body>
@@ -82,7 +82,7 @@
     </section>
     </section>
   </main>
   </main>
   <%@ include file="xingong-footer.jsp"%>
   <%@ include file="xingong-footer.jsp"%>
-  <script src="/main/ffkj-portal/xingong-blue.js?v=20261023-xingong2"></script>
+  <script src="/main/ffkj-portal/xingong-blue.js?v=20261025-mobile-1"></script>
   <%@ include file="website-guest-gate-include.jsp"%>
   <%@ include file="website-guest-gate-include.jsp"%>
 </body>
 </body>
 </html>
 </html>

+ 2 - 2
WebRoot/web/upload/ffkj-template/xingong-list.jsp

@@ -13,7 +13,7 @@
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="description" content="${navigation.desc}">
   <meta name="description" content="${navigation.desc}">
   <title>${navigation.name}_${website.seoTitle}</title>
   <title>${navigation.name}_${website.seoTitle}</title>
-  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261025-sidebar-1">
+  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261025-mobile-1">
   <%@ include file="school-schema-jsonld-include.jsp"%>
   <%@ include file="school-schema-jsonld-include.jsp"%>
 </head>
 </head>
 <body>
 <body>
@@ -42,7 +42,7 @@
     </div></section>
     </div></section>
   </main>
   </main>
   <%@ include file="xingong-footer.jsp"%>
   <%@ include file="xingong-footer.jsp"%>
-  <script src="/main/ffkj-portal/xingong-blue.js?v=20261023-xingong2"></script>
+  <script src="/main/ffkj-portal/xingong-blue.js?v=20261025-mobile-1"></script>
   <%@ include file="website-guest-gate-include.jsp"%>
   <%@ include file="website-guest-gate-include.jsp"%>
 </body>
 </body>
 </html>
 </html>

+ 2 - 2
WebRoot/web/upload/ffkj-template/xingong-search.jsp

@@ -8,7 +8,7 @@
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="description" content="${website.seoDescription}">
   <meta name="description" content="${website.seoDescription}">
   <title>站内搜索_${website.seoTitle}</title>
   <title>站内搜索_${website.seoTitle}</title>
-  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261023-xingong2">
+  <link rel="stylesheet" href="/main/ffkj-portal/xingong-blue.css?v=20261025-mobile-1">
   <%@ include file="school-schema-jsonld-include.jsp"%>
   <%@ include file="school-schema-jsonld-include.jsp"%>
 </head>
 </head>
 <body>
 <body>
@@ -33,7 +33,7 @@
     </div></section>
     </div></section>
   </main>
   </main>
   <%@ include file="xingong-footer.jsp"%>
   <%@ include file="xingong-footer.jsp"%>
-  <script src="/main/ffkj-portal/xingong-blue.js?v=20261023-xingong2"></script>
+  <script src="/main/ffkj-portal/xingong-blue.js?v=20261025-mobile-1"></script>
   <%@ include file="website-guest-gate-include.jsp"%>
   <%@ include file="website-guest-gate-include.jsp"%>
 </body>
 </body>
 </html>
 </html>