fix: 更新 layui 升级导致的 jQuery 兼容问题

This commit is contained in:
邹景立 2025-03-20 16:58:54 +08:00
parent 51245ddedd
commit 460e06bdf2
3 changed files with 10 additions and 10 deletions

View File

@ -24,7 +24,7 @@ define(['md5', 'notify'], function (SparkMD5, Notify, allowMime) {
this.option.input = $(this.option.elem.data('input')) this.option.input = $(this.option.elem.data('input'))
} else if (this.option.elem.data('field')) { } else if (this.option.elem.data('field')) {
this.option.input = $('input[name="' + this.option.elem.data('field') + '"]:not([type=file])'); this.option.input = $('input[name="' + this.option.elem.data('field') + '"]:not([type=file])');
this.option.elem.data('input', this.option.input.size() > 0 ? this.option.input.get(0) : null); this.option.elem.data('input', this.option.input.length > 0 ? this.option.input.get(0) : null);
} }
/*! 文件选择筛选,使用 MIME 规则过滤文件列表 */ /*! 文件选择筛选,使用 MIME 规则过滤文件列表 */

View File

@ -182,7 +182,7 @@ $(function () {
/*! 关闭顶层最新窗口 */ /*! 关闭顶层最新窗口 */
this.closeLastModal = function () { this.closeLastModal = function () {
while ($.msg.mdx.length > 0 && (this.tdx = $.msg.mdx.pop()) > 0) { while ($.msg.mdx.length > 0 && (this.tdx = $.msg.mdx.pop()) > 0) {
if ($('#layui-layer' + this.tdx).size()) return layer.close(this.tdx); if ($('#layui-layer' + this.tdx).length) return layer.close(this.tdx);
} }
}; };
/*! 关闭消息框 */ /*! 关闭消息框 */
@ -404,15 +404,15 @@ $(function () {
this.queryNode = function (uri, node) { this.queryNode = function (uri, node) {
// 如果该节点存在直接返回 Node 值 // 如果该节点存在直接返回 Node 值
if (/^m-/.test(node = node || location.href.replace(/.*spm=([\d\-m]+).*/ig, '$1'))) { if (/^m-/.test(node = node || location.href.replace(/.*spm=([\d\-m]+).*/ig, '$1'))) {
if ($('[data-menu-node="' + node + '"]').size()) return node; if ($('[data-menu-node="' + node + '"]').length) return node;
} }
let path = uri.replace(/\.html$/ig, ''); let path = uri.replace(/\.html$/ig, '');
// 尝试通过 URI 查询节点值 // 尝试通过 URI 查询节点值
let $menu = $('[data-menu-node][data-open*="' + path + '"]'); let $menu = $('[data-menu-node][data-open*="' + path + '"]');
if ($menu.size()) return $menu.get(0).dataset.menuNode; if ($menu.length) return $menu.get(0).dataset.menuNode;
// 尝试通过 URL 查询节点值 // 尝试通过 URL 查询节点值
$menu = $('[data-menu-node][data-open~="#' + path + '"]'); $menu = $('[data-menu-node][data-open~="#' + path + '"]');
return $menu.size() ? $menu.get(0).dataset.menuNode : (/^m-/.test(node || '') ? node : ''); return $menu.length ? $menu.get(0).dataset.menuNode : (/^m-/.test(node || '') ? node : '');
}; };
/*! 完整 URL 转 URI 地址 */ /*! 完整 URL 转 URI 地址 */
this.parseUri = function (uri, elem, vars, temp, attrs) { this.parseUri = function (uri, elem, vars, temp, attrs) {
@ -665,10 +665,10 @@ $(function () {
// 默认动态设置页数, 动态设置最大高度 // 默认动态设置页数, 动态设置最大高度
if (option.page === true) option.page = {curr: layui.sessionData('pages')[option.id] || 1}; if (option.page === true) option.page = {curr: layui.sessionData('pages')[option.id] || 1};
if (option.width === 'full') option.width = $table.parent().width(); if (option.width === 'full') option.width = $table.parent().width();
if (option.height === 'full') if ($table.parents('.iframe-pagination').size()) { if (option.height === 'full') if ($table.parents('.iframe-pagination').length) {
$table.parents('.iframe-pagination').addClass('not-footer'); $table.parents('.iframe-pagination').addClass('not-footer');
option.height = $(window).height() - $table.removeClass('layui-hide').offset().top - 20; option.height = $(window).height() - $table.removeClass('layui-hide').offset().top - 20;
} else if ($table.parents('.laytable-pagination').size()) { } else if ($table.parents('.laytable-pagination').length) {
option.height = $table.parents('.laytable-pagination').height() - $table.removeClass('layui-hide').position().top - 20; option.height = $table.parents('.laytable-pagination').height() - $table.removeClass('layui-hide').position().top - 20;
} else { } else {
option.height = $(window).height() - $table.removeClass('layui-hide').offset().top - 35; option.height = $(window).height() - $table.removeClass('layui-hide').offset().top - 35;
@ -814,7 +814,7 @@ $(function () {
let type = form.getAttribute('method') || 'POST', href = form.getAttribute('action') || location.href; let type = form.getAttribute('method') || 'POST', href = form.getAttribute('action') || location.href;
let dset = form.dataset, tips = dset.tips || undefined, time = dset.time || undefined, taid = dset.tableId || false; let dset = form.dataset, tips = dset.tips || undefined, time = dset.time || undefined, taid = dset.tableId || false;
let call = window[dset.callable || '_default_callable'] || (taid ? function (ret) { let call = window[dset.callable || '_default_callable'] || (taid ? function (ret) {
if (typeof ret === 'object' && ret.code > 0 && $('#' + taid).size() > 0) { if (typeof ret === 'object' && ret.code > 0 && $('#' + taid).length > 0) {
return $.msg.success(ret.info, 3, function () { return $.msg.success(ret.info, 3, function () {
$.msg.closeLastModal(); $.msg.closeLastModal();
(typeof ret.data === 'string' && ret.data) ? $.form.goto(ret.data) : $.layTable.reload(taid); (typeof ret.data === 'string' && ret.data) ? $.form.goto(ret.data) : $.layTable.reload(taid);
@ -853,7 +853,7 @@ $(function () {
/*! 查找表单元素, 如果没有找到将不会自动写值 */ /*! 查找表单元素, 如果没有找到将不会自动写值 */
if (!(this.$elem = $(this)).data('input') && this.$elem.data('field')) { if (!(this.$elem = $(this)).data('input') && this.$elem.data('field')) {
let $input = $('input[name="' + this.$elem.data('field') + '"]:not([type=file])'); let $input = $('input[name="' + this.$elem.data('field') + '"]:not([type=file])');
this.$elem.data('input', $input.size() > 0 ? $input.get(0) : null); this.$elem.data('input', $input.length > 0 ? $input.get(0) : null);
} }
// 单图或多图选择器 ( image|images ) // 单图或多图选择器 ( image|images )
if (typeof this.dataset.file === 'string' && /^images?$/.test(this.dataset.file)) { if (typeof this.dataset.file === 'string' && /^images?$/.test(this.dataset.file)) {

View File

@ -37,7 +37,7 @@
function apply(data) { function apply(data) {
this.$active = $("[data-wechat-type='" + data.value + "']").trigger('click'); this.$active = $("[data-wechat-type='" + data.value + "']").trigger('click');
if (this.$active.size() < 1) $("[data-wechat-type]:first").trigger('click'); if (this.$active.length < 1) $("[data-wechat-type]:first").trigger('click');
$('[data-type="' + data.value + '"]').show().siblings('[data-type]').hide(); $('[data-type="' + data.value + '"]').show().siblings('[data-type]').hide();
} }
}); });