{ "slug": "mixednavigation", "mode": "scenarios", "examples": [ { "id": "mixednavigation-ex-1", "title": "默认态(选中:全部订单)", "titleSrc": "demo", "desc": "", "html": "
\n \n
", "preview": { "show": [ [ 1 ] ], "hide": [ [ 0 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "", "jsx": "import { useState } from 'react';\nimport { KoleMixedNavigation } from 'kole-ui/react';\n\nconst ITEMS = [\n { key: 'home', label: '工作台', icon: '⊞' },\n { key: 'order', label: '订单', icon: '≡', badge: '3', children: [\n { key: 'order-all', label: '全部订单' },\n { key: 'order-ship', label: '待发货' },\n { key: 'order-refund', label: '退款' }\n ] },\n { key: 'goods', label: '商品', icon: '◇', children: [\n { key: 'goods-list', label: '商品列表' },\n { key: 'goods-cat', label: '分类管理' }\n ] },\n { key: 'data', label: '数据', icon: '▤' },\n { key: 'setting', label: '设置', icon: '⚙', disabled: true }\n];\n\nexport default function OrderNav() {\n const [active, setActive] = useState('order-all');\n return ;\n}", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { useState } from 'react';\nimport { KoleMixedNavigation } from 'kole-ui/react';\n\ninterface NavItem {\n key: string;\n label: string;\n icon?: string;\n badge?: string;\n disabled?: boolean;\n children?: ReadonlyArray;\n}\n\nconst ITEMS: ReadonlyArray = [\n { key: 'home', label: '工作台', icon: '⊞' },\n { key: 'order', label: '订单', icon: '≡', badge: '3', children: [\n { key: 'order-all', label: '全部订单' },\n { key: 'order-ship', label: '待发货' },\n { key: 'order-refund', label: '退款' },\n ] },\n { key: 'goods', label: '商品', icon: '◇', children: [\n { key: 'goods-list', label: '商品列表' },\n { key: 'goods-cat', label: '分类管理' },\n ] },\n { key: 'data', label: '数据', icon: '▤' },\n { key: 'setting', label: '设置', icon: '⚙', disabled: true },\n];\n\nexport default function OrderNav(): JSX.Element {\n const [active, setActive] = useState('order-all');\n return ;\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": "依据 frameworks/MixedNavigation.html L45-58 的 ITEMS 与 L152 首例初值 { active: \"order-all\", open: \"\" }(选中「全部订单」);prop 名取自 MixedNavigation.jsx L14(items/activeKey/onChange)与 MixedNavigation.vue3.vue L59-62。" }, { "id": "mixednavigation-ex-2", "title": "含徽章与禁用项", "titleSrc": "demo", "desc": "", "html": "
\n \n
", "preview": { "show": [ [ 3 ] ], "hide": [ [ 0 ], [ 1 ], [ 2 ], [ 4 ], [ 5 ], [ 6 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "", "jsx": "import { useState } from 'react';\nimport { KoleMixedNavigation } from 'kole-ui/react';\n\nconst ITEMS = [\n { key: 'home', label: '工作台', icon: '⊞' },\n { key: 'order', label: '订单', icon: '≡', badge: '3', children: [\n { key: 'order-all', label: '全部订单' },\n { key: 'order-ship', label: '待发货' },\n { key: 'order-refund', label: '退款' }\n ] },\n { key: 'goods', label: '商品', icon: '◇', children: [\n { key: 'goods-list', label: '商品列表' },\n { key: 'goods-cat', label: '分类管理' }\n ] },\n { key: 'data', label: '数据', icon: '▤' },\n { key: 'setting', label: '设置', icon: '⚙', disabled: true }\n];\n\nexport default function BadgeNav() {\n const [active, setActive] = useState('goods-list');\n return ;\n}", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { useState } from 'react';\nimport { KoleMixedNavigation } from 'kole-ui/react';\n\ninterface NavItem {\n key: string;\n label: string;\n icon?: string;\n badge?: string;\n disabled?: boolean;\n children?: ReadonlyArray;\n}\n\nconst ITEMS: ReadonlyArray = [\n { key: 'home', label: '工作台', icon: '⊞' },\n { key: 'order', label: '订单', icon: '≡', badge: '3', children: [\n { key: 'order-all', label: '全部订单' },\n { key: 'order-ship', label: '待发货' },\n { key: 'order-refund', label: '退款' },\n ] },\n { key: 'goods', label: '商品', icon: '◇', children: [\n { key: 'goods-list', label: '商品列表' },\n { key: 'goods-cat', label: '分类管理' },\n ] },\n { key: 'data', label: '数据', icon: '▤' },\n { key: 'setting', label: '设置', icon: '⚙', disabled: true },\n];\n\nexport default function BadgeNav(): JSX.Element {\n const [active, setActive] = useState('goods-list');\n return ;\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": "依据 frameworks/MixedNavigation.html L153 第二例初值 { active: \"goods-list\", open: \"goods\" };徽章与禁用项来自 L47 badge:\"3\" 与 L57 disabled:true(React 端 L55-56 渲染 kole-menu-badge,L40-43 加 is-disabled)。" }, { "id": "mixednavigation-ex-3", "title": "二级联动(一级切到「商品」)", "titleSrc": "demo", "desc": "", "html": "
\n \n
", "preview": { "show": [ [ 5 ] ], "hide": [ [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 6 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "", "jsx": "import { useState } from 'react';\nimport { KoleMixedNavigation } from 'kole-ui/react';\n\nconst ITEMS = [\n { key: 'home', label: '工作台', icon: '⊞' },\n { key: 'order', label: '订单', icon: '≡', badge: '3', children: [\n { key: 'order-all', label: '全部订单' },\n { key: 'order-ship', label: '待发货' },\n { key: 'order-refund', label: '退款' }\n ] },\n { key: 'goods', label: '商品', icon: '◇', children: [\n { key: 'goods-list', label: '商品列表' },\n { key: 'goods-cat', label: '分类管理' }\n ] },\n { key: 'data', label: '数据', icon: '▤' },\n { key: 'setting', label: '设置', icon: '⚙', disabled: true }\n];\n\nexport default function GoodsSwitchNav() {\n const [active, setActive] = useState('goods');\n const onSwitch = (key) => setActive(key);\n return ;\n}", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { useCallback, useState } from 'react';\nimport { KoleMixedNavigation } from 'kole-ui/react';\n\ninterface NavItem {\n key: string;\n label: string;\n icon?: string;\n badge?: string;\n disabled?: boolean;\n children?: ReadonlyArray;\n}\n\nconst ITEMS: ReadonlyArray = [\n { key: 'home', label: '工作台', icon: '⊞' },\n { key: 'order', label: '订单', icon: '≡', badge: '3', children: [\n { key: 'order-all', label: '全部订单' },\n { key: 'order-ship', label: '待发货' },\n { key: 'order-refund', label: '退款' },\n ] },\n { key: 'goods', label: '商品', icon: '◇', children: [\n { key: 'goods-list', label: '商品列表' },\n { key: 'goods-cat', label: '分类管理' },\n ] },\n { key: 'data', label: '数据', icon: '▤' },\n { key: 'setting', label: '设置', icon: '⚙', disabled: true },\n];\n\nexport default function GoodsSwitchNav(): JSX.Element {\n const [active, setActive] = useState('goods');\n const onSwitch = useCallback((key: string): void => {\n setActive(key);\n }, []);\n return ;\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": "依据 frameworks/MixedNavigation.html L156-157 第三例(altParams + { active: \"goods-list\", open: \"\" },演示一级切到「商品」后侧栏换成其 children);一级 key 判定见 MixedNavigation.jsx L21 isTopActive(it.key === active 或 children 命中),故 activeKey=\"goods\" 即「一级切到商品」。" } ], "curated": true }