site: split docs/components pages

This commit is contained in:
07akioni 2021-02-14 14:52:14 +08:00
parent 974884d0fa
commit 42b9102061
55 changed files with 630 additions and 543 deletions

View File

@ -76,6 +76,7 @@ export default {
searchPlaceholder: '搜索',
home: '首页',
doc: '文档',
component: '组件',
common: '常规',
debug: '调试',
alreadyHome: '别点了,你已经在首页了'
@ -86,6 +87,7 @@ export default {
searchPlaceholder: 'Search',
home: 'Home',
doc: 'Documentation',
component: 'Component',
common: 'Common',
debug: 'Debug',
alreadyHome: "You've already been in home page. No clicking."
@ -94,12 +96,16 @@ export default {
const menuItemsRef = computed(() => {
return [
{
name: 'home',
key: 'home',
title: t('home')
},
{
name: 'doc',
key: 'doc',
title: t('doc')
},
{
key: 'component',
title: t('component')
}
]
})
@ -192,10 +198,19 @@ export default {
this.$router.push(/^(\/[^/]+){2}/.exec(this.$route.path)[0])
}
if (value === 'doc') {
if (/^(\/[^/]+){2}\/doc/.test(this.$route.path)) {
if (/^(\/[^/]+){2}\/docs/.test(this.$route.path)) {
} else {
this.$router.push(
/^(\/[^/]+){2}/.exec(this.$route.path)[0] + '/doc/start'
/^(\/[^/]+){2}/.exec(this.$route.path)[0] + '/docs/start'
)
}
}
if (value === 'component') {
if (/^(\/[^/]+){2}\/components/.test(this.$route.path)) {
} else {
this.$router.push(
/^(\/[^/]+){2}/.exec(this.$route.path)[0] +
'/components/n-config-provider'
)
}
}

View File

@ -2,11 +2,11 @@ import { createApp } from 'vue'
import { installDemoComponents } from './init'
import SiteRoot from './SiteRoot.vue'
import naive from '../src/index'
import { routes, childRoutes } from './routes/routes'
import { routes, componentChildRoutes } from './routes/routes'
import createDemoRouter from './routes/router'
import debugRouteMixin from './routes/debug-route-mixin'
debugRouteMixin(routes, childRoutes)
debugRouteMixin(routes, componentChildRoutes)
const app = createApp(SiteRoot)

View File

@ -2,11 +2,11 @@ import { createApp } from 'vue'
import { installDemoComponents } from './init'
import SiteRoot from './TsSiteRoot.vue'
import naive from '../src/index'
import { routes, childRoutes } from './routes/routes'
import { routes, componentChildRoutes } from './routes/routes'
import createDemoRouter from './routes/router'
import debugRouteMixin from './routes/debug-route-mixin'
debugRouteMixin(routes, childRoutes)
debugRouteMixin(routes, componentChildRoutes)
const app = createApp(SiteRoot)

46
demo/pages/Layout.vue Normal file
View File

@ -0,0 +1,46 @@
<template>
<n-service-layout
ref="layoutInstRef"
:padding-body="false"
:items="items"
:sider-props="siderProps"
>
<router-view />
</n-service-layout>
</template>
<script>
// Frame component for components & docs page
import { computed, watch, toRef, ref } from 'vue'
import { useRoute } from 'vue-router'
import { useDocOptions, useComponentOptions } from '../store'
export default {
setup () {
const route = useRoute()
const layoutInstRef = ref(null)
const docOptionsRef = useDocOptions()
const componentOptionsRef = useComponentOptions()
const optionsRef = computed(() =>
route.path.includes('/docs/')
? docOptionsRef.value
: componentOptionsRef.value
)
watch(toRef(route, 'path'), (value, oldValue) => {
const langReg = /(zh-CN)|(en-US)/
if (value.replace(langReg, '') !== oldValue.replace(langReg, '')) {
layoutInstRef.value.scrollTo(0, 0)
}
})
return {
layoutInstRef,
items: optionsRef,
siderProps: {
style: {
height: '100%'
}
}
}
}
}
</script>

View File

@ -1,39 +0,0 @@
<!--anchor:on-->
# Experimental Features
<n-alert type="warning" title="Caveats">
The following features are <n-text strong>unstable</n-text>. Use them if you really need and perpare to follow the API changes.
</n-alert>
## Customize Theme
```js
// ...
import naive from 'naive-ui'
naive.styles.light.override({
derived: {
primaryColor: 'rgb(255, 0, 0)',
primaryHoverColor: 'rgb(0, 255, 0)',
primaryActiveColor: 'rgb(0, 0, 255)'
}
})
Vue.use(naive)
```
For specific variables, please see source code.
### Use Tusimple Theme
```js
// ...
import tusimpleTheme from 'naive-ui/themes/tusimple'
import naive from 'naive-ui'
naive.use(tusimpleTheme)
Vue.use(naive)
```

View File

@ -1,39 +0,0 @@
<!--anchor:on-->
# 试验性特性
<n-alert type="warning" title="注意">
下列的所有功能都是<n-text strong>不稳定</n-text>的。只在真的需要的时候再使用他们API 有可能在未来被改变。
</n-alert>
## 定制主题
```js
// ...
import naive from 'naive-ui'
naive.styles.light.override({
derived: {
primaryColor: 'rgb(255, 0, 0)',
primaryColorHover: 'rgb(0, 255, 0)',
primaryColorActive: 'rgb(0, 0, 255)'
}
})
Vue.use(naive)
```
具体可使用变量请参考源码。
### 使用图森主题
```js
// ...
import tusimpleTheme from 'naive-ui/themes/tusimple'
import naive from 'naive-ui'
naive.use(tusimpleTheme)
Vue.use(naive)
```

View File

@ -1,42 +0,0 @@
<template>
<n-service-layout
ref="layout"
:padding-body="false"
:items="items"
:sider-props="siderProps"
>
<router-view />
</n-service-layout>
</template>
<script>
import { useDocOptions } from '../../store'
export default {
provide () {
return {
NDocRoot: this
}
},
beforeRouteUpdate (to, from, next) {
this.memorizedPath = from ? from.path : null
next()
},
setup () {
return {
items: useDocOptions(),
memorizedPath: null,
siderProps: {
style: {
height: '100%'
}
}
}
},
methods: {
resetScrollPosition () {
this.$refs.layout.scrollTo(0, 0)
}
}
}
</script>

View File

@ -39,7 +39,7 @@ export default {
},
{
name: 'Morning Glory',
childItems: [
children: [
{
name: 'Hello',
path: '/en-US/dark/n-nimbus-service-layout?param=777'

View File

@ -39,7 +39,7 @@ export default {
},
{
name: 'Morning Glory',
childItems: [
children: [
{
name: 'Hello',
path: '/en-US/dark/n-nimbus-service-layout?param=777'

View File

@ -0,0 +1,66 @@
<!--anchor:on-->
# Experimental Features
<n-alert type="warning" title="Caveats">
The following features are <n-text strong>unstable</n-text>. Use them if you really need and perpare to follow the API changes.
</n-alert>
## Customize Theme
```html
<script>
import { NConfigProvider } from 'naive-ui'
/**
* @type import('../src').GlobalThemeOverrides
*/
const themeOverrides = {
common: {
primaryColor: '#FF0000'
},
Button: {
textColor: '#FF0000'
},
Select: {
peers: {
InternalSelection: {
textColor: '#FF0000'
}
}
}
// ...
}
// ...
</script>
<template>
<n-config-provider :theme-overrides="themeOverrides">
<my-app />
</n-config-provider>
</template>
```
For specific variables, please follow `GlobalThemeOverrides` type hint.
## Use Tusimple Theme
```html
<script>
import { TsConfigProvider, useDialog, useMessage } from '@naive-ui/tusimple-theme'
// danger typed api
const dialog = useDialog()
dialog.danger(...)
const message = useMessage()
message.danger(...)
</script>
<template>
<ts-config-provider>
<my-app />
</ts-config-provider>
</template>
```

View File

@ -0,0 +1,66 @@
<!--anchor:on-->
# 试验性特性
<n-alert type="warning" title="注意">
下列的所有功能都是<n-text strong>不稳定</n-text>的。只在真的需要的时候再使用他们API 有可能在未来被改变。
</n-alert>
## 定制主题
```html
<script>
import { NConfigProvider } from 'naive-ui'
/**
* @type import('../src').GlobalThemeOverrides
*/
const themeOverrides = {
common: {
primaryColor: '#FF0000'
},
Button: {
textColor: '#FF0000'
},
Select: {
peers: {
InternalSelection: {
textColor: '#FF0000'
}
}
}
// ...
}
// ...
</script>
<template>
<n-config-provider :theme-overrides="themeOverrides">
<my-app />
</n-config-provider>
</template>
```
具体可使用变量请参考 `GlobalThemeOverrides` 类型提示。
## 使用图森主题
```html
<script>
import { TsConfigProvider, useDialog, useMessage } from '@naive-ui/tusimple-theme'
// danger typed api
const dialog = useDialog()
dialog.danger(...)
const message = useMessage()
message.danger(...)
</script>
<template>
<ts-config-provider>
<my-app />
</ts-config-provider>
</template>
```

View File

@ -1,9 +1,7 @@
<template>
<div class="footer">
<n-divider v-if="showDivider" style="margin: 0 0 16px 0" />
<n-text depth="3">
Made by Tusimple
</n-text>
<n-text depth="3"> Made by Tusimple </n-text>
</div>
</template>

View File

@ -10,7 +10,8 @@
<span
@mouseenter="handleTitleMouseEnter"
@mouseleave="handleTitleMouseLeave"
>Na{{ hover ? 'ï' : 'i' }}ve UI</span>
>Na{{ hover ? 'ï' : 'i' }}ve UI</span
>
</n-h1>
<n-p style="font-size: 16px; margin-bottom: 0">
{{ t('intro1') }}

View File

@ -55,7 +55,7 @@ const childDebugRoutes = [
]
export default function debugRouteMixin (routes, childRoutes) {
childRoutes.unshift(...withPrefix('/:lang/:theme/doc', childDebugRoutes))
childRoutes.unshift(...withPrefix('/:lang/:theme/docs', childDebugRoutes))
// routes[0].children[1].children = childRoutes
routes.unshift(...rootDebugRoutes)
}

View File

@ -1,35 +1,39 @@
import { withPrefix } from './utils'
import Site from '../Site.vue'
export const childRoutes = withPrefix('/:lang/:theme/doc', [
export const docChildRoutes = withPrefix('/:lang/:theme/docs', [
// basic docs
{
path: '/intro',
component: () => import('../pages/doc/intro/index.entry')
component: () => import('../pages/docs/intro/index.entry')
},
{
path: '/start',
component: () => import('../pages/doc/start/index.entry')
component: () => import('../pages/docs/start/index.entry')
},
{
path: '/from-v1',
component: () => import('../pages/doc/vue3/index.entry')
component: () => import('../pages/docs/vue3/index.entry')
},
{
path: '/experimental-features',
component: () => import('../pages/doc/experimental-features/index.entry')
component: () => import('../pages/docs/experimental-features/index.entry')
},
{
path: '/changelog',
component: () => import('../pages/doc/changelog/index.entry')
component: () => import('../pages/docs/changelog/index.entry')
},
{
path: '/dev-guidelines',
component: () => import('../pages/doc/dev-guidelines/index.entry')
component: () => import('../pages/docs/dev-guidelines/index.entry')
},
{
path: '/n-theme',
component: () => import('../pages/doc/theme/index.entry')
},
component: () => import('../pages/docs/theme/index.entry')
}
])
export const componentChildRoutes = withPrefix('/:lang/:theme/components', [
// components
{
path: '/n-layout',
@ -303,7 +307,7 @@ export const childRoutes = withPrefix('/:lang/:theme/doc', [
{
path: '/n-nimbus-service-layout',
component: () =>
import('../pages/doc/deprecated/nimbus-service-layout/index.entry')
import('../pages/docs/deprecated/nimbus-service-layout/index.entry')
}
])
@ -311,18 +315,24 @@ export const routes = [
{
name: 'site',
path: '/:lang/:theme',
component: () => import('../Site.vue'),
component: Site,
children: [
{
name: 'home',
path: '/:lang/:theme',
component: () => import('../pages/landing/index.vue')
component: () => import('../pages/home/index.vue')
},
{
name: 'doc',
path: '/:lang/:theme/doc',
component: () => import('../pages/doc/index.vue'),
children: childRoutes
name: 'docs',
path: '/:lang/:theme/docs',
component: () => import('../pages/Layout.vue'),
children: docChildRoutes
},
{
name: 'components',
path: '/:lang/:theme/components',
component: () => import('../pages/Layout.vue'),
children: componentChildRoutes
}
]
},

View File

@ -9,7 +9,10 @@ import {
useOsTheme
} from '../../src'
import { i18n } from '../utils/composables'
import menuOptions from './menu-options'
import {
createDocumentationMenuOptions,
createComponentMenuOptions
} from './menu-options'
import hljs from './hljs'
const storeKey = 'site-store'
@ -66,7 +69,14 @@ export function siteSetup () {
})
// options
const docOptionsRef = computed(() =>
menuOptions({
createDocumentationMenuOptions({
theme: themeNameRef.value,
lang: localeNameRef.value,
mode: displayModeRef.value
})
)
const componentOptionsRef = computed(() =>
createComponentMenuOptions({
theme: themeNameRef.value,
lang: localeNameRef.value,
mode: displayModeRef.value
@ -77,12 +87,13 @@ export function siteSetup () {
const traverse = (items) => {
if (items) {
items.forEach((item) => {
if (item.childItems) traverse(item.childItems)
if (item.children) traverse(item.children)
else flattenedItems.push(item)
})
}
}
traverse(docOptionsRef.value)
traverse(componentOptionsRef.value)
return flattenedItems
})
provide(
@ -92,6 +103,7 @@ export function siteSetup () {
localeName: localeNameRef,
displayMode: displayModeRef,
docOptions: docOptionsRef,
componentOptions: componentOptionsRef,
flattenedDocOptions: flattenedDocOptionsRef
})
)
@ -130,6 +142,10 @@ export function useDocOptions () {
return toRef(inject(storeKey), 'docOptions')
}
export function useComponentOptions () {
return toRef(inject(storeKey), 'componentOptions')
}
export function useFlattenedDocOptions () {
return toRef(inject(storeKey), 'flattenedDocOptions')
}

View File

@ -1,13 +1,13 @@
// rubbish code here
const appendCounts = (item) => {
if (!item.childItems) {
if (!item.children) {
item.count = 1
return item
}
if (item.childItems) {
item.childItems.forEach(appendCounts)
item.count = item.childItems.reduce((sum, item) => sum + item.count, 0)
if (item.children) {
item.children.forEach(appendCounts)
item.count = item.children.reduce((sum, item) => sum + item.count, 0)
item.name += ` (${item.count})`
if (item.type === 'group' && item.title) item.title += ` (${item.count})`
return item
@ -26,511 +26,521 @@ const createDebugDemos = (item, mode) => {
} else return []
}
function createItems (lang, items) {
if (lang === 'zh-CN') return items
function traverse (children) {
children.forEach((child) => {
child.title = undefined
child.titleExtra = undefined
if (child.childItems) {
traverse(child.childItems)
}
})
}
traverse(items)
return items
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,
title: rawItem[langKey],
enSuffix: true,
path: rawItem.path
? `/${lang}/${theme}` + prefix + rawItem.path
: undefined
}
if (rawItem.children) {
item.children = createItems(lang, theme, prefix, rawItem.children)
}
return item
})
}
export default function (instance) {
const { lang, theme, mode } = instance
return createItems(lang, [
export function createDocumentationMenuOptions ({ lang, theme, mode }) {
return createItems(lang, theme, '/docs', [
{
name: 'Naive UI',
path: `/${lang}/${theme}/doc` + '/intro'
en: 'Naive UI',
zh: 'Naive UI',
path: '/intro'
},
{
name: 'Get Started',
title: '起步',
path: `/${lang}/${theme}/doc` + '/start'
en: 'Get Started',
zh: '起步',
path: '/start'
},
{
name: 'Change Log',
title: '变更日志',
path: `/${lang}/${theme}/doc` + '/changelog'
en: 'Change Log',
zh: '变更日志',
path: '/changelog'
},
{
name: 'Migrate From V1',
title: '从 V1 升级',
path: `/${lang}/${theme}/doc` + '/from-v1'
en: 'Migrate From V1',
zh: '从 V1 升级',
path: '/from-v1'
},
{
name: 'Create Themed Component',
title: '创建适配主题的组件',
path: `/${lang}/${theme}/doc` + '/n-theme'
en: 'Create Themed Component',
zh: '创建适配主题的组件',
path: '/n-theme'
},
{
name: 'Experimental Features',
title: '试验性特性',
path: `/${lang}/${theme}/doc` + '/experimental-features'
},
en: 'Experimental Features',
zh: '试验性特性',
path: '/experimental-features'
}
])
}
export function createComponentMenuOptions ({ lang, theme, mode }) {
return createItems(lang, theme, '/components', [
appendCounts({
title: '配置组件',
name: 'Config Components',
zh: '配置组件',
en: 'Config Components',
type: 'group',
childItems: [
children: [
{
name: 'Config Provider',
title: '配置提供者',
titleExtra: 'Config Provider',
path: `/${lang}/${theme}/doc` + '/n-config-provider'
en: 'Config Provider',
zh: '配置提供者',
enSuffix: true,
path: '/n-config-provider'
},
{
name: 'Element',
title: '元素',
titleExtra: 'Element',
path: `/${lang}/${theme}/doc` + '/n-element'
en: 'Element',
zh: '元素',
enSuffix: true,
path: '/n-element'
}
]
}),
appendCounts({
title: '布局组件',
name: 'Layout Components',
zh: '布局组件',
en: 'Layout Components',
type: 'group',
childItems: [
children: [
{
name: 'Layout',
title: '布局',
titleExtra: 'Layout',
path: `/${lang}/${theme}/doc` + '/n-layout'
en: 'Layout',
zh: '布局',
enSuffix: true,
path: '/n-layout'
},
{
name: 'Grid',
title: '栅格',
titleExtra: 'Grid',
path: `/${lang}/${theme}/doc` + '/n-grid'
en: 'Grid',
zh: '栅格',
enSuffix: true,
path: '/n-grid'
},
{
name: 'Space',
title: '间距',
titleExtra: 'Space',
path: `/${lang}/${theme}/doc` + '/n-space'
en: 'Space',
zh: '间距',
enSuffix: true,
path: '/n-space'
}
]
}),
appendCounts({
title: '通用组件',
name: 'Common Components',
zh: '通用组件',
en: 'Common Components',
type: 'group',
childItems: [
children: [
{
name: 'Avatar',
title: '头像',
titleExtra: 'Avatar',
path: `/${lang}/${theme}/doc` + '/n-avatar'
en: 'Avatar',
zh: '头像',
enSuffix: true,
path: '/n-avatar'
},
{
name: 'Button',
title: '按钮',
titleExtra: 'Button',
path: `/${lang}/${theme}/doc` + '/n-button'
en: 'Button',
zh: '按钮',
enSuffix: true,
path: '/n-button'
},
{
name: 'Card',
title: '卡片',
titleExtra: 'Card',
path: `/${lang}/${theme}/doc` + '/n-card'
en: 'Card',
zh: '卡片',
enSuffix: true,
path: '/n-card'
},
{
name: 'Collapse',
title: '折叠面板',
titleExtra: 'Collapse',
path: `/${lang}/${theme}/doc` + '/n-collapse'
en: 'Collapse',
zh: '折叠面板',
enSuffix: true,
path: '/n-collapse'
},
{
name: 'Divider',
title: '分割线',
titleExtra: 'Divider',
path: `/${lang}/${theme}/doc` + '/n-divider'
en: 'Divider',
zh: '分割线',
enSuffix: true,
path: '/n-divider'
},
{
name: 'Dropdown',
title: '下拉菜单',
titleExtra: 'Dropdown',
path: `/${lang}/${theme}/doc` + '/n-dropdown'
en: 'Dropdown',
zh: '下拉菜单',
enSuffix: true,
path: '/n-dropdown'
},
{
name: 'Gradient Text',
title: '渐变文字',
titleExtra: 'Gradient Text',
path: `/${lang}/${theme}/doc` + '/n-gradient-text'
en: 'Gradient Text',
zh: '渐变文字',
enSuffix: true,
path: '/n-gradient-text'
},
{
name: 'Icon',
title: '图标',
titleExtra: 'Icon',
path: `/${lang}/${theme}/doc` + '/n-icon'
en: 'Icon',
zh: '图标',
enSuffix: true,
path: '/n-icon'
},
{
name: 'Tag',
title: '标签',
titleExtra: 'Tag',
path: `/${lang}/${theme}/doc` + '/n-tag'
en: 'Tag',
zh: '标签',
enSuffix: true,
path: '/n-tag'
},
{
name: 'Typography',
title: '排印',
titleExtra: 'Typography',
path: `/${lang}/${theme}/doc` + '/n-typography'
en: 'Typography',
zh: '排印',
enSuffix: true,
path: '/n-typography'
}
]
}),
appendCounts({
title: '数据录入组件',
name: 'Data Input Components',
zh: '数据录入组件',
en: 'Data Input Components',
type: 'group',
childItems: [
children: [
{
name: 'Auto Complete',
title: '自动填充',
titleExtra: 'Auto Complete',
path: `/${lang}/${theme}/doc` + '/n-auto-complete'
en: 'Auto Complete',
zh: '自动填充',
enSuffix: true,
path: '/n-auto-complete'
},
{
name: 'Cascader',
title: '级联选择',
titleExtra: 'Cascader',
path: `/${lang}/${theme}/doc` + '/n-cascader'
en: 'Cascader',
zh: '级联选择',
enSuffix: true,
path: '/n-cascader'
},
{
name: 'Checkbox',
title: '复选框',
titleExtra: 'Checkbox',
path: `/${lang}/${theme}/doc` + '/n-checkbox'
en: 'Checkbox',
zh: '复选框',
enSuffix: true,
path: '/n-checkbox'
},
{
name: 'Date Picker',
title: '日期选择器',
titleExtra: 'Date Picker',
path: `/${lang}/${theme}/doc` + '/n-date-picker'
en: 'Date Picker',
zh: '日期选择器',
enSuffix: true,
path: '/n-date-picker'
},
{
name: 'Dynamic Input',
title: '动态录入',
titleExtra: 'Dynamic Input',
path: `/${lang}/${theme}/doc` + '/n-dynamic-input'
en: 'Dynamic Input',
zh: '动态录入',
enSuffix: true,
path: '/n-dynamic-input'
},
{
name: 'Dynamic Tags',
title: '动态标签',
titleExtra: 'Dynamic Tags',
path: `/${lang}/${theme}/doc` + '/n-dynamic-tags'
en: 'Dynamic Tags',
zh: '动态标签',
enSuffix: true,
path: '/n-dynamic-tags'
},
{
name: 'Form',
title: '表单',
titleExtra: 'Form',
path: `/${lang}/${theme}/doc` + '/n-form'
en: 'Form',
zh: '表单',
enSuffix: true,
path: '/n-form'
},
{
name: 'Input',
title: '文本输入',
titleExtra: 'Input',
path: `/${lang}/${theme}/doc` + '/n-input'
en: 'Input',
zh: '文本输入',
enSuffix: true,
path: '/n-input'
},
{
name: 'Input Number',
title: '数字输入',
titleExtra: 'Input Number',
path: `/${lang}/${theme}/doc` + '/n-input-number'
en: 'Input Number',
zh: '数字输入',
enSuffix: true,
path: '/n-input-number'
},
{
name: 'Radio',
title: '单选',
titleExtra: 'Radio',
path: `/${lang}/${theme}/doc` + '/n-radio'
en: 'Radio',
zh: '单选',
enSuffix: true,
path: '/n-radio'
},
{
name: 'Rate',
title: '评分',
titleExtra: 'Rate',
path: `/${lang}/${theme}/doc` + '/n-rate'
en: 'Rate',
zh: '评分',
enSuffix: true,
path: '/n-rate'
},
{
name: 'Select',
title: '选择器',
titleExtra: 'Select',
path: `/${lang}/${theme}/doc` + '/n-select'
en: 'Select',
zh: '选择器',
enSuffix: true,
path: '/n-select'
},
{
name: 'Slider',
title: '滑动选择',
titleExtra: 'Slider',
path: `/${lang}/${theme}/doc` + '/n-slider'
en: 'Slider',
zh: '滑动选择',
enSuffix: true,
path: '/n-slider'
},
{
name: 'Switch',
title: '开关',
titleExtra: 'Switch',
path: `/${lang}/${theme}/doc` + '/n-switch'
en: 'Switch',
zh: '开关',
enSuffix: true,
path: '/n-switch'
},
{
name: 'Time Picker',
title: '时间选择器',
titleExtra: 'Time Picker',
path: `/${lang}/${theme}/doc` + '/n-time-picker'
en: 'Time Picker',
zh: '时间选择器',
enSuffix: true,
path: '/n-time-picker'
},
{
name: 'Transfer',
title: '穿梭框',
titleExtra: 'Transfer',
path: `/${lang}/${theme}/doc` + '/n-transfer'
en: 'Transfer',
zh: '穿梭框',
enSuffix: true,
path: '/n-transfer'
},
{
name: 'Upload',
title: '上传',
titleExtra: 'Upload',
path: `/${lang}/${theme}/doc` + '/n-upload'
en: 'Upload',
zh: '上传',
enSuffix: true,
path: '/n-upload'
}
]
}),
appendCounts({
title: '数据展示组件',
name: 'Data Display Components',
zh: '数据展示组件',
en: 'Data Display Components',
type: 'group',
childItems: [
children: [
{
name: 'Code',
title: '代码',
titleExtra: 'Code',
path: `/${lang}/${theme}/doc` + '/n-code'
en: 'Code',
zh: '代码',
enSuffix: true,
path: '/n-code'
},
{
name: 'Data Table',
title: '数据表格',
titleExtra: 'Data Table',
path: `/${lang}/${theme}/doc` + '/n-data-table'
en: 'Data Table',
zh: '数据表格',
enSuffix: true,
path: '/n-data-table'
},
{
name: 'Descriptions',
title: '描述',
titleExtra: 'Descriptions',
path: `/${lang}/${theme}/doc` + '/n-descriptions'
en: 'Descriptions',
zh: '描述',
enSuffix: true,
path: '/n-descriptions'
},
{
name: 'Empty',
title: '无内容',
titleExtra: 'Empty',
path: `/${lang}/${theme}/doc` + '/n-empty'
en: 'Empty',
zh: '无内容',
enSuffix: true,
path: '/n-empty'
},
{
name: 'List',
title: '列表',
titleExtra: 'List',
path: `/${lang}/${theme}/doc` + '/n-list'
en: 'List',
zh: '列表',
enSuffix: true,
path: '/n-list'
},
{
name: 'Log',
title: '日志',
titleExtra: 'Log',
path: `/${lang}/${theme}/doc` + '/n-log'
en: 'Log',
zh: '日志',
enSuffix: true,
path: '/n-log'
},
{
name: 'Statistic',
title: '统计数据',
titleExtra: 'Statistic',
path: `/${lang}/${theme}/doc` + '/n-statistic'
en: 'Statistic',
zh: '统计数据',
enSuffix: true,
path: '/n-statistic'
},
{
name: 'Table',
title: '表格',
titleExtra: 'Table',
path: `/${lang}/${theme}/doc` + '/n-table'
en: 'Table',
zh: '表格',
enSuffix: true,
path: '/n-table'
},
{
name: 'Thing',
title: '东西',
titleExtra: 'Thing',
path: `/${lang}/${theme}/doc` + '/n-thing'
en: 'Thing',
zh: '东西',
enSuffix: true,
path: '/n-thing'
},
{
name: 'Time',
title: '时间',
titleExtra: 'Time',
path: `/${lang}/${theme}/doc` + '/n-time'
en: 'Time',
zh: '时间',
enSuffix: true,
path: '/n-time'
},
{
name: 'Timeline',
title: '时间线',
titleExtra: 'Timeline',
path: `/${lang}/${theme}/doc` + '/n-timeline'
en: 'Timeline',
zh: '时间线',
enSuffix: true,
path: '/n-timeline'
},
{
name: 'Tree',
title: '树',
titleExtra: 'Tree',
path: `/${lang}/${theme}/doc` + '/n-tree'
en: 'Tree',
zh: '树',
enSuffix: true,
path: '/n-tree'
}
]
}),
appendCounts({
title: '导航组件',
name: 'Navigation Components',
zh: '导航组件',
en: 'Navigation Components',
type: 'group',
childItems: [
children: [
{
name: 'Affix',
title: '固钉',
titleExtra: 'Affix',
path: `/${lang}/${theme}/doc` + '/n-affix'
en: 'Affix',
zh: '固钉',
enSuffix: true,
path: '/n-affix'
},
{
name: 'Anchor',
title: '侧边导航',
titleExtra: 'Anchor',
path: `/${lang}/${theme}/doc` + '/n-anchor'
en: 'Anchor',
zh: '侧边导航',
enSuffix: true,
path: '/n-anchor'
},
{
name: 'Back Top',
title: '回到顶部',
titleExtra: 'Back Top',
path: `/${lang}/${theme}/doc` + '/n-back-top'
en: 'Back Top',
zh: '回到顶部',
enSuffix: true,
path: '/n-back-top'
},
{
name: 'Breadcrumb',
title: '面包屑',
titleExtra: 'Breadcrumb',
path: `/${lang}/${theme}/doc` + '/n-breadcrumb'
en: 'Breadcrumb',
zh: '面包屑',
enSuffix: true,
path: '/n-breadcrumb'
},
{
name: 'Loading Bar',
title: '加载条',
titleExtra: 'Loading Bar',
path: `/${lang}/${theme}/doc` + '/n-loading-bar'
en: 'Loading Bar',
zh: '加载条',
enSuffix: true,
path: '/n-loading-bar'
},
{
name: 'Menu',
title: '菜单',
titleExtra: 'Menu',
path: `/${lang}/${theme}/doc` + '/n-menu'
en: 'Menu',
zh: '菜单',
enSuffix: true,
path: '/n-menu'
},
{
name: 'Pagination',
title: '分页',
titleExtra: 'Pagination',
path: `/${lang}/${theme}/doc` + '/n-pagination'
en: 'Pagination',
zh: '分页',
enSuffix: true,
path: '/n-pagination'
},
{
name: 'Steps',
title: '步骤',
titleExtra: 'Steps',
path: `/${lang}/${theme}/doc` + '/n-steps'
en: 'Steps',
zh: '步骤',
enSuffix: true,
path: '/n-steps'
},
{
name: 'Tabs',
title: '标签页',
titleExtra: 'Tabs',
path: `/${lang}/${theme}/doc` + '/n-tabs'
en: 'Tabs',
zh: '标签页',
enSuffix: true,
path: '/n-tabs'
}
]
}),
appendCounts({
title: '反馈组件',
name: 'Feedback Components',
zh: '反馈组件',
en: 'Feedback Components',
type: 'group',
childItems: [
children: [
{
name: 'Alert',
title: '警告信息',
titleExtra: 'Alert',
path: `/${lang}/${theme}/doc` + '/n-alert'
en: 'Alert',
zh: '警告信息',
enSuffix: true,
path: '/n-alert'
},
{
name: 'Badge',
title: '标记',
titleExtra: 'Badge',
path: `/${lang}/${theme}/doc` + '/n-badge'
en: 'Badge',
zh: '标记',
enSuffix: true,
path: '/n-badge'
},
{
name: 'Dialog',
title: '对话框',
titleExtra: 'Dialog',
path: `/${lang}/${theme}/doc` + '/n-dialog'
en: 'Dialog',
zh: '对话框',
enSuffix: true,
path: '/n-dialog'
},
{
name: 'Drawer',
title: '抽屉',
titleExtra: 'Drawer',
path: `/${lang}/${theme}/doc` + '/n-drawer'
en: 'Drawer',
zh: '抽屉',
enSuffix: true,
path: '/n-drawer'
},
{
name: 'Message',
title: '信息',
titleExtra: 'Message',
path: `/${lang}/${theme}/doc` + '/n-message'
en: 'Message',
zh: '信息',
enSuffix: true,
path: '/n-message'
},
{
name: 'Modal',
title: '模态框',
titleExtra: 'Modal',
path: `/${lang}/${theme}/doc` + '/n-modal'
en: 'Modal',
zh: '模态框',
enSuffix: true,
path: '/n-modal'
},
{
name: 'Notification',
title: '通知',
titleExtra: 'Notification',
path: `/${lang}/${theme}/doc` + '/n-notification'
en: 'Notification',
zh: '通知',
enSuffix: true,
path: '/n-notification'
},
{
name: 'Popconfirm',
title: '弹出确认',
titleExtra: 'Popconfirm',
path: `/${lang}/${theme}/doc` + '/n-popconfirm'
en: 'Popconfirm',
zh: '弹出确认',
enSuffix: true,
path: '/n-popconfirm'
},
{
name: 'Popover',
title: '弹出信息',
titleExtra: 'Popover',
path: `/${lang}/${theme}/doc` + '/n-popover'
en: 'Popover',
zh: '弹出信息',
enSuffix: true,
path: '/n-popover'
},
{
name: 'Popselect',
title: '弹出选择',
titleExtra: 'Popselect',
path: `/${lang}/${theme}/doc` + '/n-popselect'
en: 'Popselect',
zh: '弹出选择',
enSuffix: true,
path: '/n-popselect'
},
{
name: 'Progress',
title: '进度',
titleExtra: 'Progress',
path: `/${lang}/${theme}/doc` + '/n-progress'
en: 'Progress',
zh: '进度',
enSuffix: true,
path: '/n-progress'
},
{
name: 'Result',
title: '结果页',
titleExtra: 'Result',
path: `/${lang}/${theme}/doc` + '/n-result'
en: 'Result',
zh: '结果页',
enSuffix: true,
path: '/n-result'
},
{
name: 'Spin',
title: '加载',
titleExtra: 'Spin',
path: `/${lang}/${theme}/doc` + '/n-spin'
en: 'Spin',
zh: '加载',
enSuffix: true,
path: '/n-spin'
},
{
name: 'Tooltip',
title: '弹出提示',
titleExtra: 'Tooltip',
path: `/${lang}/${theme}/doc` + '/n-tooltip'
en: 'Tooltip',
zh: '弹出提示',
enSuffix: true,
path: '/n-tooltip'
}
]
}),
...createDeprecatedDemos(
{
name: 'Deprecated',
childItems: [
en: 'Deprecated',
children: [
{
name: 'Nimbus Service Layout',
path: `/${lang}/${theme}/doc` + '/n-nimbus-service-layout'
en: 'Nimbus Service Layout',
path: '/n-nimbus-service-layout'
}
]
},
@ -538,55 +548,55 @@ export default function (instance) {
),
...createDebugDemos(
{
name: 'Debug',
childItems: [
en: 'Debug',
children: [
{
name: 'SuffixDebug',
path: `/${lang}/${theme}/doc` + '/n-base-suffix-debug'
en: 'SuffixDebug',
path: '/n-base-suffix-debug'
},
{
name: 'PopoverDebug',
en: 'PopoverDebug',
path: '/n-popover-debug'
},
{
name: 'RouterDebug',
path: `/${lang}/${theme}/doc` + '/n-router-debug'
en: 'RouterDebug',
path: '/n-router-debug'
},
{
name: 'ModalDebug',
path: `/${lang}/${theme}/doc` + '/n-modal-debug'
en: 'ModalDebug',
path: '/n-modal-debug'
},
{
name: 'ScrollbarDebug',
path: `/${lang}/${theme}/doc` + '/n-scrollbar-debug'
en: 'ScrollbarDebug',
path: '/n-scrollbar-debug'
},
{
name: 'ScrollbarDebug2',
path: `/${lang}/${theme}/doc` + '/n-scrollbar-debug2'
en: 'ScrollbarDebug2',
path: '/n-scrollbar-debug2'
},
{
name: 'DatePickerDebug',
path: `/${lang}/${theme}/doc` + '/n-date-picker-debug'
en: 'DatePickerDebug',
path: '/n-date-picker-debug'
},
{
name: 'BackTopDebug',
en: 'BackTopDebug',
path: '/n-back-top-debug'
},
{
name: 'CascaderDebug',
en: 'CascaderDebug',
path: '/n-cascader-debug'
},
{
name: 'VerticalAlignDebug',
path: `/${lang}/${theme}/doc` + '/n-vertical-align-debug'
en: 'VerticalAlignDebug',
path: '/n-vertical-align-debug'
},
{
name: 'IconTransitionDebug',
path: `/${lang}/${theme}/doc` + '/n-icon-transition-debug'
en: 'IconTransitionDebug',
path: '/n-icon-transition-debug'
},
{
name: 'SelectDebug',
path: `/${lang}/${theme}/doc` + '/n-select-debug'
en: 'SelectDebug',
path: '/n-select-debug'
}
]
},

View File

@ -4,33 +4,6 @@
</div>
</template>
<script>
export default {
inject: {
NDocRoot: {
default: null
}
},
mounted () {
const paramsRegex = /\/([^/]+)\/([^/]+)\/([^/]+)\/([^/]+)/
const { NDocRoot } = this
if (NDocRoot.memorizedPath) {
const memorizedPath = NDocRoot.memorizedPath
const currentPath = this.$route.path
const memorizedDemoName = (paramsRegex.exec(memorizedPath) || [])[4]
const currentDemoName = (paramsRegex.exec(currentPath) || [])[4]
if (
memorizedDemoName &&
currentDemoName &&
memorizedDemoName !== currentDemoName
) {
NDocRoot.resetScrollPosition()
}
}
}
}
</script>
<style>
.n-documentation {
padding: 32px 24px 24px 56px;

View File

@ -97,10 +97,10 @@ export default defineComponent({
function syncValue (path?: string, items?: Item[]): void {
if (items === undefined) items = props.items
for (const item of items) {
if (item.childItems) {
syncValue(path, item.childItems)
if (item.childItems || item.children) {
syncValue(path, item.childItems || item.children)
} else if (item.path === path) {
doUpdateValue(item.name || '')
doUpdateValue(item.name || item.key || '')
return
}
}

View File

@ -3,7 +3,8 @@ export interface Item {
path?: string
title?: string
disabled?: boolean
childItems?: Item[]
children?: Item[]
key?: string
[key: string]: unknown
/** @deprecated */
@ -14,4 +15,6 @@ export interface Item {
group?: boolean
/** @deprecated */
extra?: string
/** @deprecated */
childItems?: Item[]
}

View File

@ -4,13 +4,16 @@ import { Item } from './interface'
export function createItems (items: Item[]): MenuOption[] {
return items.map((item) => {
const isGroup = item.group || item.type === 'group'
const children = item.childItems || item.children
const key = item.name || item.key
const extra = item.extra || item.titleExtra
const menuOption: MenuOption = {
path: item.path,
title: item.title || item.name || '',
extra: item.extra || item.titleExtra,
key: item.name || 'key-required',
title: item.title || key || '',
extra: extra,
key: key || 'key-required',
disabled: item.disabled,
children: item.childItems ? createItems(item.childItems) : undefined,
children: children ? createItems(children) : undefined,
type: isGroup ? 'group' : undefined
}
return menuOption