fix: 优化消息中心和医生二维码
This commit is contained in:
@@ -32,10 +32,12 @@ const [Modal, modalApi] = useVbenModal({
|
||||
modalApi.close();
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
modalApi.setState({
|
||||
loading: true,
|
||||
});
|
||||
if (isOpen) {
|
||||
const { values } = modalApi.getData<Record<string, any>>();
|
||||
if (values) {
|
||||
console.log(values, 'ssssssssssssss')
|
||||
if (values.doctor_id !== undefined) {
|
||||
doctorId.value = values.doctor_id;
|
||||
}
|
||||
@@ -57,6 +59,10 @@ const getDoctorInfoByStore = () => {
|
||||
goodAt.value = res.doctor.good_at;
|
||||
previewAddress.value =
|
||||
res.store.province.name + res.store.city.name + res.store.position;
|
||||
|
||||
modalApi.setState({
|
||||
loading: false,
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
|
||||
57
apps/web-antd/src/views/notice/compoents/UnreadUserList.vue
Normal file
57
apps/web-antd/src/views/notice/compoents/UnreadUserList.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import {Avatar, List, ListItem, ListItemMeta, Tag} from "ant-design-vue";
|
||||
|
||||
const userList = ref([]);
|
||||
const unreadCount = ref(0);
|
||||
const title = ref('通知的用户列表');
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
footer: false,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
modalApi.close();
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
if (isOpen) {
|
||||
const { values, unread_count } = modalApi.getData<Record<string, any>>();
|
||||
if (values) {
|
||||
userList.value = values;
|
||||
unreadCount.value = unread_count;
|
||||
if (unread_count > 0) {
|
||||
title.value = `通知的用户列表 - (${unread_count}个用户未读)`;
|
||||
} else {
|
||||
title.value = `通知的用户列表 - (全部已读)`;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Modal :title="title" class="w-[60%]">
|
||||
<List
|
||||
:bordered="true"
|
||||
>
|
||||
<ListItem v-for="item in userList">
|
||||
<ListItemMeta>
|
||||
<template #avatar>
|
||||
<Avatar :src="item.admin?.avatar">
|
||||
{{ item.admin?.nick_name.slice(0, 2) }}
|
||||
</Avatar>
|
||||
</template>
|
||||
<template #title>
|
||||
{{ item.admin?.nick_name }}
|
||||
</template>
|
||||
</ListItemMeta>
|
||||
<Tag v-if="item.status === 0" color="warning">未读</Tag>
|
||||
<Tag v-else-if="item.status === 1" color="success">已读</Tag>
|
||||
</ListItem>
|
||||
</List>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -2,11 +2,9 @@
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { useTabs } from '@vben/hooks';
|
||||
|
||||
import {Button} from 'ant-design-vue'
|
||||
|
||||
import {
|
||||
ArrowLeft,
|
||||
Bell,
|
||||
@@ -15,15 +13,16 @@ import {
|
||||
Megaphone,
|
||||
User,
|
||||
} from 'lucide-vue-next';
|
||||
import { MdPreview } from 'md-editor-v3';
|
||||
|
||||
import { formatTimeToRelative } from '#/util/tool';
|
||||
import { getNoticeDetailApi } from '#/views/notice/api';
|
||||
|
||||
// 新增 Markdown 解析相关依赖
|
||||
import UnreadUserList from './UnreadUserList.vue';
|
||||
|
||||
// eslint-disable-next-line n/no-extraneous-import
|
||||
import { marked } from 'marked';
|
||||
// eslint-disable-next-line n/no-extraneous-import
|
||||
import DOMPurify from 'dompurify';
|
||||
import 'md-editor-v3/lib/style.css';
|
||||
import {Icon} from "#/components/icon";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -99,18 +98,6 @@ const getTypeInfo = (typeId) => {
|
||||
return messageTypes.find((t) => t.id === typeId) || messageTypes[0];
|
||||
};
|
||||
|
||||
// 新增 Markdown 解析方法
|
||||
const parseMarkdown = (content) => {
|
||||
if (!content) return '';
|
||||
// 配置 marked(可选)
|
||||
marked.setOptions({
|
||||
gfm: true, // 启用 GitHub Flavored Markdown
|
||||
breaks: false, // 转换换行符为 <br>
|
||||
});
|
||||
// 安全净化 HTML
|
||||
return DOMPurify.sanitize(marked.parse(content));
|
||||
};
|
||||
|
||||
// 格式化内容,将换行符转换为<br>
|
||||
const formatContent = (content) => {
|
||||
return content ? content.replaceAll('\n', '<br>') : '';
|
||||
@@ -120,13 +107,22 @@ onMounted(() => {
|
||||
getNoticeDetail();
|
||||
});
|
||||
|
||||
const [UnreadUserListModal, UnreadUserListModalApi] = useVbenModal({
|
||||
connectedComponent: UnreadUserList,
|
||||
});
|
||||
|
||||
const showUnreadList = () => {
|
||||
alert('未实现')
|
||||
}
|
||||
UnreadUserListModalApi.setData({
|
||||
values: notice.value.user_list,
|
||||
unread_count: notice.value.unread_count,
|
||||
});
|
||||
UnreadUserListModalApi.open();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<UnreadUserListModal />
|
||||
<template #title>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@@ -208,7 +204,7 @@ const showUnreadList = () => {
|
||||
>
|
||||
<div class="flex items-center gap-1.5">
|
||||
来自:
|
||||
<User class="h-4 w-4" />
|
||||
<Icon icon="svg:logo" />
|
||||
<span>萧康云医</span>
|
||||
</div>
|
||||
|
||||
@@ -238,20 +234,20 @@ const showUnreadList = () => {
|
||||
|
||||
<!-- 内容 -->
|
||||
<div
|
||||
v-if="notice.edit_type === 0"
|
||||
class="rounded-lg bg-gray-50 p-4 transition-colors dark:bg-gray-700"
|
||||
>
|
||||
<div
|
||||
v-if="notice.edit_type === 0"
|
||||
class="prose prose-sm dark:prose-invert max-w-none text-gray-700 transition-colors dark:text-gray-300"
|
||||
v-html="formatContent(notice.content)"
|
||||
></div>
|
||||
<div
|
||||
v-else-if="notice.edit_type === 1"
|
||||
class="markdown-body prose-sm dark:prose-invert max-w-none text-gray-700 transition-colors dark:text-gray-300"
|
||||
v-html="parseMarkdown(notice.content)"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<MdPreview
|
||||
v-else-if="notice.edit_type === 1"
|
||||
v-model="notice.content"
|
||||
style="padding: 10px 20px"
|
||||
theme="dark"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
|
||||
@@ -20,7 +20,7 @@ import { uploadFile } from '#/api/core/upload';
|
||||
import { getUserOptionApi, sendNoticeApi } from '#/views/notice/api';
|
||||
|
||||
// Import Markdown editor (using a popular Vue 3 Markdown editor)
|
||||
import { config, MdEditor } from 'md-editor-v3';
|
||||
import { MdEditor } from 'md-editor-v3';
|
||||
|
||||
import 'md-editor-v3/lib/style.css';
|
||||
|
||||
@@ -427,7 +427,7 @@ const setupQuillPasteHandler = () => {
|
||||
|
||||
/* Markdown编辑器样式 */
|
||||
.md-editor-container {
|
||||
height: 350px;
|
||||
min-height: 400px;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useRouter } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { notification, Tag } from 'ant-design-vue';
|
||||
import { Button, notification, Tag } from 'ant-design-vue';
|
||||
import {
|
||||
Bell,
|
||||
CalendarClock,
|
||||
@@ -140,7 +140,7 @@ const markAsRead = async (event, item) => {
|
||||
message: '标记成功',
|
||||
duration: 2,
|
||||
});
|
||||
getNoticeList();
|
||||
// getNoticeList();
|
||||
} catch (error) {
|
||||
console.error('标记已读失败:', error);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ const markAllAsRead = async () => {
|
||||
message: '标记成功',
|
||||
duration: 2,
|
||||
});
|
||||
getNoticeList();
|
||||
// getNoticeList();
|
||||
} catch (error) {
|
||||
console.error('标记全部已读失败:', error);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ const toggleExpand = (event, id) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="消息中心">
|
||||
<Page title="消息中心" description="关于执行的操作通知、公告等等信息都会在这里">
|
||||
<template #extra>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-500 dark:text-gray-400">共 {{ total }} 条消息</span>
|
||||
@@ -292,6 +292,7 @@ const toggleExpand = (event, id) => {
|
||||
<CheckCircle2 class="h-4 w-4 text-gray-500 dark:text-gray-400" />
|
||||
标记全部已读
|
||||
</button>
|
||||
<Button type="link" @click="getNoticeList">刷新</Button>
|
||||
</div>
|
||||
|
||||
<!-- 消息列表 -->
|
||||
|
||||
Reference in New Issue
Block a user