<template>
<!--  <van-doc-->
<!--    active="小程序组件"-->
<!--    :config="config"-->
<!--    :github="github"-->
<!--    :versions="versions"-->
<!--    :simulator="simulator"-->
<!--    @switch-version="onSwitchVersion"-->
<!--  >-->
<!--    <router-view />-->
<!--  </van-doc>-->
  <van-doc
      active="小程序组件"
      :config="config"
      :github="github"
      :simulator="simulator"
      @switch-version="onSwitchVersion"
  >
    <router-view />
  </van-doc>
</template>

<script>
import pkgJson from '../../package.json';
import docConfig, { github, versions } from './doc.config';

const UNSHARED = ['common', 'quickstart', 'changelog', 'intro', 'transition','doubleDatePicker','carNoPicker'];

export default {
  data() {
    return {
      github,
      versions,
    };
  },
  mounted() {
    document.querySelector('.van-doc-header__logo').querySelector('img')
        .setAttribute('src','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHkAAABLCAYAAABUSCjvAAAIYElEQVR4AezBMQEAAAgEIfuXPvfPABwAAAAAAAAAAMConl17DJIk+/o4ftpTEzvtHtvGM894bdu2bRtjY23btr1j21Zj0d21/29s3BcnTmQWujobEVURnxd5Km9m9/0l7s2sEPbAzXgbv2I5ivEX1mAGPsVIHI5CSPVKqu4NpmB/vIK/w+Hwv/Hi8x3ORENIUt0JORVnY5kOLBF8tmM4GkFqVzLkXfGbCqha8VmHs5ACSaqdkA/BNp+AFmESzkAfNEMW0lGILjga9+M7hD22UYnbkiHXTsgDsC8E7THdhfIXpuD/IXFqjZuw3m1rCw6AoBUujtJ+FMZ4uAWCO1RtLIbjVOwCcQpMW+1OCPZVtZYQpQWux4v4GC/hAfSEoJtqOxjiHKHqeThDLXs5MOiQU/ErtqE9BCFchRaQBIVwCdpCkImfUGo71Sj3uaIshWCtz/ebsTsE7SPcOtZDcIuq9Yc4R2GrT9srIThI1c6DOONUvQ1eiXIbuzvokM9WO5uOTEiApqn9PRctZD4/4CrlbB0yn02uNhFhV1sCQQe1rx9wu3J1hJAPVbUyjMRJuBTP4Ng4Qz4Bdztlrr5S1fYOMuQUO4rmsw8kIL3Nvs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URIh1HL8igk4HrmQpOBDDkI22mMAhqILCpGaDOJ/7dEBBQAAAASx/q2/xIMzLME6yUhGMpKRLBnJSEYykpGMZCQjWTKSkYxkJHM1oUQlzMsR5pUAAAAASUVORK5CYII=');
    document.querySelector('.van-doc-header__logo').querySelector('img')
        .setAttribute('style','width:auto');
    document.querySelector('.van-doc-header__logo').querySelector('span').innerText='KY Weapp';
  },
  computed: {
    config() {
      return docConfig;
    },

    simulator() {
      let prefix = '';
      const { path } = this.$route.meta;

      if (
        location.hostname === '0.0.0.0' ||
        location.hostname === 'localhost'
      ) {
        prefix = 'https://vant-contrib.gitee.io';
      }

      if (!UNSHARED.includes(path)) {
        return `https://vant-contrib.gitee.io/vant/mobile.html?hide_nav=1&weapp=1#/zh-CN/${path}`;
      }

      return `./preview.html#${path}`;
    },
  },

  methods: {
    onSwitchVersion(version) {
      if (version !== pkgJson.version) {
        location.href = `https://vant-contrib.gitee.io/vant-weapp/${version}`;
      }
    },
  },
};
</script>

<style lang="less">
.van-doc-intro {
  padding-top: 20px;
  font-family: 'Dosis', 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
  text-align: center;

  &__logo {
    width: 120px;
    height: 120px;
  }

  h2 {
    font-weight: normal;
    font-size: 32px;
    line-height: 60px;
  }

  p {
    margin-bottom: 20px;
    color: #455a64;
    font-size: 15px;
  }
}
</style>
