fix: 通知完善

This commit is contained in:
easy 2023-03-13 18:01:39 +08:00
parent 6dfc0cb1db
commit 10522b0e24
1 changed files with 33 additions and 5 deletions

View File

@ -18,11 +18,11 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="tsx">
import { getList_api } from '@/api/account/notificationRecord'; import { getList_api } from '@/api/account/notificationRecord';
import NoticeInfo from './NoticeInfo.vue'; import NoticeInfo from './NoticeInfo.vue';
import { getWebSocket } from '@/utils/websocket'; import { getWebSocket } from '@/utils/websocket';
import { notification } from 'ant-design-vue'; import { notification, Button } from 'ant-design-vue';
import { changeStatus_api } from '@/api/account/notificationRecord'; import { changeStatus_api } from '@/api/account/notificationRecord';
import { useUserInfo } from '@/store/userInfo'; import { useUserInfo } from '@/store/userInfo';
@ -38,12 +38,40 @@ const subscribeNotice = () => {
.subscribe((resp: any) => { .subscribe((resp: any) => {
total.value += 1; total.value += 1;
notification.open({ notification.open({
message: 'Notification Title', message: resp?.payload?.topicName,
description: description: () => (
'This is the content of the notification. This is the content of the notification. This is the content of the notification.', <div
class="ellipsis"
style={{ cursor: 'pointer' }}
onClick={() => {
changeStatus_api('_read', [resp.id]);
}}
>
{resp?.payload?.message}
</div>
),
onClick: () => { onClick: () => {
changeStatus_api('_read', [resp.id]); changeStatus_api('_read', [resp.id]);
}, },
key: resp.payload.id,
btn: (
<Button
type="primary"
size="small"
onClick={() => {
changeStatus_api('_read', [resp.id]).then(
(resp: any) => {
if (resp.status === 200) {
notification.close(resp.payload.id);
getList();
}
},
);
}}
>
标记已读
</Button>
),
}); });
}); });
}; };