| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <template>
- <div
- class="h-80px w-screen bg-primary flex justify-center overflow-hidden items-center"
- >
- <div class="flex items-center h-full">
- <div class="w-80px"></div>
- <div
- @click="$router.push('/home')"
- :class="`menu-item ${currentPath === '/home' ? 'selected' : ''}`"
- >
- {{ $t("首页") }}
- </div>
- <div class="w-40px"></div>
- <div
- @click="$router.push('/recommend')"
- :class="`menu-item ${currentPath === '/recommend' ? 'selected' : ''}`"
- >
- {{ $t("推荐") }}
- </div>
- <div class="w-40px"></div>
- <div
- @mouseenter="typeVisible = true"
- :class="`menu-item ${currentPath === '/specific-article' ? 'selected' : ''}`"
- >
- {{ $t("分类浏览") }}
- <img src="/imgs/arrow-down.png" class="w-14px h-6px ml-6px" />
- </div>
- <div class="w-40px"></div>
- <div
- @click="$router.push('/realtime-news')"
- :class="`menu-item ${currentPath === '/realtime-news' ? 'selected' : ''}`"
- >
- {{ $t("实时新闻") }}
- </div>
- <div class="w-40px"></div>
- <div
- @click="$router.push('/vip')"
- :class="`menu-item ${currentPath === '/vip' ? 'selected' : ''}`"
- >
- {{ $t("vip专区") }}
- </div>
- <div class="w-40px"></div>
- <div
- @click="$router.push('/aboutus')"
- :class="`menu-item ${currentPath === '/aboutus' ? 'selected' : ''}`"
- >
- {{ $t("关于我们") }}
- </div>
- <div class="w-260px"></div>
- <div
- @click="$router.push('/publish')"
- :class="`menu-item ${currentPath === '/publish' ? 'selected' : ''}`"
- >
- <img class="w-30px object-contain" src="/imgs/tougao.png" />
- {{ $t("投稿") }}
- </div>
- <div class="w-36px"></div>
- <div
- @click="$router.push('/search')"
- :class="`menu-item ${currentPath === '/search' ? 'selected' : ''}`"
- >
- <img class="w-30px object-contain" src="/imgs/search.png" />
- {{ $t("搜索") }}
- </div>
- <div class="w-40px"></div>
- <div
- v-if="!$store.state.userinfo"
- @click="$router.push('/login')"
- :class="`menu-item ${currentPath === '/login' ? 'selected' : ''}`"
- >
- {{ $t("登录注册") }}
- </div>
- <div
- v-else
- @click="$router.push('/user/personal-center')"
- :class="`menu-item ${currentPath === '/login' ? 'selected' : ''}`"
- class="-align-center"
- >
- <img class="w-40px h-40px rounded-full mr-12px" v-if="$store.state.userinfo.avatar" :src="$store.state.userinfo.avatarUrl">
- <span class="font-size-20px">{{$store.state.userinfo.nickname}}</span>
- </div>
- <div class="w-44px"></div>
- <div
- @click="changeLang"
- class="w-30px h-30px rounded-full border-white-2px text-white align-middle text-center cursor-pointer"
- >
- {{ $t("cn") }}
- </div>
- </div>
- <div
- v-if="typeVisible"
- @mouseenter="typeVisible = true"
- @mouseleave="typeVisible = false"
- class="min-h-272px w-screen bg-white absolute top-80px z-50 flex justify-center pb-30px"
- >
- <div class="w-1200px flex flex-wrap">
- <div
- @click="() => {
- $router.push('/specific-article?category=' + item.code + '&name=' + item.name)
- typeVisible = false
- }"
- :class="`type-tag ${$route.query.category === item.code ? 'selected' : ''}`"
- v-for="(item, index) in cmsCategorys"
- :key="item"
- >
- <div class="name">{{item.name}}</div>
- <div class="count">{{item.artcileNum}}篇文章</div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
-
- mounted() {
-
- },
- methods:{
- changeLang(){
-
- this.$i18n.locale = this.lang[0];
- this.lang = this.lang.reverse()
- }
- },
- watch: {
- $route: function (next) {
- console.log(next.path);
- this.currentPath = next.path;
- },
- },
- data() {
- return {
- typeVisible: false,
- currentPath: this.$route.path,
- lang: ['zh-CN','zh-TW'],
- cmsCategorys:[]
- };
- },
- async created() {
- let resp = await this.$http.post(this.$api.cms.categorys);
- if(resp.data.status === 200){
- this.cmsCategorys = resp.data.data.cmsCategorys;
- }
- }
- };
- </script>
- <style>
- .menu-item {
- @apply text-white text-size-20px cursor-pointer relative h-full flex items-center;
- }
- .menu-item.selected::after {
- content: "";
- width: 100%;
- height: 3px;
- background: #fff;
- position: absolute;
- bottom: 14px;
- left: 0;
- border-radius: 3px;
- }
- .type-tag {
- @apply w-110px h-60px bg-[#F7F7F7] flex flex-col justify-center mt-30px pl-15px cursor-pointer;
- }
- .type-tag.selected {
- @apply bg-primary;
- }
- .type-tag:not(:nth-child(8n)) {
- @apply mr-40px;
- }
- .type-tag > .name {
- @apply text-size-16px mb-6px;
- }
- .type-tag.selected > .name {
- @apply text-white;
- }
- .type-tag > .count {
- @apply text-size-14px text-[#B8B8B8];
- }
- </style>
|