From 2f1811774f15ea6f229d08a4d2616db754b3d6e9 Mon Sep 17 00:00:00 2001 From: hzhfsa <1957214281@qq.com> Date: Thu, 19 Oct 2023 20:50:39 +0800 Subject: [PATCH 01/16] second commit --- deliver-front/vue/src/main.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/deliver-front/vue/src/main.ts b/deliver-front/vue/src/main.ts index 7b662cdb..9d470c42 100644 --- a/deliver-front/vue/src/main.ts +++ b/deliver-front/vue/src/main.ts @@ -8,8 +8,6 @@ import 'virtual:svg-icons-register'; import setupDefaultSetting from '@/utils/setupDefaultSetting' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' - - import Antd from 'ant-design-vue'; // 用来切换主题 import 'ant-design-vue/dist/antd.variable.min.css' -- Gitee From 53789788fd71a03a71979f36e1c743a02f7a9737 Mon Sep 17 00:00:00 2001 From: dengyu <3233891353@qq.com> Date: Tue, 7 Nov 2023 17:16:56 +0800 Subject: [PATCH 02/16] =?UTF-8?q?feat:=E6=8E=A7=E5=88=B6=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E5=A4=B4=E9=83=A8=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deliver-front/vue/src/api/dashboard.ts | 14 +++++++------- deliver-front/vue/src/main.ts | 3 +-- deliver-front/vue/src/store/index.ts | 11 +++-------- .../vue/src/store/modules/dashboard.ts | 18 ++++++++++++++++++ .../vue/src/store/modules/types/types.ts | 0 .../vue/src/views/Dashboard/index.vue | 14 ++++++++++++-- deliver-front/vue/vite.config.ts | 2 +- 7 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 deliver-front/vue/src/store/modules/dashboard.ts create mode 100644 deliver-front/vue/src/store/modules/types/types.ts diff --git a/deliver-front/vue/src/api/dashboard.ts b/deliver-front/vue/src/api/dashboard.ts index c7f963ed..a60a0649 100644 --- a/deliver-front/vue/src/api/dashboard.ts +++ b/deliver-front/vue/src/api/dashboard.ts @@ -1,13 +1,13 @@ import request from '@/utils/request' -// interface DashboardHeadData { -// numberOfMessagesToday: string -// numberOfPlatformFiles: string -// accumulatedTemplateOwnership: string -// numberOfApps: string -// } +export interface DashboardHeadData { + numberOfMessagesToday?: string + numberOfPlatformFiles?: string + accumulatedTemplateOwnership?: string + numberOfApps?: string +} -export async function getDashboardHeadData(): Promise { +export async function getDashboardHeadData(): Promise { return await request({ url: '/dashboard/getDashboardHeadData', method: 'post' diff --git a/deliver-front/vue/src/main.ts b/deliver-front/vue/src/main.ts index 3ff0f8a8..bca131b4 100644 --- a/deliver-front/vue/src/main.ts +++ b/deliver-front/vue/src/main.ts @@ -1,9 +1,8 @@ import { createApp } from 'vue' -import { createPinia } from 'pinia' import './style.css' import App from './App.vue' import router from './router' -const pinia = createPinia() +import pinia from './store' createApp(App).use(router).use(pinia).mount('#app') diff --git a/deliver-front/vue/src/store/index.ts b/deliver-front/vue/src/store/index.ts index 68ce550c..a45888d5 100644 --- a/deliver-front/vue/src/store/index.ts +++ b/deliver-front/vue/src/store/index.ts @@ -1,9 +1,4 @@ -import { defineStore } from 'pinia' +import { createPinia } from 'pinia' +const pinia = createPinia() -export const useStore = defineStore('store', { - state: () => { - return {} - }, - getters: {}, - actions: {} -}) +export default pinia diff --git a/deliver-front/vue/src/store/modules/dashboard.ts b/deliver-front/vue/src/store/modules/dashboard.ts new file mode 100644 index 00000000..c48dec25 --- /dev/null +++ b/deliver-front/vue/src/store/modules/dashboard.ts @@ -0,0 +1,18 @@ +import { defineStore } from 'pinia' +import { getDashboardHeadData, type DashboardHeadData } from '@/api/dashboard' + +export const useDashboardStore = defineStore('dashboard', { + state: () => { + return { + num: 0 + } + }, + actions: { + async getDashboardHeadData() { + const dashboardHeadData: DashboardHeadData = await getDashboardHeadData() + console.log(dashboardHeadData) + return dashboardHeadData + } + }, + getters: {} +}) diff --git a/deliver-front/vue/src/store/modules/types/types.ts b/deliver-front/vue/src/store/modules/types/types.ts new file mode 100644 index 00000000..e69de29b diff --git a/deliver-front/vue/src/views/Dashboard/index.vue b/deliver-front/vue/src/views/Dashboard/index.vue index aeaed136..65f68e09 100644 --- a/deliver-front/vue/src/views/Dashboard/index.vue +++ b/deliver-front/vue/src/views/Dashboard/index.vue @@ -8,7 +8,9 @@ import { } from '@ant-design/icons-vue' import Echarts from '@/components/Echarts/index.vue' import { type EChartsOption } from 'echarts' -import { getDashboardHeadData } from '@/api/dashboard' +import { useDashboardStore } from '@/store/modules/dashboard' +import { type DashboardHeadData } from '@/api/dashboard' +import { onMounted, ref } from 'vue' const chartsMessageOption: EChartsOption = { legend: { top: '20%' @@ -111,7 +113,15 @@ const chartsAccountOption: EChartsOption = { } ] } -const dashboardHeadData = await getDashboardHeadData() +const dashboardHeadData = ref({}) +const getDashboardHeadData = async (): Promise => { + const dashboardStore = useDashboardStore() + dashboardHeadData.value = await dashboardStore.getDashboardHeadData() +} + +onMounted(async () => { + await getDashboardHeadData() +})