diff --git a/package.json b/package.json
index fdab83f..a71b68d 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"@ant-design/pro-components": "^2.7.15",
"@ant-design/pro-layout": "^7.19.12",
"@ant-design/pro-provider": "^2.14.9",
+ "@ant-design/pro-utils": "^2.15.17",
"@formily/antd-v5": "^1.2.3",
"@formily/core": "^2.3.2",
"@formily/react": "^2.3.2",
diff --git a/src/pages/message/my/index.tsx b/src/pages/message/my/index.tsx
index 3915f36..f01aa55 100644
--- a/src/pages/message/my/index.tsx
+++ b/src/pages/message/my/index.tsx
@@ -1,5 +1,5 @@
import {useTranslation} from '@/i18n.ts'
-import {Badge, Button, Divider, Form, Input, Select, Space, Tooltip} from 'antd'
+import {Badge, Button, Divider, Form, Input, Select, Space, Table, TableColumnsType, Tooltip} from 'antd'
import {useAtom, useAtomValue} from 'jotai'
import React, {useEffect, useMemo, useState} from 'react'
import {BetaSchemaForm, ProColumns, ProFormColumnsType,} from '@ant-design/pro-components'
@@ -11,6 +11,7 @@ import {Table as ProTable} from '@/components/table'
import {msgListAtom, msgSearchAtom, saveMsgAtom} from "@/store/message/my.ts";
import {templateAllListAtom} from "@/store/message/template.ts";
import {coverType, IMsgTemplate} from "@/types/message/template.ts";
+import dayjs from "dayjs";
const i18nPrefix = 'msgMy.list'
@@ -83,7 +84,7 @@ const MdwMessage = () => {
}
},
{
- title: t(`${i18nPrefix}.columns.type`, '消息类型'),
+ title: t(`${i18nPrefix}.columns.type`, '通道类型'),
dataIndex: 'type',
valueType: 'select',
fieldProps: {
@@ -104,9 +105,12 @@ const MdwMessage = () => {
}
},
{
- title: t(`${i18nPrefix}.columns.token`, 'Telegram Token'),
+ title: t(`${i18nPrefix}.columns.token`, 'Telegram BOT API Token'),
dataIndex: 'token',
valueType: 'text',
+ fieldProps: {
+ placeholder: "请输入 @BotFather 获取到的BOT的API Token"
+ },
formItemProps: {
hidden: templateType != 'TG',
rules: [
@@ -179,14 +183,14 @@ const MdwMessage = () => {
},
},
{
- title: t(`${i18nPrefix}.columns.dest`, '收件人(多个收件人用英文逗号隔开,如果类型是TG,则填token)'),
+ title: t(`${i18nPrefix}.columns.dest`, '收件人(多个收件人用英文逗号隔开;如果类型是Telegram,请填写User ID或Chat ID)'),
dataIndex: 'dest',
valueType: 'textarea',
fieldProps: {
maxLength: 1000,
showCount: true,
rows: 5,
- placeholder: 'aaa@qq.com,bbb@gmail.com',
+ placeholder: 'aaa@qq.com,bbb@gmail.com,-1001953214222,-1001953214333',
},
formItemProps: {
rules: [
@@ -225,7 +229,19 @@ const MdwMessage = () => {
dataIndex: 'content',
},
{
- title: t(`${i18nPrefix}.columns.dest`, '收件人'),
+ title: t(`${i18nPrefix}.columns.send_at`, '预计发送时间'),
+ dataIndex: 'send_at',
+ render: (_, record) => {
+ return
{record.send_at == 0 ? "立即" : dayjs(record.send_at).format('YYYY-MM-DD HH:mm:ss')}
+ }
+ },
+ ] as ProColumns[]
+ }, [search, currentTemplate])
+
+ const expandedRowRender = (record) => {
+ const expandedColumns: TableColumnsType = [
+ {
+ title: "收件人",
dataIndex: 'dest',
},
{
@@ -240,28 +256,13 @@ const MdwMessage = () => {
{
title: t(`${i18nPrefix}.columns.send_at`, '发送时间'),
dataIndex: 'send_at',
+ render: (_, record) => {
+ return {record.send_at == 0 ? 0 : dayjs(record.send_at*1000).format('YYYY-MM-DD HH:mm:ss')}
+ }
},
- // {
- // title: t(`${i18nPrefix}.columns.option`, '操作'),
- // key: 'option',
- // valueType: 'option',
- // fixed: 'right',
- // render: (_, record) => [
- // {
- // deleteAppPackage(record.id)
- // }}
- // title={t('message.deleteConfirm')}>
- //
- // {t('actions.delete', '删除')}
- //
- // ,
- // ]
- // }
- ] as ProColumns[]
- }, [search, currentTemplate])
+ ];
+ return ;
+ }
useEffect(() => {
@@ -354,6 +355,9 @@ const MdwMessage = () => {
})
},
}}
+ expandable={{
+ expandedRowRender,
+ }}
/>
{
}}
onFinish={async (values) => {
- saveOrUpdate({...values, "template_id": currentTemplate?.id})
+ saveOrUpdate({...values, "alias": currentTemplate?.alias})
}}
columns={drawerColumns as ProFormColumnsType[]}/>
{
const [openFilter, setFilterOpen] = useState(false)
const [searchKey, setSearchKey] = useState(search?.title)
+ // 变量
const [templateField, setTemplateField] = useState([]);
const [templateTitle, setTemplateTitle] = useState('');
const [templateContent, setTemplateContent] = useState('');
const [templateType, setTemplateType] = useState('')
+
+ const preContent = "你好,我叫${.name}"
+
useEffect(() => {
setTemplateType(currentTemplate?.type)
+ // 初始化title和content,如果是创建,加载个默认值
if (form.getFieldValue('id') === 0) {
- setTemplateField(['name']);
+ form.setFieldValue('content', preContent)
+ setTemplateContent(preContent)
} else {
- setTemplateField(currentTemplate?.fields.split(","));
+ if (currentTemplate?.content) {
+ setTemplateContent(currentTemplate?.content)
+ }
+ }
+ if (currentTemplate) {
+ setTemplateTitle(currentTemplate.title)
}
}, [open]);
const handleChange = () => {
+ console.log(templateTitle, templateContent)
// 使用正则表达式匹配 ${var} 格式的变量
const regex = /\${\.([a-zA-Z0-9_]+)}/g;
const matches = [...(templateTitle + templateContent).matchAll(regex)];
@@ -111,7 +123,24 @@ const MdwMessage = () => {
}
},
{
- title: t(`${i18nPrefix}.columns.type`, '模板类型'),
+ title: t(`${i18nPrefix}.columns.alias`, '模板别名'),
+ dataIndex: 'alias',
+ valueType: 'text',
+ fieldProps: {
+ maxLength: 50,
+ showCount: true,
+ },
+ formItemProps: {
+ rules: [
+ {
+ required: true,
+ message: t('message.required', '模板名称必填')
+ }
+ ]
+ }
+ },
+ {
+ title: t(`${i18nPrefix}.columns.type`, '通道类型'),
dataIndex: 'type',
valueType: 'select',
fieldProps: {
@@ -188,6 +217,15 @@ const MdwMessage = () => {
);
}
},
+ {
+ title: t(`${i18nPrefix}.columns.tag`, '标签'),
+ dataIndex: 'tag',
+ valueType: 'text',
+ fieldProps: {
+ maxLength: 50,
+ showCount: true,
+ },
+ },
] as ProColumns[]
}, [isDeleting, currentTemplate, search, templateField, templateType])
@@ -196,15 +234,16 @@ const MdwMessage = () => {
{
title: 'ID',
dataIndex: 'id',
- hideInTable: true,
- hideInSearch: true,
- formItemProps: {hidden: true}
},
{
title: t(`${i18nPrefix}.columns.name`, '模板名称'),
dataIndex: 'name',
},
{
+ title: t(`${i18nPrefix}.columns.alias`, '别名'),
+ dataIndex: 'alias',
+ },
+ {
title: t(`${i18nPrefix}.columns.type`, '模板类型'),
dataIndex: 'type',
render: (_, record) => {
@@ -220,6 +259,10 @@ const MdwMessage = () => {
dataIndex: 'content',
},
{
+ title: t(`${i18nPrefix}.columns.tag`, '标签'),
+ dataIndex: 'tag',
+ },
+ {
title: t(`${i18nPrefix}.columns.option`, '操作'),
key: 'option',
valueType: 'option',
diff --git a/src/store/message/my.ts b/src/store/message/my.ts
index 4a62ded..c8b8b18 100644
--- a/src/store/message/my.ts
+++ b/src/store/message/my.ts
@@ -14,6 +14,8 @@ type SearchParams = IPage & {
export const msgIdsAtom = atom(0)
+export const currentRow = atom()
+
export const msgSearchAtom = atom({
key: '',
pageSize: 10,
diff --git a/src/types/message/my.ts b/src/types/message/my.ts
index 7e4c193..69c11f7 100644
--- a/src/types/message/my.ts
+++ b/src/types/message/my.ts
@@ -3,8 +3,14 @@ export interface IMsgMy {
template_id: number
title: string
send_content: string
- dest: string
type: string
+ send_at: number
+ dest: IMsgDest[]
+}
+
+export interface IMsgDest {
+ id: number
+ dest: string
status: number
error_message: string
send_at: number
diff --git a/src/types/message/template.ts b/src/types/message/template.ts
index 7ff2eec..13831de 100644
--- a/src/types/message/template.ts
+++ b/src/types/message/template.ts
@@ -6,6 +6,7 @@ export interface IMsgTemplate {
dest: string
type: string
fields: string
+ alias: string
}
export const coverType = (type: string) => {