feat: 补充前端

This commit is contained in:
橙子
2024-08-07 00:03:07 +08:00
parent 578d410b77
commit 5a4d00a788
2 changed files with 47 additions and 31 deletions

View File

@@ -4,11 +4,11 @@ import { dayjs } from 'element-plus'
const receiveMsg=(connection)=> { const receiveMsg=(connection)=> {
const noticeStore = useNoticeStore(); const noticeStore = useNoticeStore();
connection.on("Personal", (message) => { connection.on("Personal", (message,creationTime) => {
noticeStore.addNotice({ noticeStore.addNotice({
message:message, message:message,
isRead:false, isRead:false,
creationTime:dayjs().format() creationTime
}); });
}); });
}; };

View File

@@ -11,9 +11,7 @@
<el-menu-item index="1" @click="enterIndex">主页</el-menu-item> <el-menu-item index="1" @click="enterIndex">主页</el-menu-item>
<el-menu-item index="2" @click="enterStart" <el-menu-item index="2" @click="enterStart"
style="color: red;font-weight: bolder;font-size: large;" style="color: red;font-weight: bolder;font-size: large;">开始</el-menu-item>
>开始</el-menu-item>
<el-sub-menu index="3"> <el-sub-menu index="3">
<template #title>学习</template> <template #title>学习</template>
@@ -61,7 +59,7 @@
<div class="notice"> <div class="notice">
<el-dropdown trigger="click" :max-height="500"> <el-dropdown trigger="click" :max-height="500">
<el-badge v-if="noticeStore.noticeForNoReadCount>0" :value="noticeStore.noticeForNoReadCount"> <el-badge v-if="noticeStore.noticeForNoReadCount > 0" :value="noticeStore.noticeForNoReadCount">
<el-button type="primary"> <el-button type="primary">
<el-icon :size="15"> <el-icon :size="15">
<Bell /> <Bell />
@@ -69,11 +67,11 @@
</el-button> </el-button>
</el-badge> </el-badge>
<el-button v-else="noticeStore.noticeForNoReadCount" type="primary"> <el-button v-else="noticeStore.noticeForNoReadCount" type="primary">
<el-icon :size="15"> <el-icon :size="15">
<Bell /> <Bell />
</el-icon> </el-icon>
</el-button> </el-button>
<template #dropdown> <template #dropdown>
@@ -85,19 +83,27 @@
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item v-for="(item, index) in noticeList" :key="index"> <el-dropdown-item class="notice-item" v-for="(item, index) in noticeList" :key="index">
<div v-if="item.isRead" class="notice-msg" v-html="item.message"></div>
<div v-if="item.isRead" class="notice-msg" style="background-color: #f7f7f7;">
<span class="notice-time">[已读]通知时间 {{ dayjs(item.creationTime).format('YYYY年M月D日 HH时mm分ss秒') }}</span>
<div v-html="item.message"></div>
</div>
<el-badge is-dot v-else > <el-badge is-dot v-else >
<span class="notice-time">[未读]通知时间 {{ dayjs(item.creationTime).format('YYYY年M月D日 HH时mm分ss秒') }}</span>
<div class="notice-msg" v-html="item.message"></div> <div class="notice-msg" v-html="item.message"></div>
</el-badge> </el-badge>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
@@ -118,6 +124,7 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { dayjs } from 'element-plus'
import { Bell } from '@element-plus/icons-vue' import { Bell } from '@element-plus/icons-vue'
import AvatarInfo from "@/components/AvatarInfo.vue"; import AvatarInfo from "@/components/AvatarInfo.vue";
import { computed, onMounted, ref } from "vue"; import { computed, onMounted, ref } from "vue";
@@ -141,15 +148,15 @@ const userStore = useUserStore();
const { money } = storeToRefs(userStore) const { money } = storeToRefs(userStore)
const activeIndex = ref("1"); const activeIndex = ref("1");
const searchText = ref(""); const searchText = ref("");
const noticeForNoReadCount=computed(()=>{ const noticeForNoReadCount = computed(() => {
return noticeList.value.filter(x => x.isRead ==false).length; return noticeList.value.filter(x => x.isRead == false).length;
}) })
//加载初始化离线消息 //加载初始化离线消息
onMounted(async () => { onMounted(async () => {
await fetchNoticeData(); await fetchNoticeData();
}) })
const fetchNoticeData = async () => { const fetchNoticeData = async () => {
const { data } = await getNoticeList({maxResultCount:20}); const { data } = await getNoticeList({ maxResultCount: 20 });
noticeStore.setNotices(data.items); noticeStore.setNotices(data.items);
} }
@@ -200,18 +207,18 @@ const handleGithubClick = () => {
window.open("https://github.com/ccnetcore/Yi.Abp.Admin"); window.open("https://github.com/ccnetcore/Yi.Abp.Admin");
}; };
///一键已读 ///一键已读
const hanldeReadClick=async ()=>{ const hanldeReadClick = async () => {
await noticeRead(); await noticeRead();
await fetchNoticeData(); await fetchNoticeData();
ElMessage({ ElMessage({
message: `全部已读`, message: `全部已读`,
type: "success", type: "success",
}); });
} }
const enterStart=()=>{ const enterStart = () => {
router.push("/start"); router.push("/start");
} }
@@ -219,6 +226,13 @@ const enterStart=()=>{
<style scoped lang="scss"> <style scoped lang="scss">
.notice-item{
padding: 10px 0px 30px 20px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
.notice-time{
font-size: larger;
}
.money { .money {
font-size: small; font-size: small;
@@ -302,11 +316,13 @@ const enterStart=()=>{
.notice { .notice {
margin: 0 5px; margin: 0 5px;
&-oper { &-oper {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
width: 100%; width: 100%;
} }
&-msg { &-msg {
white-space: wrap !important; white-space: wrap !important;
width: 400px; width: 400px;