mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-02-23 13:31:06 +08:00
fix(router of debugComponents)
This commit is contained in:
parent
178c421965
commit
549aea2b2c
@ -1,12 +1,14 @@
|
||||
import { Vue, router, i18n } from './init'
|
||||
import { Vue, i18n } from './init'
|
||||
import hljs from './hljs'
|
||||
import demoRouterView from './demoRouterView'
|
||||
import NaiveUI from '../lib/index'
|
||||
import '../lib/styles/index.css'
|
||||
import createRouter from './routes/router'
|
||||
import { routes } from './routes/routes'
|
||||
|
||||
Vue.use(NaiveUI)
|
||||
NaiveUI.setHljs(hljs)
|
||||
|
||||
const router = createRouter(Vue, routes)
|
||||
new Vue({
|
||||
...demoRouterView,
|
||||
router,
|
||||
|
@ -1,13 +1,17 @@
|
||||
|
||||
import { Vue, router, routes, childRoutes, i18n } from './init'
|
||||
import { Vue, i18n } from './init'
|
||||
import debugRouteMixin from './routes/debugRouteMixin'
|
||||
import hljs from './hljs'
|
||||
import demoRouterView from './demoRouterView'
|
||||
import NaiveUI from '../src/index'
|
||||
import '../styles/index.scss'
|
||||
import { routes, childRoutes } from './routes/routes'
|
||||
import createRouter from './routes/router'
|
||||
|
||||
debugRouteMixin(routes, childRoutes)
|
||||
|
||||
const router = createRouter(Vue, routes)
|
||||
|
||||
Vue.use(NaiveUI)
|
||||
NaiveUI.setHljs(hljs)
|
||||
|
||||
|
24
demo/init.js
24
demo/init.js
@ -1,5 +1,4 @@
|
||||
import Vue from 'vue'
|
||||
import VueRouter from 'vue-router'
|
||||
import VueI18n from 'vue-i18n'
|
||||
import ComponentDemo from './utils/ComponentDemo'
|
||||
import ComponentDemos from './utils/ComponentDemos'
|
||||
@ -7,10 +6,8 @@ import ComponentDocumentation from './utils/ComponentDocumentation'
|
||||
import DocumentationWrapper from './utils/DocumentationWrapper'
|
||||
import EditOnGithubButton from './utils/EditOnGithubButton'
|
||||
import EditOnGithubHeader from './utils/EditOnGithubHeader'
|
||||
import { routes, childRoutes } from './routes/routes'
|
||||
import './styles/demo.scss'
|
||||
|
||||
Vue.use(VueRouter)
|
||||
Vue.use(VueI18n)
|
||||
|
||||
const i18n = new VueI18n({
|
||||
@ -24,23 +21,4 @@ Vue.component('ComponentDocumentation', ComponentDocumentation)
|
||||
Vue.component('EditOnGithubButton', EditOnGithubButton)
|
||||
Vue.component('EditOnGithubHeader', EditOnGithubHeader)
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
routes
|
||||
})
|
||||
|
||||
router.beforeEach(function (to, from, next) {
|
||||
Vue.prototype.$NLoadingBar.theme = to.params.theme
|
||||
if (to.path !== from.path) {
|
||||
Vue.prototype.$NLoadingBar.start()
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
router.afterEach(function (to, from) {
|
||||
if (to.path !== from.path) {
|
||||
Vue.prototype.$NLoadingBar.finish()
|
||||
}
|
||||
})
|
||||
|
||||
export { Vue, router, routes, childRoutes, i18n }
|
||||
export { Vue, i18n }
|
||||
|
@ -13,7 +13,7 @@ import scrollbarDebug2 from '../debugComponents/scrollbarDebug2'
|
||||
|
||||
import { withPrefix } from './utils'
|
||||
|
||||
const rootDebugRoutes = [
|
||||
const childDebugRoutes = [
|
||||
{
|
||||
path: '/n-popover-debug',
|
||||
component: popoverDebug
|
||||
@ -25,10 +25,7 @@ const rootDebugRoutes = [
|
||||
{
|
||||
path: '/n-cascader-debug',
|
||||
component: cascaderDebug
|
||||
}
|
||||
]
|
||||
|
||||
const childDebugRoutes = [
|
||||
},
|
||||
{ path: '/n-scrollbar-debug2', component: scrollbarDebug2 },
|
||||
{ path: '/n-date-picker-debug', component: datePickerDebug },
|
||||
{ path: '/n--debug', component: suffixDebug },
|
||||
@ -41,6 +38,6 @@ const childDebugRoutes = [
|
||||
]
|
||||
|
||||
export default function debugRouteMixin (routes, childRoutes) {
|
||||
routes.unshift(rootDebugRoutes)
|
||||
childRoutes.unshift(withPrefix('/:lang/:theme/doc', childDebugRoutes))
|
||||
childRoutes.unshift(...withPrefix('/:lang/:theme/doc', childDebugRoutes))
|
||||
routes[0].children[1].children = childRoutes
|
||||
}
|
||||
|
23
demo/routes/router.js
Normal file
23
demo/routes/router.js
Normal file
@ -0,0 +1,23 @@
|
||||
import VueRouter from 'vue-router'
|
||||
|
||||
export default function createRouter (Vue, routes) {
|
||||
Vue.use(VueRouter)
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
routes
|
||||
})
|
||||
router.beforeEach(function (to, from, next) {
|
||||
Vue.prototype.$NLoadingBar.theme = to.params.theme
|
||||
if (to.path !== from.path) {
|
||||
Vue.prototype.$NLoadingBar.start()
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
router.afterEach(function (to, from) {
|
||||
if (to.path !== from.path) {
|
||||
Vue.prototype.$NLoadingBar.finish()
|
||||
}
|
||||
})
|
||||
return router
|
||||
}
|
Loading…
Reference in New Issue
Block a user