1.1.6 • Published 4 months ago
customize-components v1.1.6
自定义组件使用文档
安装
进入项目根目录,执行命令
yarn add mahasthama-interpreter @types/react-router-dom react-router-dom antd @ant-design/icons axios react-redux redux redux-logger
注意:以上依赖包含公司内部资源,需要更换yarn镜像地址
yarn config set registry http://dev.ciist.com:8081/repository/npm-public
克隆
复制命令将代码克隆在项目的 src 目录中
注意️:需要保证 src 目录中没有 components 命名的目录,或者更换克隆地址后面的 components 为你想要的目录,以保证能够正常克隆组件源码在项目中。
git clone http://dev.ciist.com:9000/mahasthama-proj/customize-components.git components
组件说明
- 更新注意事项
- Header组件所有属性都变更为不是必传属性。
Footer
底部导航栏(cloud-footer)
属性表
属性名 | 含义 | 类型 | 必填 | 默认 |
---|---|---|---|---|
继承至 HTMLAttribute,与div属性一致 |
示例
class Test extends Component {
constructor(props, context) {
super(props, context);
this.state = {};
}
render() {
const {} = this.state;
return (
<div>
</div>
);
}
}
Header
头部导航栏(cloud-header)
属性表
属性名 | 含义 | 类型 | 必填 | 默认 |
---|---|---|---|---|
boxStyle | Header盒子样式 | CSSProperties | 否 | 空 |
theme | 主题风格 | "white"、"black" | 否 | "black" |
userinfo | 用户信息 | UserInfo | 否 | 空 |
productMenus | 产品菜单列表 | MenuItem[] | 否 | 空 |
messageNumber | 消息条数 | number | 否 | 0 |
phoneNumber | 购买咨询电话号码 | string | 否 | (028)8114-3611 |
productMenuColumnCount | 产品菜单展示列数 | number | 否 | 3 |
renderExtra | 自定义渲染额外内容 | ReactNode | 否 | 空 |
renderDrawerLog | 自定义渲染抽屉日志列表 | ReactNode | 否 | 空 |
renderDrawerMessage | 自定义渲染抽屉消息列表 | ReactNode | 否 | 空 |
onLogoClick | 触发Logo点击事件 | (href:string) => void | 否 | 空 |
onOverviewClick | 触发概览点击事件 | (href:string) => void | 否 | 空 |
onProductMenuItemClick | 触发产品列表项点击事件 | (menuItem?: MenuItem) => void | 否 | 空 |
onAccountInfoClick | 触发账号中心点击事件 | (href:string) => void | 否 | 空 |
onAccountSafeClick | 触发账号安全点击事件 | (href:string) => void | 否 | 空 |
onUnitOrganizationClick | 触发组织管理点击事件 | (href:string) => void | 否 | 空 |
onSwitchIdentifyClick | 触发切换身份点击事件 | (href:string) => void | 否 | 空 |
onAppExitClick | 触发登出点击事件 | (href:string) => void | 否 | 空 |
示例
class Test extends Component {
constructor(props, context) {
super(props, context);
this.state = {
userinfo: {
name: "何旺",
organization: fasle
},
productMenus: [
{
title: "乡村美旅",
icon: "https://main.qcloudimg.com/image/product/500/16_16/gray.svg",
subItem: [
{title: "页面配置", url: "/"},
{title: "信息发布", url: "/"},
{title: "信息主体管理", url: "/"},
{title: "活动管理", url: "/"}
]
},
{
title: "国扶数据分析",
icon: "https://main.qcloudimg.com/image/product/500/16_16/gray.svg",
subItem: [
{title: "贫困户数据导出", url: "/"},
{title: "调度清洗", url: "/"}
]
}
],
phoneNumber: "(028)1611-0258"
};
}
render() {
const {userinfo, productMenus, phoneNumber} = this.state;
return (
<div>
<Header
userinfo={userinfo}
productMenus={productMenus}
phoneNumber={phoneNumber}
/>
</div>
);
}
}
Home
云平台通用主页(cloud-home)
注:️Home组件引用了Header、Footer、Sidebar等相关组件,所以继承有相应的属性
属性表
属性名 | 含义 | 类型 | 必填 | 默认 |
---|---|---|---|---|
showAfterMenu | 渲染菜单数据后显示 | boolean | 否 | true |
pageTitle | 页面标题 | string | 否 | 空 |
pageOpen | 页面参数 | pageOpen | 否 | {type: "page"} |
HeaderProps | ... | ... | ... | ... |
FooterProps | ... | ... | ... | ... |
SidebarProps | ... | ... | ... | ... |
示例
class Test extends Component {
constructor(props, context) {
super(props, context);
//数据例子见相关组件示例
this.state = {
...,
};
}
render() {
const {userinfo, productMenus, sidebarMenus} = this.state;
return (
<div>
<Home
userinfo={userinfo}
productMenus={productMenus}
sidebarMenus={sidebarMenus}
/>
</div>
);
}
}
Sidebar
侧边菜单栏(cloud-sidebar)
注:该组件目前仅支持二级显示,无法显示三级或多级,当数据超过三级以上时,将会引发UI交互错乱。
属性表
属性名 | 含义 | 类型 | 必填 | 默认 |
---|---|---|---|---|
title | 标题 | string | 否 | 空 |
sidebarMenus | 侧边栏菜单列表 | SidebarMenuItem[] | 否 | 空 |
alwaysExpanded | 总是展开 | boolean | 否 | false |
onMenuItemClick | 菜单项触发点击触发事件 | (menuItem: SidebarMenuItem) => void | 否 | 空 |
示例
class Test extends Component {
constructor(props, context) {
super(props, context);
this.state = {
sidebarMenus: [
{
title: "概览",
url: "/overview",
icon: "https://cloudcache.tencent-cloud.com/qcloud/tcloud_dtc/static/console_aside_v4/1ef998a5-9ae2-43af-b175-32d4031a2d75.svg",
selectedIcon: "https://cloudcache.tencent-cloud.com/qcloud/tcloud_dtc/static/console_aside_v4/1ef998a5-9ae2-43af-b175-32d4031a2d75-hover.svg",
open: {
type: "page",
code: "overview"
}
}, {
title: "分类",
label: true
}, {
title: "服务",
url: "/service",
icon: "https://cloudcache.tencent-cloud.com/qcloud/tcloud_dtc/static/console_aside_v4/8a8468a2-0f4a-43ff-a19f-c3493f5c5410.svg",
selectedIcon: "https://cloudcache.tencent-cloud.com/qcloud/tcloud_dtc/static/console_aside_v4/8a8468a2-0f4a-43ff-a19f-c3493f5c5410-hover.svg",
externalLink: true
}, {
title: "工具",
icon: "https://cloudcache.tencent-cloud.com/qcloud/tcloud_dtc/static/console_aside_v4/eb16fe8b-e68f-4cd9-9c29-b6cb44a6b450.svg",
selectedIcon: "https://cloudcache.tencent-cloud.com/qcloud/tcloud_dtc/static/console_aside_v4/eb16fe8b-e68f-4cd9-9c29-b6cb44a6b450-hover.svg",
subItem: [
{
title: "签名工具",
url: "/tool",
open: {
type: "page",
code: "tool"
}
}, {
title: "请求工具",
url: "https://www.baidu.com",
externalLink: true
}
]
}
]
};
}
/**
* 触发侧边栏菜单选项点击
* @param menuItem 被点击的菜单项
*/
onSidebarMenuItemClick(menuItem) {
//输出选中菜单的信息
console.debug("menuItem", menuItem);
}
render() {
const {sidebarMenus} = this.state;
return (
<div>
<Sidebar
sidebarMenus={sidebarMenus}
onMenuItemClick={this.onSidebarMenuItemClick.bind(this)}
/>
</div>
);
}
}
DrawerLayout
抽屉容器组件(cloud-drawer)
属性表
属性名 | 含义 | 类型 | 必填 | 默认 |
---|---|---|---|---|
title | 标题 | string | 否 | 空 |
subTitle | 副标题 | string | 否 | 空 |
extra | 额外描述 | string | 否 | 空 |
onSubTitleClick | 触发副标题点击 | () => void | 否 | 空 |
onExtraClick | 触发额外内容点击 | () => void | 否 | 空 |
示例
<DrawerLayout title="消息中心" extra="更多站内消息">
<List dataSource={dataSource} noSourceTips="暂无消息内容" renderItem={
(item: any, index: number) =>
<ItemMessage
key={index}
content={item.content}
description={item.description}
time={item.time}
//...
/>
}/>
</DrawerLayout>
List
抽屉容器组件(cloud-list)
属性表
属性名 | 含义 | 类型 | 必填 | 默认 |
---|---|---|---|---|
dataSource | 数据源 | any[]/ItemMessageSource[] | 否 | 空 |
noSourceTips | 没有数据时的提示 | string | 否 | 空 |
loading | 是否加载中 | boolean | 否 | false |
renderItem | 自定义渲染列表项 | (item: any, index?: number) => ReactNode | 否 | 空 |
ItemMessage
抽屉容器组件(cloud-list)
属性表
属性名 | 含义 | 类型 | 必填 | 默认 |
---|---|---|---|---|
id | 资源ID | string/number | 否 | 空 |
description | 描述 | string | 否 | 空 |
time | 时间 | string | 否 | 空 |
content | 内容 | string | 否 | 空 |
url | 链接地址 | string | 否 | 空 |
hoverTips | 鼠标移入时显示的提示 | string | 否 | 空 |
extra | 额外内容 | string | 否 | 空 |
onExtraClick | 触发额外内容点击 | (source?: ItemMessageSource) => void | 否 | 空 |
onItemClick | 触发列表项点击 | (url?: string) => void | 否 | 空 |