@hzab/sider
v1.0.5
Published
侧边栏
Readme
@hzab/sider
侧边栏组件
- Node.js ≥ 24
安装
pnpm add @hzab/sider本包同时发布到公共 npm(registry.npmjs.org,public access)与企业私有源(ld / old)。
默认源可直接安装,无需额外配置;若团队要求走内网源,见消费方接入指南。
消费方需自备 peerDependencies:@ant-design/icons、antd、lodash、react、react-dom、react-router-dom(本包不会随包安装)。
引入方式见下方「组件」章节。
发布形态:本包在本仓以源码直出方式发布——
main指向src,由消费方打包器编译 TypeScript 与.less样式;@hzab/sider/src/*深路径同样可直接引用。随包发布的dist/仅用于 类型解析(types→dist/index.d.ts),不是运行时入口。
组件
示例
import Demo from "@hzab/sider";
<Demo
menus={[
{ key: "/", label: "首页", title: "首页" },
{
key: "/user-server",
label: "用户服务",
icon: "UserOutlined",
children: [
{
key: "/user-server/user-list",
label: "用户管理",
},
{
key: "/user-server/role-list",
label: "角色管理",
},
{
key: "/user-server/org-list",
label: "组织管理",
},
],
},
{
key: "/sys-server",
label: "系统服务",
icon: "UserOutlined",
children: [
{
key: "/sys-server/config-list",
label: "配置管理",
},
{
key: "/sys-server/color-list",
label: "颜色管理",
},
{
key: "/sys-server/size-list",
label: "尺寸管理",
},
],
},
]}
/>;API
InfoPanel Attributes
| 参数 | 类型 | 必填 | 默认值 | 说明 | | -------------- | ------- | ---- | ------ | ----------------------------------------------- | --- | | menus | Array | 是 | - | 侧边栏数据 | | | collapsible | boolean | 否 | - | 是否可以收起 | | | collapsedWidth | number | 否 | - | 收缩宽度,设置为 0 会出现特殊 trigger(定位块) | |
MenuItem
| 参数 | 类型 | 必填 | 默认值 | 说明 | | -------- | ------ | ---- | ------ | ----------------------------- | --- | | key | string | 是 | - | 跳转地址 | | | label | string | 是 | - | 文案 | | | icon | string | 是 | - | icon,可以是 antd icon 字符串 | | | children | Array | 是 | - | 子集 | |
