From b02a4fb3378803216201194d23a8d53a72eb3c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=BA=E6=99=BA=E7=9A=84=E5=B0=8F=E9=B1=BC=E5=90=9B?= <44761872+dragon-fish@users.noreply.github.com> Date: Thu, 4 Jan 2024 16:26:35 +0800 Subject: [PATCH] fix: drop alternative clicks (close #241) (#243) * fix: drop alternative clicks (close #241) * chore: rename files * fix: edge case of Safari --------- Co-authored-by: Dragon-Fish --- src/method/init.js | 2 +- src/module/_analytics.js | 2 +- src/module/_resolveExists.js | 4 ++-- src/module/linksHere.js | 2 +- src/module/loadQuickDiff.js | 8 ++++---- src/module/quickDelete.js | 6 +++--- src/module/quickDiff.js | 2 +- src/module/quickEdit.js | 10 +++++----- src/module/quickPreview.js | 2 +- src/module/quickRedirect.js | 2 +- src/module/quickRename.js | 8 ++++---- src/module/syncPreferences.js | 2 +- src/module/test.js | 3 --- src/{method => module}/updateNotice.js | 8 ++++---- src/module/version.js | 3 +-- src/{module/_hasRight.js => utils/hasRight.js} | 4 +++- src/utils/mouseEvent.js | 17 +++++++++++++++++ src/{module => utils}/mw.js | 2 +- 18 files changed, 51 insertions(+), 36 deletions(-) delete mode 100644 src/module/test.js rename src/{method => module}/updateNotice.js (87%) rename src/{module/_hasRight.js => utils/hasRight.js} (79%) create mode 100644 src/utils/mouseEvent.js rename src/{module => utils}/mw.js (85%) diff --git a/src/method/init.js b/src/method/init.js index 3c3d9cc..1a668a4 100644 --- a/src/method/init.js +++ b/src/method/init.js @@ -3,7 +3,6 @@ import _dir from './_dir' import { loadScript } from './loadScript' import { initQueryData } from './initQueryData' import { loadStyles } from './loadStyles' -import { updateNotice } from './updateNotice' import { syncI18nData } from './syncI18nData' import version from '../module/version' @@ -27,6 +26,7 @@ import { quickPreview } from '../module/quickPreview' import { quickRedirect } from '../module/quickRedirect' import { quickRename } from '../module/quickRename' import { specialNotice } from '../module/specialNotice' +import { updateNotice } from '../module/updateNotice' import { versionInfo } from '../module/versionInfo' /** diff --git a/src/module/_analytics.js b/src/module/_analytics.js index 6479ff6..2146829 100644 --- a/src/module/_analytics.js +++ b/src/module/_analytics.js @@ -1,6 +1,6 @@ import { analyticsApi } from './endpoints' import { preference } from './preference' -import { mwConfig } from './mw' +import { mwConfig } from '../utils/mw' import version from './version' /** diff --git a/src/module/_resolveExists.js b/src/module/_resolveExists.js index fda7939..0feb7bf 100644 --- a/src/module/_resolveExists.js +++ b/src/module/_resolveExists.js @@ -1,5 +1,5 @@ import { _msg } from './_msg' -import { _hasRight } from './_hasRight' +import { hasRight } from '../utils/hasRight' import { quickDelete } from './quickDelete' import { quickEdit } from './quickEdit' @@ -11,7 +11,7 @@ import { quickEdit } from './quickEdit' * @param {String} reason.edit 编辑原因 */ export const _resolveExists = function (page, reason = {}) { - const canDelete = _hasRight('delete') + const canDelete = hasRight('delete') if (typeof reason === 'string') { reason = { diff --git a/src/module/linksHere.js b/src/module/linksHere.js index 4534f92..183b95c 100644 --- a/src/module/linksHere.js +++ b/src/module/linksHere.js @@ -6,7 +6,7 @@ import { _analytics } from './_analytics' import { $progress, $link } from './_elements' import { _msg } from './_msg' -import { mwApi, mwConfig } from './mw' +import { mwApi, mwConfig } from '../utils/mw' import { quickEdit } from './quickEdit' /** diff --git a/src/module/loadQuickDiff.js b/src/module/loadQuickDiff.js index 1f515d2..82311a0 100644 --- a/src/module/loadQuickDiff.js +++ b/src/module/loadQuickDiff.js @@ -2,7 +2,8 @@ import { _msg } from './_msg' import { _analytics } from './_analytics' import { quickDiff } from './quickDiff' import { quickEdit } from './quickEdit' -import { mwConfig } from './mw' +import { mwConfig } from '../utils/mw' +import { isPureLMBClick } from '../utils/mouseEvent' const { getParamValue } = mw.util function injectLinks(container) { @@ -87,6 +88,7 @@ function injectLinks(container) { // 点击事件 $this.on('click', function (e) { + if (!isPureLMBClick(e)) return e.preventDefault() _analytics('quick_diff_recentchanges') return quickDiff(params) @@ -108,9 +110,7 @@ export function loadQuickDiff(container) { $('