From fcbab338099aa75243870f2f83f7b742393297ed Mon Sep 17 00:00:00 2001 From: eondrcode <2106626532@qq.com> Date: Sun, 24 May 2026 16:09:48 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A1.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lang/locale/en.ts | 9 +- src/lang/locale/es.ts | 3 +- src/lang/locale/fr.ts | 1 + src/lang/locale/ja.ts | 3 +- src/lang/locale/ko.ts | 3 +- src/lang/locale/ru.ts | 1 + src/lang/locale/zh_cn.ts | 3 +- src/modal/manager-modal.ts | 1112 ++++++++++++++++++------------------ 8 files changed, 583 insertions(+), 552 deletions(-) diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index a89b650..e4fc2c2 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -116,10 +116,11 @@ export default { 管理器_检查更新_描述: 'Check for plugin updates', 管理器_更多操作_描述: 'More actions', 管理器_一键禁用_描述: 'Disable all plugins at once', - 管理器_一键启用_描述: 'Enable all plugins at once', - 管理器_全选取消_描述: 'Select all / clear current list', - 管理器_插件设置_描述: 'Manage plugin settings', - 管理器_仅启用_描述: 'Only display enabled plugins', + 管理器_一键启用_描述: 'Enable all plugins at once', + 管理器_全选取消_描述: 'Select all / clear current list', + 管理器_插件市场_描述: 'Open plugin market', + 管理器_插件设置_描述: 'Manage plugin settings', + 管理器_仅启用_描述: 'Only display enabled plugins', 管理器_未分组_描述: 'Filter all ungrouped plugins', 管理器_打开设置_描述: 'Open the settings interface', 管理器_还原内容_描述: 'Restore to the initial state', diff --git a/src/lang/locale/es.ts b/src/lang/locale/es.ts index fb17a32..8271fee 100644 --- a/src/lang/locale/es.ts +++ b/src/lang/locale/es.ts @@ -24,7 +24,8 @@ export default { 管理器_更多操作_描述: 'Más acciones', 管理器_一键禁用_描述: 'Deshabilitar todos los plugins a la vez', 管理器_一键启用_描述: 'Habilitar todos los plugins a la vez', - 管理器_插件设置_描述: 'Administrar configuración de plugins', + 管理器_插件市场_描述: 'Abrir mercado de plugins', + 管理器_插件设置_描述: 'Administrar configuración de plugins', 管理器_仅启用_描述: 'Mostrar solo plugins habilitados', 管理器_打开设置_描述: 'Abrir la interfaz de configuración', 管理器_还原内容_描述: 'Restaurar al estado inicial', diff --git a/src/lang/locale/fr.ts b/src/lang/locale/fr.ts index 7dbe2a3..149e48c 100644 --- a/src/lang/locale/fr.ts +++ b/src/lang/locale/fr.ts @@ -96,6 +96,7 @@ export default { 管理器_检查更新_描述: 'Vérifier les mises à jour de plugins', 管理器_一键禁用_描述: 'Tout désactiver en un clic', 管理器_一键启用_描述: 'Tout activer en un clic', + 管理器_插件市场_描述: 'Ouvrir le marché des plugins', 管理器_插件设置_描述: 'Gérer les paramètres du plugin', 管理器_仅启用_描述: 'Afficher uniquement les plugins activés', 管理器_未分组_描述: 'Filtrer les plugins non groupés', diff --git a/src/lang/locale/ja.ts b/src/lang/locale/ja.ts index 2f25847..043a4d3 100644 --- a/src/lang/locale/ja.ts +++ b/src/lang/locale/ja.ts @@ -23,7 +23,8 @@ export default { 管理器_检查更新_描述: 'プラグインの更新を確認する', 管理器_一键禁用_描述: '一度にすべてのプラグインを無効にします', 管理器_一键启用_描述: '一度にすべてのプラグインを有効にします', - 管理器_插件设置_描述: 'プラグインの設定を管理する', + 管理器_插件市场_描述: 'プラグインマーケットを開く', + 管理器_插件设置_描述: 'プラグインの設定を管理する', 管理器_仅启用_描述: '有効なプラグインのみを表示する', 管理器_打开设置_描述: '設定インターフェースを開く', 管理器_还原内容_描述: '初期状態に戻す', diff --git a/src/lang/locale/ko.ts b/src/lang/locale/ko.ts index 6d528f9..7c5e0d0 100644 --- a/src/lang/locale/ko.ts +++ b/src/lang/locale/ko.ts @@ -23,7 +23,8 @@ export default { 管理器_检查更新_描述: '플러그인 업데이트를 확인하세요', 管理器_一键禁用_描述: '한 번에 모든 플러그인을 비활성화하세요', 管理器_一键启用_描述: '한 번에 모든 플러그인을 활성화하세요', - 管理器_插件设置_描述: '플러그인 설정을 관리하세요', + 管理器_插件市场_描述: '플러그인 마켓 열기', + 管理器_插件设置_描述: '플러그인 설정을 관리하세요', 管理器_仅启用_描述: '활성화된 플러그인만 표시하세요', 管理器_打开设置_描述: '설정 인터페이스를 엽니다', 管理器_还原内容_描述: '초기 상태로 복원하세요', diff --git a/src/lang/locale/ru.ts b/src/lang/locale/ru.ts index 755d40b..db8d0e1 100644 --- a/src/lang/locale/ru.ts +++ b/src/lang/locale/ru.ts @@ -80,6 +80,7 @@ export default { 管理器_检查更新_描述: 'Проверить обновления плагинов', 管理器_一键禁用_描述: 'Отключить все плагины разом', 管理器_一键启用_描述: 'Включить все плагины разом', + 管理器_插件市场_描述: 'Открыть магазин плагинов', 管理器_插件设置_描述: 'Управление настройками плагина', 管理器_仅启用_描述: 'Показывать только включенные', 管理器_打开设置_描述: 'Открыть настройки', diff --git a/src/lang/locale/zh_cn.ts b/src/lang/locale/zh_cn.ts index e9fc885..ac2bb97 100644 --- a/src/lang/locale/zh_cn.ts +++ b/src/lang/locale/zh_cn.ts @@ -41,8 +41,9 @@ export default { 管理器_一键禁用_描述: '一键禁用所有插件', 管理器_一键启用_描述: '一键启用所有插件', 管理器_全选取消_描述: '全选/全部取消当前列表', + 管理器_插件市场_描述: '打开插件市场', 管理器_插件设置_描述: '管理插件设置', - 管理器_仅启用_描述: '仅显示已启用插件', + 管理器_仅启用_描述: '仅显示已启用插件', 管理器_未分组_描述: '筛选所有未分组插件', 管理器_打开设置_描述: '打开设置界面', 管理器_还原内容_描述: '还原初始状态', diff --git a/src/modal/manager-modal.ts b/src/modal/manager-modal.ts index 55b9076..541b400 100644 --- a/src/modal/manager-modal.ts +++ b/src/modal/manager-modal.ts @@ -17,7 +17,7 @@ import { } from "obsidian"; import { BetaSource, BPM_IGNORE_TAG, InstallHistoryItem, ManagerPlugin, PluginLayoutItem } from "../data/types"; -import { DEFAULT_MAIN_PAGE_ACTION_PLACEMENT, MainPageActionId, ManagerSettings } from "../settings/data"; +import { DEFAULT_MAIN_PAGE_ACTION_PLACEMENT, MainPageActionId, ManagerSettings } from "../settings/data"; import { managerOpen } from "../utils"; import Manager from "main"; @@ -54,19 +54,19 @@ type ManagerPage = "plugins" | "install" | "sources" | "transfer" | "ribbon" | " const SUPPORT_QQ_GROUP_URL = "https://qm.qq.com/cgi-bin/qm/qr?k=kHTS0iC1FC5igTXbdbKzff6_tc54mOF5&jump_from=webapi&authKey=AoSkriW+nDeDzBPqBl9jcpbAYkPXN2QRbrMh0hFbvMrGbqZyRAbJwaD6JKbOy4Nx"; const SUPPORT_QQ_GROUP_LABEL = "\u52a0\u5165 QQ \u7fa4"; const SUPPORT_QQ_GROUP_TOOLTIP = "\u52a0\u5165 QQ \u7fa4\u54a8\u8be2\u95ee\u9898"; -type PluginUpdateViewStatus = { - hasUpdate?: boolean; - remoteVersion?: string | null; - repo?: string | null; - versions?: ReleaseVersion[]; - error?: string; -}; - -type PluginRepoActionState = { - repo: string | null; - tooltip: string; - disabled: boolean; -}; +type PluginUpdateViewStatus = { + hasUpdate?: boolean; + remoteVersion?: string | null; + repo?: string | null; + versions?: ReleaseVersion[]; + error?: string; +}; + +type PluginRepoActionState = { + repo: string | null; + tooltip: string; + disabled: boolean; +}; @@ -207,12 +207,12 @@ export class ManagerModal extends Modal { new UpdateModal(this.app, this.manager, pluginId, versions, updateInfo.remoteVersion, updateInfo.repo || undefined).open(); } - private addPluginDownloadButton(controlEl: HTMLElement, pluginId: string, updateInfo: PluginUpdateViewStatus, prepend = false) { - if (!updateInfo.remoteVersion) return; - if (!this.isMainPageActionOnItem("downloadUpdate")) return; - const downloadBtn = new ExtraButtonComponent(controlEl); - downloadBtn.setIcon("download"); - downloadBtn.setTooltip(this.manager.translator.t("管理器_下载更新_描述")); + private addPluginDownloadButton(controlEl: HTMLElement, pluginId: string, updateInfo: PluginUpdateViewStatus, prepend = false) { + if (!updateInfo.remoteVersion) return; + if (!this.isMainPageActionOnItem("downloadUpdate")) return; + const downloadBtn = new ExtraButtonComponent(controlEl); + downloadBtn.setIcon("download"); + downloadBtn.setTooltip(this.manager.translator.t("管理器_下载更新_描述")); downloadBtn.onClick(() => this.openPluginUpdateModal(pluginId, updateInfo)); const downloadEl = this.getExtraButtonEl(downloadBtn); downloadEl?.addClass("manager-plugin-card__download-update"); @@ -247,109 +247,119 @@ export class ManagerModal extends Modal { this.addPluginDownloadButton(controlEl, pluginId, updateInfo, true); } - if (this.filter === "has-update" && !hasUpdate) { - card.remove(); - this.displayPlugins = this.displayPlugins.filter((plugin) => plugin.id !== pluginId); - } - } - - private getMainPageActionPlacement(actionId: MainPageActionId) { - return this.settings.MAIN_PAGE_ACTION_PLACEMENT?.[actionId] - ?? DEFAULT_MAIN_PAGE_ACTION_PLACEMENT[actionId]; - } - - private isMainPageActionOnItem(actionId: MainPageActionId): boolean { - return this.getMainPageActionPlacement(actionId) === "item"; - } - - private isMainPageActionInMenu(actionId: MainPageActionId): boolean { - return this.getMainPageActionPlacement(actionId) === "menu"; - } - - private createConfiguredItemAction(controlEl: HTMLElement, actionId: MainPageActionId): ExtraButtonComponent | null { - if (!this.isMainPageActionOnItem(actionId)) return null; - return new ExtraButtonComponent(controlEl); - } - - private resolvePluginRepoAction(pluginId: string, repo: string | null): PluginRepoActionState { - if (repo) { - return { - repo, - tooltip: this.manager.translator.t("管理器_打开仓库_提示").replace("{repo}", repo), - disabled: false, - }; - } - - const isBpmInstall = this.manager.settings.BPM_INSTALLED.includes(pluginId); - return { - repo: null, - tooltip: isBpmInstall - ? this.manager.translator.t("管理器_仓库未记录_提示") - : this.manager.translator.t("管理器_仓库需手动添加_提示"), - disabled: true, - }; - } - - private handleMissingRepo(pluginId: string) { - const isBpmInstall = this.manager.settings.BPM_INSTALLED.includes(pluginId); - new Notice(isBpmInstall - ? this.manager.translator.t("管理器_仓库未记录_提示") - : this.manager.translator.t("管理器_仓库需手动添加_提示")); - } - - private async openPluginRepo(pluginId: string, repo?: string | null) { - const resolvedRepo = repo ?? await this.manager.repoResolver.resolveRepo(pluginId); - if (resolvedRepo) { - window.open(`https://github.com/${resolvedRepo}`); - return; - } - this.handleMissingRepo(pluginId); - } - - private async uninstallPluginWithConfirm(plugin: PluginManifest, isSelf: boolean) { - if (isSelf) return; - new DeleteModal(this.app, this.manager, async () => { - await this.appPlugins.uninstallPlugin(plugin.id); - await this.appPlugins.loadManifests(); - this.reloadShowData(); - Commands(this.app, this.manager); - this.manager.synchronizePlugins(Object.values(this.appPlugins.manifests).filter((pm: PluginManifest) => pm.id !== this.manager.manifest.id) as PluginManifest[]); - new Notice(this.manager.translator.t("卸载_通知_一")); - }, { id: plugin.id, name: plugin.name }).open(); - } - - private async singleStartPlugin(plugin: PluginManifest) { - new Notice(this.manager.translator.t("管理器_单次启动中_提示")); - await this.appPlugins.enablePlugin(plugin.id); - await this.reloadShowData(); - } - - private async restartPlugin(plugin: PluginManifest) { - new Notice(this.manager.translator.t("管理器_重启中_提示")); - await this.appPlugins.disablePluginAndSave(plugin.id); - await this.appPlugins.enablePluginAndSave(plugin.id); - await this.reloadShowData(); - } - - private togglePluginHidden(pluginId: string) { - const isHidden = this.settings.HIDES.includes(pluginId); - if (isHidden) { - this.settings.HIDES = this.settings.HIDES.filter(id => id !== pluginId); - } else { - this.settings.HIDES.push(pluginId); - } - this.manager.saveSettings(); - this.reloadShowData(); - } - - private async openPluginHotkeys(pluginId: string) { - await this.appSetting.open(); - await this.appSetting.openTabById("hotkeys"); - const tab = await this.appSetting.activeTab; - tab.searchComponent.inputEl.value = pluginId; - tab.updateHotkeyVisibility(); - tab.searchComponent.inputEl.blur(); - } + if (this.filter === "has-update" && !hasUpdate) { + card.remove(); + this.displayPlugins = this.displayPlugins.filter((plugin) => plugin.id !== pluginId); + } + } + + private getMainPageActionPlacement(actionId: MainPageActionId) { + return this.settings.MAIN_PAGE_ACTION_PLACEMENT?.[actionId] + ?? DEFAULT_MAIN_PAGE_ACTION_PLACEMENT[actionId]; + } + + private isMainPageActionOnItem(actionId: MainPageActionId): boolean { + return this.getMainPageActionPlacement(actionId) === "item"; + } + + private isMainPageActionInMenu(actionId: MainPageActionId): boolean { + return this.getMainPageActionPlacement(actionId) === "menu"; + } + + private createConfiguredItemAction(controlEl: HTMLElement, actionId: MainPageActionId): ExtraButtonComponent | null { + if (!this.isMainPageActionOnItem(actionId)) return null; + return new ExtraButtonComponent(controlEl); + } + + private resolvePluginRepoAction(pluginId: string, repo: string | null): PluginRepoActionState { + if (repo) { + return { + repo, + tooltip: this.manager.translator.t("管理器_打开仓库_提示").replace("{repo}", repo), + disabled: false, + }; + } + + const isBpmInstall = this.manager.settings.BPM_INSTALLED.includes(pluginId); + return { + repo: null, + tooltip: isBpmInstall + ? this.manager.translator.t("管理器_仓库未记录_提示") + : this.manager.translator.t("管理器_仓库需手动添加_提示"), + disabled: true, + }; + } + + private handleMissingRepo(pluginId: string) { + const isBpmInstall = this.manager.settings.BPM_INSTALLED.includes(pluginId); + new Notice(isBpmInstall + ? this.manager.translator.t("管理器_仓库未记录_提示") + : this.manager.translator.t("管理器_仓库需手动添加_提示")); + } + + private async openPluginRepo(pluginId: string, repo?: string | null) { + const resolvedRepo = repo ?? await this.manager.repoResolver.resolveRepo(pluginId); + if (resolvedRepo) { + window.open(`https://github.com/${resolvedRepo}`); + return; + } + this.handleMissingRepo(pluginId); + } + + private async uninstallPluginWithConfirm(plugin: PluginManifest, isSelf: boolean) { + if (isSelf) return; + new DeleteModal(this.app, this.manager, async () => { + await this.appPlugins.uninstallPlugin(plugin.id); + await this.appPlugins.loadManifests(); + this.reloadShowData(); + Commands(this.app, this.manager); + this.manager.synchronizePlugins(Object.values(this.appPlugins.manifests).filter((pm: PluginManifest) => pm.id !== this.manager.manifest.id) as PluginManifest[]); + new Notice(this.manager.translator.t("卸载_通知_一")); + }, { id: plugin.id, name: plugin.name }).open(); + } + + private async singleStartPlugin(plugin: PluginManifest) { + new Notice(this.manager.translator.t("管理器_单次启动中_提示")); + await this.appPlugins.enablePlugin(plugin.id); + await this.reloadShowData(); + } + + private async restartPlugin(plugin: PluginManifest) { + new Notice(this.manager.translator.t("管理器_重启中_提示")); + await this.appPlugins.disablePluginAndSave(plugin.id); + await this.appPlugins.enablePluginAndSave(plugin.id); + await this.reloadShowData(); + } + + private togglePluginHidden(pluginId: string) { + const isHidden = this.settings.HIDES.includes(pluginId); + if (isHidden) { + this.settings.HIDES = this.settings.HIDES.filter(id => id !== pluginId); + } else { + this.settings.HIDES.push(pluginId); + } + this.manager.saveSettings(); + this.reloadShowData(); + } + + private async openPluginHotkeys(pluginId: string) { + await this.appSetting.open(); + await this.appSetting.openTabById("hotkeys"); + const tab = await this.appSetting.activeTab; + tab.searchComponent.inputEl.value = pluginId; + tab.updateHotkeyVisibility(); + tab.searchComponent.inputEl.blur(); + } + + private async openPluginMarket() { + await this.appSetting.open(); + await this.appSetting.openTabById("community-plugins"); + window.setTimeout(() => { + const tab = this.appSetting.activeTab; + const marketButton = tab?.containerEl?.querySelector("button.mod-cta"); + marketButton?.click(); + }, 50); + } private async runSinglePluginUpdateCheck(pluginId: string) { const progress = this.showInlineProgress(this.manager.translator.t("通知_检测更新中文案"), pluginId); @@ -742,6 +752,16 @@ export class ManagerModal extends Modal { this.bindLongPressTooltip(supportGroupButton.buttonEl, SUPPORT_QQ_GROUP_TOOLTIP); supportGroupButton.onClick(() => this.openSupportQQGroup()); + // [操作行] 插件市场 + const marketButton = new ButtonComponent(actionBar.controlEl); + markTool(marketButton, "global"); + marketButton.setIcon("store"); + marketButton.setTooltip(this.manager.translator.t("管理器_插件市场_描述")); + this.bindLongPressTooltip(marketButton.buttonEl, this.manager.translator.t("管理器_插件市场_描述")); + marketButton.onClick(() => { + void this.openPluginMarket(); + }); + // [操作行] 插件设置 const settingsButton = new ButtonComponent(actionBar.controlEl); markTool(settingsButton, "global"); @@ -997,6 +1017,10 @@ export class ManagerModal extends Modal { menu.addItem((item) => item.setTitle(t("管理器_Ribbon管理_描述")).setIcon("grip-vertical").onClick(() => { new RibbonModal(this.app, this.manager).open(); })); + // 插件市场 + menu.addItem((item) => item.setTitle(t("管理器_插件市场_描述")).setIcon("store").onClick(() => { + void this.openPluginMarket(); + })); // 插件设置 menu.addItem((item) => item.setTitle(t("管理器_插件设置_描述")).setIcon("settings").onClick(() => { this.appSetting.open(); @@ -1398,67 +1422,67 @@ export class ManagerModal extends Modal { itemEl.controlEl.setAttribute("aria-label", this.manager.translator.t("管理器_插件操作_标签", { name: ManagerPlugin.name })); // [右键操作] - itemEl.settingEl.addEventListener("contextmenu", (event) => { - event.preventDefault(); // 阻止默认的右键菜单 - const menu = new Menu(); - let hasContextMenuItems = false; - const addContextSeparator = () => { - if (hasContextMenuItems) menu.addSeparator(); - }; - // 第一组:插件信息类 - if (this.isMainPageActionInMenu("checkUpdate")) { - menu.addItem((item) => - item.setTitle(this.manager.translator.t("菜单_检查更新_标题")) - .setIcon("rss") - .onClick(async () => { - await this.runSinglePluginUpdateCheck(plugin.id); - }) - ); - hasContextMenuItems = true; - } - const currentUpdateInfo = this.manager.updateStatus?.[plugin.id] as PluginUpdateViewStatus | undefined; - if (this.isMainPageActionInMenu("downloadUpdate") && currentUpdateInfo?.hasUpdate && currentUpdateInfo.remoteVersion) { - menu.addItem((item) => - item.setTitle(this.manager.translator.t("管理器_下载更新_描述")) - .setIcon("download") - .onClick(() => { - this.openPluginUpdateModal(plugin.id, currentUpdateInfo); - }) - ); - hasContextMenuItems = true; - } - // 第二组:插件管理类 - const hasManageMenuItems = (!this.settings.DELAY && (this.isMainPageActionInMenu("singleStart") || this.isMainPageActionInMenu("restart"))) || this.isMainPageActionInMenu("hide"); - if (hasManageMenuItems) addContextSeparator(); - // [菜单] 单次启动 - if (!this.settings.DELAY && this.isMainPageActionInMenu("singleStart")) menu.addItem((item) => - item.setTitle(this.manager.translator.t("菜单_单次启动_描述")) - .setIcon("repeat-1") - .setDisabled(isSelf || isEnabled) - .onClick(async () => { - await this.singleStartPlugin(plugin); - }) - ); - // [菜单] 重启插件 - if (!this.settings.DELAY && this.isMainPageActionInMenu("restart")) menu.addItem((item) => - item.setTitle(this.manager.translator.t("菜单_重启插件_描述")) - .setIcon("refresh-ccw") - .setDisabled(isSelf || !isEnabled) - .onClick(async () => { - await this.restartPlugin(plugin); - }) - ); - // [菜单] 隐藏插件 - if (this.isMainPageActionInMenu("hide")) menu.addItem((item) => - item.setTitle(this.manager.translator.t("菜单_隐藏插件_标题")) - .setIcon("eye-off") - .setDisabled(isSelf) - .onClick(() => { - if (isSelf) return; - this.togglePluginHidden(plugin.id); - }) - ); - if (hasManageMenuItems) hasContextMenuItems = true; + itemEl.settingEl.addEventListener("contextmenu", (event) => { + event.preventDefault(); // 阻止默认的右键菜单 + const menu = new Menu(); + let hasContextMenuItems = false; + const addContextSeparator = () => { + if (hasContextMenuItems) menu.addSeparator(); + }; + // 第一组:插件信息类 + if (this.isMainPageActionInMenu("checkUpdate")) { + menu.addItem((item) => + item.setTitle(this.manager.translator.t("菜单_检查更新_标题")) + .setIcon("rss") + .onClick(async () => { + await this.runSinglePluginUpdateCheck(plugin.id); + }) + ); + hasContextMenuItems = true; + } + const currentUpdateInfo = this.manager.updateStatus?.[plugin.id] as PluginUpdateViewStatus | undefined; + if (this.isMainPageActionInMenu("downloadUpdate") && currentUpdateInfo?.hasUpdate && currentUpdateInfo.remoteVersion) { + menu.addItem((item) => + item.setTitle(this.manager.translator.t("管理器_下载更新_描述")) + .setIcon("download") + .onClick(() => { + this.openPluginUpdateModal(plugin.id, currentUpdateInfo); + }) + ); + hasContextMenuItems = true; + } + // 第二组:插件管理类 + const hasManageMenuItems = (!this.settings.DELAY && (this.isMainPageActionInMenu("singleStart") || this.isMainPageActionInMenu("restart"))) || this.isMainPageActionInMenu("hide"); + if (hasManageMenuItems) addContextSeparator(); + // [菜单] 单次启动 + if (!this.settings.DELAY && this.isMainPageActionInMenu("singleStart")) menu.addItem((item) => + item.setTitle(this.manager.translator.t("菜单_单次启动_描述")) + .setIcon("repeat-1") + .setDisabled(isSelf || isEnabled) + .onClick(async () => { + await this.singleStartPlugin(plugin); + }) + ); + // [菜单] 重启插件 + if (!this.settings.DELAY && this.isMainPageActionInMenu("restart")) menu.addItem((item) => + item.setTitle(this.manager.translator.t("菜单_重启插件_描述")) + .setIcon("refresh-ccw") + .setDisabled(isSelf || !isEnabled) + .onClick(async () => { + await this.restartPlugin(plugin); + }) + ); + // [菜单] 隐藏插件 + if (this.isMainPageActionInMenu("hide")) menu.addItem((item) => + item.setTitle(this.manager.translator.t("菜单_隐藏插件_标题")) + .setIcon("eye-off") + .setDisabled(isSelf) + .onClick(() => { + if (isSelf) return; + this.togglePluginHidden(plugin.id); + }) + ); + if (hasManageMenuItems) hasContextMenuItems = true; // [菜单] 分享插件 // menu.addItem((item) => // item.setTitle("分享插件_标题") @@ -1469,72 +1493,72 @@ export class ManagerModal extends Modal { // }) // ); - const hasOpenMenuItems = this.isMainPageActionInMenu("openSettings") || this.isMainPageActionInMenu("openDir") || this.isMainPageActionInMenu("openRepo") || this.isMainPageActionInMenu("delete"); - if (hasOpenMenuItems) addContextSeparator(); - if (this.isMainPageActionInMenu("openSettings")) { - menu.addItem((item) => - item.setTitle(this.manager.translator.t("管理器_打开设置_描述")) - .setIcon("settings") - .setDisabled(!isEnabled) - .onClick(() => { - this.appSetting.open(); - this.appSetting.openTabById(plugin.id); - }) - ); - } - if (this.isMainPageActionInMenu("openDir")) { - menu.addItem((item) => - item.setTitle(this.manager.translator.t("管理器_打开目录_描述")) - .setIcon("folder-open") - .onClick(() => { - managerOpen(pluginDir, this.manager); - }) - ); - } - if (this.isMainPageActionInMenu("openRepo")) { - menu.addItem((item) => - item.setTitle(this.manager.translator.t("管理器_打开仓库_标题")) - .setIcon("github") - .onClick(async () => { - await this.openPluginRepo(plugin.id); - }) - ); - } - if (this.isMainPageActionInMenu("delete")) { - menu.addItem((item) => - item.setTitle(this.manager.translator.t("管理器_删除插件_描述")) - .setIcon("trash") - .setDisabled(isSelf) - .onClick(async () => { - await this.uninstallPluginWithConfirm(plugin, isSelf); - }) - ); - } - if (hasOpenMenuItems) hasContextMenuItems = true; - - // 第三组:插件设置类 - const hasConfigMenuItems = this.isMainPageActionInMenu("note") || this.isMainPageActionInMenu("hotkeys") || this.isMainPageActionInMenu("copyId"); - if (hasConfigMenuItems) addContextSeparator(); - // [菜单] 插件笔记 - if (this.isMainPageActionInMenu("note")) menu.addItem((item) => - item.setTitle(this.manager.translator.t("菜单_笔记_标题")).setIcon("notebook-pen").onClick(() => { new NoteModal(this.app, this.manager, ManagerPlugin, this).open(); }) - ); - // [菜单] 快捷键 - if (this.isMainPageActionInMenu("hotkeys")) menu.addItem((item) => - item.setTitle(this.manager.translator.t("菜单_快捷键_标题")).setIcon("circle-plus").onClick(async () => { - await this.openPluginHotkeys(plugin.id); - }) - ); - // [菜单] 复制ID - if (this.isMainPageActionInMenu("copyId")) menu.addItem((item) => - item.setTitle(this.manager.translator.t("菜单_复制ID_标题")) - .setIcon("copy") + const hasOpenMenuItems = this.isMainPageActionInMenu("openSettings") || this.isMainPageActionInMenu("openDir") || this.isMainPageActionInMenu("openRepo") || this.isMainPageActionInMenu("delete"); + if (hasOpenMenuItems) addContextSeparator(); + if (this.isMainPageActionInMenu("openSettings")) { + menu.addItem((item) => + item.setTitle(this.manager.translator.t("管理器_打开设置_描述")) + .setIcon("settings") + .setDisabled(!isEnabled) + .onClick(() => { + this.appSetting.open(); + this.appSetting.openTabById(plugin.id); + }) + ); + } + if (this.isMainPageActionInMenu("openDir")) { + menu.addItem((item) => + item.setTitle(this.manager.translator.t("管理器_打开目录_描述")) + .setIcon("folder-open") + .onClick(() => { + managerOpen(pluginDir, this.manager); + }) + ); + } + if (this.isMainPageActionInMenu("openRepo")) { + menu.addItem((item) => + item.setTitle(this.manager.translator.t("管理器_打开仓库_标题")) + .setIcon("github") + .onClick(async () => { + await this.openPluginRepo(plugin.id); + }) + ); + } + if (this.isMainPageActionInMenu("delete")) { + menu.addItem((item) => + item.setTitle(this.manager.translator.t("管理器_删除插件_描述")) + .setIcon("trash") + .setDisabled(isSelf) + .onClick(async () => { + await this.uninstallPluginWithConfirm(plugin, isSelf); + }) + ); + } + if (hasOpenMenuItems) hasContextMenuItems = true; + + // 第三组:插件设置类 + const hasConfigMenuItems = this.isMainPageActionInMenu("note") || this.isMainPageActionInMenu("hotkeys") || this.isMainPageActionInMenu("copyId"); + if (hasConfigMenuItems) addContextSeparator(); + // [菜单] 插件笔记 + if (this.isMainPageActionInMenu("note")) menu.addItem((item) => + item.setTitle(this.manager.translator.t("菜单_笔记_标题")).setIcon("notebook-pen").onClick(() => { new NoteModal(this.app, this.manager, ManagerPlugin, this).open(); }) + ); + // [菜单] 快捷键 + if (this.isMainPageActionInMenu("hotkeys")) menu.addItem((item) => + item.setTitle(this.manager.translator.t("菜单_快捷键_标题")).setIcon("circle-plus").onClick(async () => { + await this.openPluginHotkeys(plugin.id); + }) + ); + // [菜单] 复制ID + if (this.isMainPageActionInMenu("copyId")) menu.addItem((item) => + item.setTitle(this.manager.translator.t("菜单_复制ID_标题")) + .setIcon("copy") .onClick(() => { navigator.clipboard.writeText(plugin.id); new Notice(this.manager.translator.t("通知_ID已复制")); - }) - ); - if (hasConfigMenuItems) hasContextMenuItems = true; + }) + ); + if (hasConfigMenuItems) hasContextMenuItems = true; // 第三组:测试类 // menu.addSeparator(); // 分隔符 @@ -1719,9 +1743,9 @@ export class ManagerModal extends Modal { versionWrap.appendChild(arrow); const remote = createSpan({ text: `${updateInfo.remoteVersion}`, cls: ["manager-item__name-remote"] }); versionWrap.appendChild(remote); - if (!this.editorMode) { - this.addPluginDownloadButton(itemEl.controlEl, plugin.id, updateInfo); - } + if (!this.editorMode) { + this.addPluginDownloadButton(itemEl.controlEl, plugin.id, updateInfo); + } } itemEl.nameEl.appendChild(versionWrap); @@ -1799,291 +1823,291 @@ export class ManagerModal extends Modal { let openPluginSetting: ExtraButtonComponent | null = null; let openPluginSettingEl: HTMLElement | undefined; - if (isMobile && [ - "checkUpdate", - "downloadUpdate", - "singleStart", - "restart", - "hide", - "note", - "hotkeys", - "copyId", - "openRepo", - "openSettings", - "openDir", - "delete", - ].some((id) => this.isMainPageActionInMenu(id as MainPageActionId))) { - const moreButton = new ExtraButtonComponent(itemEl.controlEl); - moreButton.setIcon("more-vertical"); - moreButton.setTooltip(this.manager.translator.t("管理器_更多操作_描述")); + if (isMobile && [ + "checkUpdate", + "downloadUpdate", + "singleStart", + "restart", + "hide", + "note", + "hotkeys", + "copyId", + "openRepo", + "openSettings", + "openDir", + "delete", + ].some((id) => this.isMainPageActionInMenu(id as MainPageActionId))) { + const moreButton = new ExtraButtonComponent(itemEl.controlEl); + moreButton.setIcon("more-vertical"); + moreButton.setTooltip(this.manager.translator.t("管理器_更多操作_描述")); const moreEl = ((moreButton as any).extraSettingsEl || (moreButton as any).buttonEl) as HTMLElement | undefined; this.bindLongPressTooltip(moreEl, this.manager.translator.t("管理器_更多操作_描述")); moreEl?.addEventListener("click", (event) => { - event.preventDefault(); - event.stopPropagation(); - const menu = new Menu(); - let hasPreviousGroup = false; - let hasCurrentGroup = false; - if (this.isMainPageActionInMenu("checkUpdate")) { - menu.addItem((item) => item - .setTitle(this.manager.translator.t("菜单_检查更新_标题")) - .setIcon("rss") - .onClick(async () => { - await this.runSinglePluginUpdateCheck(plugin.id); - })); - hasCurrentGroup = true; - } - const currentUpdateInfo = this.manager.updateStatus?.[plugin.id] as PluginUpdateViewStatus | undefined; - if (this.isMainPageActionInMenu("downloadUpdate") && currentUpdateInfo?.hasUpdate && currentUpdateInfo.remoteVersion) { - menu.addItem((item) => item - .setTitle(this.manager.translator.t("管理器_下载更新_描述")) - .setIcon("download") + event.preventDefault(); + event.stopPropagation(); + const menu = new Menu(); + let hasPreviousGroup = false; + let hasCurrentGroup = false; + if (this.isMainPageActionInMenu("checkUpdate")) { + menu.addItem((item) => item + .setTitle(this.manager.translator.t("菜单_检查更新_标题")) + .setIcon("rss") + .onClick(async () => { + await this.runSinglePluginUpdateCheck(plugin.id); + })); + hasCurrentGroup = true; + } + const currentUpdateInfo = this.manager.updateStatus?.[plugin.id] as PluginUpdateViewStatus | undefined; + if (this.isMainPageActionInMenu("downloadUpdate") && currentUpdateInfo?.hasUpdate && currentUpdateInfo.remoteVersion) { + menu.addItem((item) => item + .setTitle(this.manager.translator.t("管理器_下载更新_描述")) + .setIcon("download") .onClick(() => { - this.openPluginUpdateModal(plugin.id, currentUpdateInfo); - })); - hasCurrentGroup = true; - } - hasPreviousGroup = hasCurrentGroup; - hasCurrentGroup = false; - - if (!this.settings.DELAY && this.isMainPageActionInMenu("singleStart")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("菜单_单次启动_描述")) - .setIcon("repeat-1") - .setDisabled(isSelf || isEnabled) - .onClick(async () => { - await this.singleStartPlugin(plugin); - })); - hasCurrentGroup = true; - } - if (!this.settings.DELAY && this.isMainPageActionInMenu("restart")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("菜单_重启插件_描述")) - .setIcon("refresh-ccw") - .setDisabled(isSelf || !isEnabled) - .onClick(async () => { - await this.restartPlugin(plugin); - })); - hasCurrentGroup = true; - } - if (this.isMainPageActionInMenu("hide")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("菜单_隐藏插件_标题")) - .setIcon("eye-off") - .setDisabled(isSelf) - .onClick(() => { - if (isSelf) return; - this.togglePluginHidden(plugin.id); - })); - hasCurrentGroup = true; - } - hasPreviousGroup = hasPreviousGroup || hasCurrentGroup; - hasCurrentGroup = false; - - if (this.isMainPageActionInMenu("openSettings")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("管理器_打开设置_描述")) - .setIcon("settings") - .setDisabled(!isEnabled) - .onClick(() => { - this.appSetting.open(); - this.appSetting.openTabById(plugin.id); - })); - hasCurrentGroup = true; - } - if (this.isMainPageActionInMenu("openDir")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("管理器_打开目录_描述")) - .setIcon("folder-open") - .onClick(() => { - managerOpen(pluginDir, this.manager); - })); - hasCurrentGroup = true; - } - if (this.isMainPageActionInMenu("openRepo")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("管理器_打开仓库_标题")) - .setIcon("github") - .onClick(async () => { - await this.openPluginRepo(plugin.id); - })); - hasCurrentGroup = true; - } - if (this.isMainPageActionInMenu("delete")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("管理器_删除插件_描述")) - .setIcon("trash") - .setDisabled(isSelf) - .onClick(async () => { - await this.uninstallPluginWithConfirm(plugin, isSelf); - })); - hasCurrentGroup = true; - } - hasPreviousGroup = hasPreviousGroup || hasCurrentGroup; - hasCurrentGroup = false; - - if (this.isMainPageActionInMenu("note")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("菜单_笔记_标题")) - .setIcon("notebook-pen") - .onClick(() => { new NoteModal(this.app, this.manager, ManagerPlugin, this).open(); })); - hasCurrentGroup = true; - } - if (this.isMainPageActionInMenu("hotkeys")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("菜单_快捷键_标题")) - .setIcon("circle-plus") - .onClick(async () => { - await this.openPluginHotkeys(plugin.id); - })); - hasCurrentGroup = true; - } - if (this.isMainPageActionInMenu("copyId")) { - if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); - menu.addItem((item) => item - .setTitle(this.manager.translator.t("菜单_复制ID_标题")) - .setIcon("copy") - .onClick(() => { - navigator.clipboard.writeText(plugin.id); - new Notice(this.manager.translator.t("通知_ID已复制")); - })); - } - menu.showAtMouseEvent(event as MouseEvent); - }); - } - - const checkUpdateButton = this.createConfiguredItemAction(itemEl.controlEl, "checkUpdate"); - if (checkUpdateButton) { - checkUpdateButton.setIcon("rss"); - checkUpdateButton.setTooltip(this.manager.translator.t("菜单_检查更新_标题")); - checkUpdateButton.onClick(async () => { - await this.runSinglePluginUpdateCheck(plugin.id); - }); - } - - if (!this.settings.DELAY) { - const singleStartButton = this.createConfiguredItemAction(itemEl.controlEl, "singleStart"); - if (singleStartButton) { - singleStartButton.setIcon("repeat-1"); - singleStartButton.setTooltip(this.manager.translator.t("菜单_单次启动_描述")); - singleStartButton.setDisabled(isSelf || isEnabled); - singleStartButton.onClick(async () => { - await this.singleStartPlugin(plugin); - }); - } - - const restartButton = this.createConfiguredItemAction(itemEl.controlEl, "restart"); - if (restartButton) { - restartButton.setIcon("refresh-ccw"); - restartButton.setTooltip(this.manager.translator.t("菜单_重启插件_描述")); - restartButton.setDisabled(isSelf || !isEnabled); - restartButton.onClick(async () => { - await this.restartPlugin(plugin); - }); - } - } - - const hideButton = this.createConfiguredItemAction(itemEl.controlEl, "hide"); - if (hideButton) { - hideButton.setIcon("eye-off"); - hideButton.setTooltip(this.manager.translator.t("菜单_隐藏插件_标题")); - hideButton.setDisabled(isSelf); - hideButton.onClick(() => { - if (isSelf) return; - this.togglePluginHidden(plugin.id); - }); - } - - const noteButton = this.createConfiguredItemAction(itemEl.controlEl, "note"); - if (noteButton) { - noteButton.setIcon("notebook-pen"); - noteButton.setTooltip(this.manager.translator.t("菜单_笔记_标题")); - noteButton.onClick(() => { new NoteModal(this.app, this.manager, ManagerPlugin, this).open(); }); - } - - const hotkeysButton = this.createConfiguredItemAction(itemEl.controlEl, "hotkeys"); - if (hotkeysButton) { - hotkeysButton.setIcon("circle-plus"); - hotkeysButton.setTooltip(this.manager.translator.t("菜单_快捷键_标题")); - hotkeysButton.onClick(async () => { - await this.openPluginHotkeys(plugin.id); - }); - } - - const copyIdButton = this.createConfiguredItemAction(itemEl.controlEl, "copyId"); - if (copyIdButton) { - copyIdButton.setIcon("copy"); - copyIdButton.setTooltip(this.manager.translator.t("菜单_复制ID_标题")); - copyIdButton.onClick(() => { - navigator.clipboard.writeText(plugin.id); - new Notice(this.manager.translator.t("通知_ID已复制")); - }); - } - - const openRepoButton = this.createConfiguredItemAction(itemEl.controlEl, "openRepo"); - if (openRepoButton) { - openRepoButton.setIcon("github"); - openRepoButton.setTooltip(this.manager.translator.t("管理器_仓库检测中_提示")); - openRepoButton.setDisabled(true); - const repo = await this.manager.repoResolver.resolveRepo(plugin.id); - if (!this.isRenderCurrent(renderGeneration, page)) return; - const repoState = this.resolvePluginRepoAction(plugin.id, repo); - openRepoButton.setTooltip(repoState.tooltip); - openRepoButton.setDisabled(repoState.disabled); - openRepoButton.onClick(async () => { - await this.openPluginRepo(plugin.id, repoState.repo); - }); - } - - // [按钮] 打开设置 - openPluginSetting = this.createConfiguredItemAction(itemEl.controlEl, "openSettings"); - if (openPluginSetting) { - openPluginSetting.setIcon("settings"); - openPluginSetting.setTooltip(this.manager.translator.t("管理器_打开设置_描述")); - openPluginSetting.onClick(() => { + this.openPluginUpdateModal(plugin.id, currentUpdateInfo); + })); + hasCurrentGroup = true; + } + hasPreviousGroup = hasCurrentGroup; + hasCurrentGroup = false; + + if (!this.settings.DELAY && this.isMainPageActionInMenu("singleStart")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("菜单_单次启动_描述")) + .setIcon("repeat-1") + .setDisabled(isSelf || isEnabled) + .onClick(async () => { + await this.singleStartPlugin(plugin); + })); + hasCurrentGroup = true; + } + if (!this.settings.DELAY && this.isMainPageActionInMenu("restart")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("菜单_重启插件_描述")) + .setIcon("refresh-ccw") + .setDisabled(isSelf || !isEnabled) + .onClick(async () => { + await this.restartPlugin(plugin); + })); + hasCurrentGroup = true; + } + if (this.isMainPageActionInMenu("hide")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("菜单_隐藏插件_标题")) + .setIcon("eye-off") + .setDisabled(isSelf) + .onClick(() => { + if (isSelf) return; + this.togglePluginHidden(plugin.id); + })); + hasCurrentGroup = true; + } + hasPreviousGroup = hasPreviousGroup || hasCurrentGroup; + hasCurrentGroup = false; + + if (this.isMainPageActionInMenu("openSettings")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("管理器_打开设置_描述")) + .setIcon("settings") + .setDisabled(!isEnabled) + .onClick(() => { + this.appSetting.open(); + this.appSetting.openTabById(plugin.id); + })); + hasCurrentGroup = true; + } + if (this.isMainPageActionInMenu("openDir")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("管理器_打开目录_描述")) + .setIcon("folder-open") + .onClick(() => { + managerOpen(pluginDir, this.manager); + })); + hasCurrentGroup = true; + } + if (this.isMainPageActionInMenu("openRepo")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("管理器_打开仓库_标题")) + .setIcon("github") + .onClick(async () => { + await this.openPluginRepo(plugin.id); + })); + hasCurrentGroup = true; + } + if (this.isMainPageActionInMenu("delete")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("管理器_删除插件_描述")) + .setIcon("trash") + .setDisabled(isSelf) + .onClick(async () => { + await this.uninstallPluginWithConfirm(plugin, isSelf); + })); + hasCurrentGroup = true; + } + hasPreviousGroup = hasPreviousGroup || hasCurrentGroup; + hasCurrentGroup = false; + + if (this.isMainPageActionInMenu("note")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("菜单_笔记_标题")) + .setIcon("notebook-pen") + .onClick(() => { new NoteModal(this.app, this.manager, ManagerPlugin, this).open(); })); + hasCurrentGroup = true; + } + if (this.isMainPageActionInMenu("hotkeys")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("菜单_快捷键_标题")) + .setIcon("circle-plus") + .onClick(async () => { + await this.openPluginHotkeys(plugin.id); + })); + hasCurrentGroup = true; + } + if (this.isMainPageActionInMenu("copyId")) { + if (hasPreviousGroup && !hasCurrentGroup) menu.addSeparator(); + menu.addItem((item) => item + .setTitle(this.manager.translator.t("菜单_复制ID_标题")) + .setIcon("copy") + .onClick(() => { + navigator.clipboard.writeText(plugin.id); + new Notice(this.manager.translator.t("通知_ID已复制")); + })); + } + menu.showAtMouseEvent(event as MouseEvent); + }); + } + + const checkUpdateButton = this.createConfiguredItemAction(itemEl.controlEl, "checkUpdate"); + if (checkUpdateButton) { + checkUpdateButton.setIcon("rss"); + checkUpdateButton.setTooltip(this.manager.translator.t("菜单_检查更新_标题")); + checkUpdateButton.onClick(async () => { + await this.runSinglePluginUpdateCheck(plugin.id); + }); + } + + if (!this.settings.DELAY) { + const singleStartButton = this.createConfiguredItemAction(itemEl.controlEl, "singleStart"); + if (singleStartButton) { + singleStartButton.setIcon("repeat-1"); + singleStartButton.setTooltip(this.manager.translator.t("菜单_单次启动_描述")); + singleStartButton.setDisabled(isSelf || isEnabled); + singleStartButton.onClick(async () => { + await this.singleStartPlugin(plugin); + }); + } + + const restartButton = this.createConfiguredItemAction(itemEl.controlEl, "restart"); + if (restartButton) { + restartButton.setIcon("refresh-ccw"); + restartButton.setTooltip(this.manager.translator.t("菜单_重启插件_描述")); + restartButton.setDisabled(isSelf || !isEnabled); + restartButton.onClick(async () => { + await this.restartPlugin(plugin); + }); + } + } + + const hideButton = this.createConfiguredItemAction(itemEl.controlEl, "hide"); + if (hideButton) { + hideButton.setIcon("eye-off"); + hideButton.setTooltip(this.manager.translator.t("菜单_隐藏插件_标题")); + hideButton.setDisabled(isSelf); + hideButton.onClick(() => { + if (isSelf) return; + this.togglePluginHidden(plugin.id); + }); + } + + const noteButton = this.createConfiguredItemAction(itemEl.controlEl, "note"); + if (noteButton) { + noteButton.setIcon("notebook-pen"); + noteButton.setTooltip(this.manager.translator.t("菜单_笔记_标题")); + noteButton.onClick(() => { new NoteModal(this.app, this.manager, ManagerPlugin, this).open(); }); + } + + const hotkeysButton = this.createConfiguredItemAction(itemEl.controlEl, "hotkeys"); + if (hotkeysButton) { + hotkeysButton.setIcon("circle-plus"); + hotkeysButton.setTooltip(this.manager.translator.t("菜单_快捷键_标题")); + hotkeysButton.onClick(async () => { + await this.openPluginHotkeys(plugin.id); + }); + } + + const copyIdButton = this.createConfiguredItemAction(itemEl.controlEl, "copyId"); + if (copyIdButton) { + copyIdButton.setIcon("copy"); + copyIdButton.setTooltip(this.manager.translator.t("菜单_复制ID_标题")); + copyIdButton.onClick(() => { + navigator.clipboard.writeText(plugin.id); + new Notice(this.manager.translator.t("通知_ID已复制")); + }); + } + + const openRepoButton = this.createConfiguredItemAction(itemEl.controlEl, "openRepo"); + if (openRepoButton) { + openRepoButton.setIcon("github"); + openRepoButton.setTooltip(this.manager.translator.t("管理器_仓库检测中_提示")); + openRepoButton.setDisabled(true); + const repo = await this.manager.repoResolver.resolveRepo(plugin.id); + if (!this.isRenderCurrent(renderGeneration, page)) return; + const repoState = this.resolvePluginRepoAction(plugin.id, repo); + openRepoButton.setTooltip(repoState.tooltip); + openRepoButton.setDisabled(repoState.disabled); + openRepoButton.onClick(async () => { + await this.openPluginRepo(plugin.id, repoState.repo); + }); + } + + // [按钮] 打开设置 + openPluginSetting = this.createConfiguredItemAction(itemEl.controlEl, "openSettings"); + if (openPluginSetting) { + openPluginSetting.setIcon("settings"); + openPluginSetting.setTooltip(this.manager.translator.t("管理器_打开设置_描述")); + openPluginSetting.onClick(() => { openPluginSetting?.setDisabled(true); this.appSetting.open(); this.appSetting.openTabById(plugin.id); openPluginSetting?.setDisabled(false); }); openPluginSettingEl = ((openPluginSetting as any).extraSettingsEl || (openPluginSetting as any).buttonEl) as HTMLElement | undefined; - if (!isEnabled) { - openPluginSetting.setDisabled(true); - if (openPluginSettingEl) openPluginSettingEl.style.display = "none"; - } - } - - // [按钮] 打开目录 - const openPluginDirButton = this.createConfiguredItemAction(itemEl.controlEl, "openDir"); - if (openPluginDirButton) { - openPluginDirButton.setIcon("folder-open"); - openPluginDirButton.setTooltip(this.manager.translator.t("管理器_打开目录_描述")); - openPluginDirButton.onClick(() => { + if (!isEnabled) { + openPluginSetting.setDisabled(true); + if (openPluginSettingEl) openPluginSettingEl.style.display = "none"; + } + } + + // [按钮] 打开目录 + const openPluginDirButton = this.createConfiguredItemAction(itemEl.controlEl, "openDir"); + if (openPluginDirButton) { + openPluginDirButton.setIcon("folder-open"); + openPluginDirButton.setTooltip(this.manager.translator.t("管理器_打开目录_描述")); + openPluginDirButton.onClick(() => { openPluginDirButton.setDisabled(true); - managerOpen(pluginDir, this.manager); - openPluginDirButton.setDisabled(false); - }); - } - - // [按钮] 删除插件 - const deletePluginButton = this.createConfiguredItemAction(itemEl.controlEl, "delete"); - if (deletePluginButton) { - deletePluginButton.setIcon("trash"); - deletePluginButton.setTooltip(this.manager.translator.t("管理器_删除插件_描述")); - if (isSelf) deletePluginButton.setDisabled(true); - deletePluginButton.onClick(async () => { - await this.uninstallPluginWithConfirm(plugin, isSelf); - }); - } + managerOpen(pluginDir, this.manager); + openPluginDirButton.setDisabled(false); + }); + } + + // [按钮] 删除插件 + const deletePluginButton = this.createConfiguredItemAction(itemEl.controlEl, "delete"); + if (deletePluginButton) { + deletePluginButton.setIcon("trash"); + deletePluginButton.setTooltip(this.manager.translator.t("管理器_删除插件_描述")); + if (isSelf) deletePluginButton.setDisabled(true); + deletePluginButton.onClick(async () => { + await this.uninstallPluginWithConfirm(plugin, isSelf); + }); + } // [按钮] 切换状态 const toggleSwitch = new ToggleComponent(itemEl.controlEl); @@ -2091,8 +2115,8 @@ export class ManagerModal extends Modal { toggleSwitch.setValue(isEnabled); // 检查 BPM 忽略标签 - const managerPluginForToggle = ManagerPlugin; - const isBpmIgnored = managerPluginForToggle.tags?.includes(BPM_IGNORE_TAG); + const managerPluginForToggle = ManagerPlugin; + const isBpmIgnored = managerPluginForToggle.tags?.includes(BPM_IGNORE_TAG); if (isSelf) { toggleSwitch.setValue(true); @@ -2135,24 +2159,24 @@ export class ManagerModal extends Modal { // 更新底部统计 this.updateStats(); }; - if (this.settings.DELAY) { - if (targetEnabled) { - managerPluginForToggle.enabled = true; - await this.manager.savePluginAndExport(plugin.id); - await this.appPlugins.enablePlugin(plugin.id); - } else { - managerPluginForToggle.enabled = false; - await this.manager.savePluginAndExport(plugin.id); - await this.appPlugins.disablePlugin(plugin.id); - } - } else { - if (targetEnabled) { - managerPluginForToggle.enabled = true; - await this.appPlugins.enablePluginAndSave(plugin.id); - } else { - managerPluginForToggle.enabled = false; - await this.appPlugins.disablePluginAndSave(plugin.id); - } + if (this.settings.DELAY) { + if (targetEnabled) { + managerPluginForToggle.enabled = true; + await this.manager.savePluginAndExport(plugin.id); + await this.appPlugins.enablePlugin(plugin.id); + } else { + managerPluginForToggle.enabled = false; + await this.manager.savePluginAndExport(plugin.id); + await this.appPlugins.disablePlugin(plugin.id); + } + } else { + if (targetEnabled) { + managerPluginForToggle.enabled = true; + await this.appPlugins.enablePluginAndSave(plugin.id); + } else { + managerPluginForToggle.enabled = false; + await this.appPlugins.disablePluginAndSave(plugin.id); + } await this.manager.savePluginAndExport(plugin.id); } Commands(this.app, this.manager);