|
|
@@ -3,8 +3,13 @@
|
|
|
<doc-header></doc-header>
|
|
|
<doc-nav></doc-nav>
|
|
|
<div class="doc-content">
|
|
|
- <div class="doc-content-document">
|
|
|
- <!-- <doc-issue></doc-issue> -->
|
|
|
+ <div class="doc-title" v-if="isShow()">
|
|
|
+ <div class="doc-title-position" :class="{ fixed: fixed, hidden: hidden }">
|
|
|
+ <div class="title">{{ componentName.name }} {{ componentName.cName }}</div>
|
|
|
+ <doc-issue class=""></doc-issue>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="doc-content-document" :class="{ isComponent: isShow() }">
|
|
|
<div class="doc-content-tabs" v-if="isShow() && isShowTaroDoc">
|
|
|
<div
|
|
|
class="tab-item"
|
|
|
@@ -15,14 +20,12 @@
|
|
|
>{{ item.text }}</div
|
|
|
>
|
|
|
</div>
|
|
|
- <div class="doc-content-tabs" v-if="isShow() && !isShowTaroDoc">
|
|
|
- <div class="tab-item cur">vue/taro</div>
|
|
|
+ <div class="doc-content-tabs single" v-if="isShow() && !isShowTaroDoc">
|
|
|
+ <div class="tab-item cur">vue / taro</div>
|
|
|
</div>
|
|
|
<router-view />
|
|
|
</div>
|
|
|
- <!-- <doc-issue class="fixed"></doc-issue> -->
|
|
|
- <!-- <doc-issue class="vertical"></doc-issue> -->
|
|
|
- <doc-demo-preview :url="demoUrl"></doc-demo-preview>
|
|
|
+ <doc-demo-preview v-if="isShow()" :url="demoUrl" :class="{ fixed: fixed }"></doc-demo-preview>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -49,6 +52,15 @@ export default defineComponent({
|
|
|
const router = useRouter();
|
|
|
initSiteLang();
|
|
|
const excludeTaro = ['/intro', '/start', '/theme', '/joinus', '/starttaro', '/contributing'];
|
|
|
+ const state = reactive({
|
|
|
+ fixed: false, // 是否吸顶
|
|
|
+ hidden: false, // 是否隐藏
|
|
|
+ // 组件名称
|
|
|
+ componentName: {
|
|
|
+ name: '',
|
|
|
+ cName: ''
|
|
|
+ }
|
|
|
+ });
|
|
|
const data = reactive({
|
|
|
demoUrl: 'demo.html',
|
|
|
curKey: 'vue',
|
|
|
@@ -83,7 +95,8 @@ export default defineComponent({
|
|
|
};
|
|
|
|
|
|
const isShow = () => {
|
|
|
- return !excludeTaro.includes(route.path);
|
|
|
+ // return !excludeTaro.includes(route.path);
|
|
|
+ return route.path != '/zh-CN/';
|
|
|
};
|
|
|
|
|
|
const isShowTaroDoc = computed(() => {
|
|
|
@@ -97,27 +110,70 @@ export default defineComponent({
|
|
|
data.demoUrl = url.replace('/zh-CN', '').replace('/en-US', '');
|
|
|
};
|
|
|
|
|
|
- const watchDocMd = () => {
|
|
|
+ const watchDocMd = (curKey: string) => {
|
|
|
const path = route.path;
|
|
|
- router.replace(isTaro(route) ? path.substr(0, path.length - 5) : `${path}-taro`);
|
|
|
+ // router.replace(isTaro(route) ? path.substr(0, path.length - 5) : `${path}-taro`);
|
|
|
+ if (curKey.includes('taro')) {
|
|
|
+ router.replace(isTaro(route) ? path : `${path}-taro`);
|
|
|
+ } else {
|
|
|
+ router.replace(isTaro(route) ? path.substr(0, path.length - 5) : path);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
const handleTabs = (curKey: string) => {
|
|
|
data.curKey = curKey;
|
|
|
- watchDocMd();
|
|
|
+ watchDocMd(curKey);
|
|
|
};
|
|
|
|
|
|
onMounted(() => {
|
|
|
+ componentTitle();
|
|
|
watchDemoUrl(route);
|
|
|
data.curKey = isTaro(route) ? 'taro' : 'vue';
|
|
|
+ document.addEventListener('scroll', scrollTitle);
|
|
|
});
|
|
|
|
|
|
+ const scrollTitle = () => {
|
|
|
+ let top = document.documentElement.scrollTop;
|
|
|
+ // console.log('state.hidden', state.hidden)
|
|
|
+ if (top > 127) {
|
|
|
+ state.fixed = true;
|
|
|
+ if (top < 142) {
|
|
|
+ state.hidden = true;
|
|
|
+ } else {
|
|
|
+ state.hidden = false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ state.fixed = false;
|
|
|
+ state.hidden = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获得组件名称
|
|
|
+ const componentTitle = (to?: any) => {
|
|
|
+ if (to?.path) {
|
|
|
+ state.componentName.name = to.path.split('/zh-CN/')[1];
|
|
|
+ } else {
|
|
|
+ state.componentName.name = route.path.split('/zh-CN/')[1];
|
|
|
+ }
|
|
|
+ nav.forEach((item: any) => {
|
|
|
+ item.packages.forEach((sItem: any) => {
|
|
|
+ if (sItem.name.toLowerCase() == state.componentName.name) {
|
|
|
+ state.componentName.name = sItem.name;
|
|
|
+ state.componentName.cName = sItem.cName;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
onBeforeRouteUpdate((to) => {
|
|
|
watchDemoUrl(to);
|
|
|
data.curKey = isTaro(to) ? 'taro' : 'vue';
|
|
|
+ componentTitle(to);
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
+ ...toRefs(state),
|
|
|
...toRefs(data),
|
|
|
handleTabs,
|
|
|
isShow,
|
|
|
@@ -128,6 +184,7 @@ export default defineComponent({
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+$doc-title-height: 137px;
|
|
|
.doc {
|
|
|
&-content {
|
|
|
margin-left: 290px;
|
|
|
@@ -136,42 +193,116 @@ export default defineComponent({
|
|
|
|
|
|
&-document {
|
|
|
min-height: 800px;
|
|
|
+
|
|
|
+ .markdown-body {
|
|
|
+ min-height: 600px;
|
|
|
+ }
|
|
|
}
|
|
|
&-tabs {
|
|
|
position: absolute;
|
|
|
- right: 445px;
|
|
|
+ right: 475px;
|
|
|
top: 48px;
|
|
|
display: flex;
|
|
|
- height: 50px;
|
|
|
+ height: 40px;
|
|
|
align-items: center;
|
|
|
- margin-bottom: 20px;
|
|
|
+ justify-content: space-between;
|
|
|
z-index: 1;
|
|
|
+ padding: 2px;
|
|
|
+ box-sizing: border-box;
|
|
|
+
|
|
|
+ border-radius: 2px;
|
|
|
+ background: #eee;
|
|
|
+ box-shadow: rgb(0 0 0 / 15%) 0px 2px 4px;
|
|
|
+ &.single {
|
|
|
+ padding: 0;
|
|
|
+ .tab-item {
|
|
|
+ line-height: 40px;
|
|
|
+ cursor: auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
.tab-item {
|
|
|
position: relative;
|
|
|
- padding: 10px 25px;
|
|
|
- height: 100%;
|
|
|
+ padding: 0 10px;
|
|
|
+ line-height: 36px;
|
|
|
cursor: pointer;
|
|
|
font-size: 16px;
|
|
|
color: #323232;
|
|
|
text-align: center;
|
|
|
- border-radius: 4px;
|
|
|
+ border-radius: 2px;
|
|
|
+ background: #eee;
|
|
|
&.cur {
|
|
|
- color: #fa2c19;
|
|
|
- &:after {
|
|
|
- content: ' ';
|
|
|
- position: absolute;
|
|
|
- bottom: 0;
|
|
|
- left: 0;
|
|
|
- width: 100%;
|
|
|
- height: 3px;
|
|
|
- background-color: #fa2c19;
|
|
|
- }
|
|
|
+ font-weight: bold;
|
|
|
+ color: #323232;
|
|
|
+ background: #fff;
|
|
|
}
|
|
|
- &:hover {
|
|
|
- background-color: #f7f8fa;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ &-contributors {
|
|
|
+ margin: 50px 0;
|
|
|
+ a {
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ img {
|
|
|
+ height: 26px;
|
|
|
+ height: 26px;
|
|
|
+ border-radius: 50%;
|
|
|
+ margin-left: 8px;
|
|
|
+ }
|
|
|
+ .contributors-hover {
|
|
|
+ display: none;
|
|
|
+ padding: 5px 10px;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 12px;
|
|
|
+ background-color: #000;
|
|
|
+ border-radius: 5px;
|
|
|
+ position: absolute;
|
|
|
+ /* min-width:150px; */
|
|
|
+ white-space: nowrap;
|
|
|
+ top: -200%;
|
|
|
+ transform: translateX(-55%);
|
|
|
+ }
|
|
|
+ a:hover {
|
|
|
+ .contributors-hover {
|
|
|
+ display: inline-block;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ &-title {
|
|
|
+ width: 100%;
|
|
|
+ height: $doc-title-height;
|
|
|
+ z-index: 2;
|
|
|
+ &-position {
|
|
|
+ top: 0px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 40px;
|
|
|
+ // line-height: 56px;
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
+ background: #fff;
|
|
|
+ visibility: visible;
|
|
|
+ opacity: 1;
|
|
|
+ // transition: opacity 0.8s linear, visibility 0.8s linear;
|
|
|
+ transition: opacity 0.8s;
|
|
|
+ &.fixed {
|
|
|
+ width: calc(100% - 290px);
|
|
|
+ position: fixed;
|
|
|
+ padding: 24px 48px;
|
|
|
+ .title {
|
|
|
+ font-size: 24px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ &.hidden {
|
|
|
+ visibility: hidden;
|
|
|
+ opacity: 0;
|
|
|
+ }
|
|
|
+ .title {
|
|
|
+ font-size: 40px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|