Skip to content

Commit

Permalink
feat: 实现首页TopBar分离
Browse files Browse the repository at this point in the history
  • Loading branch information
oustr committed Aug 2, 2023
1 parent 00de49a commit 5c24763
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 38 deletions.
34 changes: 34 additions & 0 deletions src/components/TopBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<view class="nav-bar" :style="{ height: navBarHeight + 'px' }">
<view class="top-bar" :style="{ height: topBarHeight + 'px' }"></view>
<view class="capsule-bar" :style="{ height: capsuleBarHeight + 'px' }">
<slot></slot>
</view>
</view>
<view :style="{ height: navBarHeight + 'px' }"></view>
</template>

<script setup lang="ts">
const topBarHeight = uni.getSystemInfoSync().statusBarHeight as number;
const capsuleData = uni.getMenuButtonBoundingClientRect();
const capsuleBarHeight =
capsuleData.height + (capsuleData.top - topBarHeight) * 2;
const navBarHeight = topBarHeight + capsuleBarHeight;
</script>

<style scoped lang="scss">
.nav-bar {
position: fixed;
background-color: #fafcff;
width: 100vw;
z-index: 100;
}
.top-bar {
width: 100vw;
}
.capsule-bar {
width: 100vw;
display: flex;
align-items: center;
}
</style>
7 changes: 0 additions & 7 deletions src/components/top-bar/top-bar.vue

This file was deleted.

44 changes: 13 additions & 31 deletions src/pages/community/community.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
<template>
<view class="nav-bar" :style="{ height: navBarHeight + 'px' }">
<view class="top-bar" :style="{ height: topBarHeight + 'px' }"></view>
<view class="capsule-bar" :style="{ height: capsuleBarHeight + 'px' }">
<view class="school-box">
<view class="school-select-box">
<image class="arrow" :src="Icons.Location" @click="onClickSwitch" />
<view class="names" @click="onClickSwitch">
<view class="school-name">
{{ currentSchool }}
</view>
<view v-if="currentSchool !== currentCampus" class="campus-name">
({{ currentCampus }})</view
>
<view v-else class="campus-name"></view>
<TopBar bg-color="#fafcff">
<view class="school-box">
<view class="school-select-box">
<image class="arrow" :src="Icons.Location" @click="onClickSwitch" />
<view class="names" @click="onClickSwitch">
<view class="school-name">
{{ currentSchool }}
</view>
<view v-if="currentSchool !== currentCampus" class="campus-name">
({{ currentCampus }})</view
>
<view v-else class="campus-name"></view>
</view>
</view>
</view>
</view>
<view :style="{ height: navBarHeight + 'px' }"></view>
</TopBar>

<view class="background">
<view v-if="!isRefreshing">
Expand All @@ -44,6 +40,7 @@

<script lang="ts" setup>
import { reactive, ref } from "vue";
import TopBar from "@/components/TopBar.vue";
import { Icons } from "@/utils/url";
import MasonryFrame from "@/pages/community/masonry-frame.vue";
import Cards from "@/pages/community/cards/cards.vue";
Expand Down Expand Up @@ -151,21 +148,6 @@ onShow(() => {
margin-left: 20rpx;
}
.nav-bar {
position: fixed;
background-color: #fafcff;
width: 100vw;
z-index: 100;
}
.top-bar {
width: 100vw;
}
.capsule-bar {
width: 100vw;
display: flex;
align-items: center;
}
.navbtn {
color: #939393;
font-size: calc(10 / 390 * 100vw);
Expand Down

0 comments on commit 5c24763

Please sign in to comment.