From 06030165f539cdac246a860e249ac5ced4a03fbb Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 1 Dec 2022 01:07:49 +0800 Subject: [PATCH] perf: hide toast on setup page (halo-dev/console#740) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### 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 ``` --- src/main.ts | 5 ++++- src/stores/system-states.ts | 15 ++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 3c721df98..7833dd03b 100644 --- a/src/main.ts +++ b/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 { diff --git a/src/stores/system-states.ts b/src/stores/system-states.ts index b3e61952d..8cada689e 100644 --- a/src/stores/system-states.ts +++ b/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( + `${ + import.meta.env.VITE_API_URL + }/api/v1alpha1/configmaps/system-states`, + { + withCredentials: true, + } + ); if (data.data) { this.states = JSON.parse(data.data["states"]);