2016-11-09 19:15:25 +08:00
|
|
|
<style>
|
2017-09-30 15:50:04 +08:00
|
|
|
.page-component__scroll {
|
|
|
|
height: calc(100% - 80px);
|
|
|
|
margin-top: 80px;
|
|
|
|
|
|
|
|
.el-scrollbar__wrap {
|
|
|
|
overflow-x: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-09 19:15:25 +08:00
|
|
|
.page-component {
|
2016-11-18 16:49:07 +08:00
|
|
|
box-sizing: border-box;
|
2017-09-29 11:36:38 +08:00
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
&.page-container {
|
|
|
|
padding: 0;
|
|
|
|
}
|
2017-09-30 15:50:04 +08:00
|
|
|
|
2017-09-29 11:36:38 +08:00
|
|
|
.page-component__nav {
|
|
|
|
width: 240px;
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
2017-09-30 15:50:04 +08:00
|
|
|
margin-top: 80px;
|
2017-09-29 11:36:38 +08:00
|
|
|
transition: padding-top .3s;
|
2017-09-30 15:50:04 +08:00
|
|
|
|
|
|
|
.el-scrollbar__wrap {
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
2017-09-29 11:36:38 +08:00
|
|
|
&.is-extended {
|
|
|
|
padding-top: 0;
|
|
|
|
}
|
|
|
|
}
|
2017-09-30 15:50:04 +08:00
|
|
|
|
2017-09-29 11:36:38 +08:00
|
|
|
.side-nav {
|
|
|
|
height: 100%;
|
|
|
|
padding-top: 50px;
|
|
|
|
padding-bottom: 50px;
|
|
|
|
padding-right: 0;
|
2017-09-30 15:50:04 +08:00
|
|
|
|
2017-09-29 11:36:38 +08:00
|
|
|
& > ul {
|
|
|
|
padding-bottom: 50px;
|
|
|
|
}
|
|
|
|
}
|
2017-03-24 15:38:31 +08:00
|
|
|
|
2017-09-29 11:36:38 +08:00
|
|
|
.page-component__content {
|
|
|
|
padding-left: 270px;
|
2017-09-29 19:34:35 +08:00
|
|
|
padding-bottom: 100px;
|
2017-09-30 15:50:04 +08:00
|
|
|
box-sizing: border-box;
|
2017-09-29 11:36:38 +08:00
|
|
|
}
|
2017-09-30 15:50:04 +08:00
|
|
|
|
2017-09-29 11:36:38 +08:00
|
|
|
.content {
|
2017-09-30 15:50:04 +08:00
|
|
|
padding-top: 50px;
|
|
|
|
|
2016-11-09 19:15:25 +08:00
|
|
|
> {
|
|
|
|
h3 {
|
2017-09-29 15:37:50 +08:00
|
|
|
margin: 55px 0 20px;
|
2016-11-09 19:15:25 +08:00
|
|
|
}
|
2017-09-28 20:15:00 +08:00
|
|
|
|
2016-11-09 19:15:25 +08:00
|
|
|
table {
|
|
|
|
border-collapse: collapse;
|
|
|
|
width: 100%;
|
|
|
|
background-color: #fff;
|
|
|
|
font-size: 14px;
|
|
|
|
margin-bottom: 45px;
|
2017-03-24 15:38:31 +08:00
|
|
|
line-height: 1.5em;
|
|
|
|
|
2016-11-09 19:15:25 +08:00
|
|
|
strong {
|
|
|
|
font-weight: normal;
|
|
|
|
}
|
2017-09-28 20:15:00 +08:00
|
|
|
|
|
|
|
td, th {
|
2019-01-23 11:34:19 +08:00
|
|
|
border-bottom: 1px solid #dcdfe6;
|
2017-09-28 20:15:00 +08:00
|
|
|
padding: 15px;
|
|
|
|
max-width: 250px;
|
|
|
|
}
|
|
|
|
|
2016-11-09 19:15:25 +08:00
|
|
|
th {
|
|
|
|
text-align: left;
|
2016-12-13 22:52:29 +08:00
|
|
|
white-space: nowrap;
|
2019-01-23 11:34:19 +08:00
|
|
|
color: #909399;
|
2017-09-28 20:15:00 +08:00
|
|
|
font-weight: normal;
|
2016-11-09 19:15:25 +08:00
|
|
|
}
|
2017-09-28 20:15:00 +08:00
|
|
|
|
|
|
|
td {
|
2019-01-23 11:34:19 +08:00
|
|
|
color: #606266;
|
2016-11-09 19:15:25 +08:00
|
|
|
}
|
2017-09-28 20:15:00 +08:00
|
|
|
|
2016-11-09 19:15:25 +08:00
|
|
|
th:first-child, td:first-child {
|
|
|
|
padding-left: 10px;
|
|
|
|
}
|
|
|
|
}
|
2017-09-28 20:15:00 +08:00
|
|
|
|
|
|
|
ul:not(.timeline) {
|
2017-07-24 19:09:36 +08:00
|
|
|
margin: 10px 0;
|
|
|
|
padding: 0 0 0 20px;
|
|
|
|
font-size: 14px;
|
|
|
|
color: #5e6d82;
|
|
|
|
line-height: 2em;
|
|
|
|
}
|
2016-11-09 19:15:25 +08:00
|
|
|
}
|
|
|
|
}
|
2017-09-30 15:50:04 +08:00
|
|
|
|
2017-03-06 18:51:37 +08:00
|
|
|
.page-component-up {
|
2017-09-29 19:34:35 +08:00
|
|
|
background-color: #fff;
|
2017-03-06 18:51:37 +08:00
|
|
|
position: fixed;
|
|
|
|
right: 100px;
|
|
|
|
bottom: 150px;
|
2019-03-01 18:35:08 +08:00
|
|
|
width: 40px;
|
|
|
|
height: 40px;
|
2017-09-29 19:34:35 +08:00
|
|
|
size: 40px;
|
|
|
|
border-radius: 20px;
|
2017-03-06 18:51:37 +08:00
|
|
|
cursor: pointer;
|
|
|
|
transition: .3s;
|
2017-09-29 19:34:35 +08:00
|
|
|
box-shadow: 0 0 6px rgba(0,0,0, .12);
|
2017-12-25 21:16:40 +08:00
|
|
|
z-index: 5;
|
2017-09-29 19:34:35 +08:00
|
|
|
|
2017-03-06 18:51:37 +08:00
|
|
|
i {
|
2017-09-30 15:50:04 +08:00
|
|
|
color: #409EFF;
|
2017-03-06 18:51:37 +08:00
|
|
|
display: block;
|
2017-09-29 19:34:35 +08:00
|
|
|
line-height: 40px;
|
2017-03-06 18:51:37 +08:00
|
|
|
text-align: center;
|
2017-10-18 16:12:54 +08:00
|
|
|
font-size: 18px;
|
2017-03-06 18:51:37 +08:00
|
|
|
}
|
2017-09-29 19:34:35 +08:00
|
|
|
|
2017-03-06 18:51:37 +08:00
|
|
|
&.hover {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.back-top-fade-enter,
|
|
|
|
.back-top-fade-leave-active {
|
|
|
|
transform: translateY(-30px);
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2016-11-09 19:15:25 +08:00
|
|
|
}
|
2017-10-03 16:46:07 +08:00
|
|
|
|
2019-02-28 16:00:59 +08:00
|
|
|
@media (min-width: 1140px) {
|
|
|
|
.page-component__content {
|
|
|
|
transition:padding-right 0.3s ease;
|
|
|
|
&.theme-config {
|
|
|
|
padding-right: 26%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.page-container.page-component {
|
2019-03-01 18:35:08 +08:00
|
|
|
transition:all 0.3s ease;
|
2019-02-28 16:00:59 +08:00
|
|
|
&.theme-config {
|
|
|
|
width: 98%;
|
2019-03-01 18:35:08 +08:00
|
|
|
.page-component__nav {
|
|
|
|
animation-delay: 1s;
|
|
|
|
padding-left: 2%;
|
|
|
|
}
|
2019-02-28 16:00:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (min-width: 1600px) {
|
|
|
|
.page-component__content {
|
|
|
|
&.theme-config {
|
|
|
|
padding-right: 25%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.page-container.page-component {
|
|
|
|
&.theme-config {
|
|
|
|
width: 1600px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-03 16:46:07 +08:00
|
|
|
@media (max-width: 768px) {
|
|
|
|
.page-component {
|
|
|
|
.page-component__nav {
|
|
|
|
width: 100%;
|
|
|
|
position: static;
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
|
|
|
.side-nav {
|
|
|
|
padding-top: 0;
|
|
|
|
padding-left: 50px;
|
|
|
|
}
|
|
|
|
.page-component__content {
|
|
|
|
padding-left: 10px;
|
|
|
|
padding-right: 10px;
|
|
|
|
}
|
|
|
|
.content {
|
|
|
|
padding-top: 0;
|
|
|
|
}
|
|
|
|
.content > table {
|
|
|
|
overflow: auto;
|
|
|
|
display: block;
|
|
|
|
}
|
2017-10-16 14:07:24 +08:00
|
|
|
.page-component-up {
|
|
|
|
display: none;
|
|
|
|
}
|
2017-10-03 16:46:07 +08:00
|
|
|
}
|
|
|
|
}
|
2016-11-09 19:15:25 +08:00
|
|
|
</style>
|
|
|
|
<template>
|
2017-09-30 15:50:04 +08:00
|
|
|
<el-scrollbar class="page-component__scroll" ref="componentScrollBar">
|
2019-02-28 16:00:59 +08:00
|
|
|
<div class="page-container page-component" :class="{'theme-config': isThemeConfigVisible}">
|
2017-09-30 15:50:04 +08:00
|
|
|
<el-scrollbar class="page-component__nav">
|
2017-09-29 11:36:38 +08:00
|
|
|
<side-nav :data="navsData[lang]" :base="`/${ lang }/component`"></side-nav>
|
2017-09-30 15:50:04 +08:00
|
|
|
</el-scrollbar>
|
2019-02-28 16:00:59 +08:00
|
|
|
<div class="page-component__content" :class="{'theme-config': isThemeConfigVisible}">
|
2017-09-29 11:36:38 +08:00
|
|
|
<router-view class="content"></router-view>
|
|
|
|
<footer-nav></footer-nav>
|
|
|
|
</div>
|
2017-03-06 18:51:37 +08:00
|
|
|
<transition name="back-top-fade">
|
|
|
|
<div
|
|
|
|
class="page-component-up"
|
|
|
|
:class="{ 'hover': hover }"
|
|
|
|
v-show="showBackToTop"
|
|
|
|
@mouseenter="hover = true"
|
|
|
|
@mouseleave="hover = false"
|
|
|
|
@click="toTop">
|
|
|
|
<i class="el-icon-caret-top"></i>
|
|
|
|
</div>
|
|
|
|
</transition>
|
2016-11-09 19:15:25 +08:00
|
|
|
</div>
|
2017-09-30 15:50:04 +08:00
|
|
|
</el-scrollbar>
|
2016-11-09 19:15:25 +08:00
|
|
|
</template>
|
|
|
|
<script>
|
2017-09-29 11:36:38 +08:00
|
|
|
import bus from '../../bus';
|
2016-11-09 19:15:25 +08:00
|
|
|
import navsData from '../../nav.config.json';
|
2017-03-06 18:51:37 +08:00
|
|
|
import throttle from 'throttle-debounce/throttle';
|
2017-09-28 20:15:00 +08:00
|
|
|
|
2016-11-09 19:15:25 +08:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
lang: this.$route.meta.lang,
|
2017-03-06 18:51:37 +08:00
|
|
|
navsData,
|
|
|
|
hover: false,
|
2017-09-29 11:36:38 +08:00
|
|
|
showBackToTop: false,
|
|
|
|
scrollTop: 0,
|
2017-09-30 15:50:04 +08:00
|
|
|
showHeader: true,
|
|
|
|
componentScrollBar: null,
|
2019-02-28 16:00:59 +08:00
|
|
|
componentScrollBoxElement: null,
|
|
|
|
isThemeConfigVisible: false
|
2016-11-09 19:15:25 +08:00
|
|
|
};
|
2017-03-06 18:51:37 +08:00
|
|
|
},
|
2017-09-30 15:50:04 +08:00
|
|
|
watch: {
|
|
|
|
'$route.path'() {
|
|
|
|
// 触发伪滚动条更新
|
|
|
|
this.componentScrollBox.scrollTop = 0;
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.componentScrollBar.update();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2017-03-06 18:51:37 +08:00
|
|
|
methods: {
|
2017-10-09 17:34:29 +08:00
|
|
|
renderAnchorHref() {
|
|
|
|
if (/changelog/g.test(location.href)) return;
|
2018-12-14 11:14:46 +08:00
|
|
|
const anchors = document.querySelectorAll('h2 a,h3 a,h4 a,h5 a');
|
2017-10-09 17:34:29 +08:00
|
|
|
const basePath = location.href.split('#').splice(0, 2).join('#');
|
|
|
|
|
|
|
|
[].slice.call(anchors).forEach(a => {
|
|
|
|
const href = a.getAttribute('href');
|
|
|
|
a.href = basePath + href;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
goAnchor() {
|
|
|
|
if (location.href.match(/#/g).length > 1) {
|
|
|
|
const anchor = location.href.match(/#[^#]+$/g);
|
|
|
|
if (!anchor) return;
|
|
|
|
const elm = document.querySelector(anchor[0]);
|
|
|
|
if (!elm) return;
|
|
|
|
|
|
|
|
setTimeout(_ => {
|
|
|
|
this.componentScrollBox.scrollTop = elm.offsetTop;
|
|
|
|
}, 50);
|
|
|
|
}
|
|
|
|
},
|
2017-03-06 18:51:37 +08:00
|
|
|
toTop() {
|
|
|
|
this.hover = false;
|
|
|
|
this.showBackToTop = false;
|
2017-09-30 18:13:26 +08:00
|
|
|
this.componentScrollBox.scrollTop = 0;
|
2017-03-06 18:51:37 +08:00
|
|
|
},
|
2017-10-09 17:34:29 +08:00
|
|
|
|
2017-03-06 18:51:37 +08:00
|
|
|
handleScroll() {
|
2017-09-30 18:13:26 +08:00
|
|
|
const scrollTop = this.componentScrollBox.scrollTop;
|
2017-09-29 11:36:38 +08:00
|
|
|
this.showBackToTop = scrollTop >= 0.5 * document.body.clientHeight;
|
|
|
|
if (this.showHeader !== this.scrollTop > scrollTop) {
|
|
|
|
this.showHeader = this.scrollTop > scrollTop;
|
|
|
|
}
|
|
|
|
if (scrollTop === 0) {
|
|
|
|
this.showHeader = true;
|
|
|
|
}
|
2017-09-29 15:37:50 +08:00
|
|
|
if (!this.navFaded) {
|
|
|
|
bus.$emit('fadeNav');
|
|
|
|
}
|
2017-09-29 11:36:38 +08:00
|
|
|
this.scrollTop = scrollTop;
|
2017-03-06 18:51:37 +08:00
|
|
|
}
|
|
|
|
},
|
2017-09-29 15:37:50 +08:00
|
|
|
created() {
|
|
|
|
bus.$on('navFade', val => {
|
|
|
|
this.navFaded = val;
|
|
|
|
});
|
2019-02-28 16:00:59 +08:00
|
|
|
bus.$on('user-theme-config-visible', val => {
|
|
|
|
this.isThemeConfigVisible = val;
|
|
|
|
});
|
2017-10-09 17:34:29 +08:00
|
|
|
window.addEventListener('hashchange', () => {
|
|
|
|
if (location.href.match(/#/g).length < 2) {
|
|
|
|
document.documentElement.scrollTop = document.body.scrollTop = 0;
|
|
|
|
this.renderAnchorHref();
|
|
|
|
} else {
|
|
|
|
this.goAnchor();
|
|
|
|
}
|
|
|
|
});
|
2017-09-29 15:37:50 +08:00
|
|
|
},
|
2017-03-06 18:51:37 +08:00
|
|
|
mounted() {
|
2019-02-28 16:00:59 +08:00
|
|
|
if (window.userThemeConfigVisible) {
|
|
|
|
this.isThemeConfigVisible = window.userThemeConfigVisible;
|
|
|
|
}
|
2017-09-30 15:50:04 +08:00
|
|
|
this.componentScrollBar = this.$refs.componentScrollBar;
|
|
|
|
this.componentScrollBox = this.componentScrollBar.$el.querySelector('.el-scrollbar__wrap');
|
2017-03-06 18:51:37 +08:00
|
|
|
this.throttledScrollHandler = throttle(300, this.handleScroll);
|
2017-09-30 15:50:04 +08:00
|
|
|
this.componentScrollBox.addEventListener('scroll', this.throttledScrollHandler);
|
2017-10-09 17:34:29 +08:00
|
|
|
this.renderAnchorHref();
|
|
|
|
this.goAnchor();
|
2017-10-09 10:42:42 +08:00
|
|
|
document.body.classList.add('is-component');
|
|
|
|
},
|
|
|
|
destroyed() {
|
|
|
|
document.body.classList.remove('is-component');
|
2017-03-06 18:51:37 +08:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2017-09-30 15:50:04 +08:00
|
|
|
this.componentScrollBox.removeEventListener('scroll', this.throttledScrollHandler);
|
2016-11-09 19:15:25 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|