From 06b2497ee160f82eba9343b97e589e4c18bd15ba Mon Sep 17 00:00:00 2001 From: "lzyme.dev@gmail.com" Date: Sun, 30 Aug 2026 20:10:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D115=E5=9B=BA=E6=9C=89jq?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=8A=A0=E8=BD=BD=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/jhs-enhance.user.js | 44 +++++++++++++++++++++------------------- src/core/globals.js | 6 ++---- src/main.js | 44 +++++++++++++++++++++------------------- vite.config.mjs | 15 -------------- 4 files changed, 48 insertions(+), 61 deletions(-) diff --git a/dist/jhs-enhance.user.js b/dist/jhs-enhance.user.js index 64ab7fa..30e72bc 100644 --- a/dist/jhs-enhance.user.js +++ b/dist/jhs-enhance.user.js @@ -1100,7 +1100,7 @@ ); insertStyle(mainCss); insertStyle(subtitleModalCss); - window.jQuery = $$1; + window.$ = window.jQuery = $$1; if (typeof $$1.trim !== "function") { $$1.trim = function (text) { return text == null ? "" : (text + "").trim(); @@ -16944,26 +16944,28 @@ ${err.stack}` : ""); var el; })); })(); - const originalLayerClose = layer.close; - layer.close = function(index) { - const result = originalLayerClose.call(this, index); - !(function(waitTime = 10) { - setTimeout((() => { - const openLayerCount = document.querySelectorAll(".layui-layer-shade").length; - document.documentElement.style.overflow = openLayerCount > 0 ? "hidden" : ""; - }), waitTime); - })(); - return result; - }; - const originalLayerOpen = layer.open; - layer.open = function(options) { - const originalSuccess = (options = options || {}).success; - options.success = function(layero, index) { - "function" == typeof originalSuccess && originalSuccess.call(this, layero, index); - utils.setupEscClose(index); - }; - return originalLayerOpen.call(this, options); - }; + if (typeof layer !== "undefined") { + const originalLayerClose = layer.close; + layer.close = function (index) { + const result = originalLayerClose.call(this, index); + !(function (waitTime = 10) { + setTimeout((() => { + const openLayerCount = document.querySelectorAll(".layui-layer-shade").length; + document.documentElement.style.overflow = openLayerCount > 0 ? "hidden" : ""; + }), waitTime); + })(); + return result; + }; + const originalLayerOpen = layer.open; + layer.open = function (options) { + const originalSuccess = (options = options || {}).success; + options.success = function (layero, index) { + "function" == typeof originalSuccess && originalSuccess.call(this, layero, index); + utils.setupEscClose(index); + }; + return originalLayerOpen.call(this, options); + }; + } utils.importResource("https://cdn.jsdelivr.net/npm/layui-layer@1.0.9/layer.min.css"); utils.importResource("https://cdn.jsdelivr.net/npm/toastify-js@1.12.0/src/toastify.min.css"); utils.importResource("https://cdn.jsdelivr.net/npm/viewerjs@1.11.1/dist/viewer.min.css"); diff --git a/src/core/globals.js b/src/core/globals.js index 5f2a914..2898142 100644 --- a/src/core/globals.js +++ b/src/core/globals.js @@ -6,7 +6,7 @@ import Viewer from 'viewerjs'; import QRCode from 'qrcodejs'; import { currentHref, isJavDb, isJavBus, isSearchPage, Status_RUNNING, Status_SUCCESS, Status_FAIL, Status_LOADING, Status_FILTER, Status_FAVORITE, Status_HAS_DOWN, Status_HAS_WATCH, NO, YES } from './constants.js'; -window.jQuery = $; +window.$ = window.jQuery = $; if (typeof $.trim !== 'function') { $.trim = function (text) { return text == null ? '' : (text + '').trim(); @@ -31,6 +31,4 @@ window.Status_FAVORITE = Status_FAVORITE; window.Status_HAS_DOWN = Status_HAS_DOWN; window.Status_HAS_WATCH = Status_HAS_WATCH; window.NO = NO; -window.YES = YES; - -import 'layui-layer'; \ No newline at end of file +window.YES = YES; \ No newline at end of file diff --git a/src/main.js b/src/main.js index 7488691..83a7738 100644 --- a/src/main.js +++ b/src/main.js @@ -820,29 +820,31 @@ window.ImageHoverPreview = class { })); }(); -const originalLayerClose = layer.close; +if (typeof layer !== 'undefined') { + const originalLayerClose = layer.close; -layer.close = function(index) { - const result = originalLayerClose.call(this, index); - !function(waitTime = 10) { - setTimeout((() => { - const openLayerCount = document.querySelectorAll(".layui-layer-shade").length; - document.documentElement.style.overflow = openLayerCount > 0 ? "hidden" : ""; - }), waitTime); - }(); - return result; -}; - -const originalLayerOpen = layer.open; - -layer.open = function(options) { - const originalSuccess = (options = options || {}).success; - options.success = function(layero, index) { - "function" == typeof originalSuccess && originalSuccess.call(this, layero, index); - utils.setupEscClose(index); + layer.close = function (index) { + const result = originalLayerClose.call(this, index); + !function (waitTime = 10) { + setTimeout((() => { + const openLayerCount = document.querySelectorAll(".layui-layer-shade").length; + document.documentElement.style.overflow = openLayerCount > 0 ? "hidden" : ""; + }), waitTime); + }(); + return result; }; - return originalLayerOpen.call(this, options); -}; + + const originalLayerOpen = layer.open; + + layer.open = function (options) { + const originalSuccess = (options = options || {}).success; + options.success = function (layero, index) { + "function" == typeof originalSuccess && originalSuccess.call(this, layero, index); + utils.setupEscClose(index); + }; + return originalLayerOpen.call(this, options); + }; +} utils.importResource("https://cdn.jsdelivr.net/npm/layui-layer@1.0.9/layer.min.css"); diff --git a/vite.config.mjs b/vite.config.mjs index e7c2f68..a2a1e3d 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -99,23 +99,8 @@ export default defineConfig({ 'tabulator-tables': 'Tabulator', 'viewerjs': 'Viewer', 'qrcodejs': 'QRCode', - 'layui-layer': 'layer', }, }, }), - { - name: 'layui-layer-dev-shim', - apply: 'serve', - resolveId(id) { - if (id === 'layui-layer') { - return '\0layui-layer-shim'; - } - }, - load(id) { - if (id === '\0layui-layer-shim') { - return 'export default window.layer;'; - } - }, - }, ], }); \ No newline at end of file