mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 10:44:59 +00:00
load doc && demo in demand
This commit is contained in:
@@ -30,6 +30,10 @@ module.exports = {
|
||||
"path": "/changelog",
|
||||
"title": "更新日志",
|
||||
noExample: true
|
||||
},
|
||||
{
|
||||
"title": "业务组件",
|
||||
"link": "/zanui/captain/component/quickstart"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -2,16 +2,9 @@ import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import App from './ExamplesDocsApp';
|
||||
import routes from './router.config';
|
||||
import ZanUI from 'src/index.js';
|
||||
import ZanDoc from 'zan-doc';
|
||||
import packageJson from '../../package.json';
|
||||
import DemoBlock from './components/demo-block';
|
||||
|
||||
const global = {
|
||||
version: packageJson.version
|
||||
};
|
||||
window._global = global;
|
||||
|
||||
import '../assets/docs.css';
|
||||
import 'packages/vant-css/src/index.css';
|
||||
|
||||
@@ -22,11 +15,7 @@ function isMobile() {
|
||||
}
|
||||
|
||||
Vue.use(VueRouter);
|
||||
Vue.use(ZanUI);
|
||||
Vue.use(ZanDoc);
|
||||
Vue.use(ZanUI.Lazyload, {
|
||||
lazyComponent: true
|
||||
});
|
||||
Vue.component('demo-block', DemoBlock);
|
||||
|
||||
const routesConfig = routes();
|
||||
|
@@ -1,4 +1,6 @@
|
||||
const navs = require('./doc.config')['zh-CN'].nav;
|
||||
import componentDocs from '../examples-dist/entry-docs';
|
||||
import componentDemos from '../examples-dist/entry-demos';
|
||||
|
||||
const registerRoute = (isExample) => {
|
||||
let route = [];
|
||||
@@ -9,31 +11,26 @@ const registerRoute = (isExample) => {
|
||||
|
||||
if (nav.groups) {
|
||||
nav.groups.forEach(group => {
|
||||
group.list.forEach(nav => {
|
||||
addRoute(nav);
|
||||
});
|
||||
group.list.forEach(addRoute);
|
||||
});
|
||||
} else if (nav.children) {
|
||||
nav.children.forEach(nav => {
|
||||
addRoute(nav);
|
||||
});
|
||||
nav.children.forEach(addRoute);
|
||||
} else {
|
||||
addRoute(nav);
|
||||
}
|
||||
});
|
||||
|
||||
function addRoute(page) {
|
||||
const component = isExample
|
||||
? require(`../examples-dist${page.path}.vue`)
|
||||
: require(`../examples-docs${page.path}.md`);
|
||||
route.push({
|
||||
path: '/component' + page.path,
|
||||
component: component.default || component
|
||||
});
|
||||
const { path } = page;
|
||||
if (path) {
|
||||
const name = path.replace('/', '');
|
||||
route.push({
|
||||
path: '/component' + path,
|
||||
component: isExample ? componentDemos[name] : componentDocs[name]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(route);
|
||||
|
||||
return route;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user