feat:【antd】【mp】mp 的代码评审

This commit is contained in:
YunaiV
2025-11-20 18:08:15 +08:00
parent 7f9041da18
commit 5b4d3c9820
4 changed files with 20 additions and 17 deletions

View File

@@ -1,10 +1,11 @@
<script lang="ts" setup>
// TODO @hw这里 Reply 貌似不存在
import type { Reply } from '#/views/mp/components';
import { computed, nextTick, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { AutoReplyMsgType as MsgType, ReplyType } from '@vben/constants';
import { AutoReplyMsgType, ReplyType } from '@vben/constants';
import { message } from 'ant-design-vue';
@@ -18,7 +19,7 @@ const emit = defineEmits(['success']);
const formData = ref<{
accountId?: number;
msgType: MsgType;
msgType: AutoReplyMsgType;
row?: any;
}>();
const getTitle = computed(() => {
@@ -36,7 +37,7 @@ const [Form, formApi] = useVbenForm({
labelWidth: 100,
},
layout: 'horizontal',
schema: useFormSchema(MsgType.Keyword),
schema: useFormSchema(AutoReplyMsgType.Keyword),
showDefaultActions: false,
});
@@ -96,7 +97,7 @@ const [Modal, modalApi] = useVbenModal({
// 加载数据
const data = modalApi.getData<{
accountId?: number;
msgType: MsgType;
msgType: AutoReplyMsgType;
row?: any;
}>();
if (!data) {
@@ -134,7 +135,7 @@ const [Modal, modalApi] = useVbenModal({
accountId: data.accountId || -1,
type: data.msgType,
requestKeyword: undefined,
requestMatch: data.msgType === MsgType.Keyword ? 1 : undefined,
requestMatch: data.msgType === AutoReplyMsgType.Keyword ? 1 : undefined,
requestMessageType: undefined,
reply: {
type: ReplyType.Text,

View File

@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { MpMsgType as MsgType } from '@vben/constants';
import { MpMsgType } from '@vben/constants';
import { IconifyIcon } from '@vben/icons';
import {
@@ -21,28 +21,28 @@ defineProps<{
<template>
<div>
<MsgEvent v-if="item.type === MsgType.Event" :item="item" />
<MsgEvent v-if="item.type === MpMsgType.Event" :item="item" />
<div v-else-if="item.type === MsgType.Text">{{ item.content }}</div>
<div v-else-if="item.type === MpMsgType.Text">{{ item.content }}</div>
<div v-else-if="item.type === MsgType.Voice">
<div v-else-if="item.type === MpMsgType.Voice">
<WxVoicePlayer :url="item.mediaUrl" :content="item.recognition" />
</div>
<div v-else-if="item.type === MsgType.Image">
<div v-else-if="item.type === MpMsgType.Image">
<a :href="item.mediaUrl" target="_blank">
<img :src="item.mediaUrl" class="w-[100px]" alt="图片消息" />
</a>
</div>
<div
v-else-if="item.type === MsgType.Video || item.type === 'shortvideo'"
v-else-if="item.type === MpMsgType.Video || item.type === 'shortvideo'"
class="text-center"
>
<WxVideoPlayer :url="item.mediaUrl" />
</div>
<div v-else-if="item.type === MsgType.Link" class="flex flex-col gap-2">
<div v-else-if="item.type === MpMsgType.Link" class="flex flex-col gap-2">
<a :href="item.url" target="_blank" class="text-success no-underline">
<div class="flex items-center text-sm font-medium text-[#52c41a]">
<IconifyIcon icon="lucide:link" class="mr-1" />
@@ -52,7 +52,7 @@ defineProps<{
<div class="text-xs text-[#666]">{{ item.description }}</div>
</div>
<div v-else-if="item.type === MsgType.Location">
<div v-else-if="item.type === MpMsgType.Location">
<WxLocation
:label="item.label"
:location-y="item.locationY"
@@ -60,11 +60,11 @@ defineProps<{
/>
</div>
<div v-else-if="item.type === MsgType.News" class="w-[300px]">
<div v-else-if="item.type === MpMsgType.News" class="w-[300px]">
<WxNews :articles="item.articles" />
</div>
<div v-else-if="item.type === MsgType.Music">
<div v-else-if="item.type === MpMsgType.Music">
<WxMusic
:title="item.title"
:description="item.description"

View File

@@ -4,7 +4,7 @@ import type { Dayjs } from 'dayjs';
import { reactive, ref } from 'vue';
import { Page } from '@vben/common-ui';
import { DICT_TYPE, MpMsgType as MsgType } from '@vben/constants';
import { DICT_TYPE, MpMsgType } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { IconifyIcon } from '@vben/icons';
@@ -44,7 +44,7 @@ const queryParams = reactive<{
openid: '',
pageNo: 1,
pageSize: 10,
type: MsgType.Text,
type: MpMsgType.Text,
}); // 搜索参数
const queryFormRef = ref(); // 搜索的表单
@@ -189,6 +189,7 @@ function showTotal(total: number) {
:footer="null"
destroy-on-close
>
<!-- TODO @hw@dlayn这里有告警 -->
<WxMsg :user-id="messageBoxUserId" />
</Modal>
</Page>

View File

@@ -30,6 +30,7 @@ export enum MpMsgType {
Location = 'location',
Music = 'music',
News = 'news',
ShortVideo = 'shortvideo',
Text = 'text',
Video = 'video',
Voice = 'voice',