parent
d6293e879d
commit
50d5c4080d
|
|
@ -4,12 +4,17 @@ import type {
|
|||
DashboardConfigType,
|
||||
} from "@/gql/graphql";
|
||||
import type { DashboardCourseConfigType } from "@/services/dashboard";
|
||||
import { fetchDashboardConfigv2, fetchStatisticData } from "@/services/dashboard";
|
||||
import {
|
||||
fetchDashboardConfig,
|
||||
fetchDashboardConfigv2,
|
||||
fetchStatisticData,
|
||||
} from "@/services/dashboard";
|
||||
import { defineStore } from "pinia";
|
||||
import type { Ref } from "vue";
|
||||
import { ref } from "vue";
|
||||
|
||||
export const useDashboardStore = defineStore("dashboard", () => {
|
||||
const dashboardConfigs: Ref<DashboardConfigType[]> = ref([]);
|
||||
const dashboardConfigsv2: Ref<DashboardCourseConfigType[]> = ref([]);
|
||||
const currentDashboardConfig: Ref<DashboardConfigType | undefined> = ref();
|
||||
const dashBoardDataCache: Record<
|
||||
|
|
@ -25,6 +30,15 @@ export const useDashboardStore = defineStore("dashboard", () => {
|
|||
await loadDashboardDetails();
|
||||
};
|
||||
|
||||
const loadDashboardConfig = async () => {
|
||||
if (dashboardConfigs.value.length > 0) return;
|
||||
const configData = await fetchDashboardConfig();
|
||||
if (configData && configData.length > 0) {
|
||||
dashboardConfigs.value = configData;
|
||||
await switchAndLoadDashboardConfig(configData[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const loadDashboardDetails = async () => {
|
||||
loading.value = true;
|
||||
dashboardConfigsv2.value = await fetchDashboardConfigv2();
|
||||
|
|
@ -45,9 +59,11 @@ export const useDashboardStore = defineStore("dashboard", () => {
|
|||
};
|
||||
|
||||
return {
|
||||
dashboardConfigs,
|
||||
dashboardConfigsv2,
|
||||
currentDashboardConfig,
|
||||
switchAndLoadDashboardConfig,
|
||||
loadDashboardConfig,
|
||||
loadDashboardDetails,
|
||||
currentDashBoardData,
|
||||
loading,
|
||||
|
|
|
|||
Loading…
Reference in New Issue