userNews.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div class="layout-navbars-breadcrumb-user-news">
  3. <div class="head-box">
  4. <div class="head-box-title">{{ $t('message.user.newTitle') }}</div>
  5. <!-- <div class="head-box-btn" v-if="state.newsList.length > 0" @click="onAllReadClick">{{ $t('message.user.newBtn') }}</div>-->
  6. </div>
  7. <div class="content-box">
  8. <template v-if="state.newsList.length > 0">
  9. <div class="content-box-item" v-for="(v, k) in state.newsList" :key="k">
  10. <div>{{ v.title }}</div>
  11. <div class="content-box-msg">
  12. <div v-html="v.content"></div>
  13. </div>
  14. <div class="content-box-time">{{ v.create_datetime }}</div>
  15. </div>
  16. </template>
  17. <el-empty :description="$t('message.user.newDesc')" v-else></el-empty>
  18. </div>
  19. <div class="foot-box" @click="onGoToGiteeClick" v-if="state.newsList.length > 0">{{ $t('message.user.newGo') }}</div>
  20. </div>
  21. </template>
  22. <script setup lang="ts" name="layoutBreadcrumbUserNews">
  23. import { reactive,onBeforeMount,ref,onMounted } from 'vue';
  24. // 定义变量内容
  25. const state = reactive({
  26. newsList: [] as any,
  27. });
  28. // 全部已读点击
  29. const onAllReadClick = () => {
  30. state.newsList = [];
  31. };
  32. // 前往通知中心点击
  33. import {useRouter } from "vue-router";
  34. const route = useRouter()
  35. const onGoToGiteeClick = () => {
  36. route.push('/messageCenter')
  37. };
  38. //获取最新消息
  39. import { request } from "/@/utils/service";
  40. const getLastMsg= ()=>{
  41. request({
  42. url: '/api/system/message_center/get_newest_msg/',
  43. method: 'get',
  44. params: {}
  45. }).then((res:any) => {
  46. const { data } = res
  47. state.newsList= [data]
  48. })
  49. }
  50. onMounted(()=>{
  51. getLastMsg()
  52. })
  53. </script>
  54. <style scoped lang="scss">
  55. .layout-navbars-breadcrumb-user-news {
  56. .head-box {
  57. display: flex;
  58. border-bottom: 1px solid var(--el-border-color-lighter);
  59. box-sizing: border-box;
  60. color: var(--el-text-color-primary);
  61. justify-content: space-between;
  62. height: 35px;
  63. align-items: center;
  64. .head-box-btn {
  65. color: var(--el-color-primary);
  66. font-size: 13px;
  67. cursor: pointer;
  68. opacity: 0.8;
  69. &:hover {
  70. opacity: 1;
  71. }
  72. }
  73. }
  74. .content-box {
  75. font-size: 13px;
  76. .content-box-item {
  77. padding-top: 12px;
  78. &:last-of-type {
  79. padding-bottom: 12px;
  80. }
  81. .content-box-msg {
  82. color: var(--el-text-color-secondary);
  83. margin-top: 5px;
  84. margin-bottom: 5px;
  85. }
  86. .content-box-time {
  87. color: var(--el-text-color-secondary);
  88. }
  89. }
  90. }
  91. .foot-box {
  92. height: 35px;
  93. color: var(--el-color-primary);
  94. font-size: 13px;
  95. cursor: pointer;
  96. opacity: 0.8;
  97. display: flex;
  98. align-items: center;
  99. justify-content: center;
  100. border-top: 1px solid var(--el-border-color-lighter);
  101. &:hover {
  102. opacity: 1;
  103. }
  104. }
  105. :deep(.el-empty__description p) {
  106. font-size: 13px;
  107. }
  108. }
  109. </style>