马宇豪
2023-08-07 7ed4982b8f2a345bfad95a96070143c32142bc61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<template>
    <div class="layout-navbars-breadcrumb-user-news">
        <div class="head-box">
            <div class="head-box-title">{{ $t('message.user.newTitle') }}</div>
            <div class="head-box-btn" v-if="newsList.length > 0" @click="onAllReadClick">{{ $t('message.user.newBtn') }}</div>
        </div>
        <div class="content-box">
            <template v-if="newsList.length > 0">
                <div class="content-box-item" v-for="(v, k) in newsList" :key="k">
                    <div>{{ v.label }}</div>
                    <div class="content-box-msg">
                        {{ v.value }}
                    </div>
                    <div class="content-box-time">{{ v.time }}</div>
                </div>
            </template>
            <el-empty :description="$t('message.user.newDesc')" v-else></el-empty>
        </div>
        <div class="foot-box" @click="onGoToGiteeClick" v-if="newsList.length > 0">{{ $t('message.user.newGo') }}</div>
    </div>
</template>
 
<script lang="ts">
import { reactive, toRefs, defineComponent } from 'vue';
 
export default defineComponent({
    name: 'layoutBreadcrumbUserNews',
    setup() {
        const state = reactive({
            newsList: [
                {
                    label: '关于版本发布的通知',
                    value: 'vue-next-admin,基于 vue3 + CompositionAPI + typescript + vite + element plus,正式发布时间:2021年02月28日!',
                    time: '2020-12-08',
                },
                {
                    label: '关于学习交流的通知',
                    value: 'QQ群号码 665452019,欢迎小伙伴入群学习交流探讨!',
                    time: '2020-12-08',
                },
            ],
        });
        // 全部已读点击
        const onAllReadClick = () => {
            state.newsList = [];
        };
        // 前往通知中心点击
        const onGoToGiteeClick = () => {
            window.open('https://gitee.com/lyt-top/vue-next-admin');
        };
        return {
            onAllReadClick,
            onGoToGiteeClick,
            ...toRefs(state),
        };
    },
});
</script>
 
<style scoped lang="scss">
.layout-navbars-breadcrumb-user-news {
    .head-box {
        display: flex;
        border-bottom: 1px solid var(--el-border-color-lighter);
        box-sizing: border-box;
        color: var(--el-text-color-primary);
        justify-content: space-between;
        height: 35px;
        align-items: center;
        .head-box-btn {
            color: var(--el-color-primary);
            font-size: 13px;
            cursor: pointer;
            opacity: 0.8;
            &:hover {
                opacity: 1;
            }
        }
    }
    .content-box {
        font-size: 13px;
        .content-box-item {
            padding-top: 12px;
            &:last-of-type {
                padding-bottom: 12px;
            }
            .content-box-msg {
                color: var(--el-text-color-secondary);
                margin-top: 5px;
                margin-bottom: 5px;
            }
            .content-box-time {
                color: var(--el-text-color-secondary);
            }
        }
    }
    .foot-box {
        height: 35px;
        color: var(--el-color-primary);
        font-size: 13px;
        cursor: pointer;
        opacity: 0.8;
        display: flex;
        align-items: center;
        justify-content: center;
        border-top: 1px solid var(--el-border-color-lighter);
        &:hover {
            opacity: 1;
        }
    }
    ::v-deep(.el-empty__description p) {
        font-size: 13px;
    }
}
</style>