Skip to content

Commit f130d5e

Browse files
committed
feat: 适配首页公告卡片并完善通知公告
1 parent 99498a3 commit f130d5e

File tree

16 files changed

+241
-276
lines changed

16 files changed

+241
-276
lines changed

src/apis/common/home.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import type * as Common from './type'
44
const BASE_URL = '/dashboard'
55

66
/** @desc 查询访问趋势 */
7-
export function listAccessTrend(days: number) {
7+
export function listDashboardAccessTrend(days: number) {
88
return http.get<Common.DashboardAccessTrendResp[]>(`${BASE_URL}/access/trend/${days}`)
99
}
10+
11+
/** @desc 查询公告列表 */
12+
export function listDashboardNotice() {
13+
return http.get<Common.DashboardNoticeResp[]>(`${BASE_URL}/notice`)
14+
}

src/apis/common/type.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ export interface ImageCaptchaResp {
44
img: string
55
}
66

7-
/** 仪表盘访问趋势 */
7+
/** 仪表盘访问趋势类型 */
88
export interface DashboardAccessTrendResp {
99
date: string
1010
pvCount: number
1111
ipCount: number
1212
}
13+
14+
/** 仪表盘公告类型 */
15+
export interface DashboardNoticeResp {
16+
id: number
17+
title: string
18+
type: number
19+
}

src/apis/system/announcement.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/apis/system/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export * from './user'
22
export * from './role'
33
export * from './menu'
44
export * from './dept'
5-
export * from './announcement'
5+
export * from './notice'
66
export * from './dict'
77
export * from './file'
88
export * from './storage'

src/apis/system/notice.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import http from '@/utils/http'
2+
import type * as System from './type'
3+
4+
const BASE_URL = '/system/notice'
5+
6+
/** @desc 查询公告列表 */
7+
export function listNotice(query: System.NoticeQuery) {
8+
return http.get<PageRes<System.NoticeResp[]>>(`${BASE_URL}`, query)
9+
}
10+
11+
/** @desc 查询公告详情 */
12+
export function getNotice(id: string) {
13+
return http.get<System.NoticeResp>(`${BASE_URL}/${id}`)
14+
}
15+
16+
/** @desc 新增公告 */
17+
export function addNotice(data: any) {
18+
return http.post(BASE_URL, data)
19+
}
20+
21+
/** @desc 修改公告 */
22+
export function updateNotice(data: any, id: string) {
23+
return http.put(`${BASE_URL}/${id}`, data)
24+
}
25+
26+
/** @desc 删除公告 */
27+
export function deleteNotice(ids: string | Array<number>) {
28+
return http.del(`${BASE_URL}/${ids}`)
29+
}

src/apis/system/type.ts

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,25 @@ export interface DeptQuery {
119119
sort: Array<string>
120120
}
121121

122+
/** 系统公告类型 */
123+
export interface NoticeResp {
124+
id: string
125+
title: string
126+
content: string
127+
status: number
128+
type: string
129+
effectiveTime: string
130+
terminateTime: string
131+
createUserString: string
132+
createTime: string
133+
updateUserString: string
134+
updateTime: string
135+
}
136+
export interface NoticeQuery extends PageQuery {
137+
title?: string
138+
type?: string
139+
}
140+
122141
/** 系统字典类型 */
123142
export interface DictResp {
124143
id: string
@@ -222,26 +241,3 @@ export interface BindSocialAccountRes {
222241
source: string
223242
description: string
224243
}
225-
226-
/** 公告类型 */
227-
export interface AnnouncementResp {
228-
id: string
229-
title: string
230-
content: string
231-
status: number
232-
type?: string
233-
effectiveTime?: string
234-
terminateTime?: string
235-
createUser: string
236-
createTime: string
237-
updateUser: string
238-
updateTime: string
239-
createUserString: string
240-
updateUserString: string
241-
}
242-
243-
export interface AnnouncementQuery extends PageQuery {
244-
title?: string
245-
status?: number
246-
type?: string
247-
}

src/layout/components/HeaderRightBar/Message.vue

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<template>
22
<div class="message">
33
<a-tabs default-active-key="1">
4-
<a-tab-pane key="1">
4+
<a-tab-pane key="1" disabled>
55
<template #title>通知(1)</template>
66
</a-tab-pane>
7-
<a-tab-pane key="2">
7+
<a-tab-pane key="2" disabled>
88
<template #title>关注(1)</template>
99
</a-tab-pane>
10-
<a-tab-pane key="3">
10+
<a-tab-pane key="3" disabled>
1111
<template #title>待办(2)</template>
1212
</a-tab-pane>
1313
</a-tabs>
@@ -22,7 +22,7 @@
2222
>
2323
<template #actions></template>
2424
<template #avatar>
25-
<a-avatar><img :src="item.avatar" /></a-avatar>
25+
<a-avatar><img :src="item.avatar" alt="avatar" /></a-avatar>
2626
</template>
2727
</a-comment>
2828
</section>
@@ -31,24 +31,13 @@
3131

3232
<script setup lang="ts">
3333
defineOptions({ name: 'Message' })
34+
3435
const list = [
3536
{
3637
name: 'Socrates',
3738
datetime: '1小时之前',
38-
content: 'Comment body content.',
39+
content: 'v3.1.0 重构消息通知',
3940
avatar: 'https://lolicode.gitee.io/scui-doc/demo/img/avatar2.gif'
40-
},
41-
{
42-
name: '木木糖醇',
43-
datetime: '2小时之前',
44-
content: '关注了你',
45-
avatar: 'https://s1.ax1x.com/2022/06/14/XhteeO.jpg'
46-
},
47-
{
48-
name: '徐欣',
49-
datetime: '2个半小时之前',
50-
content: '收藏了你的文章',
51-
avatar: 'https://s1.ax1x.com/2022/06/14/XhtSwF.jpg'
5241
}
5342
]
5443
</script>

src/views/home/components/AccessTrendCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</template>
1414

1515
<script lang="ts" setup>
16-
import { listAccessTrend, type DashboardAccessTrendResp } from '@/apis'
16+
import { listDashboardAccessTrend, type DashboardAccessTrendResp } from '@/apis'
1717
import VCharts from 'vue-echarts'
1818
import { graphic } from 'echarts'
1919
import { useChart } from '@/hooks'
@@ -180,7 +180,7 @@ const getChartData = async (days: number) => {
180180
xData.value = []
181181
pvStatisticsData.value = []
182182
ipStatisticsData.value = []
183-
const { data: chartData } = await listAccessTrend(days)
183+
const { data: chartData } = await listDashboardAccessTrend(days)
184184
chartData.forEach((el: DashboardAccessTrendResp) => {
185185
xData.value.unshift(el.date)
186186
pvStatisticsData.value.unshift(el.pvCount)

src/views/home/components/NoticeCard.vue

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,41 @@
1313
>
1414
<template #content>
1515
<div class="content">
16-
<a-tag v-if="item.type === 1" color="blue" size="small">通知</a-tag>
17-
<a-tag v-if="item.type === 2" color="orangered" size="small">活动</a-tag>
18-
<a-tag v-if="item.type === 3" color="cyan" size="small">消息</a-tag>
19-
<p>{{ item.content }}</p>
16+
<GiCellTag :value="item.type" :dict="notice_type" />
17+
<p>
18+
<a-link @click="onDetail(item.id)">{{ item.title }}</a-link>
19+
</p>
2020
</div>
2121
</template>
2222
</a-comment>
2323
</a-card>
24+
25+
<NoticeDetailModal ref="NoticeDetailModalRef" />
2426
</template>
2527

2628
<script setup lang="ts">
27-
const dataList = [
28-
{ type: 1, content: 'v2.4.0 版本发布公告🎉' },
29-
{ type: 1, content: 'v2.3.0 版本发布公告🎉' },
30-
{ type: 1, content: 'v2.2.0 版本发布公告🎉' },
31-
{ type: 2, content: '作者喊你来贡献代码了~' },
32-
{ type: 2, content: '作者喊你来提需求了~' }
33-
]
29+
import { listDashboardNotice, type DashboardNoticeResp } from '@/apis'
30+
import { useDict } from '@/hooks/app'
31+
import NoticeDetailModal from '@/views/system/notice/NoticeDetailModal.vue'
32+
33+
const { notice_type } = useDict('notice_type')
34+
35+
const dataList = ref<DashboardNoticeResp[]>([])
36+
// 查询列表数据
37+
const getDataList = async () => {
38+
const res = await listDashboardNotice()
39+
dataList.value = res.data
40+
}
41+
42+
const NoticeDetailModalRef = ref<InstanceType<typeof NoticeDetailModal>>()
43+
// 详情
44+
const onDetail = (id: string) => {
45+
NoticeDetailModalRef.value?.onDetail(id)
46+
}
47+
48+
onMounted(() => {
49+
getDataList()
50+
})
3451
</script>
3552

3653
<style lang="scss" scoped>
@@ -52,4 +69,16 @@ const dataList = [
5269
margin-left: 6px;
5370
}
5471
}
72+
73+
.arco-link {
74+
color: rgb(var(--gray-8));
75+
}
76+
77+
.icon {
78+
margin-right: 3px;
79+
}
80+
81+
.update-time-row {
82+
text-align: right;
83+
}
5584
</style>

src/views/system/dict/DictAddModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ const onUpdate = async (id: string) => {
7474
7575
// 保存
7676
const save = async () => {
77+
const isInvalid = await formRef.value?.formRef?.validate()
78+
if (isInvalid) return false
7779
try {
78-
const isInvalid = await formRef.value?.formRef?.validate()
79-
if (isInvalid) return false
8080
if (isUpdate.value) {
8181
await updateDict(form, dataId.value)
8282
Message.success('修改成功')

0 commit comments

Comments
 (0)