Explorar o código

Merge commit 'refs/pull/543/head' of https://gitee.com/zuohuaijun/Admin.NET into next

zuohuaijun %!s(int64=3) %!d(string=hai) anos
pai
achega
bcbe92749f

+ 2 - 1
Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs

@@ -144,7 +144,8 @@ public class SysAuthService : IDynamicApiController, ITransient
             Os = client.OS.Family + client.OS.Major,
             VisType = LoginTypeEnum.Login,
             Account = user.Account,
-            RealName = user.RealName
+            RealName = user.RealName,
+            TenantId = user.TenantId,
         });
 
         return new LoginUserOutput

+ 22 - 4
Web/src/layout/navBars/breadcrumb/user.vue

@@ -35,7 +35,7 @@
 		<div class="layout-navbars-breadcrumb-user-icon">
 			<el-popover placement="bottom" trigger="hover" transition="el-zoom-in-top" :width="300" :persistent="false">
 				<template #reference>
-					<el-badge :is-dot="true">
+					<el-badge :is-dot="hasUnreadNotice">
 						<el-icon :title="$t('message.user.title4')">
 							<ele-Bell />
 						</el-icon>
@@ -74,7 +74,7 @@
 </template>
 
 <script setup lang="ts" name="layoutBreadcrumbUser">
-import { defineAsyncComponent, ref, computed, reactive, onMounted } from 'vue';
+import { defineAsyncComponent, ref, computed, reactive, onMounted, onUnmounted } from 'vue';
 import { useRouter } from 'vue-router';
 import { ElMessageBox, ElMessage, ElNotification } from 'element-plus';
 import screenfull from 'screenfull';
@@ -120,6 +120,10 @@ const layoutUserFlexNum = computed(() => {
 	else num = '';
 	return num;
 });
+// 是否有未读消息
+const hasUnreadNotice = computed(() => {
+	return state.noticeList.some((r: any) => r.readStatus == undefined || r.readStatus == 0);
+});
 // 全屏点击时
 const onScreenfullClick = () => {
 	if (!screenfull.isEnabled) {
@@ -212,9 +216,23 @@ onMounted(async () => {
 	state.noticeList = res.data.result ?? [];
 
 	// 接收站内信
-	signalR.on('PublicNotice', reciveNotice);
+	signalR.on('PublicNotice', receiveNotice);
+
+	// 处理消息已读
+	mittBus.on('noticeRead', (id) => {
+		const notice = state.noticeList.find((r: any) => r.id == id);
+		if (notice == undefined) return;
+
+		// 设置已读
+		notice.readStatus = 1;
+	});
+});
+// 页面卸载时
+onUnmounted(() => {
+	mittBus.off('noticeRead', () => {});
 });
-const reciveNotice = (msg: any) => {
+
+const receiveNotice = (msg: any) => {
 	state.noticeList.unshift(msg);
 
 	ElNotification({

+ 2 - 0
Web/src/types/mitt.d.ts

@@ -33,6 +33,8 @@ declare type MittType<T = any> = {
 	submitRefreshFk?: string; // 代码生成主键刷新
 
 	uploadCropperImg?: any; // 上传裁剪图片
+
+	noticeRead: number; // 消息已读事件
 };
 
 // mitt 参数类型定义

+ 3 - 7
Web/src/views/home/notice/index.vue

@@ -97,14 +97,8 @@ const state = reactive({
 });
 onMounted(async () => {
 	handleQuery();
-
-	mittBus.on('submitRefresh', () => {
-		handleQuery();
-	});
-});
-onUnmounted(() => {
-	mittBus.off('submitRefresh', () => {});
 });
+onUnmounted(() => {});
 // 查询操作
 const handleQuery = async () => {
 	state.loading = true;
@@ -135,6 +129,8 @@ const viewDetail = async (row: any) => {
 	state.dialogVisible = true;
 
 	row.readStatus = 1;
+
+	mittBus.emit('noticeRead', row.sysNotice.id);
 	await getAPI(SysNoticeApi).sysNoticeSetReadPost({ id: row.sysNotice.id });
 };
 

+ 1 - 1
Web/src/views/system/cache/index.vue

@@ -135,7 +135,7 @@ export default defineComponent({
 </script>
 +
 
-<style lang="scss">
+<style lang="scss" scoped>
 .card-header {
 	display: flex;
 	justify-content: space-between;

+ 1 - 1
Web/src/views/system/formDes/index.vue

@@ -24,7 +24,7 @@ export default defineComponent({
 });
 </script>
 
-<style lang="scss">
+<style lang="scss" scoped>
 body {
 	margin: 0; // 去除页面垂直滚动条
 }

+ 1 - 1
Web/src/views/system/job/component/jobCluster.vue

@@ -52,4 +52,4 @@ const openDrawer = () => {
 defineExpose({ openDrawer });
 </script>
 
-<style lang="scss"></style>
+<style lang="scss" scoped></style>

+ 1 - 1
Web/src/views/system/job/dashboard.vue

@@ -4,7 +4,7 @@
 
 <script setup lang="ts" name="jobDashboard"></script>
 
-<style lang="scss">
+<style lang="scss" scoped>
 .layout-padding {
 	margin: 8px;
 }

+ 1 - 1
Web/src/views/system/log/difflog/index.vue

@@ -142,7 +142,7 @@ export default defineComponent({
 });
 </script>
 
-<style lang="scss">
+<style lang="scss" scoped>
 .el-popper {
 	max-width: 60%;
 }

+ 1 - 1
Web/src/views/system/log/exlog/index.vue

@@ -155,7 +155,7 @@ export default defineComponent({
 });
 </script>
 
-<style lang="scss">
+<style lang="scss" scoped>
 .el-popper {
 	max-width: 60%;
 }

+ 1 - 1
Web/src/views/system/log/oplog/index.vue

@@ -194,7 +194,7 @@ export default defineComponent({
 });
 </script>
 
-<style lang="scss">
+<style lang="scss" scoped>
 .el-popper {
 	max-width: 60%;
 }

+ 1 - 1
Web/src/views/system/onlineUser/index.vue

@@ -143,4 +143,4 @@ const handleCurrentChange = (val: number) => {
 defineExpose({ openDrawer });
 </script>
 
-<style lang="scss"></style>
+<style lang="scss" scoped></style>

+ 1 - 1
Web/src/views/system/server/index.vue

@@ -203,7 +203,7 @@ export default defineComponent({
 });
 </script>
 
-<style lang="scss">
+<style lang="scss" scoped>
 .sysInfo_table {
 	width: 100%;
 	min-height: 40px;