fix: plugin failed to get settings when plugin is stopped (#750)

#### What type of PR is this?

/kind bug
/milestone 2.0.1

#### What this PR does / why we need it:

修复插件停止时,仍然获取设置选项导致提示失败的问题。

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2866

#### Special notes for your reviewer:

测试方式:

1. 安装一个插件,将其停止之后检查是否有获取 setting 的请求以及页面上是否有提示。

#### Does this PR introduce a user-facing change?

```release-note
修复在 Console 端停止插件时,仍然获取设置选项导致显示失败提示的问题。
```
pull/758/head
Ryan Wang 2022-12-07 12:38:53 +08:00 committed by GitHub
parent 5a8b046862
commit 581f7156f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import BasicLayout from "@/layouts/BasicLayout.vue";
import type { Ref } from "vue";
import type { Plugin, SettingForm } from "@halo-dev/api-client";
import { usePermission } from "@/utils/permission";
import { usePluginLifeCycle } from "../composables/use-plugin";
const { currentUserHasPermission } = usePermission();
@ -60,6 +61,8 @@ provide<Ref<string | undefined>>("activeTab", activeTab);
const settingName = computed(() => plugin.value?.spec.settingName);
const configMapName = computed(() => plugin.value?.spec.configMapName);
const { isStarted } = usePluginLifeCycle(plugin);
const { setting, handleFetchSettings } = useSettingForm(
settingName,
configMapName
@ -112,7 +115,9 @@ onMounted(async () => {
return;
}
if (isStarted.value) {
await handleFetchSettings();
}
tabs.value = cloneDeep(initialTabs);