From f8ffcaa5937c29f22e28144d527799c3d2018651 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 24 Feb 2023 17:52:25 +0800 Subject: [PATCH] refactor: support configuring plugin when the plugin is stopped (halo-dev/console#875) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement #### What this PR does / why we need it: 1. 插件停止时支持配置插件设置项。 2. 修改插件异常信息的获取方式。 适配:https://github.com/halo-dev/halo/pull/3355 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3352 #### Special notes for your reviewer: 测试方式: 1. Halo 需要切换到 https://github.com/halo-dev/halo/pull/3355 分支。 2. Console 需要 `pnpm build:packages` 3. 根据 https://github.com/halo-dev/halo/pull/3355 中的描述进行测试。 #### Does this PR introduce a user-facing change? ```release-note None ``` --- .../api-client/src/models/plugin-status.ts | 20 ++++++------------- .../plugins/components/PluginListItem.vue | 9 ++++++++- .../system/plugins/layouts/PluginLayout.vue | 6 ++---- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/packages/api-client/src/models/plugin-status.ts b/packages/api-client/src/models/plugin-status.ts index dca435a50..b32abd1bf 100644 --- a/packages/api-client/src/models/plugin-status.ts +++ b/packages/api-client/src/models/plugin-status.ts @@ -12,6 +12,10 @@ * Do not edit the class manually. */ +// May contain unused imports in some cases +// @ts-ignore +import { Condition } from './condition' + /** * * @export @@ -26,28 +30,16 @@ export interface PluginStatus { phase?: PluginStatusPhaseEnum /** * - * @type {string} + * @type {Array} * @memberof PluginStatus */ - reason?: string - /** - * - * @type {string} - * @memberof PluginStatus - */ - message?: string + conditions?: Array /** * * @type {string} * @memberof PluginStatus */ lastStartTime?: string - /** - * - * @type {string} - * @memberof PluginStatus - */ - lastTransitionTime?: string /** * * @type {string} diff --git a/src/modules/system/plugins/components/PluginListItem.vue b/src/modules/system/plugins/components/PluginListItem.vue index a8371a0c4..e05a7af07 100644 --- a/src/modules/system/plugins/components/PluginListItem.vue +++ b/src/modules/system/plugins/components/PluginListItem.vue @@ -66,6 +66,13 @@ const handleResetSettingConfig = async () => { }, }); }; + +const getFailedMessage = (plugin: Plugin) => { + if (plugin.status?.conditions?.length) { + const lastCondition = plugin.status.conditions[0]; + return [lastCondition.reason, lastCondition.message].join(":"); + } +};