mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 09:24:25 +00:00
feat(cli): support more features
This commit is contained in:
@@ -2,15 +2,15 @@
|
||||
<div class="van-doc-header">
|
||||
<div class="van-doc-row">
|
||||
<div class="van-doc-header__top">
|
||||
<a class="van-doc-header__logo" :href="config.logo.href">
|
||||
<img :src="config.logo.image">
|
||||
<span>{{ config.logo.title }}</span>
|
||||
<a class="van-doc-header__logo">
|
||||
<img :src="config.logo">
|
||||
<span>{{ config.title }}</span>
|
||||
</a>
|
||||
|
||||
<search-input v-if="searchConfig" :lang="lang" :search-config="searchConfig" />
|
||||
|
||||
<ul class="van-doc-header__top-nav">
|
||||
<li v-for="item in config.nav.logoLink" class="van-doc-header__top-nav-item">
|
||||
<li v-for="item in config.iconLinks" class="van-doc-header__top-nav-item">
|
||||
<a class="van-doc-header__logo-link" target="_blank" :href="item.url">
|
||||
<img :src="item.image">
|
||||
</a>
|
||||
@@ -30,10 +30,10 @@
|
||||
</transition>
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<!--
|
||||
<li v-if="config.nav.lang" class="van-doc-header__top-nav-item">
|
||||
<a class="van-doc-header__cube" :href="langLink">{{ config.nav.lang.text }}</a>
|
||||
</li>
|
||||
</li> -->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -2,8 +2,8 @@
|
||||
<div class="van-doc">
|
||||
<doc-header
|
||||
:lang="lang"
|
||||
:config="config"
|
||||
:versions="versions"
|
||||
:config="config.header"
|
||||
:search-config="searchConfig"
|
||||
@switch-version="$emit('switch-version', $event)"
|
||||
/>
|
||||
|
@@ -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';
|
||||
|
||||
|
@@ -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 };
|
||||
|
@@ -11,9 +11,7 @@
|
||||
import DemoNav from './components/DemoNav';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
DemoNav
|
||||
}
|
||||
components: { DemoNav }
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<section class="van-doc-demo-block">
|
||||
<div class="van-doc-demo-block">
|
||||
<h2 class="van-doc-demo-block__title">{{ title }}</h2>
|
||||
<slot />
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-show="title" class="van-doc-demo-nav">
|
||||
<div class="van-doc-demo-nav__title">{{ title }}</div>
|
||||
<svg class="van-doc-demo-nav__back" viewBox="0 0 1000 1000" @click="onBack">
|
||||
<div v-show="title" class="demo-nav">
|
||||
<div class="demo-nav__title">{{ title }}</div>
|
||||
<svg class="demo-nav__back" viewBox="0 0 1000 1000" @click="onBack">
|
||||
<path fill="#969799" fill-rule="evenodd" :d="path" />
|
||||
</svg>
|
||||
</div>
|
||||
@@ -19,7 +19,8 @@ export default {
|
||||
|
||||
computed: {
|
||||
title() {
|
||||
const { name } = this.$route.meta || {};
|
||||
const route = this.$route || {};
|
||||
const { name } = route.meta || {};
|
||||
return name ? name.replace(/-/g, '') : '';
|
||||
}
|
||||
},
|
||||
@@ -33,7 +34,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.van-doc-demo-nav {
|
||||
.demo-nav {
|
||||
position: relative;
|
||||
height: 56px;
|
||||
line-height: 56px;
|
||||
|
@@ -12,7 +12,7 @@ export default {
|
||||
|
||||
computed: {
|
||||
demoName() {
|
||||
const { meta } = this.$route;
|
||||
const { meta } = this.$route || {};
|
||||
if (meta && meta.name) {
|
||||
return `demo-${decamelize(meta.name, '-')}`;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import DemoBlock from './components/DemoBlock';
|
||||
import DemoSection from './components/DemoSection';
|
||||
import routes from './router';
|
||||
import { routes } from './router';
|
||||
import App from './App';
|
||||
import '@vant/touch-emulator';
|
||||
import '../common/iframe-router';
|
||||
@@ -18,7 +18,9 @@ const router = new VueRouter({
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
Vue.nextTick(window.syncPath);
|
||||
if (!router.currentRoute.redirectedFrom) {
|
||||
Vue.nextTick(window.syncPath);
|
||||
}
|
||||
});
|
||||
|
||||
window.vueRouter = router;
|
||||
|
@@ -1,24 +1,29 @@
|
||||
import decamelize from 'decamelize';
|
||||
import DemoHome from './components/DemoHome';
|
||||
import { demos } from '../../dist/mobile-config';
|
||||
|
||||
const routes = [];
|
||||
const names = Object.keys(demos);
|
||||
|
||||
Object.keys(demos).forEach((name, index) => {
|
||||
if (index === 0) {
|
||||
routes.push({
|
||||
path: '*',
|
||||
redirect: () => `/${names[0]}`
|
||||
});
|
||||
}
|
||||
routes.push({
|
||||
path: '/home',
|
||||
component: DemoHome
|
||||
});
|
||||
|
||||
routes.push({
|
||||
path: '*',
|
||||
redirect: '/home'
|
||||
});
|
||||
|
||||
names.forEach(name => {
|
||||
routes.push({
|
||||
name,
|
||||
component: demos[name],
|
||||
path: `/${name}`,
|
||||
path: `/${decamelize(name, '-')}`,
|
||||
meta: {
|
||||
name
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export default routes;
|
||||
export { routes };
|
||||
|
Reference in New Issue
Block a user