Browse Source

perf: hide toast on setup page (#740)

#### What type of PR is this?

/kind improvement
/milestone 2.0

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

在首次初始化页面隐藏 `资源不存在` 的提示,这是由 https://github.com/halo-dev/console/pull/732 带来的问题。

#### Special notes for your reviewer:

测试方式:

1. 准备全新的环境。
2. 进入初始化页面,检查是否存在 `资源不存在` 的提示。

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

```release-note
None
```
pull/741/head
Ryan Wang 2 years ago committed by GitHub
parent
commit
97a8bd1075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/main.ts
  2. 15
      src/stores/system-states.ts

5
src/main.ts

@ -228,7 +228,6 @@ async function initApp() {
}
await loadUserPermissions();
await loadActivatedTheme();
try {
await loadPluginModules();
@ -239,6 +238,10 @@ async function initApp() {
// load system setup state
const systemStateStore = useSystemStatesStore();
await systemStateStore.fetchSystemStates();
if (systemStateStore.states.isSetup) {
await loadActivatedTheme();
}
} catch (e) {
console.error(e);
} finally {

15
src/stores/system-states.ts

@ -1,5 +1,6 @@
import { apiClient } from "@/utils/api-client";
import { defineStore } from "pinia";
import axios from "axios";
import type { ConfigMap } from "@halo-dev/api-client";
interface SystemState {
isSetup: boolean;
@ -19,10 +20,14 @@ export const useSystemStatesStore = defineStore({
actions: {
async fetchSystemStates() {
try {
const { data } =
await apiClient.extension.configMap.getv1alpha1ConfigMap({
name: "system-states",
});
const { data } = await axios.get<ConfigMap>(
`${
import.meta.env.VITE_API_URL
}/api/v1alpha1/configmaps/system-states`,
{
withCredentials: true,
}
);
if (data.data) {
this.states = JSON.parse(data.data["states"]);

Loading…
Cancel
Save