| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,15 +37,15 @@ | |||
| 37 | 37 | "hightlights": [[true, false, false, false, false, false, false, false, false]], | |
| 38 | 38 | "routes": [ | |
| 39 | 39 | [ | |
| 40 | - "/component/product/component/introduction", | ||
| 41 | - "/component/product/component/download", | ||
| 42 | - "/component/product/component/developEnvironment", | ||
| 43 | - "/component/product/component/authorization", | ||
| 44 | - "/component/product/component/moduleIntroduction", | ||
| 45 | - "/component/product/component/relatedProduct", | ||
| 46 | - "/component/product/component/thirdPartyProducts", | ||
| 47 | - "/component/product/component/newFeatures", | ||
| 48 | - "/component/product/component/startDevelop" | ||
| 40 | + "/product/component/introduction", | ||
| 41 | + "/product/component/download", | ||
| 42 | + "/product/component/developEnvironment", | ||
| 43 | + "/product/component/authorization", | ||
| 44 | + "/product/component/moduleIntroduction", | ||
| 45 | + "/product/component/relatedProduct", | ||
| 46 | + "/product/component/thirdPartyProducts", | ||
| 47 | + "/product/component/newFeatures", | ||
| 48 | + "/product/component/startDevelop" | ||
| 49 | 49 | ] | |
| 50 | 50 | ] | |
| 51 | 51 | }, | |
@@ -69,7 +69,7 @@ | |||
| 69 | 69 | ] | |
| 70 | 70 | ], | |
| 71 | 71 | "hightlights": [[false, false, false, false, false, false, false, false, false, false, false, false]], | |
| 72 | - "routes": [["/guide/component/development_mapboxgl", "", "", "", "", "", "", "", "", "", "", ""]] | ||
| 72 | + "routes": [["/guide/component/development_component", "", "", "", "", "", "", "", "", "", "", ""]] | ||
| 73 | 73 | }, | |
| 74 | 74 | { | |
| 75 | 75 | "title": "在线示例", | |
@@ -104,15 +104,15 @@ | |||
| 104 | 104 | "hightlights": [[true, false, false, false, false, false, false, false, false]], | |
| 105 | 105 | "routes": [ | |
| 106 | 106 | [ | |
| 107 | - "/component/product/cesium/produce_cesium", | ||
| 108 | - "/component/product/cesium/download", | ||
| 109 | - "/component/product/cesium/developEnvironment", | ||
| 110 | - "/component/product/cesium/authorization", | ||
| 111 | - "/component/product/cesium/moduleIntroduction", | ||
| 112 | - "/component/product/cesium/relatedProduct", | ||
| 113 | - "/component/product/cesium/thirdPartyProducts", | ||
| 114 | - "/component/product/cesium/newFeatures", | ||
| 115 | - "/component/product/cesium/startDevelop" | ||
| 107 | + "/product/cesium/produce_cesium", | ||
| 108 | + "/product/cesium/download", | ||
| 109 | + "/product/cesium/developEnvironment", | ||
| 110 | + "/product/cesium/authorization", | ||
| 111 | + "/product/cesium/moduleIntroduction", | ||
| 112 | + "/product/cesium/relatedProduct", | ||
| 113 | + "/product/cesium/thirdPartyProducts", | ||
| 114 | + "/product/cesium/newFeatures", | ||
| 115 | + "/product/cesium/startDevelop" | ||
| 116 | 116 | ] | |
| 117 | 117 | ] | |
| 118 | 118 | }, | |
@@ -231,15 +231,15 @@ | |||
| 231 | 231 | "hightlights": [[true, false, false, false, false, false, false, false, false]], | |
| 232 | 232 | "routes": [ | |
| 233 | 233 | [ | |
| 234 | - "/component/product/mapboxgl/produce_mapboxgl", | ||
| 235 | - "/component/product/mapboxgl/download", | ||
| 236 | - "/component/product/mapboxgl/developEnvironment", | ||
| 237 | - "/component/product/mapboxgl/authorization", | ||
| 238 | - "/component/product/mapboxgl/moduleIntroduction", | ||
| 239 | - "/component/product/mapboxgl/relatedProduct", | ||
| 240 | - "/component/product/mapboxgl/thirdPartyProducts", | ||
| 241 | - "/component/product/mapboxgl/newFeatures", | ||
| 242 | - "/component/product/mapboxgl/startDevelop" | ||
| 234 | + "/product/mapboxgl/produce_mapboxgl", | ||
| 235 | + "/product/mapboxgl/download", | ||
| 236 | + "/product/mapboxgl/developEnvironment", | ||
| 237 | + "/product/mapboxgl/authorization", | ||
| 238 | + "/product/mapboxgl/moduleIntroduction", | ||
| 239 | + "/product/mapboxgl/relatedProduct", | ||
| 240 | + "/product/mapboxgl/thirdPartyProducts", | ||
| 241 | + "/product/mapboxgl/newFeatures", | ||
| 242 | + "/product/mapboxgl/startDevelop" | ||
| 243 | 243 | ] | |
| 244 | 244 | ] | |
| 245 | 245 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,7 +154,7 @@ export const routes = [ | |||
| 154 | 154 | name: '*' | |
| 155 | 155 | }, | |
| 156 | 156 | { | |
| 157 | - path: '/component/product/:mapmode/:file', | ||
| 157 | + path: '/product/:mapmode/:file', | ||
| 158 | 158 | component: Product, | |
| 159 | 159 | name: 'product' | |
| 160 | 160 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,35 +1,18 @@ | |||
| 1 | 1 | <template> | |
| 2 | - <el-container> | ||
| 3 | - <el-header | ||
| 4 | - style="padding:0px;" | ||
| 5 | - :height="mobile?'48px':'64px'" | ||
| 6 | - > | ||
| 2 | + <el-container class="mapgis-product-wrapper"> | ||
| 3 | + <el-header style="padding:0px;" :height="mobile?'48px':'64px'"> | ||
| 7 | 4 | <Header></Header> | |
| 8 | 5 | </el-header> | |
| 9 | 6 | <div class="product-header"> | |
| 10 | - <span class="product-span">组件</span> | ||
| 7 | + <span class="product-span">{{ asideMenu.title }}</span> | ||
| 11 | 8 | </div> | |
| 12 | 9 | <el-container class="product-container"> | |
| 13 | - <el-aside | ||
| 14 | - class="aside-scroll-content" | ||
| 15 | - > | ||
| 16 | - <el-scrollbar | ||
| 17 | - class="element-scroll-content" | ||
| 18 | - wrapStyle="overflow-x: hidden;" | ||
| 19 | - viewStyle="overflow-y: hidden;" | ||
| 20 | - > | ||
| 10 | + <el-aside class="aside-scroll-content"> | ||
| 11 | + <el-scrollbar class="element-scroll-content" wrapStyle="overflow-x: hidden;" viewStyle="overflow-y: hidden;"> | ||
| 21 | 12 | <div class="header-menu-col"> | |
| 22 | 13 | <span class="strong">{{ asideMenu.title }}</span> | |
| 23 | - <div class="header-menu-links" v-for="(link, i) in asideMenu.links" :key="i"> | ||
| 24 | - <div class="header-menu-link" v-for="(l, j) in link" :key="j"> | ||
| 25 | - <div class="header-menu-link-text"> | ||
| 26 | - <el-badge type="success" :value="asideMenu.hightlights[i][j] ? hint : ''" class="menu-badge"> | ||
| 27 | - <a class="header-menu-link-text" :href="asideMenu.routes[i][j]"> | ||
| 28 | - <span :class="{ 'light-subtitle': light }">{{ l }}</span> | ||
| 29 | - </a> | ||
| 30 | - </el-badge> | ||
| 31 | - </div> | ||
| 32 | - </div> | ||
| 14 | + <div class="header-menu-col"> | ||
| 15 | + <div id="develop-markdown-toc"></div> | ||
| 33 | 16 | </div> | |
| 34 | 17 | </div> | |
| 35 | 18 | </el-scrollbar> | |
@@ -40,9 +23,14 @@ | |||
| 40 | 23 | :style="{padding: '2px 1vw'}" | |
| 41 | 24 | :source="markdown" | |
| 42 | 25 | :html="true" | |
| 43 | - :toc="false" | ||
| 26 | + :toc="true" | ||
| 27 | + :toc-first-level="2" | ||
| 28 | + toc-id="develop-markdown-toc" | ||
| 29 | + toc-class="mapgis-toc-class" | ||
| 30 | + :toc-anchor-link="true" | ||
| 44 | 31 | :linkify="true" | |
| 45 | 32 | @rendered="markdownRendered" | |
| 33 | + @toc-rendered="tocRendered" | ||
| 46 | 34 | ></vue-markdown> | |
| 47 | 35 | <el-backtop></el-backtop> | |
| 48 | 36 | </el-main> | |
@@ -74,7 +62,10 @@ export default { | |||
| 74 | 62 | asideMenu: "", | |
| 75 | 63 | light: true, | |
| 76 | 64 | hint: '新', | |
| 77 | - markdown: "> `暂无说明`, 请检查改目录下的帮助说明是否存在", | ||
| 65 | + markdown: "> `暂无说明`, 请检查该目录下的帮助说明是否存在", | ||
| 66 | + mode: "", | ||
| 67 | + isContentFinish: false, | ||
| 68 | + isTocFinish: false | ||
| 78 | 69 | } | |
| 79 | 70 | }, | |
| 80 | 71 | components: { | |
@@ -84,20 +75,51 @@ export default { | |||
| 84 | 75 | }, | |
| 85 | 76 | mounted() { | |
| 86 | 77 | this.initConfig(); | |
| 78 | + this.initScroll(); | ||
| 79 | + }, | ||
| 80 | + watch: { | ||
| 81 | + "$route.path"() { | ||
| 82 | + this.initConfig(); | ||
| 83 | + } | ||
| 87 | 84 | }, | |
| 88 | 85 | methods: { | |
| 86 | + initScroll() { | ||
| 87 | + /** | ||
| 88 | + * 目标元素和视窗viewport的交集的变化的方法API | ||
| 89 | + * @type {IntersectionObserver} | ||
| 90 | + */ | ||
| 91 | + const observer = new IntersectionObserver((entries) => { | ||
| 92 | + entries.forEach((entry) => { | ||
| 93 | + let id = entry.target.getAttribute('id'); | ||
| 94 | + id = encodeURI(id); | ||
| 95 | + //intersectionRatio:目标元素出现在视窗的比例 | ||
| 96 | + if (entry.intersectionRatio > 0) { | ||
| 97 | + document.querySelector(`li a[href="#${id}"]`).parentElement.classList.add('active'); | ||
| 98 | + } else { | ||
| 99 | + document.querySelector(`li a[href="#${id}"]`).parentElement.classList.remove('active'); | ||
| 100 | + } | ||
| 101 | + }); | ||
| 102 | + }); | ||
| 103 | + //observer.observe():监听当前所有的h2[id] | ||
| 104 | + document.querySelectorAll('h2[id]').forEach((section) => { | ||
| 105 | + observer.observe(section); | ||
| 106 | + }); | ||
| 107 | + document.querySelectorAll('h3[id]').forEach((section) => { | ||
| 108 | + observer.observe(section); | ||
| 109 | + }); | ||
| 110 | + }, | ||
| 89 | 111 | initConfig() { | |
| 90 | 112 | let anchors = location.href.split("#"); | |
| 91 | 113 | if (!anchors || anchors.length < 2) return; | |
| 92 | 114 | ||
| 93 | 115 | let hrefs = anchors[1].split("/").slice(2); | |
| 94 | - let mode = this.getMapMode(); | ||
| 116 | + this.mode = this.getMapMode(); | ||
| 95 | 117 | let file = hrefs[hrefs.length - 1]; | |
| 96 | 118 | let first; | |
| 97 | 119 | if (hrefs.length <= 3) { | |
| 98 | 120 | first = hrefs[hrefs.length - 3]; | |
| 99 | 121 | } | |
| 100 | - this.resetHtml(mode, file, first); | ||
| 122 | + this.resetHtml(this.mode, file, first); | ||
| 101 | 123 | this.getAsideList(); | |
| 102 | 124 | }, | |
| 103 | 125 | getMapMode() { | |
@@ -138,24 +160,69 @@ export default { | |||
| 138 | 160 | axios.get(asideUrl).then(response => { | |
| 139 | 161 | let temp = response.data; | |
| 140 | 162 | for (let i in temp) { | |
| 141 | - if ("组件" === (temp[i].title).toLowerCase()) { | ||
| 163 | + if (self.mode === "component") { | ||
| 164 | + self.mode = "组件"; | ||
| 165 | + } | ||
| 166 | + if (self.mode === (temp[i].title).toLowerCase()) { | ||
| 142 | 167 | self.asideContent = temp[i]; | |
| 143 | 168 | break; | |
| 144 | 169 | } | |
| 145 | 170 | } | |
| 146 | 171 | self.asideMenu = self.asideContent.menus[0]; | |
| 147 | 172 | }); | |
| 148 | 173 | }, | |
| 174 | + /** | ||
| 175 | + * @rendered: markdown内容已渲染完毕时调用下面方法 | ||
| 176 | + */ | ||
| 149 | 177 | markdownRendered() { | |
| 178 | + this.isContentFinish = true; | ||
| 179 | + if (this.isTocFinish && this.isContentFinish) { | ||
| 180 | + this.initScroll(); | ||
| 181 | + } | ||
| 150 | 182 | this.$nextTick(() => { | |
| 151 | 183 | Prism.highlightAll(); | |
| 152 | 184 | }); | |
| 153 | 185 | }, | |
| 186 | + /** | ||
| 187 | + * @toc-rendered: toc目录渲染完成时调用下面方法 | ||
| 188 | + */ | ||
| 189 | + tocRendered() { | ||
| 190 | + this.isTocFinish = true; | ||
| 191 | + if (this.isTocFinish && this.isContentFinish) { | ||
| 192 | + this.initScroll(); | ||
| 193 | + } | ||
| 194 | + } | ||
| 154 | 195 | } | |
| 155 | 196 | } | |
| 156 | 197 | </script> | |
| 157 | 198 | ||
| 158 | - <style scoped lang="scss"> | ||
| 199 | + <style lang="scss"> | ||
| 200 | + .mapgis-product-wrapper { | ||
| 201 | + .mapgis-toc-class { | ||
| 202 | + ul { | ||
| 203 | + list-style-type: none; | ||
| 204 | + padding-left: 16px; | ||
| 205 | + margin: 8px 0px; | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + li { | ||
| 209 | + list-style-type: none; | ||
| 210 | + margin: 8px 0px; | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + a { | ||
| 214 | + color: #3f454d; | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + .active { | ||
| 218 | + border-left: 3px solid #000000; | ||
| 219 | + padding-left: 6px; | ||
| 220 | + color: #000000; | ||
| 221 | + font-weight: bold; | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + | ||
| 159 | 226 | .product-header { | |
| 160 | 227 | padding: 0; | |
| 161 | 228 | height: 240px !important; | |
@@ -209,10 +276,12 @@ export default { | |||
| 209 | 276 | .light-subtitle { | |
| 210 | 277 | color: #3C4858 !important; | |
| 211 | 278 | } | |
| 212 | - .header-menu-link{ | ||
| 279 | + | ||
| 280 | + .header-menu-link { | ||
| 213 | 281 | margin: 4px 0px; | |
| 214 | 282 | width: fit-content; | |
| 215 | 283 | height: fit-content; | |
| 284 | + | ||
| 216 | 285 | span { | |
| 217 | 286 | width: 60px; | |
| 218 | 287 | height: 14px; | |
@@ -222,7 +291,12 @@ export default { | |||
| 222 | 291 | line-height: 30px; | |
| 223 | 292 | } | |
| 224 | 293 | } | |
| 225 | - .header-menu-col{ | ||
| 226 | - padding: 5px 90px; | ||
| 294 | + | ||
| 295 | + .header-menu-col { | ||
| 296 | + padding: 5px 5px; | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + #develop-markdown-toc { | ||
| 300 | + width: fit-content; | ||
| 227 | 301 | } | |
| 228 | 302 | </style> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments