小程序首页配置
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
import React from 'react';
|
||||
import { Image, Tag, Typography } from 'antd';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings.ts';
|
||||
import type IHomeBanner from '@/domain/iHomeBanner.ts';
|
||||
import { HOME_BANNER_STATUS_MAP } from '@/domain/iHomeBanner.ts';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
/**
|
||||
* 首页轮播图配置(小程序首页)
|
||||
*/
|
||||
const HomeBannerPage: React.FC = () => {
|
||||
const columns: XinTableColumn<IHomeBanner>[] = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
width: 70,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '标题',
|
||||
dataIndex: 'title',
|
||||
valueType: 'text',
|
||||
required: true,
|
||||
rules: [{ required: true, message: '请输入轮播图标题' }],
|
||||
},
|
||||
{
|
||||
title: '轮播图片',
|
||||
dataIndex: 'image_id',
|
||||
valueType: 'image',
|
||||
required: true,
|
||||
rules: [{ required: true, message: '请上传轮播图片' }],
|
||||
fieldProps: {
|
||||
action: '/client/banner/upload',
|
||||
mode: 'single',
|
||||
maxCount: 1,
|
||||
changeType: 'id',
|
||||
},
|
||||
render: (_, record: IHomeBanner) => {
|
||||
const url = record.image_url;
|
||||
if (!url) return '-';
|
||||
return (
|
||||
<Image
|
||||
src={url}
|
||||
width={80}
|
||||
height={40}
|
||||
style={{ objectFit: 'cover', borderRadius: 4 }}
|
||||
/>
|
||||
);
|
||||
},
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '跳转链接',
|
||||
dataIndex: 'link',
|
||||
valueType: 'text',
|
||||
hideInSearch: true,
|
||||
fieldProps: {
|
||||
placeholder: '小程序页面路径,如 /pages/goods/detail?id=1',
|
||||
},
|
||||
render: (_, record) => record.link || '-',
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
valueType: 'digit',
|
||||
hideInSearch: true,
|
||||
initialValue: 0,
|
||||
fieldProps: { min: 0, precision: 0 },
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
initialValue: 1,
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 1, label: '正常' },
|
||||
{ value: 0, label: '停用' },
|
||||
],
|
||||
},
|
||||
render: (_, record) => {
|
||||
const item = HOME_BANNER_STATUS_MAP[record.status ?? 1];
|
||||
return <Tag color={item?.color}>{item?.text}</Tag>;
|
||||
},
|
||||
align: 'center',
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'created_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IHomeBanner> = {
|
||||
api: '/client/banner',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'client.banner',
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
layout: 'vertical',
|
||||
rowProps: { gutter: 24 },
|
||||
},
|
||||
modalProps: { width: 640 },
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>首页轮播图</Title>
|
||||
<Text type="secondary">
|
||||
小程序首页顶部轮播图;停用后不展示,排序越小越靠前;跳转链接为小程序页面路径,留空则点击不跳转。
|
||||
</Text>
|
||||
</div>
|
||||
<XinTable<IHomeBanner> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default HomeBannerPage;
|
||||
@@ -0,0 +1,131 @@
|
||||
import React from 'react';
|
||||
import { Image, Tag, Typography } from 'antd';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings.ts';
|
||||
import type IHomeNav from '@/domain/iHomeNav.ts';
|
||||
import { HOME_NAV_STATUS_MAP } from '@/domain/iHomeNav.ts';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
/**
|
||||
* 宫格导航配置(小程序首页)
|
||||
*/
|
||||
const HomeNavPage: React.FC = () => {
|
||||
const columns: XinTableColumn<IHomeNav>[] = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
width: 70,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '导航名称',
|
||||
dataIndex: 'name',
|
||||
valueType: 'text',
|
||||
required: true,
|
||||
rules: [{ required: true, message: '请输入导航名称' }],
|
||||
},
|
||||
{
|
||||
title: '导航图标',
|
||||
dataIndex: 'image_id',
|
||||
valueType: 'image',
|
||||
required: true,
|
||||
rules: [{ required: true, message: '请上传导航图标' }],
|
||||
fieldProps: {
|
||||
action: '/client/nav/upload',
|
||||
mode: 'single',
|
||||
maxCount: 1,
|
||||
changeType: 'id',
|
||||
},
|
||||
render: (_, record: IHomeNav) => {
|
||||
const url = record.image_url;
|
||||
if (!url) return '-';
|
||||
return (
|
||||
<Image
|
||||
src={url}
|
||||
width={40}
|
||||
height={40}
|
||||
style={{ objectFit: 'cover', borderRadius: 4 }}
|
||||
/>
|
||||
);
|
||||
},
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '跳转链接',
|
||||
dataIndex: 'link',
|
||||
valueType: 'text',
|
||||
hideInSearch: true,
|
||||
fieldProps: {
|
||||
placeholder: '小程序页面路径,如 /pages/category/index',
|
||||
},
|
||||
render: (_, record) => record.link || '-',
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
valueType: 'digit',
|
||||
hideInSearch: true,
|
||||
initialValue: 0,
|
||||
fieldProps: { min: 0, precision: 0 },
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
initialValue: 1,
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 1, label: '正常' },
|
||||
{ value: 0, label: '停用' },
|
||||
],
|
||||
},
|
||||
render: (_, record) => {
|
||||
const item = HOME_NAV_STATUS_MAP[record.status ?? 1];
|
||||
return <Tag color={item?.color}>{item?.text}</Tag>;
|
||||
},
|
||||
align: 'center',
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'created_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IHomeNav> = {
|
||||
api: '/client/nav',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'client.nav',
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
layout: 'vertical',
|
||||
rowProps: { gutter: 24 },
|
||||
},
|
||||
modalProps: { width: 640 },
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>宫格导航</Title>
|
||||
<Text type="secondary">
|
||||
小程序首页宫格入口(如商品分类、促销活动等);停用后不展示,排序越小越靠前。
|
||||
</Text>
|
||||
</div>
|
||||
<XinTable<IHomeNav> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default HomeNavPage;
|
||||
@@ -0,0 +1,138 @@
|
||||
import React from 'react';
|
||||
import { Image, Tag, Typography } from 'antd';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings.ts';
|
||||
import type IHomePromo from '@/domain/iHomePromo.ts';
|
||||
import { HOME_PROMO_STATUS_MAP } from '@/domain/iHomePromo.ts';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
/**
|
||||
* 促销推荐卡片配置(小程序首页)
|
||||
*/
|
||||
const HomePromoPage: React.FC = () => {
|
||||
const columns: XinTableColumn<IHomePromo>[] = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
width: 70,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '卡片标题',
|
||||
dataIndex: 'title',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: '副标题',
|
||||
dataIndex: 'sub_title',
|
||||
valueType: 'text',
|
||||
hideInSearch: true,
|
||||
fieldProps: {
|
||||
placeholder: '促销文案,如「限时特惠 8 折起」',
|
||||
},
|
||||
render: (_, record) => record.sub_title || '-',
|
||||
},
|
||||
{
|
||||
title: '卡片图片',
|
||||
dataIndex: 'image_id',
|
||||
valueType: 'image',
|
||||
required: true,
|
||||
rules: [{ required: true, message: '请上传卡片图片' }],
|
||||
fieldProps: {
|
||||
action: '/client/promo/upload',
|
||||
mode: 'single',
|
||||
maxCount: 1,
|
||||
changeType: 'id',
|
||||
},
|
||||
render: (_, record: IHomePromo) => {
|
||||
const url = record.image_url;
|
||||
if (!url) return '-';
|
||||
return (
|
||||
<Image
|
||||
src={url}
|
||||
width={80}
|
||||
height={40}
|
||||
style={{ objectFit: 'cover', borderRadius: 4 }}
|
||||
/>
|
||||
);
|
||||
},
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '跳转链接',
|
||||
dataIndex: 'link',
|
||||
valueType: 'text',
|
||||
hideInSearch: true,
|
||||
fieldProps: {
|
||||
placeholder: '小程序页面路径,如 /pages/promo/detail?id=1',
|
||||
},
|
||||
render: (_, record) => record.link || '-',
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
valueType: 'digit',
|
||||
hideInSearch: true,
|
||||
initialValue: 0,
|
||||
fieldProps: { min: 0, precision: 0 },
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
initialValue: 1,
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 1, label: '正常' },
|
||||
{ value: 0, label: '停用' },
|
||||
],
|
||||
},
|
||||
render: (_, record) => {
|
||||
const item = HOME_PROMO_STATUS_MAP[record.status ?? 1];
|
||||
return <Tag color={item?.color}>{item?.text}</Tag>;
|
||||
},
|
||||
align: 'center',
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'created_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IHomePromo> = {
|
||||
api: '/client/promo',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'client.promo',
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: { width: 640 },
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>促销推荐卡片</Title>
|
||||
<Text type="secondary">
|
||||
小程序首页促销位卡片;副标题展示促销文案,停用后不展示,排序越小越靠前。
|
||||
</Text>
|
||||
</div>
|
||||
<XinTable<IHomePromo> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default HomePromoPage;
|
||||
Reference in New Issue
Block a user