fix: todo修复

This commit is contained in:
hw
2025-11-20 10:34:21 +08:00
237 changed files with 2791 additions and 3444 deletions

View File

@@ -1,21 +1,13 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
import type { MpAccountApi } from '#/api/mp/account';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { DICT_TYPE, AutoReplyMsgType as MsgType } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getSimpleAccountList } from '#/api/mp/account';
import { WxReply } from '#/views/mp/components';
import { MsgType } from './types';
/** 关联数据 */
let accountList: MpAccountApi.AccountSimple[] = [];
getSimpleAccountList().then((data) => (accountList = data));
// TODO @芋艿:要不要使用统一枚举?
const RequestMessageTypes = new Set([
'image',
@@ -155,21 +147,12 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
}
/** 列表的搜索表单 */
// TODO @芋艿:貌似可能微信号拿不到。
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'accountId',
label: '公众号',
component: 'ApiSelect',
componentProps: {
options: accountList.map((item) => ({
label: item.name,
value: item.id,
})),
placeholder: '请选择公众号',
},
defaultValue: accountList[0]?.id,
component: 'Input',
},
];
}

View File

@@ -5,6 +5,7 @@ import type { MpAutoReplyApi } from '#/api/mp/autoReply';
import { computed, nextTick, ref } from 'vue';
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { AutoReplyMsgType as MsgType } from '@vben/constants';
import { IconifyIcon } from '@vben/icons';
import { message, Row, Tabs } from 'ant-design-vue';
@@ -16,11 +17,11 @@ import {
getAutoReplyPage,
} from '#/api/mp/autoReply';
import { $t } from '#/locales';
import { WxAccountSelect } from '#/views/mp/components';
import { useGridColumns, useGridFormSchema } from './data';
import ReplyContentCell from './modules/content.vue';
import Form from './modules/form.vue';
import { MsgType } from './types';
defineOptions({ name: 'MpAutoReply' });
@@ -43,6 +44,12 @@ function handleRefresh() {
gridApi.query();
}
/** 公众号变化时查询数据 */
function handleAccountChange(accountId: number) {
gridApi.formApi.setValues({ accountId });
gridApi.formApi.submitForm();
}
/** 切换回复类型 */
async function onTabChange(tabName: any) {
msgType.value = tabName;
@@ -106,7 +113,6 @@ const [FormModal, formModalApi] = useVbenModal({
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
submitOnChange: true, // 表单值变化时自动提交,这样 accountId 会被正确传递到查询函数
},
gridOptions: {
columns: useGridColumns(Number(msgType.value) as MsgType),
@@ -123,6 +129,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
},
},
autoLoad: false,
},
rowConfig: {
keyField: 'id',
@@ -144,6 +151,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="handleRefresh" />
<Grid>
<template #form-accountId>
<WxAccountSelect @change="handleAccountChange" />
</template>
<template #toolbar-actions>
<Tabs
v-model:active-key="msgType"

View File

@@ -4,16 +4,15 @@ 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 { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { createAutoReply, updateAutoReply } from '#/api/mp/autoReply';
import { $t } from '#/locales';
import { ReplyType } from '#/views/mp/components/constants';
import { useFormSchema } from '../data';
import { MsgType } from '../types';
const emit = defineEmits(['success']);

View File

@@ -1,7 +0,0 @@
// 消息类型Follow: 关注时回复Message: 消息回复Keyword: 关键词回复)
// 作为 tab.nameenum 的数字不能随意修改,与 api 参数相关
export enum MsgType {
Follow = 1,
Keyword = 3,
Message = 2,
}

View File

@@ -1,32 +0,0 @@
export enum ReplyType {
Image = 'image',
Music = 'music',
News = 'news',
Text = 'text',
Video = 'video',
Voice = 'voice',
}
export enum NewsType {
Draft = '2',
Published = '1',
}
export enum MaterialType {
Image = 'image',
News = 'news',
Video = 'video',
Voice = 'voice',
}
export enum MsgType {
Event = 'event',
Image = 'image',
Link = 'link',
Location = 'location',
Music = 'music',
News = 'news',
Text = 'text',
Video = 'video',
Voice = 'voice',
}

View File

@@ -1,11 +1,9 @@
export * from './constants';
export * from './wx-account-select';
export * from './wx-location';
export * from './wx-material-select';
export * from './wx-msg';
export * from './wx-music';
export * from './wx-news';
export * from './wx-reply';
export * from './wx-video-play';
export * from './wx-voice-play';
export { default as WxAccountSelect } from './wx-account-select/account-select.vue';
export { default as WxLocation } from './wx-location/wx-location.vue';
export { default as WxMaterialSelect } from './wx-material-select/wx-material-select.vue';
export { default as WxMsg } from './wx-msg/msg.vue';
export { default as WxMusic } from './wx-music/wx-music.vue';
export { default as WxNews } from './wx-news/wx-news.vue';
export { default as WxReply } from './wx-reply/wx-reply.vue';
export { default as WxVideoPlayer } from './wx-video-play/wx-video-play.vue';
export { default as WxVoicePlayer } from './wx-voice-play/wx-voice-play.vue';

View File

@@ -59,7 +59,7 @@ onMounted(handleQuery);
<Select
v-model:value="account.id"
placeholder="请选择公众号"
class="!w-[240px]"
class="!w-full"
@change="onChanged"
>
<Select.Option v-for="item in accountList" :key="item.id" :value="item.id">

View File

@@ -4,6 +4,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { reactive, ref, watch } from 'vue';
import { Page } from '@vben/common-ui';
import { NewsType } from '@vben/constants';
import { IconifyIcon } from '@vben/icons';
import { Button, Pagination, Row, Spin } from 'ant-design-vue';
@@ -14,8 +15,6 @@ import { getFreePublishPage } from '#/api/mp/freePublish';
import { getMaterialPage } from '#/api/mp/material';
import { WxNews, WxVideoPlayer, WxVoicePlayer } from '#/views/mp/components';
import { NewsType } from '../constants';
defineOptions({ name: 'WxMaterialSelect' });
const props = withDefaults(

View File

@@ -1,4 +1,5 @@
<script lang="ts" setup>
import { MpMsgType as MsgType } from '@vben/constants';
import { IconifyIcon } from '@vben/icons';
import {
@@ -9,7 +10,6 @@ import {
WxVoicePlayer,
} from '#/views/mp/components';
import { MsgType } from '../constants';
import MsgEvent from './msg-event.vue';
defineOptions({ name: 'Msg' });

View File

@@ -3,14 +3,13 @@ import type { Reply } from './types';
import { computed, ref } from 'vue';
import { NewsType } from '@vben/constants';
import { IconifyIcon } from '@vben/icons';
import { Button, Col, Modal, Row } from 'ant-design-vue';
import { WxMaterialSelect, WxNews } from '#/views/mp/components';
import { NewsType } from '../constants';
defineOptions({ name: 'TabNews' });
const props = defineProps<{

View File

@@ -1,6 +1,6 @@
import type { Ref } from 'vue';
import type { ReplyType } from '../constants';
import type { ReplyType } from '@vben/constants';
import { unref } from 'vue';

View File

@@ -12,11 +12,11 @@ import type { Reply } from './types';
import { computed, ref, unref, watch } from 'vue';
import { NewsType, ReplyType } from '@vben/constants';
import { IconifyIcon } from '@vben/icons';
import { Row, Tabs } from 'ant-design-vue';
import { NewsType, ReplyType } from '../constants';
import TabImage from './tab-image.vue';
import TabMusic from './tab-music.vue';
import TabNews from './tab-news.vue';

View File

@@ -1,12 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MpAccountApi } from '#/api/mp/account';
import { getSimpleAccountList } from '#/api/mp/account';
/** 关联数据 */
let accountList: MpAccountApi.AccountSimple[] = [];
getSimpleAccountList().then((data) => (accountList = data));
/** 获取表格列配置 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
@@ -32,15 +25,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
{
fieldName: 'accountId',
label: '公众号',
component: 'ApiSelect',
componentProps: {
options: accountList.map((item) => ({
label: item.name,
value: item.id,
})),
placeholder: '请选择公众号',
},
defaultValue: accountList[0]?.id,
component: 'Input',
},
];
}

View File

@@ -10,6 +10,7 @@ import { message } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { createEmptyNewsItem, deleteDraft, getDraftPage } from '#/api/mp/draft';
import { submitFreePublish } from '#/api/mp/freePublish';
import { WxAccountSelect } from '#/views/mp/components';
import { useGridColumns, useGridFormSchema } from './data';
import DraftTableCell from './modules/draft-table.vue';
@@ -22,6 +23,12 @@ function handleRefresh() {
gridApi.query();
}
/** 公众号变化时查询数据 */
function handleAccountChange(accountId: number) {
gridApi.formApi.setValues({ accountId });
gridApi.formApi.submitForm();
}
/** 新增草稿 */
async function handleCreate() {
const formValues = await gridApi.formApi.getValues();
@@ -113,7 +120,6 @@ const [FormModal, formModalApi] = useVbenModal({
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
submitOnChange: true,
},
gridOptions: {
columns: useGridColumns(),
@@ -142,6 +148,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
};
},
},
autoLoad: false,
},
rowConfig: {
keyField: 'mediaId',
@@ -164,6 +171,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="handleRefresh" />
<Grid table-title="草稿列表">
<template #form-accountId>
<WxAccountSelect @change="handleAccountChange" />
</template>
<template #toolbar-tools>
<TableAction
:actions="[

View File

@@ -34,8 +34,6 @@ const [Modal, modalApi] = useVbenModal({
if (!formData.value) {
return;
}
// DONE @hw是不是 isSubmitting 非必须哈?因为 modal 已经去 lock 啦。
modalApi.lock();
try {
if (formData.value.mediaId) {

View File

@@ -1,4 +1,5 @@
import { message } from 'ant-design-vue';
// TODO @xingyu这种要想办法全局共享起来么
import { $t } from '#/locales';

View File

@@ -3,13 +3,13 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { onMounted, watch } from 'vue';
import { MpMsgType as MsgType } from '@vben/constants';
import { formatDate2 } from '@vben/utils';
import { Button, Image, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
MsgType,
WxLocation,
WxMusic,
WxNews,

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 } from '@vben/constants';
import { DICT_TYPE, MpMsgType as MsgType } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { IconifyIcon } from '@vben/icons';
@@ -20,7 +20,7 @@ import {
} from 'ant-design-vue';
import { getMessagePage } from '#/api/mp/message';
import { MsgType, WxAccountSelect, WxMsg } from '#/views/mp/components';
import { WxAccountSelect, WxMsg } from '#/views/mp/components';
import MessageTable from './MessageTable.vue';

View File

@@ -1,29 +1,14 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { MpAccountApi } from '#/api/mp/account';
import { beginOfDay, endOfDay, formatDateTime } from '@vben/utils';
import { getSimpleAccountList } from '#/api/mp/account';
/** 关联数据 */
let accountList: MpAccountApi.AccountSimple[] = [];
getSimpleAccountList().then((data) => (accountList = data));
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'accountId',
label: '公众号',
component: 'ApiSelect',
componentProps: {
options: accountList.map((item) => ({
label: item.name,
value: item.id,
})),
placeholder: '请选择公众号',
},
defaultValue: accountList[0]?.id,
component: 'Input',
},
{
fieldName: 'dateRange',
@@ -36,7 +21,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
defaultValue: [
formatDateTime(beginOfDay(new Date(Date.now() - 3600 * 1000 * 24 * 7))),
formatDateTime(endOfDay(new Date(Date.now() - 3600 * 1000 * 24))),
] as [Date, Date],
],
},
];
}

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts';
import { onMounted, ref } from 'vue';
import { ref } from 'vue';
import { ContentWrap, Page } from '@vben/common-ui';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
@@ -16,6 +16,7 @@ import {
getUserCumulate,
getUserSummary,
} from '#/api/mp/statistics';
import { WxAccountSelect } from '#/views/mp/components';
import {
interfaceSummaryOption,
@@ -95,6 +96,12 @@ async function getSummary(values: Record<string, any>) {
);
}
/** 公众号变化时查询数据 */
function handleAccountChange(accountId: number) {
queryFormApi.setValues({ accountId });
queryFormApi.submitForm();
}
const [QueryForm, queryFormApi] = useVbenForm({
commonConfig: {
componentProps: {
@@ -106,17 +113,16 @@ const [QueryForm, queryFormApi] = useVbenForm({
wrapperClass: 'grid-cols-1 md:grid-cols-2',
handleSubmit: getSummary,
});
/** 初始化 */
onMounted(() => {
queryFormApi.submitForm();
});
</script>
<template>
<Page auto-content-height>
<ContentWrap class="h-full w-full">
<QueryForm />
<QueryForm>
<template #accountId>
<WxAccountSelect @change="handleAccountChange" />
</template>
</QueryForm>
<div class="flex h-1/3 w-full gap-4">
<Card class="h-full w-1/2" title="用户增减数据">

View File

@@ -1,12 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
import type { MpAccountApi } from '#/api/mp/account';
import { getSimpleAccountList } from '#/api/mp/account';
/** 关联数据 */
let accountList: MpAccountApi.AccountSimple[] = [];
getSimpleAccountList().then((data) => (accountList = data));
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@@ -41,21 +34,12 @@ export function useFormSchema(): VbenFormSchema[] {
}
/** 列表的搜索表单 */
// TODO @YunaiV 这种方式获取刷新浏览器会导致空白
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'accountId',
label: '公众号',
component: 'ApiSelect',
componentProps: {
options: accountList.map((item) => ({
label: item.name,
value: item.id,
})),
placeholder: '请选择公众号',
},
defaultValue: accountList[0]?.id,
component: 'Input',
},
];
}

View File

@@ -9,6 +9,7 @@ import { message } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { deleteTag, getTagPage, syncTag } from '#/api/mp/tag';
import { $t } from '#/locales';
import { WxAccountSelect } from '#/views/mp/components';
import { useGridColumns, useGridFormSchema } from './data';
import Form from './modules/form.vue';
@@ -23,6 +24,12 @@ function handleRefresh() {
gridApi.query();
}
/** 公众号变化时查询数据 */
function handleAccountChange(accountId: number) {
gridApi.formApi.setValues({ accountId });
gridApi.formApi.submitForm();
}
/** 创建标签 */
async function handleCreate() {
const formValues = await gridApi.formApi.getValues();
@@ -101,6 +108,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
},
},
autoLoad: false,
},
rowConfig: {
keyField: 'id',
@@ -118,6 +126,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
<Page auto-content-height>
<FormModal @success="handleRefresh" />
<Grid table-title="公众号标签列表">
<template #form-accountId>
<WxAccountSelect @change="handleAccountChange" />
</template>
<template #toolbar-tools>
<TableAction
:actions="[

View File

@@ -1,11 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MpAccountApi } from '#/api/mp/account';
import { getSimpleAccountList } from '#/api/mp/account';
let accountList: MpAccountApi.AccountSimple[] = [];
getSimpleAccountList().then((data) => (accountList = data));
/** 修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@@ -43,15 +37,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
{
fieldName: 'accountId',
label: '公众号',
component: 'Select',
componentProps: {
options: accountList.map((item) => ({
label: item.name,
value: item.id,
})),
placeholder: '请选择公众号',
},
defaultValue: accountList[0]?.id,
component: 'Input',
},
{
fieldName: 'openid',

View File

@@ -9,6 +9,7 @@ import { message } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getUserPage, syncUser } from '#/api/mp/user';
import { $t } from '#/locales';
import { WxAccountSelect } from '#/views/mp/components';
import { useGridColumns, useGridFormSchema } from './data';
import Form from './modules/form.vue';
@@ -25,6 +26,12 @@ function handleRefresh() {
gridApi.query();
}
/** 公众号变化时查询数据 */
function handleAccountChange(accountId: number) {
gridApi.formApi.setValues({ accountId });
gridApi.formApi.submitForm();
}
/** 编辑用户 */
function handleEdit(row: MpUserApi.User) {
formModalApi.setData({ id: row.id }).open();
@@ -73,6 +80,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
},
},
autoLoad: false,
},
rowConfig: {
keyField: 'id',
@@ -95,6 +103,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="handleRefresh" />
<Grid table-title="粉丝列表">
<template #form-accountId>
<WxAccountSelect @change="handleAccountChange" />
</template>
<template #toolbar-tools>
<TableAction
:actions="[