From 1fb3ba0d0ce76034106264c063a173c99ef58244 Mon Sep 17 00:00:00 2001 From: Karson Date: Tue, 1 Apr 2025 09:06:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=AD=E8=A8=80=E5=8C=85?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=92=8C=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-backend.js | 11 ++++++++++- public/assets/js/require-frontend.js | 19 +++++++++++++++++-- public/assets/js/require-table.js | 4 +++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/public/assets/js/require-backend.js b/public/assets/js/require-backend.js index c67470f5..0cdbdd3f 100644 --- a/public/assets/js/require-backend.js +++ b/public/assets/js/require-backend.js @@ -19,7 +19,7 @@ require.config({ 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch', 'bootstrap-table-template': 'bootstrap-table-template', // - // 以下的包从bower的libs目录加载 + // 以下的包从libs目录加载 'jquery': '../libs/jquery/dist/jquery.min', 'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min', 'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min', @@ -133,6 +133,15 @@ require(['jquery', 'bootstrap'], function ($, undefined) { paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language; // 避免目录冲突 paths['backend/'] = 'backend/'; + // 如果是英文,则移除默认的定义 + if (Config.language === 'en') { + $.each(requirejs.s.contexts._.config.paths, function (key, value) { + if (key.match(/\-lang$/)) { + define(key); + } + }); + define('moment/locale/zh-cn'); + } require.config({paths: paths}); // 初始化 diff --git a/public/assets/js/require-frontend.js b/public/assets/js/require-frontend.js index 67f259cc..13183d7e 100644 --- a/public/assets/js/require-frontend.js +++ b/public/assets/js/require-frontend.js @@ -19,7 +19,7 @@ require.config({ 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch', 'bootstrap-table-template': 'bootstrap-table-template', // - // 以下的包从bower的libs目录加载 + // 以下的包从libs目录加载 'jquery': '../libs/jquery/dist/jquery.min', 'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min', 'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min', @@ -132,6 +132,15 @@ require(['jquery', 'bootstrap'], function ($, undefined) { paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language; // 避免目录冲突 paths['frontend/'] = 'frontend/'; + // 如果是英文,则移除默认的定义 + if (Config.language === 'en') { + $.each(requirejs.s.contexts._.config.paths, function (key, value) { + if (key.match(/\-lang$/)) { + define(key); + } + }); + define('moment/locale/zh-cn'); + } require.config({paths: paths}); // 初始化 @@ -141,7 +150,13 @@ require(['jquery', 'bootstrap'], function ($, undefined) { //加载相应模块 if (Config.jsname) { require([Config.jsname], function (Controller) { - Controller[Config.actionname] != undefined && Controller[Config.actionname](); + if (Controller.hasOwnProperty(Config.actionname)) { + Controller[Config.actionname](); + } else { + if (Controller.hasOwnProperty("_empty")) { + Controller._empty(); + } + } }, function (e) { console.error(e); // 这里可捕获模块加载的错误 diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index 5ba1f901..4c98aa66 100644 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -34,7 +34,9 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table singleSelect: false, //是否启用单选 showRefresh: false, showJumpto: true, - locale: Config.language === 'zh-cn' ? 'zh-CN' : 'en-US', + locale: Config.language === 'en' ? 'en-US' : Config.language.replace(/\-(\w+)$/, function (value) { + return value.toUpperCase(); + }), showToggle: true, showColumns: true, pk: 'id',