viewport.vue 3.5 KB
Newer Older
M
init  
miaodian 已提交
1 2
<template>
  <div class="docs-view">
D
dolymood 已提交
3
    <img class="toggle-catalog" @click="toggleCatalog" src="./catalog.svg">
F
funanamy 已提交
4
    <div class="nav-list-wrapper" :class="{ active: showCatalog }">
A
AmyFoxFN 已提交
5 6
      <side-list :nav-list="navList"></side-list>
    </div>
F
update  
funanamy 已提交
7
    <div v-show="showCatalog" class="mask" :class="{ active: showCatalog }" @click="toggleCatalog"></div>
F
funanamy 已提交
8
    <router-view class="page-doc md-body" v-highlight></router-view>
D
sync  
dolymood 已提交
9
    <display></display>
M
init  
miaodian 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
  </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 已提交
27
        navList: menuConfig[this.lang],
F
funanamy 已提交
28
        showCatalog: false
A
AmyFoxFN 已提交
29 30
      }
    },
F
funanamy 已提交
31 32 33
    watch: {
      $route() {
        this.showCatalog = false
A
AmyFoxFN 已提交
34
        window.scrollTo(0, 0)
F
funanamy 已提交
35 36
      }
    },
F
funanamy 已提交
37 38 39 40 41
    methods: {
      toggleCatalog() {
        this.showCatalog = !this.showCatalog
      }
    },
X
XRene 已提交
42 43 44 45 46
    mounted () {
      const mdBodyEle = document.querySelector('.md-body')
      const pattern = /#cube-(.*)-anchor/
      const matcher = window.location.hash.match(pattern)
      if (matcher) {
D
doly mood 已提交
47
        const anchor = decodeURIComponent(matcher[1])
D
dolymood 已提交
48 49
        const el = mdBodyEle.querySelector(`#${anchor}`)
        el && el.scrollIntoView()
X
XRene 已提交
50 51
      }
    },
M
init  
miaodian 已提交
52 53 54 55 56 57 58 59
    components: {
      SideList,
      Display
    }
  }
</script>

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

M
init  
miaodian 已提交
62 63 64 65
  .docs-view
    display: flex
    width: 100%
    height: 100%
L
liyirui_i 已提交
66
    box-sizing: border-box
A
AmyFoxFN 已提交
67
    flex-wrap: wrap
F
funanamy 已提交
68
    overflow: hidden
L
liyirui_i 已提交
69 70 71 72 73 74 75
    &::after
      content: ""
      position: absolute
      left: 0
      top: 0
      bottom: 0
      border-left: #FC9153 10px solid
F
funanamy 已提交
76 77 78 79
    @media screen and (max-width: 960px)
      position: relative
      height: auto
    .toggle-catalog
F
funanamy 已提交
80 81 82
      display: none
      @media screen and (max-width: 960px)
        display: block
F
funanamy 已提交
83 84 85
        position: absolute
        right: 20px
        top: 20px
D
dolymood 已提交
86 87 88 89 90 91 92
        width: 20px
        height: 20px
        padding: 10px
        background-color: $color-white
        box-shadow: $box-shadow-content
      &:active
        opacity: .6
A
AmyFoxFN 已提交
93
    .nav-list-wrapper
D
dolymood 已提交
94
      height: 100%
A
AmyFoxFN 已提交
95
      @media screen and (max-width: 960px)
F
funanamy 已提交
96
        position: absolute
D
dolymood 已提交
97
        right: 0
F
funanamy 已提交
98
        top: 0
F
funanamy 已提交
99 100
        background-color: $color-white
        z-index: 1
A
AmyFoxFN 已提交
101
        overflow: hidden
D
dolymood 已提交
102
        transform: translate(100%, 0)
F
funanamy 已提交
103
        transition: all 0.4s ease
F
funanamy 已提交
104
        &.active
D
dolymood 已提交
105
          transform: translate(0, 0)
F
funanamy 已提交
106 107 108 109 110 111
    .mask
      position: absolute
      top: 0
      left: 0
      width: 100%
      height: 100%
D
dolymood 已提交
112
      background-color: transparent
F
update  
funanamy 已提交
113 114
      &.active
        background-color: rgba(0, 0, 0 ,0.2)
D
dolymood 已提交
115
        transition: all 0.4s ease
L
liyirui_i 已提交
116 117 118
    .page-sidelist
      flex: none
      width: 280px
F
funanamy 已提交
119
      height: 100%
L
liyirui_i 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
      box-sizing: border-box
      overflow-y: auto
      padding-right: 40px
      @media screen and (max-width: 960px)
        height: 100%
        padding: 5px 20px
    .page-doc
      flex: 1
      height: 100%
      padding: 44px 20px 20px 20px
      box-sizing: border-box
      overflow-y: auto
      @media screen and (max-width: 960px)
        flex: 1 1 100%
        height: auto
        padding: 20px 20px 0 20px
      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%
        height: 800px
M
init  
miaodian 已提交
145
</style>