From 5e50dba1a15b2e312c640347f7fa10cf83111af1 Mon Sep 17 00:00:00 2001 From: sight <26325820+Sight-wcg@users.noreply.github.com> Date: Thu, 22 May 2025 22:08:15 +0800 Subject: [PATCH] =?UTF-8?q?wip(i18n):=20laypage=20=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layui.js | 11 +++++++++++ src/modules/laypage.js | 25 +++++++++++++++---------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/layui.js b/src/layui.js index 7cffa388..34628521 100644 --- a/src/layui.js +++ b/src/layui.js @@ -57,6 +57,17 @@ week: '周', day: '天' } + }, + laypage: { + prev: '上一页', + next: '下一页', + first: '首页', + last: '尾页', + total: '共 {total} 条', + pagesize: '条/页', + goto: '到第', + page: '页', + confirm: '确定' } } // 基础配置 diff --git a/src/modules/laypage.js b/src/modules/laypage.js index 0a7eba91..2c486bea 100644 --- a/src/modules/laypage.js +++ b/src/modules/laypage.js @@ -72,8 +72,8 @@ layui.define(function(exports) { groups = config.pages; } - config.prev = 'prev' in config ? config.prev : layui.$t('上一页'); // 上一页文本 - config.next = 'next' in config ? config.next : layui.$t('下一页'); // 下一页文本 + config.prev = 'prev' in config ? config.prev : layui.$t('lay.laypage.prev'); // 上一页文本 + config.next = 'next' in config ? config.next : layui.$t('lay.laypage.next'); // 下一页文本 // 计算当前组 var index = config.pages > groups @@ -100,7 +100,7 @@ layui.define(function(exports) { // 首页 if(index > 1 && config.first !== false && groups !== 0){ - pager.push(layui.$t('')+ (config.first || 1) +''); + pager.push('' + (config.first || 1) +''); } // 计算当前页码组的起始页 @@ -119,6 +119,8 @@ layui.define(function(exports) { // 输出左分割符 if(config.first !== false && start > 2){ pager.push('...') + console.log(pager); + } // 输出连续页码 @@ -137,7 +139,7 @@ layui.define(function(exports) { pager.push('...'); } if(groups !== 0){ - pager.push(layui.$t(''+ (config.last || config.pages) +''); + pager.push(''+ (config.last || config.pages) +''); } } @@ -153,15 +155,18 @@ layui.define(function(exports) { // 数据总数 count: function(){ - var countText = typeof config.countText === 'object' ? config.countText : [layui.$t('共')+ ' ', ' ' + layui.$t('条')]; - return ''+ countText[0] + config.count + countText[1] +'' + var countText = typeof config.countText === 'object' + ? countText[0] + config.count + countText[1] + : layui.$t('lay.laypage.total', {total: config.count}); + + return ''+ countText +'' }(), // 每页条数 limit: function(){ var elemArr = ['