diff --git a/package.json b/package.json index 47bf5f701..6b6bff78f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "husky": { "hooks": { "pre-commit": "lint-staged", - "commit-msg": "vant commit-lint" + "commit-msg": "vant-cli commit-lint" } }, "lint-staged": { @@ -70,7 +70,7 @@ "@babel/preset-env": "^7.7.1", "@babel/preset-typescript": "^7.7.2", "@types/jest": "^24.0.22", - "@vant/cli": "^1.0.6", + "@vant/cli": "^2.0.0-beta.2", "@vant/doc": "^2.6.1", "@vant/eslint-config": "^1.4.0", "@vant/markdown-loader": "^2.2.0", diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json index b520092c2..5a2c9801a 100644 --- a/packages/vant-cli/package.json +++ b/packages/vant-cli/package.json @@ -67,6 +67,7 @@ "cross-env": "^6.0.3", "css-loader": "^3.2.0", "csso": "^4.0.2", + "decamelize": "^3.2.0", "dependency-tree": "^7.0.2", "eslint": "^6.6.0", "gh-pages": "2.0.1", diff --git a/packages/vant-cli/site/desktop/components/Header.vue b/packages/vant-cli/site/desktop/components/Header.vue index 0447bb964..d5faab095 100644 --- a/packages/vant-cli/site/desktop/components/Header.vue +++ b/packages/vant-cli/site/desktop/components/Header.vue @@ -2,15 +2,15 @@
diff --git a/packages/vant-cli/site/desktop/components/index.vue b/packages/vant-cli/site/desktop/components/index.vue index 40448476b..6683f6063 100644 --- a/packages/vant-cli/site/desktop/components/index.vue +++ b/packages/vant-cli/site/desktop/components/index.vue @@ -2,8 +2,8 @@
diff --git a/packages/vant-cli/site/desktop/main.js b/packages/vant-cli/site/desktop/main.js index bac4c27f2..f43901a2e 100644 --- a/packages/vant-cli/site/desktop/main.js +++ b/packages/vant-cli/site/desktop/main.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import VueRouter from 'vue-router'; import App from './App'; -import routes from './router'; +import { routes } from './router'; import { isMobile } from '../common'; import '../common/iframe-router'; diff --git a/packages/vant-cli/site/desktop/router.js b/packages/vant-cli/site/desktop/router.js index 7e327f16d..68501985f 100644 --- a/packages/vant-cli/site/desktop/router.js +++ b/packages/vant-cli/site/desktop/router.js @@ -1,24 +1,28 @@ +import decamelize from 'decamelize'; import { documents } from '../../dist/desktop-config'; const routes = []; const names = Object.keys(documents); -Object.keys(documents).forEach((name, index) => { - if (index === 0) { - routes.push({ - path: '*', - redirect: () => `/${names[0]}` - }); - } +routes.push({ + path: '/home', + component: documents.Home +}); +routes.push({ + path: '*', + redirect: '/home' +}); + +names.forEach(name => { routes.push({ name, component: documents[name], - path: `/${name}`, + path: `/${decamelize(name, '-')}`, meta: { name } }); }); -export default routes; +export { routes }; diff --git a/packages/vant-cli/site/mobile/App.vue b/packages/vant-cli/site/mobile/App.vue index 99f2db83d..a238bb5b4 100644 --- a/packages/vant-cli/site/mobile/App.vue +++ b/packages/vant-cli/site/mobile/App.vue @@ -11,9 +11,7 @@ import DemoNav from './components/DemoNav'; export default { - components: { - DemoNav - } + components: { DemoNav } }; diff --git a/packages/vant-cli/site/mobile/components/DemoBlock.vue b/packages/vant-cli/site/mobile/components/DemoBlock.vue index 56b79c4c4..8521b8815 100644 --- a/packages/vant-cli/site/mobile/components/DemoBlock.vue +++ b/packages/vant-cli/site/mobile/components/DemoBlock.vue @@ -1,8 +1,8 @@