@@ -17,6 +20,7 @@
import DocHeader from './header.vue'
import menuOptions from './menuOptions'
import { i18n } from './init'
+import { setState } from './store'
export default {
components: {
@@ -34,8 +38,17 @@ export default {
beforeRouteUpdate (to, from, next) {
this.$i18n.locale = to.params.lang
next()
+ this.mode = localStorage.getItem('mode')
+ },
+ data () {
+ return {
+ mode: localStorage.getItem('mode') ? localStorage.getItem('mode') : 'debug'
+ }
},
computed: {
+ env () {
+ return process.env.NODE_ENV
+ },
items () {
return menuOptions(this.lang, this)
},
@@ -72,6 +85,11 @@ export default {
methods: {
handleLangChange (lang) {
this.lang = lang
+ },
+ handleModeChange (mode) {
+ this.mode = mode
+ localStorage.setItem('mode', mode)
+ setState(mode)
}
}
}
diff --git a/demo/header.vue b/demo/header.vue
index f4f0ac346..19912490b 100644
--- a/demo/header.vue
+++ b/demo/header.vue
@@ -6,6 +6,8 @@
"searchPlaceholder": "搜索组件",
"home": "首页",
"doc": "文档",
+ "common": "常规",
+ "debug": "调试",
"alreadyHome": "别点了,你已经在首页了"
},
"en-US": {
@@ -14,6 +16,8 @@
"searchPlaceholder": "Search Components",
"home": "Home",
"doc": "Documentation",
+ "common": "Common",
+ "debug": "Debug",
"alreadyHome": "You've already been in home page. No clicking."
}
}
@@ -50,12 +54,19 @@
-
+
{{ themeOptions[theme].label }}
-
+
{{ langOptions[lang].label }}
+
+ {{ modeOptions[mode].label }}
+
@@ -82,6 +93,14 @@ export default {
items: {
type: Array,
default: () => []
+ },
+ env: {
+ type: String,
+ default: null
+ },
+ mode: {
+ type: String,
+ default: null
}
},
data () {
@@ -107,6 +126,16 @@ export default {
label: '中文',
next: 'zh-CN'
}
+ },
+ modeOptions: {
+ 'debug': {
+ label: 'Common',
+ next: 'common'
+ },
+ 'common': {
+ label: 'Debug',
+ next: 'debug'
+ }
}
}
},
@@ -183,6 +212,10 @@ export default {
handleThemeChange () {
this.NConfigProvider.$parent.theme = this.themeOptions[this.theme].next
},
+
+ handleModeChange () {
+ this.$emit('mode-change', this.modeOptions[this.mode].next)
+ },
handleLanguageChange () {
this.$emit('lang-change', this.langOptions[this.lang].next)
}
@@ -215,4 +248,11 @@ export default {
.nav-menu .n-menu-item {
height: 63px !important;
}
+.nav-picker {
+ cursor: pointer;
+ margin-right: 12px;
+ &:last-child {
+ margin-right: 0;
+ }
+}
diff --git a/demo/init.js b/demo/init.js
index f402d66c6..4bca5df70 100644
--- a/demo/init.js
+++ b/demo/init.js
@@ -146,6 +146,94 @@ const withPrefix = (prefix, routes) =>
return route
})
+const children = [
+ { path: '/intro', component: intro },
+ { path: '/start', component: start },
+ { path: '/dev-guildlines', component: devGuildlines },
+ { path: '/n-nimbus-service-layout', component: nimbusServiceLayoutDemo },
+ { path: '/n-layout', component: layout },
+ { path: '/n-gradient-text', component: gradientText },
+ {
+ path: '/n-icon',
+ component: () => import('./documentation/components/icon')
+ },
+ { path: '/n-checkbox', component: checkbox },
+ { path: '/n-button', component: button },
+ { path: '/n-switch', component: nswitch },
+ // { path: '/n-table', component: tableDemo },
+ { path: '/n-data-table', component: dataTable },
+ { path: '/n-input', component: input },
+ { path: '/n-select', component: select },
+ { path: '/n-cascader', component: cascader },
+ { path: '/n-custom-input', component: customInput },
+ { path: '/n-modal', component: modal },
+ { path: '/n-message', component: message },
+ { path: '/n-tooltip', component: tooltip },
+ { path: '/n-popover', component: popover },
+ { path: '/n-notification', component: notification },
+ { path: '/n-pagination', component: pagination },
+ { path: '/n-alert', component: alert },
+ { path: '/n-date-picker', component: datePicker },
+ { path: '/n-input-number', component: inputNumber },
+ { path: '/n-radio', component: radio },
+ { path: '/n-form', component: form },
+ { path: '/n-tabs', component: tabs },
+ { path: '/n-time-picker', component: timePicker },
+ { path: '/n-confirm', component: confirm },
+ { path: '/n-router-debug', component: routerDebug },
+ { path: '/n-modal-debug', component: modalDebug },
+ { path: '/n-scrollbar-debug', component: scrollbarDebug },
+ { path: '/n-badge', component: badge },
+ { path: '/n-steps', component: steps },
+ { path: '/n-collapse', component: collapse },
+ { path: '/n-progress', component: progress },
+ { path: '/n-tag', component: tag },
+ { path: '/n-menu', component: menu },
+ { path: '/n-timeline', component: timeline },
+ { path: '/n-scrollbar-debug2', component: scrollbarDebug2 },
+ { path: '/n-back-top', component: backTop },
+ { path: '/n-date-picker-debug', component: datePickerDebug },
+ { path: '/n-divider', component: divider },
+ { path: '/n-popconfirm', component: popconfirm },
+ { path: '/n-anchor', component: anchor },
+ { path: '/n-dropdown', component: dropdown },
+ { path: '/n-popselect', component: popselect },
+ { path: '/n-config-provider', component: configProvider },
+ { path: '/n--debug', component: suffixDebug },
+ { path: '/n-transfer', component: transfer },
+ { path: '/n-spin', component: spin },
+ { path: '/n-drawer', component: drawer },
+ { path: '/n-loading-bar', component: loadingBar },
+ { path: '/n-time', component: time },
+ { path: '/n-slider', component: slider },
+ { path: '/n-tree', component: tree },
+ { path: '/n-vertical-align-debug', component: verticalAlignDebug },
+ { path: '/n-affix', component: affix },
+ { path: '/n-statistic', component: statistic },
+ { path: '/n-grid', component: grid },
+ { path: '/n-breadcrumb', component: breadcrumb },
+ { path: '/n-config-consumer', component: configConsumer },
+ { path: '/n-descriptions', component: descriptions },
+ { path: '/n-list', component: list },
+ { path: '/n-card', component: card },
+ { path: '/n-avatar', component: avatar },
+ { path: '/n-result', component: result },
+ { path: '/n-thing', component: thing },
+ { path: '/n-auto-complete', component: autoComplete },
+ { path: '/n-empty', component: empty },
+ { path: '/n-theme', component: theme },
+ { path: '/n-element', component: element },
+ { path: '/n-log', component: log },
+ { path: '/n-code', component: code },
+ { path: '/n-typography', component: typography },
+ { path: '/n-upload', component: upload },
+ { path: '/n-table', component: table },
+ {
+ path: '/n-icon-transition-debug',
+ component: iconTransitionDebug
+ },
+ { path: '/n-select-debug', component: selectDebug }
+]
const routes = [
{
path: '/:lang/:theme/n-popover-debug',
@@ -171,94 +259,7 @@ const routes = [
{
path: '/:lang/:theme/doc',
component: DocEntry,
- children: withPrefix('/:lang/:theme/doc', [
- { path: '/intro', component: intro },
- { path: '/start', component: start },
- { path: '/dev-guildlines', component: devGuildlines },
- { path: '/n-nimbus-service-layout', component: nimbusServiceLayoutDemo },
- { path: '/n-layout', component: layout },
- { path: '/n-gradient-text', component: gradientText },
- {
- path: '/n-icon',
- component: () => import('./documentation/components/icon')
- },
- { path: '/n-checkbox', component: checkbox },
- { path: '/n-button', component: button },
- { path: '/n-switch', component: nswitch },
- // { path: '/n-table', component: tableDemo },
- { path: '/n-data-table', component: dataTable },
- { path: '/n-input', component: input },
- { path: '/n-select', component: select },
- { path: '/n-cascader', component: cascader },
- { path: '/n-custom-input', component: customInput },
- { path: '/n-modal', component: modal },
- { path: '/n-message', component: message },
- { path: '/n-tooltip', component: tooltip },
- { path: '/n-popover', component: popover },
- { path: '/n-notification', component: notification },
- { path: '/n-pagination', component: pagination },
- { path: '/n-alert', component: alert },
- { path: '/n-date-picker', component: datePicker },
- { path: '/n-input-number', component: inputNumber },
- { path: '/n-radio', component: radio },
- { path: '/n-form', component: form },
- { path: '/n-tabs', component: tabs },
- { path: '/n-time-picker', component: timePicker },
- { path: '/n-confirm', component: confirm },
- { path: '/n-router-debug', component: routerDebug },
- { path: '/n-modal-debug', component: modalDebug },
- { path: '/n-scrollbar-debug', component: scrollbarDebug },
- { path: '/n-badge', component: badge },
- { path: '/n-steps', component: steps },
- { path: '/n-collapse', component: collapse },
- { path: '/n-progress', component: progress },
- { path: '/n-tag', component: tag },
- { path: '/n-menu', component: menu },
- { path: '/n-timeline', component: timeline },
- { path: '/n-scrollbar-debug2', component: scrollbarDebug2 },
- { path: '/n-back-top', component: backTop },
- { path: '/n-date-picker-debug', component: datePickerDebug },
- { path: '/n-divider', component: divider },
- { path: '/n-popconfirm', component: popconfirm },
- { path: '/n-anchor', component: anchor },
- { path: '/n-dropdown', component: dropdown },
- { path: '/n-popselect', component: popselect },
- { path: '/n-config-provider', component: configProvider },
- { path: '/n--debug', component: suffixDebug },
- { path: '/n-transfer', component: transfer },
- { path: '/n-spin', component: spin },
- { path: '/n-drawer', component: drawer },
- { path: '/n-loading-bar', component: loadingBar },
- { path: '/n-time', component: time },
- { path: '/n-slider', component: slider },
- { path: '/n-tree', component: tree },
- { path: '/n-vertical-align-debug', component: verticalAlignDebug },
- { path: '/n-affix', component: affix },
- { path: '/n-statistic', component: statistic },
- { path: '/n-grid', component: grid },
- { path: '/n-breadcrumb', component: breadcrumb },
- { path: '/n-config-consumer', component: configConsumer },
- { path: '/n-descriptions', component: descriptions },
- { path: '/n-list', component: list },
- { path: '/n-card', component: card },
- { path: '/n-avatar', component: avatar },
- { path: '/n-result', component: result },
- { path: '/n-thing', component: thing },
- { path: '/n-auto-complete', component: autoComplete },
- { path: '/n-empty', component: empty },
- { path: '/n-theme', component: theme },
- { path: '/n-element', component: element },
- { path: '/n-log', component: log },
- { path: '/n-code', component: code },
- { path: '/n-typography', component: typography },
- { path: '/n-upload', component: upload },
- { path: '/n-table', component: table },
- {
- path: '/n-icon-transition-debug',
- component: iconTransitionDebug
- },
- { path: '/n-select-debug', component: selectDebug }
- ])
+ children: withPrefix('/:lang/:theme/doc', children)
}
]
},
diff --git a/demo/menuOptions.js b/demo/menuOptions.js
index 680897a5f..3614a6bcd 100644
--- a/demo/menuOptions.js
+++ b/demo/menuOptions.js
@@ -1,3 +1,5 @@
+const env = process.env.NODE_ENV
+
const appendCounts = item => {
if (!item.childItems) {
item.count = 1
@@ -34,8 +36,8 @@ const appendCounts = item => {
}
}
-const appendDebugDemos = (item) => {
- if (process.env.NODE_ENV === 'development') {
+const appendDebugDemos = (item, mode) => {
+ if (env === 'development' && mode === 'debug') {
return [item]
} else return []
}
@@ -940,7 +942,7 @@ export default function (locale, instance) {
path: `/${instance.lang}/${instance.theme}/doc` + '/n-select-debug'
}
]
- })
+ }, instance.mode)
]
}
}
diff --git a/demo/store.js b/demo/store.js
new file mode 100644
index 000000000..4fc6ab796
--- /dev/null
+++ b/demo/store.js
@@ -0,0 +1,7 @@
+export const state = {
+ mode: localStorage.getItem('mode')
+}
+
+export function setState (mode) {
+ state.mode = mode
+}
diff --git a/demo/utils/ComponentDemo.vue b/demo/utils/ComponentDemo.vue
index 124778160..0415df31c 100644
--- a/demo/utils/ComponentDemo.vue
+++ b/demo/utils/ComponentDemo.vue
@@ -13,6 +13,7 @@