naive-ui/demo/store/menu-options.js

748 lines
16 KiB
JavaScript
Raw Normal View History

2020-11-13 18:57:28 +08:00
// rubbish code here
2020-10-07 21:03:23 +08:00
import { h } from 'vue'
import { RouterLink } from 'vue-router'
export const renderMenuLabel = (option) => {
if (!('path' in option) || option.label === '--Debug') {
return option.label
}
return h(
RouterLink,
{
to: option.path
},
{ default: () => option.label }
)
}
2020-12-12 13:51:22 +08:00
const appendCounts = (item) => {
2021-02-14 14:52:14 +08:00
if (!item.children) {
2020-02-04 23:13:53 +08:00
item.count = 1
return item
}
2021-02-14 14:52:14 +08:00
if (item.children) {
item.children.forEach(appendCounts)
item.count = item.children.reduce((sum, item) => sum + item.count, 0)
2021-02-14 15:19:32 +08:00
if (item.type === 'group') {
item.en += ` (${item.count})`
item.zh += ` (${item.count})`
}
2020-02-04 23:13:53 +08:00
return item
}
}
2020-11-14 20:38:30 +08:00
const createDebugDemos = (item, mode) => {
2020-10-30 17:42:34 +08:00
if (__DEV__ && mode === 'debug') {
2020-02-26 12:41:50 +08:00
return [item]
} else return []
}
2021-02-14 14:52:14 +08:00
function createItems (lang, theme, prefix, items) {
const isZh = lang === 'zh-CN'
const langKey = isZh ? 'zh' : 'en'
return items.map((rawItem) => {
const item = {
...rawItem,
key: rawItem.en,
label: rawItem[langKey] || rawItem.en,
2021-02-14 15:19:32 +08:00
extra: rawItem.enSuffix && isZh ? rawItem.en : undefined,
2021-02-14 14:52:14 +08:00
path: rawItem.path
? `/${lang}/${theme}` + prefix + rawItem.path
: undefined
}
if (rawItem.children) {
item.children = createItems(lang, theme, prefix, rawItem.children)
}
return item
})
2020-11-13 18:57:28 +08:00
}
2021-02-14 14:52:14 +08:00
export function createDocumentationMenuOptions ({ lang, theme, mode }) {
return createItems(lang, theme, '/docs', [
2021-04-19 21:47:29 +08:00
{
en: 'Introduction',
zh: '介绍',
type: 'group',
children: [
{
en: 'Naive UI',
zh: 'Naive UI',
path: '/introduction'
}
]
},
2020-11-13 18:57:28 +08:00
{
en: 'Getting Started',
zh: '快速上手',
2020-11-13 18:57:28 +08:00
type: 'group',
2021-02-14 14:52:14 +08:00
children: [
2020-11-13 18:57:28 +08:00
{
en: 'Installation',
zh: '安装',
path: '/installation'
2020-11-13 18:57:28 +08:00
},
{
en: 'Usage in SFC',
zh: '在 SFC 中使用',
path: '/usage-sfc'
},
2021-06-06 18:34:02 +08:00
{
en: 'Configuring Fonts',
zh: '配置字体',
path: '/fonts'
},
{
en: 'Import on Demand',
zh: '按需引入',
path: '/import-on-demand'
},
{
en: 'Supported Platforms',
zh: '支持的平台',
path: '/supported-platforms'
2021-06-03 01:15:27 +08:00
},
{
en: 'Common Issues',
zh: '常见问题',
path: '/common-issues'
2020-11-13 18:57:28 +08:00
}
]
},
{
en: 'Guides',
zh: '指南',
2020-11-13 18:57:28 +08:00
type: 'group',
2021-02-14 14:52:14 +08:00
children: [
2021-03-18 15:51:25 +08:00
{
en: 'JSX & TSX',
zh: 'JSX & TSX',
path: '/jsx'
},
2021-06-02 16:17:13 +08:00
{
en: 'Server-Sider Rendering',
zh: '服务端渲染 SSR',
path: '/ssr'
},
2021-04-07 01:44:02 +08:00
{
en: 'Customizing Theme',
2021-04-07 01:44:02 +08:00
zh: '调整主题',
path: '/customize-theme'
},
2020-11-13 18:57:28 +08:00
{
en: 'Create Themed Component',
zh: '创建适配主题的组件',
path: '/theme'
}
2021-06-05 23:24:07 +08:00
// {
// en: 'Experimental Features',
// zh: '试验性特性',
// path: '/experimental-features'
// }
]
},
{
en: 'Version',
zh: '版本',
type: 'group',
children: [
{
en: 'Change Log',
zh: '变更日志',
path: '/changelog'
2020-11-13 18:57:28 +08:00
}
2021-06-06 18:34:02 +08:00
// {
// en: 'Migrate From V1',
// zh: '从 V1 升级',
// path: '/from-v1'
// }
2020-11-13 18:57:28 +08:00
]
}
])
}
export function createComponentMenuOptions ({ lang, theme, mode }) {
return createItems(lang, theme, '/components', [
2020-11-13 18:57:28 +08:00
appendCounts({
2021-02-14 14:52:14 +08:00
zh: '通用组件',
en: 'Common Components',
2020-11-13 18:57:28 +08:00
type: 'group',
2021-02-14 14:52:14 +08:00
children: [
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Avatar',
zh: '头像',
enSuffix: true,
path: '/avatar'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Button',
zh: '按钮',
enSuffix: true,
path: '/button'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Card',
zh: '卡片',
enSuffix: true,
path: '/card'
2020-11-13 18:57:28 +08:00
},
{
en: 'Carousel',
zh: '轮播图',
enSuffix: true,
path: '/carousel'
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Collapse',
zh: '折叠面板',
enSuffix: true,
path: '/collapse'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Divider',
zh: '分割线',
enSuffix: true,
path: '/divider'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Dropdown',
zh: '下拉菜单',
enSuffix: true,
path: '/dropdown'
2020-11-13 18:57:28 +08:00
},
2021-03-21 01:02:13 +08:00
{
en: 'Ellipsis',
zh: '文本省略',
enSuffix: true,
path: '/ellipsis'
2021-03-21 01:02:13 +08:00
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Gradient Text',
zh: '渐变文字',
enSuffix: true,
path: '/gradient-text'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Icon',
zh: '图标',
enSuffix: true,
path: '/icon'
2020-11-13 18:57:28 +08:00
},
2021-04-03 11:29:37 +08:00
{
en: 'PageHeader',
zh: '页头',
enSuffix: true,
path: '/page-header'
2021-04-03 11:29:37 +08:00
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Tag',
zh: '标签',
enSuffix: true,
path: '/tag'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Typography',
zh: '排印',
enSuffix: true,
path: '/typography'
2020-11-13 18:57:28 +08:00
}
]
}),
appendCounts({
2021-02-14 14:52:14 +08:00
zh: '数据录入组件',
en: 'Data Input Components',
2020-11-13 18:57:28 +08:00
type: 'group',
2021-02-14 14:52:14 +08:00
children: [
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Auto Complete',
zh: '自动填充',
enSuffix: true,
path: '/auto-complete'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Cascader',
zh: '级联选择',
enSuffix: true,
path: '/cascader'
2020-11-13 18:57:28 +08:00
},
2021-04-10 10:30:04 +08:00
{
en: 'Color Picker',
2021-04-13 19:50:31 +08:00
zh: '颜色选择器',
2021-04-10 10:30:04 +08:00
enSuffix: true,
path: '/color-picker'
2021-04-10 10:30:04 +08:00
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Checkbox',
zh: '复选框',
enSuffix: true,
path: '/checkbox'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Date Picker',
zh: '日期选择器',
enSuffix: true,
path: '/date-picker'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Dynamic Input',
zh: '动态录入',
enSuffix: true,
path: '/dynamic-input'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Dynamic Tags',
zh: '动态标签',
enSuffix: true,
path: '/dynamic-tags'
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Form',
zh: '表单',
enSuffix: true,
path: '/form'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Input',
zh: '文本输入',
enSuffix: true,
path: '/input'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Input Number',
zh: '数字输入',
enSuffix: true,
path: '/input-number'
2020-11-13 18:57:28 +08:00
},
2021-03-27 12:06:08 +08:00
{
en: 'Mention',
zh: '提及',
enSuffix: true,
path: '/mention'
2021-03-27 12:06:08 +08:00
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Radio',
zh: '单选',
enSuffix: true,
path: '/radio'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Rate',
zh: '评分',
enSuffix: true,
path: '/rate'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Select',
zh: '选择器',
enSuffix: true,
path: '/select'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Slider',
zh: '滑动选择',
enSuffix: true,
path: '/slider'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Switch',
zh: '开关',
enSuffix: true,
path: '/switch'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Time Picker',
zh: '时间选择器',
enSuffix: true,
path: '/time-picker'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Transfer',
zh: '穿梭框',
enSuffix: true,
path: '/transfer'
2020-11-13 18:57:28 +08:00
},
{
en: 'Tree Select',
zh: '树型选择',
enSuffix: true,
path: '/tree-select'
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Upload',
zh: '上传',
enSuffix: true,
path: '/upload'
2020-11-13 18:57:28 +08:00
}
]
}),
appendCounts({
2021-02-14 14:52:14 +08:00
zh: '数据展示组件',
en: 'Data Display Components',
2020-11-13 18:57:28 +08:00
type: 'group',
2021-02-14 14:52:14 +08:00
children: [
2021-04-09 12:43:05 +08:00
{
en: 'Calendar',
zh: '日历',
enSuffix: true,
path: '/calendar'
2021-04-09 12:43:05 +08:00
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Code',
zh: '代码',
enSuffix: true,
path: '/code'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Data Table',
zh: '数据表格',
enSuffix: true,
path: '/data-table'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Descriptions',
zh: '描述',
enSuffix: true,
path: '/descriptions'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Empty',
zh: '无内容',
enSuffix: true,
path: '/empty'
2020-11-13 18:57:28 +08:00
},
2021-04-07 13:10:45 +08:00
{
en: 'Image',
zh: '图像',
enSuffix: true,
path: '/image'
2021-04-07 13:10:45 +08:00
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'List',
zh: '列表',
enSuffix: true,
path: '/list'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Log',
zh: '日志',
enSuffix: true,
path: '/log'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Statistic',
zh: '统计数据',
enSuffix: true,
path: '/statistic'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Table',
zh: '表格',
enSuffix: true,
path: '/table'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Thing',
zh: '东西',
enSuffix: true,
path: '/thing'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Time',
zh: '时间',
enSuffix: true,
path: '/time'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Timeline',
zh: '时间线',
enSuffix: true,
path: '/timeline'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Tree',
zh: '树',
enSuffix: true,
path: '/tree'
2020-11-13 18:57:28 +08:00
}
]
}),
appendCounts({
2021-02-14 14:52:14 +08:00
zh: '导航组件',
en: 'Navigation Components',
2020-11-13 18:57:28 +08:00
type: 'group',
2021-02-14 14:52:14 +08:00
children: [
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Affix',
zh: '固钉',
enSuffix: true,
path: '/affix'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Anchor',
zh: '侧边导航',
enSuffix: true,
path: '/anchor'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Back Top',
zh: '回到顶部',
enSuffix: true,
path: '/back-top'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Breadcrumb',
zh: '面包屑',
enSuffix: true,
path: '/breadcrumb'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Loading Bar',
zh: '加载条',
enSuffix: true,
path: '/loading-bar'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Menu',
zh: '菜单',
enSuffix: true,
path: '/menu'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Pagination',
zh: '分页',
enSuffix: true,
path: '/pagination'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Steps',
zh: '步骤',
enSuffix: true,
path: '/steps'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Tabs',
zh: '标签页',
enSuffix: true,
path: '/tabs'
2020-11-13 18:57:28 +08:00
}
]
}),
appendCounts({
2021-02-14 14:52:14 +08:00
zh: '反馈组件',
en: 'Feedback Components',
2020-11-13 18:57:28 +08:00
type: 'group',
2021-02-14 14:52:14 +08:00
children: [
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Alert',
zh: '警告信息',
enSuffix: true,
path: '/alert'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Badge',
zh: '标记',
enSuffix: true,
path: '/badge'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Dialog',
zh: '对话框',
enSuffix: true,
path: '/dialog'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Drawer',
zh: '抽屉',
enSuffix: true,
path: '/drawer'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Message',
zh: '信息',
enSuffix: true,
path: '/message'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Modal',
zh: '模态框',
enSuffix: true,
path: '/modal'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Notification',
zh: '通知',
enSuffix: true,
path: '/notification'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Popconfirm',
zh: '弹出确认',
enSuffix: true,
path: '/popconfirm'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Popover',
zh: '弹出信息',
enSuffix: true,
path: '/popover'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Popselect',
zh: '弹出选择',
enSuffix: true,
path: '/popselect'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Progress',
zh: '进度',
enSuffix: true,
path: '/progress'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Result',
zh: '结果页',
enSuffix: true,
path: '/result'
2020-11-13 18:57:28 +08:00
},
2021-04-09 00:43:33 +08:00
{
en: 'Skeleton',
zh: '骨架屏',
enSuffix: true,
path: '/skeleton'
2021-04-09 00:43:33 +08:00
},
2020-11-13 18:57:28 +08:00
{
2021-02-14 14:52:14 +08:00
en: 'Spin',
zh: '加载',
enSuffix: true,
path: '/spin'
2020-11-13 18:57:28 +08:00
},
{
2021-02-14 14:52:14 +08:00
en: 'Tooltip',
zh: '弹出提示',
enSuffix: true,
path: '/tooltip'
2020-11-13 18:57:28 +08:00
}
]
}),
appendCounts({
zh: '布局组件',
en: 'Layout Components',
type: 'group',
children: [
{
en: 'Layout',
zh: '布局',
enSuffix: true,
path: '/layout'
},
{
en: 'Grid',
zh: '栅格',
enSuffix: true,
path: '/grid'
},
{
en: 'Space',
zh: '间距',
enSuffix: true,
path: '/space'
}
]
}),
appendCounts({
zh: '配置组件',
en: 'Config Components',
type: 'group',
children: [
{
en: 'Config Provider',
zh: '全局化配置',
enSuffix: true,
path: '/config-provider'
},
{
en: 'Element',
zh: '元素',
enSuffix: true,
path: '/element'
2021-04-06 18:06:04 +08:00
},
{
en: 'Global Style',
zh: '全局样式',
enSuffix: true,
path: '/global-style'
}
]
}),
{
zh: '废弃',
en: 'Deprecated',
type: 'group',
children: [
{
en: 'Legacy Grid',
zh: '旧版栅格',
enSuffix: true,
path: '/legacy-grid'
}
]
},
2020-11-14 20:38:30 +08:00
...createDebugDemos(
2020-06-18 01:33:55 +08:00
{
2021-04-06 01:31:09 +08:00
en: '--Debug',
2021-02-14 14:52:14 +08:00
children: [
{
2021-02-14 14:52:14 +08:00
en: 'SuffixDebug',
path: '/base-suffix-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'PopoverDebug',
path: '/popover-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'RouterDebug',
path: '/router-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'ModalDebug',
path: '/modal-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'ScrollbarDebug',
path: '/scrollbar-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'ScrollbarDebug2',
path: '/scrollbar-debug2'
},
{
2021-02-14 14:52:14 +08:00
en: 'DatePickerDebug',
path: '/date-picker-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'BackTopDebug',
path: '/back-top-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'CascaderDebug',
path: '/cascader-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'VerticalAlignDebug',
path: '/vertical-align-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'IconTransitionDebug',
path: '/icon-transition-debug'
},
{
2021-02-14 14:52:14 +08:00
en: 'SelectDebug',
path: '/select-debug'
}
]
2020-12-12 13:51:22 +08:00
},
mode
)
2020-11-13 18:57:28 +08:00
])
2020-02-04 23:13:53 +08:00
}