From 35b1b26f1fe16550b4ee2881a26d599456fe59b4 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期四, 22 一月 2026 17:01:11 +0800
Subject: [PATCH] #i18n翻译

---
 src/main/webapp/static/layui/lay/modules/index.js |   43 +++++++++++++++++++++++++++++++------------
 1 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/src/main/webapp/static/layui/lay/modules/index.js b/src/main/webapp/static/layui/lay/modules/index.js
index 93d9297..803f271 100644
--- a/src/main/webapp/static/layui/lay/modules/index.js
+++ b/src/main/webapp/static/layui/lay/modules/index.js
@@ -31,8 +31,21 @@
                     return admin.activeNav(index.mTabPosition);
                 }
                 mIsAddTab = true;
+                var titleHtml = param.menuName || '';
+                if (!param.i18nKey && param.menuPath) {
+                    var $menuItem = $(sideDOM).find('a[lay-href="' + param.menuPath + '"]');
+                    if ($menuItem.length > 0) {
+                        param.i18nKey = $menuItem.attr('data-i18n-key');
+                    }
+                }
+                if (param.i18nKey && typeof I18n !== 'undefined') {
+                    titleHtml = I18n.t(param.i18nKey);
+                }
+                if (param.i18nKey) {
+                    titleHtml = '<span data-i18n="' + param.i18nKey + '">' + titleHtml + '</span>';
+                }
                 element.tabAdd(tabFilter, {
-                    id: param.menuPath, title: '<span class="title">' + (param.menuName || '') + '</span>',
+                    id: param.menuPath, title: '<span class="title">' + titleHtml + '</span>',
                     content: '<iframe class="admin-iframe" lay-id="' + param.menuPath + '" src="' + param.menuPath +
                         '" onload="layui.index.hideLoading(this);" frameborder="0"></iframe>'
                 });
@@ -63,11 +76,16 @@
             index.mTabList.splice(0, index.mTabList.length);
             if (param.menuPath === index.homeUrl) {
                 index.mTabPosition = undefined;
-                index.setTabTitle($(param.menuName).text() || $(sideDOM + ' [lay-href="' + index.homeUrl + '"]').text() || '涓婚〉');
+                var homeTitle = $(param.menuName).text() || $(sideDOM + ' [lay-href="' + index.homeUrl + '"]').text() || '<span data-i18n="home">涓婚〉</span>';
+                index.setTabTitle(homeTitle);
             } else {
                 index.mTabPosition = param.menuPath;
                 index.mTabList.push(param);
-                index.setTabTitle(param.menuName);
+                var titleHtml = param.menuName || '';
+                if (param.i18nKey) {
+                    titleHtml = '<span data-i18n="' + param.i18nKey + '">' + titleHtml + '</span>';
+                }
+                index.setTabTitle(titleHtml);
             }
             if (!setter.cacheTab) return;
             admin.putTempData('indexTabs', index.mTabList);
@@ -97,7 +115,7 @@
     index.openTab = function (param) {
         if (window !== top && !admin.isTop() && top.layui && top.layui.index) return top.layui.index.openTab(param);
         if (param.end) tabEndCall[param.url] = param.end;
-        index.loadView({menuPath: param.url, menuName: param.title});
+        index.loadView({menuPath: param.url, menuName: param.title, i18nKey: param.i18nKey});
     };
 
     /** 鍏抽棴tab */
@@ -196,9 +214,9 @@
             '   <ul class="layui-nav" lay-filter="admin-pagetabs-nav">',
             '      <li class="layui-nav-item" lay-unselect>',
             '         <dl class="layui-nav-child layui-anim-fadein">',
-            '            <dd ew-event="closeThisTabs" lay-unselect><a>鍏抽棴褰撳墠鏍囩椤�</a></dd>',
-            '            <dd ew-event="closeOtherTabs" lay-unselect><a>鍏抽棴鍏跺畠鏍囩椤�</a></dd>',
-            '            <dd ew-event="closeAllTabs" lay-unselect><a>鍏抽棴鍏ㄩ儴鏍囩椤�</a></dd>',
+            '            <dd ew-event="closeThisTabs" lay-unselect><a data-i18n="鍏抽棴褰撳墠鏍囩椤�">鍏抽棴褰撳墠鏍囩椤�</a></dd>',
+            '            <dd ew-event="closeOtherTabs" lay-unselect><a data-i18n="鍏抽棴鍏朵粬鏍囩椤�">鍏抽棴鍏跺畠鏍囩椤�</a></dd>',
+            '            <dd ew-event="closeAllTabs" lay-unselect><a data-i18n="鍏抽棴鎵�鏈夋爣绛鹃〉">鍏抽棴鍏ㄩ儴鏍囩椤�</a></dd>',
             '         </dl>',
             '      </li>',
             '   </ul>',
@@ -214,6 +232,7 @@
         if (!href || href === '#') return;
         if (href.indexOf('javascript:') === 0) return new Function(href.substring(11))();
         var name = $that.attr('ew-title') || $that.text().replace(/(^\s*)|(\s*$)/g, '');
+        var i18nKey = $that.attr('data-i18n-key');
         var end = $that.attr('ew-end');
         try {
             if (end) end = new Function(end);
@@ -221,7 +240,7 @@
         } catch (e) {
             console.error(e);
         }
-        index.openTab({url: href, title: name, end: end});
+        index.openTab({url: href, title: name, end: end, i18nKey: i18nKey});
         layui.event.call(this, 'admin', 'side({*})', {href: href});
     });
 
@@ -269,26 +288,26 @@
                 var layId = $(this).attr('lay-id');
                 layui.contextMenu.show([{
                     icon: 'layui-icon layui-icon-refresh',
-                    name: '鍒锋柊褰撳墠',
+                    name: typeof I18n !== 'undefined' ? I18n.t('鍒锋柊') : '鍒锋柊褰撳墠',
                     click: function () {
                         element.tabChange(tabFilter, layId);
                         if ('true' != $(tabDOM).attr('lay-autoRefresh')) admin.refresh(layId);
                     }
                 }, {
                     icon: 'layui-icon layui-icon-close-fill ctx-ic-lg',
-                    name: '鍏抽棴褰撳墠',
+                    name: typeof I18n !== 'undefined' ? I18n.t('鍏抽棴褰撳墠') : '鍏抽棴褰撳墠',
                     click: function () {
                         admin.closeThisTabs(layId);
                     }
                 }, {
                     icon: 'layui-icon layui-icon-unlink',
-                    name: '鍏抽棴鍏朵粬',
+                    name: typeof I18n !== 'undefined' ? I18n.t('鍏抽棴鍏朵粬') : '鍏抽棴鍏朵粬',
                     click: function () {
                         admin.closeOtherTabs(layId);
                     }
                 }, {
                     icon: 'layui-icon layui-icon-close ctx-ic-lg',
-                    name: '鍏抽棴鍏ㄩ儴',
+                    name: typeof I18n !== 'undefined' ? I18n.t('鍏抽棴鎵�鏈�') : '鍏抽棴鍏ㄩ儴',
                     click: function () {
                         admin.closeAllTabs();
                     }

--
Gitblit v1.9.1