From 7e75600154c67df9dfa20837cf866c64114d0c9d Mon Sep 17 00:00:00 2001 From: cccccyb <995134776@qq.com> Date: Fri, 12 May 2023 02:39:56 +0800 Subject: [PATCH] add pinia to manage data --- ui/src/components/notice/NoticeHead.vue | 183 +++++++++++------- .../components/notice/NoticeManageTable.vue | 16 +- ui/src/components/notice/NoticeViewTable.vue | 25 ++- ui/src/pages/notice/NoticeManage.vue | 20 +- ui/src/pages/notice/NoticeView.vue | 35 ++-- ui/src/store/notice-manage.ts | 22 +++ ui/src/store/notice-view.ts | 22 +++ ui/src/store/notice.ts | 0 8 files changed, 205 insertions(+), 118 deletions(-) create mode 100644 ui/src/store/notice-manage.ts create mode 100644 ui/src/store/notice-view.ts delete mode 100644 ui/src/store/notice.ts diff --git a/ui/src/components/notice/NoticeHead.vue b/ui/src/components/notice/NoticeHead.vue index b289465..662f0c9 100644 --- a/ui/src/components/notice/NoticeHead.vue +++ b/ui/src/components/notice/NoticeHead.vue @@ -1,51 +1,105 @@ diff --git a/ui/src/components/notice/NoticeManageTable.vue b/ui/src/components/notice/NoticeManageTable.vue index 4cae845..c4b296e 100644 --- a/ui/src/components/notice/NoticeManageTable.vue +++ b/ui/src/components/notice/NoticeManageTable.vue @@ -113,6 +113,9 @@ diff --git a/ui/src/components/notice/NoticeViewTable.vue b/ui/src/components/notice/NoticeViewTable.vue index a19b9c3..c62ff11 100644 --- a/ui/src/components/notice/NoticeViewTable.vue +++ b/ui/src/components/notice/NoticeViewTable.vue @@ -6,10 +6,10 @@ >清除筛选条件 diff --git a/ui/src/pages/notice/NoticeView.vue b/ui/src/pages/notice/NoticeView.vue index 69ea359..9572f5a 100644 --- a/ui/src/pages/notice/NoticeView.vue +++ b/ui/src/pages/notice/NoticeView.vue @@ -14,43 +14,36 @@ 已读 未读 - + - + diff --git a/ui/src/store/notice-manage.ts b/ui/src/store/notice-manage.ts new file mode 100644 index 0000000..0123d7d --- /dev/null +++ b/ui/src/store/notice-manage.ts @@ -0,0 +1,22 @@ +import { defineStore } from 'pinia' +import request from '@/services' + +export const useNoticeManageStore = defineStore('notice-manage', { + state: () => { + return { + selectData: [], + loading: true + } + }, + getters: {}, + actions: { + selectAllNotice() { + void request.get('http://localhost:8621/notice').then((response) => { + this.selectData = response.data.data + if (this.selectData.length !== 0) { + this.loading = false + } + }) + } + } +}) diff --git a/ui/src/store/notice-view.ts b/ui/src/store/notice-view.ts new file mode 100644 index 0000000..dffdb20 --- /dev/null +++ b/ui/src/store/notice-view.ts @@ -0,0 +1,22 @@ +import { defineStore } from 'pinia' +import request from '@/services' + +export const useNoticeViewStore = defineStore('notice-view', { + state: () => { + return { + selectData: [], + getLoading: true + } + }, + getters: {}, + actions: { + selectAllNoticeByUserId(): void { + void request.get('http://localhost:8621/notice/ByUserId').then((response) => { + this.selectData = response.data.data + if (this.selectData.length !== 0) { + this.getLoading = false + } + }) + } + } +}) diff --git a/ui/src/store/notice.ts b/ui/src/store/notice.ts deleted file mode 100644 index e69de29..0000000