From efeb4aa5a3a52e468482da5e208709123654f15e Mon Sep 17 00:00:00 2001 From: sunhao Date: Wed, 28 Aug 2024 13:35:44 +0800 Subject: [PATCH] * [ui] support open next and prev url in detail page by hotkey. --- lib/zin/wg/detail/v1.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/zin/wg/detail/v1.php b/lib/zin/wg/detail/v1.php index 4db5339f23..84020b0d65 100644 --- a/lib/zin/wg/detail/v1.php +++ b/lib/zin/wg/detail/v1.php @@ -544,6 +544,19 @@ CSS; $this->buildBody(), $layout === 'simple' ? null : $this->buildPrevAndNext(), html($app->control->appendExtendCssAndJS('', '', $this->prop('object'))), + js + ( + 'const $doc = $(document)', + 'const binddedKey = "zt.detail.bindded"', + 'if($doc.data(binddedKey)) return', + '$doc.on("keyup.detail.zt", e => {', + 'let $btn = null', + 'if(e.keyCode === 37) $btn = $(".detail-prev-btn")', + 'else if(e.keyCode === 39) $btn = $(".detail-next-btn")', + 'if($btn && $btn.length) $btn[0].click()', + '}).data(binddedKey, true)', + '$doc.one("pageunmount.app", () => {$(document).off("keyup.detail.zt").removeData(binddedKey)})' + ) ); } }