viewport.vue 4.0 KB
Newer Older
M
init  
miaodian 已提交
1 2
<template>
  <div class="docs-view">
D
UI  
dolymood 已提交
3 4 5 6
    <img class="menu" v-show="showCatalog" @click="toggleCatalog" src="./close.svg">
    <img class="menu" v-show="!showCatalog" @click="toggleCatalog" src="./menu.svg">
    <img class="menu to-home" @click="toHome" src="./back.svg">
    <div v-show="showCatalog" class="mask" :class="{ active: showCatalog }" @click="toggleCatalog"></div>
F
funanamy 已提交
7
    <div class="nav-list-wrapper" :class="{ active: showCatalog }">
A
AmyFoxFN 已提交
8 9
      <side-list :nav-list="navList"></side-list>
    </div>
F
funanamy 已提交
10
    <router-view class="page-doc md-body" v-highlight></router-view>
D
sync  
dolymood 已提交
11
    <display></display>
M
init  
miaodian 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  </div>
</template>

<script>
  import SideList from '../side-list/side-list.vue'
  import Display from '../display/display.vue'
  import menuConfig from '../../common/config/menu'

  export default {
    props: {
      lang: {
        type: String,
        default: 'zh-CN'
      }
    },
    data() {
      return {
A
AmyFoxFN 已提交
29
        navList: menuConfig[this.lang],
F
funanamy 已提交
30
        showCatalog: false
A
AmyFoxFN 已提交
31 32
      }
    },
F
funanamy 已提交
33 34 35
    watch: {
      $route() {
        this.showCatalog = false
A
AmyFoxFN 已提交
36
        window.scrollTo(0, 0)
F
funanamy 已提交
37 38
      }
    },
F
funanamy 已提交
39 40 41
    methods: {
      toggleCatalog() {
        this.showCatalog = !this.showCatalog
D
UI  
dolymood 已提交
42 43 44
      },
      toHome() {
        this.$router.push('/')
F
funanamy 已提交
45 46
      }
    },
X
XRene 已提交
47 48 49 50 51
    mounted () {
      const mdBodyEle = document.querySelector('.md-body')
      const pattern = /#cube-(.*)-anchor/
      const matcher = window.location.hash.match(pattern)
      if (matcher) {
D
doly mood 已提交
52
        const anchor = decodeURIComponent(matcher[1])
D
dolymood 已提交
53 54
        const el = mdBodyEle.querySelector(`#${anchor}`)
        el && el.scrollIntoView()
X
XRene 已提交
55 56
      }
    },
M
init  
miaodian 已提交
57 58 59 60 61 62 63 64
    components: {
      SideList,
      Display
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
D
dolymood 已提交
65
  @require "~@/common/stylus/variable.styl"
A
AmyFoxFN 已提交
66

M
init  
miaodian 已提交
67 68 69 70
  .docs-view
    display: flex
    width: 100%
    height: 100%
L
liyirui_i 已提交
71
    box-sizing: border-box
A
AmyFoxFN 已提交
72
    flex-wrap: wrap
D
UI  
dolymood 已提交
73
    &::before
L
liyirui_i 已提交
74
      content: ""
D
UI  
dolymood 已提交
75 76 77 78 79 80 81
      position: relative
      z-index: 5
      display: block
      width: 100%
      height: 1px
      margin-top: -1px
      box-shadow: 0 1px 2px rgba(0, 0, 0, .15)
F
funanamy 已提交
82 83 84
    @media screen and (max-width: 960px)
      position: relative
      height: auto
D
UI  
dolymood 已提交
85
    .menu
F
funanamy 已提交
86 87 88
      display: none
      @media screen and (max-width: 960px)
        display: block
F
funanamy 已提交
89
        position: absolute
D
UI  
dolymood 已提交
90 91
        right: 6px
        top: -44px
D
dolymood 已提交
92 93 94
        width: 20px
        height: 20px
        padding: 10px
D
UI  
dolymood 已提交
95 96 97
        &.to-home
          right: auto
          left: 3px
D
dolymood 已提交
98 99
      &:active
        opacity: .6
A
AmyFoxFN 已提交
100
    .nav-list-wrapper
D
UI  
dolymood 已提交
101
      width: 279px
D
dolymood 已提交
102
      height: 100%
D
UI  
dolymood 已提交
103
      border-right: 1px solid #e3e3e3
A
AmyFoxFN 已提交
104
      @media screen and (max-width: 960px)
F
funanamy 已提交
105
        position: absolute
D
dolymood 已提交
106
        right: 0
F
funanamy 已提交
107
        top: 0
F
funanamy 已提交
108 109
        background-color: $color-white
        z-index: 1
A
AmyFoxFN 已提交
110
        overflow: hidden
D
dolymood 已提交
111
        transform: translate(100%, 0)
F
funanamy 已提交
112
        transition: all 0.4s ease
D
UI  
dolymood 已提交
113
        border-right: none
F
funanamy 已提交
114
        &.active
D
dolymood 已提交
115
          transform: translate(0, 0)
D
UI  
dolymood 已提交
116 117 118 119 120 121 122 123 124 125 126 127
    @media screen and (max-width: 960px)
      .mask
        z-index: 1
        position: absolute
        top: 0
        left: 0
        width: 100%
        height: 100%
        background-color: transparent
        &.active
          background-color: rgba(0, 0, 0 ,0.05)
          transition: all 0.4s ease
L
liyirui_i 已提交
128
    .page-sidelist
F
funanamy 已提交
129
      height: 100%
D
UI  
dolymood 已提交
130 131
      padding: 50px 0
      margin-right: -1px
L
liyirui_i 已提交
132 133 134 135
      box-sizing: border-box
      overflow-y: auto
      @media screen and (max-width: 960px)
        height: 100%
D
UI  
dolymood 已提交
136 137 138 139 140 141 142 143 144
        padding: 30px 0
        font-size: 12px
        .nav-li
          .nav-name
            font-size: 15px
          .angle
            font-size: 12px
          .arrow
            top: 27px
L
liyirui_i 已提交
145 146 147
    .page-doc
      flex: 1
      height: 100%
D
UI  
dolymood 已提交
148
      padding: 54px 30px 30px
L
liyirui_i 已提交
149 150 151 152 153
      box-sizing: border-box
      overflow-y: auto
      @media screen and (max-width: 960px)
        flex: 1 1 100%
        height: auto
D
UI  
dolymood 已提交
154 155
        padding: 20px
        font-size: 13px
L
liyirui_i 已提交
156 157 158 159 160 161 162 163
      h2:first-child
        margin-top: 0
    .page-display
      flex: none
      height: 100%
      overflow-y: auto
      @media screen and (max-width: 960px)
        flex: 1 1 100%
D
UI  
dolymood 已提交
164
        height: 680px
M
init  
miaodian 已提交
165
</style>