diff --git a/packages/i18n/src/locales/en/settings.yaml b/packages/i18n/src/locales/en/settings.yaml index 16886baa6..65902b8f6 100644 --- a/packages/i18n/src/locales/en/settings.yaml +++ b/packages/i18n/src/locales/en/settings.yaml @@ -1641,6 +1641,13 @@ pages: markdown-stress: title: Markdown Stress description: Stress markdown parsing and rendering with heavy chat payloads + plugin-host: + actions: + enable-and-load: Enable and Load + disable-and-unload: Disable and Unload + errors: + enable-and-load: 'Failed to enable and load plugin {extensionId}.' + disable-and-unload: 'Failed to disable and unload plugin {extensionId}.' use-magic-keys: title: useMagicKeys Tool description: Test shortcuts diff --git a/packages/i18n/src/locales/zh-Hans/settings.yaml b/packages/i18n/src/locales/zh-Hans/settings.yaml index 82c7ea33b..acfaf13b4 100644 --- a/packages/i18n/src/locales/zh-Hans/settings.yaml +++ b/packages/i18n/src/locales/zh-Hans/settings.yaml @@ -1555,6 +1555,13 @@ pages: markdown-stress: title: Markdown Stress description: 用大量聊天负载来测试 Markdown 的解析和渲染能力 + plugin-host: + actions: + enable-and-load: 启用并加载 + disable-and-unload: 停用并卸载 + errors: + enable-and-load: '启用并加载插件 {extensionId} 失败。' + disable-and-unload: '停用并卸载插件 {extensionId} 失败。' use-magic-keys: title: useMagicKeys 工具 description: 测试快捷键 diff --git a/packages/stage-pages/src/pages/devtools/plugin-host.vue b/packages/stage-pages/src/pages/devtools/plugin-host.vue index 2c03faa0c..9d153381c 100644 --- a/packages/stage-pages/src/pages/devtools/plugin-host.vue +++ b/packages/stage-pages/src/pages/devtools/plugin-host.vue @@ -9,9 +9,11 @@ import { Section } from '@proj-airi/stage-ui/components' import { usePluginHostInspectorStore } from '@proj-airi/stage-ui/stores/devtools/plugin-host-debug' import { Button, Callout, GhostButton, Input } from '@proj-airi/ui' import { computed, onMounted, ref } from 'vue' +import { useI18n } from 'vue-i18n' import { toast } from 'vue-sonner' const store = usePluginHostInspectorStore() +const { t } = useI18n() const filter = ref('') const selectedExtensionId = ref('') @@ -150,6 +152,24 @@ async function unloadPlugin(plugin: PluginManifestSummary) { } } +async function enableAndLoadPlugin(plugin: PluginManifestSummary) { + try { + await store.enableAndLoad({ extensionId: plugin.extensionId, path: plugin.path }) + } + catch (error) { + toast.error(errorMessageFrom(error) ?? t('settings.pages.system.sections.section.developer.sections.section.plugin-host.errors.enable-and-load', { extensionId: plugin.extensionId })) + } +} + +async function disableAndUnloadPlugin(plugin: PluginManifestSummary) { + try { + await store.disableAndUnload({ extensionId: plugin.extensionId, path: plugin.path }) + } + catch (error) { + toast.error(errorMessageFrom(error) ?? t('settings.pages.system.sections.section.developer.sections.section.plugin-host.errors.disable-and-unload', { extensionId: plugin.extensionId })) + } +} + async function loadSelectedPlugin() { const extensionId = selectedExtensionId.value.trim() if (!extensionId) { @@ -304,6 +324,22 @@ onMounted(async () => {
+