reactor:【system 系统管理】notifymessage、operatelog、socialuser
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h } from 'vue';
|
||||
@@ -165,7 +166,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'userType',
|
||||
label: '用户类型',
|
||||
content: (data) => {
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.USER_TYPE,
|
||||
value: data?.userType,
|
||||
@@ -195,7 +196,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'templateParams',
|
||||
label: '模版参数',
|
||||
content: (data) => {
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
try {
|
||||
return JSON.stringify(data?.templateParams);
|
||||
} catch {
|
||||
@@ -206,7 +207,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'templateType',
|
||||
label: '模版类型',
|
||||
content: (data) => {
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
|
||||
value: data?.templateType,
|
||||
@@ -216,7 +217,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'readStatus',
|
||||
label: '是否已读',
|
||||
content: (data) => {
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.INFRA_BOOLEAN_STRING,
|
||||
value: data?.readStatus,
|
||||
@@ -226,12 +227,16 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'readTime',
|
||||
label: '阅读时间',
|
||||
content: (data) => formatDateTime(data?.readTime || '') as string,
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return formatDateTime(data?.readTime || '') as string;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '创建时间',
|
||||
content: (data) => formatDateTime(data?.createTime || '') as string,
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return formatDateTime(data?.createTime || '') as string;
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h } from 'vue';
|
||||
@@ -102,30 +103,36 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '发送时间',
|
||||
content: (data) => formatDateTime(data?.createTime) as string,
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return formatDateTime(data?.createTime || '') as string;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'templateType',
|
||||
label: '消息类型',
|
||||
content: (data) =>
|
||||
h(DictTag, {
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
|
||||
value: data?.templateType,
|
||||
}),
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'readStatus',
|
||||
label: '是否已读',
|
||||
content: (data) =>
|
||||
h(DictTag, {
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.INFRA_BOOLEAN_STRING,
|
||||
value: data?.readStatus,
|
||||
}),
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'readTime',
|
||||
label: '阅读时间',
|
||||
content: (data) => formatDateTime(data?.readTime) as string,
|
||||
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
|
||||
return formatDateTime(data?.readTime || '') as string;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'templateContent',
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { useDescription } from '#/components/description';
|
||||
|
||||
import { useDetailSchema } from '../data';
|
||||
|
||||
const [Description, descApi] = useDescription({
|
||||
const formData = ref<SystemNotifyMessageApi.NotifyMessage>();
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
componentProps: {
|
||||
bordered: true,
|
||||
column: 1,
|
||||
@@ -19,6 +23,7 @@ const [Description, descApi] = useDescription({
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
@@ -28,7 +33,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
descApi.setState({ data });
|
||||
formData.value = data;
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
@@ -38,11 +43,11 @@ const [Modal, modalApi] = useVbenModal({
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
title="消息详情"
|
||||
title="站内信详情"
|
||||
class="w-1/3"
|
||||
:show-cancel-button="false"
|
||||
:show-confirm-button="false"
|
||||
>
|
||||
<Description />
|
||||
<Descriptions :data="formData" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemOperateLogApi } from '#/api/system/operate-log';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
@@ -135,7 +136,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'traceId',
|
||||
label: '链路追踪',
|
||||
content: (data) => data?.traceId || '',
|
||||
hidden: (data: SystemOperateLogApi.OperateLog) => !data?.traceId,
|
||||
},
|
||||
{
|
||||
field: 'userId',
|
||||
@@ -168,20 +169,23 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'extra',
|
||||
label: '操作拓展参数',
|
||||
hidden: (data: SystemOperateLogApi.OperateLog) => !data?.extra,
|
||||
},
|
||||
{
|
||||
field: 'requestUrl',
|
||||
label: '请求 URL',
|
||||
content: (data) => {
|
||||
const method = data?.requestMethod || '';
|
||||
const url = data?.requestUrl || '';
|
||||
return `${method} ${url}`.trim();
|
||||
content: (data: SystemOperateLogApi.OperateLog) => {
|
||||
if (data?.requestMethod && data?.requestUrl) {
|
||||
return `${data.requestMethod} ${data.requestUrl}`;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '操作时间',
|
||||
content: (data) => formatDateTime(data?.createTime || '') as string,
|
||||
content: (data: SystemOperateLogApi.OperateLog) => {
|
||||
return formatDateTime(data?.createTime || '') as string;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'bizId',
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemSocialUserApi } from '#/api/system/social/user';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
@@ -99,3 +105,61 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 详情页的字段 */
|
||||
export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
return [
|
||||
{
|
||||
field: 'type',
|
||||
label: '社交平台',
|
||||
content: (data: SystemSocialUserApi.SocialUser) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.SYSTEM_SOCIAL_TYPE,
|
||||
value: data?.type,
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'nickname',
|
||||
label: '用户昵称',
|
||||
},
|
||||
{
|
||||
field: 'avatar',
|
||||
label: '用户头像',
|
||||
content: (data: SystemSocialUserApi.SocialUser) => {
|
||||
if (data?.avatar) {
|
||||
// TODO @芋艿:使用 antd 的 Image 组件
|
||||
return h('img', {
|
||||
src: data.avatar,
|
||||
style: 'width: 30px; height: 30px; cursor: pointer;',
|
||||
onClick: () => {
|
||||
// 可以添加图片预览功能
|
||||
window.open(data.avatar, '_blank');
|
||||
},
|
||||
});
|
||||
}
|
||||
return '无';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'token',
|
||||
label: '社交 token',
|
||||
},
|
||||
{
|
||||
field: 'rawTokenInfo',
|
||||
label: '原始 Token 数据',
|
||||
},
|
||||
{
|
||||
field: 'rawUserInfo',
|
||||
label: '原始 User 数据',
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
label: '最后一次的认证 code',
|
||||
},
|
||||
{
|
||||
field: 'state',
|
||||
label: '最后一次的认证 state',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
<script lang="ts" setup>
|
||||
<script setup lang="ts">
|
||||
import type { SystemSocialUserApi } from '#/api/system/social/user';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
|
||||
import { Descriptions, DescriptionsItem, Image } from 'ant-design-vue';
|
||||
|
||||
import { getSocialUser } from '#/api/system/social/user';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { useDescription } from '#/components/description';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailSchema } from '../data';
|
||||
|
||||
const formData = ref<SystemSocialUserApi.SocialUser>();
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
componentProps: {
|
||||
bordered: true,
|
||||
column: 1,
|
||||
size: 'middle',
|
||||
class: 'mx-4',
|
||||
labelStyle: { width: '185px' },
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
title: $t('ui.actionTitle.detail'),
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
@@ -43,37 +53,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
:show-cancel-button="false"
|
||||
:show-confirm-button="false"
|
||||
>
|
||||
<Descriptions
|
||||
bordered
|
||||
:column="1"
|
||||
size="middle"
|
||||
class="mx-4"
|
||||
:label-style="{ width: '185px' }"
|
||||
>
|
||||
<DescriptionsItem label="社交平台">
|
||||
<DictTag :type="DICT_TYPE.SYSTEM_SOCIAL_TYPE" :value="formData?.type" />
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="用户昵称">
|
||||
{{ formData?.nickname }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="用户头像">
|
||||
<Image :src="formData?.avatar" :width="30" :height="30" />
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="社交 token">
|
||||
{{ formData?.token }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="原始 Token 数据">
|
||||
{{ formData?.rawTokenInfo }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="原始 User 数据">
|
||||
{{ formData?.rawUserInfo }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="最后一次的认证 code">
|
||||
{{ formData?.code }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="最后一次的认证 state">
|
||||
{{ formData?.state }}
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
<Descriptions :data="formData" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user