naive-ui/demo/init.js

260 lines
11 KiB
JavaScript
Raw Normal View History

import Vue from 'vue'
2019-09-04 21:56:58 +08:00
import VueRouter from 'vue-router'
2019-09-21 17:03:37 +08:00
import VueI18n from 'vue-i18n'
2019-10-10 22:38:29 +08:00
import intro from './documentation/intro/intro'
import start from './documentation/intro/start'
import devGuildlines from './documentation/intro/devGuidelines'
2019-12-31 18:26:21 +08:00
import nimbusServiceLayoutDemo from './documentation/deprecated/nimbusServiceLayout'
2019-10-16 23:20:40 +08:00
import gradientText from './documentation/components/gradientText'
import checkbox from './documentation/components/checkbox'
2019-10-12 16:15:20 +08:00
import button from './documentation/components/button'
import nswitch from './documentation/components/switch'
2019-10-10 14:30:36 +08:00
import input from './documentation/components/input'
2019-10-18 16:45:40 +08:00
import select from './documentation/components/select'
2019-10-23 13:56:20 +08:00
import cascader from './documentation/components/cascader'
2019-10-25 15:50:09 +08:00
import customInput from './documentation/components/customInput'
2019-09-29 00:13:01 +08:00
import modal from './documentation/components/modal'
2019-10-08 13:34:34 +08:00
import message from './documentation/components/message'
2019-09-28 13:47:54 +08:00
import tooltip from './documentation/components/tooltip'
import popover from './documentation/components/popover'
import alert from './documentation/components/alert'
2019-10-15 14:55:05 +08:00
import datePicker from './documentation/components/datePicker'
2019-10-22 14:27:25 +08:00
import inputNumber from './documentation/components/inputNumber'
2019-10-21 14:49:08 +08:00
import radio from './documentation/components/radio'
2019-11-01 19:01:55 +08:00
import form from './documentation/components/form'
2019-10-22 16:56:50 +08:00
import tabs from './documentation/components/tabs'
2019-10-17 23:16:38 +08:00
import timePicker from './documentation/components/timePicker'
import confirm from './documentation/components/confirm'
2019-10-16 13:45:13 +08:00
import backTop from './documentation/components/backTop'
2019-10-22 13:48:51 +08:00
import dropdown from './documentation/components/dropdown'
2019-09-04 21:56:58 +08:00
import scrollbarDebug from './debugComponents/scrollbarDebug'
import scrollbarDebug2 from './debugComponents/scrollbarDebug2'
2019-10-08 19:06:23 +08:00
import badge from './documentation/components/badge'
2019-10-21 15:49:06 +08:00
import steps from './documentation/components/steps'
2019-10-16 23:28:36 +08:00
import notification from './documentation/components/notification'
2019-10-12 23:55:50 +08:00
import pagination from './documentation/components/pagination'
import collapse from './documentation/components/collapse'
import tag from './documentation/components/tag'
2019-11-27 17:01:21 +08:00
import menu from './documentation/components/menu'
2019-10-18 18:26:09 +08:00
import timeline from './documentation/components/timeline'
2019-10-18 16:45:40 +08:00
import progress from './documentation/components/progress'
2019-10-12 19:08:11 +08:00
import divider from './documentation/components/divider'
2019-10-21 15:37:41 +08:00
import popconfirm from './documentation/components/popconfirm'
2019-10-12 23:22:52 +08:00
import anchor from './documentation/components/anchor'
2019-10-18 11:23:45 +08:00
import popselect from './documentation/components/popselect'
import configProvider from './documentation/components/configProvider'
import dataTable from './documentation/components/dataTable'
2019-12-20 17:15:54 +08:00
import typography from './documentation/components/typography'
2019-10-25 12:59:50 +08:00
import transfer from './documentation/components/transfer'
2019-10-15 18:01:18 +08:00
import spin from './documentation/components/spin'
2019-10-22 13:19:12 +08:00
import drawer from './documentation/components/drawer'
2019-10-08 14:14:30 +08:00
import loadingBar from './documentation/components/loadingBar'
2019-10-21 15:37:41 +08:00
import time from './documentation/components/time'
2019-10-22 17:02:35 +08:00
import slider from './documentation/components/slider'
2019-10-25 12:59:50 +08:00
import tree from './documentation/components/tree'
import affix from './documentation/components/affix'
2019-10-28 18:29:52 +08:00
import statistic from './documentation/components/statistic'
import grid from './documentation/components/grid'
2019-10-29 12:38:42 +08:00
import breadcrumb from './documentation/components/breadcrumb'
import configConsumer from './documentation/components/configConsumer'
2019-11-12 15:04:42 +08:00
import descriptions from './documentation/components/descriptions'
import list from './documentation/components/list'
2019-11-13 00:02:42 +08:00
import card from './documentation/components/card'
2019-11-18 18:37:20 +08:00
import layout from './documentation/components/layout'
import avatar from './documentation/components/avatar'
2019-11-21 23:50:53 +08:00
import result from './documentation/components/result'
2019-11-22 16:54:32 +08:00
import thing from './documentation/components/thing'
import autoComplete from './documentation/components/autoComplete'
import empty from './documentation/components/empty'
2019-12-07 00:02:31 +08:00
import theme from './documentation/theme'
2019-12-10 22:42:17 +08:00
import element from './documentation/components/element'
2019-12-13 22:34:38 +08:00
import log from './documentation/components/log'
2019-12-14 00:03:35 +08:00
import code from './documentation/components/code'
2019-09-04 21:56:58 +08:00
import demo from './demo'
2019-09-23 15:04:57 +08:00
import ComponentDemo from './utils/ComponentDemo'
import ComponentDemos from './utils/ComponentDemos'
import ComponentDocumentation from './utils/ComponentDocumentation'
import DocumentationWrapper from './utils/DocumentationWrapper'
import './styles/demo.scss'
2019-09-04 21:56:58 +08:00
import popoverDebug from './debugComponents/popoverDebug'
import routerDebug from './debugComponents/routerDebug'
import modalDebug from './debugComponents/modalDebug'
import datePickerDebug from './debugComponents/datePickerDebug'
import backTopDebug from './debugComponents/backTopDebug'
import cancelMarkDebug from './debugComponents/cancelMarkDebug'
import cascaderDebug from './debugComponents/cascaderDebug'
2019-09-12 11:58:46 +08:00
import verticalAlignDebug from './debugComponents/verticalAlignDebug'
import iconTransitionDebug from './debugComponents/iconTransitionDebug'
2019-12-27 14:25:24 +08:00
import selectDebug from './debugComponents/selectDebug'
2019-09-04 21:56:58 +08:00
2019-12-13 23:55:19 +08:00
import hljs from 'highlight.js/lib/highlight'
import javascript from 'highlight.js/lib/languages/javascript'
import python from 'highlight.js/lib/languages/python'
import cpp from 'highlight.js/lib/languages/cpp'
hljs.registerLanguage('javascript', javascript)
hljs.registerLanguage('python', python)
hljs.registerLanguage('cpp', cpp)
hljs.registerLanguage('naive-log', () => ({
contains: [
{
className: 'number',
begin: /\d+/
}
]
}))
2019-09-04 21:56:58 +08:00
2019-09-21 17:03:37 +08:00
Vue.use(VueI18n)
2019-09-04 21:56:58 +08:00
Vue.use(VueRouter)
2019-09-21 17:03:37 +08:00
const i18n = new VueI18n({
2019-12-23 16:31:26 +08:00
locale: 'en-US'
2019-09-21 17:03:37 +08:00
})
2019-09-04 21:56:58 +08:00
2019-09-23 15:04:57 +08:00
Vue.component('ComponentDemo', ComponentDemo)
2019-09-21 17:03:37 +08:00
Vue.component('ComponentDemos', ComponentDemos)
Vue.component('DocumentationWrapper', DocumentationWrapper)
Vue.component('ComponentDocumentation', ComponentDocumentation)
2019-09-04 21:56:58 +08:00
2019-09-24 16:59:07 +08:00
const withPrefix = (prefix, routes) =>
routes.map(route => {
2019-09-24 16:59:07 +08:00
route.path = prefix + route.path
return route
})
2019-09-04 21:56:58 +08:00
const routes = [
{
path: '/:lang/:theme/n-popover-debug',
2019-09-04 21:56:58 +08:00
component: popoverDebug
},
{
path: '/n-back-top-debug',
component: backTopDebug
},
{
path: '/n-cascader-debug',
component: cascaderDebug
},
{
2019-09-27 16:02:06 +08:00
path: '/:lang/:theme/start',
2019-09-04 21:56:58 +08:00
component: demo,
2019-09-27 16:02:06 +08:00
children: withPrefix('/:lang/:theme', [
2019-10-10 22:38:29 +08:00
{ path: '/intro', component: intro },
{ path: '/start', component: start },
{ path: '/dev-guildlines', component: devGuildlines },
2019-09-04 21:56:58 +08:00
{ path: '/n-nimbus-service-layout', component: nimbusServiceLayoutDemo },
2019-11-18 18:37:20 +08:00
{ path: '/n-layout', component: layout },
2019-10-16 23:20:40 +08:00
{ path: '/n-gradient-text', component: gradientText },
{
path: '/n-icon',
component: () => import('./documentation/components/icon')
},
{ path: '/n-checkbox', component: checkbox },
2019-10-12 16:15:20 +08:00
{ path: '/n-button', component: button },
{ path: '/n-switch', component: nswitch },
2019-10-21 15:37:41 +08:00
// { path: '/n-table', component: tableDemo },
{ path: '/n-data-table', component: dataTable },
2019-10-10 14:30:36 +08:00
{ path: '/n-input', component: input },
2019-10-18 16:45:40 +08:00
{ path: '/n-select', component: select },
2019-10-23 13:56:20 +08:00
{ path: '/n-cascader', component: cascader },
2019-10-25 15:50:09 +08:00
{ path: '/n-custom-input', component: customInput },
2019-09-29 00:13:01 +08:00
{ path: '/n-modal', component: modal },
2019-10-08 13:34:34 +08:00
{ path: '/n-message', component: message },
2019-09-28 13:47:54 +08:00
{ path: '/n-tooltip', component: tooltip },
{ path: '/n-popover', component: popover },
2019-10-16 23:28:36 +08:00
{ path: '/n-notification', component: notification },
2019-10-12 23:55:50 +08:00
{ path: '/n-pagination', component: pagination },
{ path: '/n-alert', component: alert },
2019-10-15 14:55:05 +08:00
{ path: '/n-date-picker', component: datePicker },
2019-10-22 14:27:25 +08:00
{ path: '/n-input-number', component: inputNumber },
2019-10-21 14:49:08 +08:00
{ path: '/n-radio', component: radio },
{ path: '/n-form', component: form },
2019-10-22 16:56:50 +08:00
{ path: '/n-tabs', component: tabs },
2019-10-17 23:16:38 +08:00
{ path: '/n-time-picker', component: timePicker },
{ path: '/n-confirm', component: confirm },
2019-09-04 21:56:58 +08:00
{ path: '/n-router-debug', component: routerDebug },
{ path: '/n-modal-debug', component: modalDebug },
{ path: '/n-scrollbar-debug', component: scrollbarDebug },
2019-10-08 19:06:23 +08:00
{ path: '/n-badge', component: badge },
2019-10-21 15:49:06 +08:00
{ path: '/n-steps', component: steps },
{ path: '/n-collapse', component: collapse },
2019-10-18 16:45:40 +08:00
{ path: '/n-progress', component: progress },
{ path: '/n-tag', component: tag },
2019-11-27 17:01:21 +08:00
{ path: '/n-menu', component: menu },
2019-10-18 18:26:09 +08:00
{ path: '/n-timeline', component: timeline },
2019-09-04 21:56:58 +08:00
{ path: '/n-scrollbar-debug2', component: scrollbarDebug2 },
2019-10-16 13:45:13 +08:00
{ path: '/n-back-top', component: backTop },
2019-09-04 21:56:58 +08:00
{ path: '/n-date-picker-debug', component: datePickerDebug },
2019-10-12 19:08:11 +08:00
{ path: '/n-divider', component: divider },
2019-10-21 15:37:41 +08:00
{ path: '/n-popconfirm', component: popconfirm },
2019-10-12 23:22:52 +08:00
{ path: '/n-anchor', component: anchor },
2019-10-22 13:48:51 +08:00
{ path: '/n-dropdown', component: dropdown },
2019-10-18 11:23:45 +08:00
{ path: '/n-popselect', component: popselect },
{ path: '/n-config-provider', component: configProvider },
2019-09-04 21:56:58 +08:00
{ path: '/n-cancel-mark-debug', component: cancelMarkDebug },
2019-10-25 12:59:50 +08:00
{ path: '/n-transfer', component: transfer },
2019-10-15 18:01:18 +08:00
{ path: '/n-spin', component: spin },
2019-10-22 13:19:12 +08:00
{ path: '/n-drawer', component: drawer },
2019-10-08 14:14:30 +08:00
{ path: '/n-loading-bar', component: loadingBar },
2019-10-21 15:37:41 +08:00
{ path: '/n-time', component: time },
2019-10-22 17:02:35 +08:00
{ path: '/n-slider', component: slider },
2019-10-25 12:59:50 +08:00
{ path: '/n-tree', component: tree },
{ path: '/n-vertical-align-debug', component: verticalAlignDebug },
2019-10-28 18:29:52 +08:00
{ path: '/n-affix', component: affix },
{ path: '/n-statistic', component: statistic },
2019-10-29 12:38:42 +08:00
{ path: '/n-grid', component: grid },
2019-11-09 15:02:34 +08:00
{ path: '/n-breadcrumb', component: breadcrumb },
2019-11-12 15:04:42 +08:00
{ path: '/n-config-consumer', component: configConsumer },
{ path: '/n-descriptions', component: descriptions },
{ path: '/n-list', component: list },
{ path: '/n-card', component: card },
2019-11-21 23:50:53 +08:00
{ path: '/n-avatar', component: avatar },
2019-11-22 16:54:32 +08:00
{ path: '/n-result', component: result },
{ path: '/n-thing', component: thing },
{ path: '/n-auto-complete', component: autoComplete },
2019-12-07 00:02:31 +08:00
{ path: '/n-empty', component: empty },
2019-12-10 22:42:17 +08:00
{ path: '/n-theme', component: theme },
{ path: '/n-element', component: element },
2019-12-13 22:34:38 +08:00
{ path: '/n-log', component: log },
2019-12-14 00:03:35 +08:00
{ path: '/n-code', component: code },
2019-12-20 17:15:54 +08:00
{
path: '/n-typography', component: typography
},
{
path: '/n-icon-transition-debug',
component: iconTransitionDebug
2019-12-27 14:25:24 +08:00
},
{ path: '/n-select-debug', component: selectDebug }
2019-09-24 16:59:07 +08:00
])
2019-09-04 21:56:58 +08:00
},
{
path: '/*',
2020-02-05 13:49:02 +08:00
redirect: '/zh-CN/light/start'
2019-09-04 21:56:58 +08:00
}
]
const router = new VueRouter({
2019-10-14 13:10:26 +08:00
mode: 'history',
2019-09-04 21:56:58 +08:00
routes
})
router.beforeEach(function (to, from, next) {
2019-10-08 14:14:30 +08:00
Vue.prototype.$NLoadingBar.theme = to.params.theme
2019-10-14 13:10:26 +08:00
if (to.path !== from.path) {
Vue.prototype.$NLoadingBar.start()
}
2019-09-06 16:15:19 +08:00
next()
})
router.afterEach(function (to, from) {
2019-10-14 13:10:26 +08:00
if (to.path !== from.path) {
Vue.prototype.$NLoadingBar.finish()
}
2019-09-06 16:15:19 +08:00
})
2020-02-12 13:44:53 +08:00
export { Vue, router, i18n, hljs }