| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- <template>
- <div class="head-wrap">
- <div class="left">
- <div
- class="logo"
- @click="router.push('/')"
- >
- Billd直播
- </div>
- <div class="nav">
- <a
- :class="{
- item: 1,
- active: router.currentRoute.value.name === routerName.rank,
- }"
- href="/rank"
- @click.prevent="router.push({ name: routerName.rank })"
- >
- 排行榜
- </a>
- <a
- :class="{
- item: 1,
- active: router.currentRoute.value.name === routerName.support,
- }"
- href="/support"
- @click.prevent="router.push({ name: routerName.support })"
- >
- 付费支持
- </a>
- <div
- v-for="(item, index) in navLeftList.filter(
- (item) => router.currentRoute.value.query.liveType === item.liveType
- )"
- :key="index"
- :class="{
- item: 1,
- active: router.currentRoute.value.query.liveType === item.liveType,
- }"
- @click="goPushPage(item.routerName)"
- >
- {{ item.title }}
- </div>
- <div
- v-for="(item, index) in pullList.filter(
- (item) => router.currentRoute.value.query.liveType === item.liveType
- )"
- :key="index"
- :class="{
- item: 1,
- active: router.currentRoute.value.query.liveType === item.liveType,
- }"
- >
- {{ item.title }}
- </div>
- </div>
- </div>
- <div class="right">
- <div
- v-if="!userStore.userInfo"
- class="qqlogin"
- @click="useQQLogin()"
- >
- 登录
- </div>
- <n-dropdown
- v-else
- trigger="hover"
- :options="userOptions"
- @select="handleUserSelect"
- >
- <div
- class="qqlogin"
- :style="{ backgroundImage: `url(${userStore.userInfo.avatar})` }"
- @click="useQQLogin()"
- ></div>
- </n-dropdown>
- <a
- class="sponsors"
- href="/sponsors"
- @click.prevent="router.push({ name: routerName.sponsors })"
- >
- 赞助
- </a>
- <a
- class="about"
- href="/about"
- @click.prevent="router.push({ name: routerName.about })"
- >
- 关于
- </a>
- <a
- class="bilibili"
- target="_blank"
- href="https://space.bilibili.com/381307133/channel/seriesdetail?sid=3285689"
- >
- b站视频
- </a>
- <a
- class="github"
- target="_blank"
- href="https://github.com/galaxy-s10/billd-live"
- >
- <span class="txt">github</span>
- <img
- :src="githubStar"
- alt=""
- />
- </a>
- <n-dropdown
- v-if="router.currentRoute.value.name !== routerName.push"
- trigger="hover"
- :options="options"
- @select="handlePushSelect"
- >
- <div class="start-live">我要开播</div>
- </n-dropdown>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { openToTarget } from 'billd-utils';
- import { onMounted, ref } from 'vue';
- import { useRouter } from 'vue-router';
- import { useQQLogin } from '@/hooks/use-login';
- import { liveTypeEnum } from '@/interface';
- import { routerName } from '@/router';
- import { useUserStore } from '@/store/user';
- const router = useRouter();
- const userStore = useUserStore();
- const githubStar = ref('');
- const navLeftList = ref([
- {
- title: 'Webrtc Push',
- routerName: routerName.push,
- liveType: liveTypeEnum.webrtcPush,
- },
- {
- title: 'SRS WebRTC Push',
- routerName: routerName.push,
- liveType: liveTypeEnum.srsPush,
- },
- ]);
- const pullList = ref([
- {
- title: 'Webrtc Pull',
- routerName: routerName.pull,
- liveType: liveTypeEnum.webrtcPull,
- },
- {
- title: 'SRS WebRTC Pull Flv',
- routerName: routerName.pull,
- liveType: liveTypeEnum.srsFlvPull,
- },
- {
- title: 'SRS WebRTC Pull',
- routerName: routerName.pull,
- liveType: liveTypeEnum.srsWebrtcPull,
- },
- ]);
- const userOptions = ref([
- {
- label: '退出',
- key: '1',
- },
- ]);
- const options = ref([
- {
- label: 'webrtc开播',
- key: liveTypeEnum.webrtcPush,
- },
- {
- label: 'srs-webrtc开播',
- key: liveTypeEnum.srsPush,
- },
- ]);
- onMounted(() => {
- githubStar.value =
- 'https://img.shields.io/github/stars/galaxy-s10/billd-live?label=Star&logo=GitHub&labelColor=white&logoColor=black&style=social&cacheSeconds=3600';
- });
- function handleUserSelect(key) {
- if (key === '1') {
- userStore.logout();
- }
- }
- function handlePushSelect(key) {
- if (key === liveTypeEnum.webrtcPush || key === liveTypeEnum.srsPush) {
- const url = router.resolve({
- name: routerName.push,
- query: { liveType: key },
- });
- openToTarget(url.href);
- }
- }
- function goPushPage(routerName: string) {
- const url = router.resolve({ name: routerName });
- openToTarget(url.href);
- }
- </script>
- <style lang="scss" scoped>
- .head-wrap {
- display: flex;
- align-items: center;
- justify-content: space-between;
- min-width: $medium-width;
- height: 64px;
- background-color: #fff;
- box-shadow: inset 0 -1px #f1f2f3 !important;
- .left {
- display: flex;
- align-items: center;
- .logo {
- margin: 0 20px;
- width: 100px;
- height: 40px;
- background-color: skyblue;
- color: white;
- text-align: center;
- line-height: 40px;
- cursor: pointer;
- }
- .nav {
- display: flex;
- align-items: center;
- .item {
- position: relative;
- padding: 0 10px;
- color: black;
- text-decoration: none;
- cursor: pointer;
- &.active {
- &::after {
- position: absolute;
- bottom: -6px;
- left: 50%;
- width: 40% !important;
- height: 2px;
- background-color: red;
- content: '';
- transition: all 0.1s ease;
- transform: translateX(-50%);
- }
- }
- &::after {
- width: 0px !important;
- @extend .active;
- }
- &:hover {
- &::after {
- width: 40% !important;
- }
- }
- }
- }
- }
- .right {
- display: flex;
- align-items: center;
- margin-right: 20px;
- .qqlogin {
- box-sizing: border-box;
- margin-right: 15px;
- width: 35px;
- height: 35px;
- border-radius: 50%;
- background-color: skyblue;
- background-position: center;
- background-size: cover;
- background-repeat: no-repeat;
- color: white;
- text-align: center;
- font-size: 13px;
- line-height: 35px;
- cursor: pointer;
- }
- .sponsors,
- .bilibili,
- .about,
- .github {
- position: relative;
- margin-right: 15px;
- border-radius: 6px;
- color: black;
- text-decoration: none;
- font-size: 14px;
- cursor: pointer;
- &.active {
- &::after {
- position: absolute;
- bottom: -6px;
- left: 50%;
- width: 40%;
- height: 2px;
- background-color: red;
- content: '';
- transition: all 0.1s ease;
- transform: translateX(-50%);
- }
- }
- &::after {
- width: 0px !important;
- @extend .active;
- }
- &:hover {
- &::after {
- width: 40% !important;
- }
- }
- }
- .github {
- display: flex;
- align-items: center;
- .txt {
- margin-right: 5px;
- }
- }
- .start-live {
- margin-right: 10px;
- padding: 5px 10px;
- border-radius: 6px;
- background-color: skyblue;
- color: white;
- font-size: 14px;
- cursor: pointer;
- }
- }
- }
- </style>
|