reghao před 2 roky
rodič
revize
7400faa065

+ 7 - 1
src/api/search.js

@@ -2,7 +2,8 @@ import { get, post } from '@/utils/request'
 
 const searchApi = {
   keywordSuggestApi: '/api/search/suggest',
-  videoSearchApi: '/api/search/query'
+  videoSearchApi: '/api/search/query',
+  hotSearchApi: '/api/search/hot'
 }
 
 // 关键词建议
@@ -14,3 +15,8 @@ export function keywordSuggest(keyword) {
 export function videoQuery(keyword, page) {
   return get(searchApi.videoSearchApi + '?keyword=' + keyword + '&page=' + page)
 }
+
+// 视频搜索
+export function hotKeyword() {
+  return get(searchApi.hotSearchApi)
+}

+ 5 - 0
src/api/video.js

@@ -11,6 +11,7 @@ const videoApi = {
   videoSubmitApi: '/api/content/video/submit',
   userVideoListApi: '/api/content/video/user',
   userContentDataApi: '/api/content/video/userdata',
+  hotVideoApi: '/api/content/video/hot',
 
   playerRecordApi: '/api/media/video/play/record',
   userRecentlyVideoListApi: '/api/media/video/post/user/recently',
@@ -79,3 +80,7 @@ export function getDisplayedVideoList() {
 export function getUserContentData(userId) {
   return get(videoApi.userContentDataApi + '?userId=' + userId)
 }
+
+export function getHotVideo() {
+  return get(videoApi.hotVideoApi)
+}

+ 7 - 0
src/assets/js/mixin.js

@@ -201,6 +201,13 @@ export const userMixin = {
     goToProfile() {
       window.open("//account.reghao.cn", "_blank");
     },
+    goToPost() {
+      if (this.$route.path === '/user/post/list') {
+        this.$router.go(0)
+        return
+      }
+      this.$router.push('/user/post/list')
+    },
     goToCollection() {
       if (this.$route.path === '/u/collection') {
         this.$router.go(0)

+ 10 - 2
src/components/card/HotSearch.vue

@@ -19,6 +19,8 @@
 </template>
 
 <script>
+import { hotKeyword } from '@/api/search'
+
 export default {
   name: 'HotSearch',
   data() {
@@ -47,7 +49,13 @@ export default {
     }
   },
   created() {
-    this.videos = [
+    hotKeyword().then(res => {
+      if (res.code === 0) {
+        console.log(res.data)
+      } else {
+      }
+    })
+    /*this.videos = [
       {
         vname: '大奶',
         coverurl: 'https://picx.zhimg.com/v2-ea15e9203a1d95a465a78da043a9315d_xl.jpg',
@@ -108,7 +116,7 @@ export default {
         releasetime: '2023-04-24 16:47:00',
         visited: 10
       }
-    ]
+    ]*/
     /* getHotTen().then((res) => {
       this.videos = res
     })*/

+ 11 - 5
src/components/card/HotVideo.vue

@@ -19,6 +19,8 @@
 </template>
 
 <script>
+import { getHotVideo } from '@/api/video'
+
 export default {
   name: 'HotVideo',
   data() {
@@ -47,7 +49,14 @@ export default {
     }
   },
   created() {
-    this.videos = [
+    getHotVideo().then(res => {
+      if (res.code === 0) {
+        console.log(res.data)
+      } else {
+      }
+    })
+
+    /*this.videos = [
       {
         vname: '哈1',
         coverurl: 'https://picx.zhimg.com/v2-ea15e9203a1d95a465a78da043a9315d_xl.jpg',
@@ -108,10 +117,7 @@ export default {
         releasetime: '2023-04-24 16:47:00',
         visited: 10
       }
-    ]
-    /* getHotTen().then((res) => {
-      this.videos = res
-    })*/
+    ]*/
   },
   methods: {}
 }

+ 13 - 2
src/components/layout/NavBar.vue

@@ -33,8 +33,13 @@
           <span>文章</span>
         </a>
       </el-col>
+      <el-col :md="1" class="right">
+        <a href="/discover" class="tit">
+          <span>发现</span>
+        </a>
+      </el-col>
       <!--搜索框-->
-      <el-col :md="9" class="search">
+      <el-col :md="8" class="search">
         <search-box />
       </el-col>
       <el-col :md="2" class="logo">
@@ -84,7 +89,13 @@
               icon="el-icon-user-solid"
               class="size"
               @click.native="goToProfile"
-            >个人帐号</el-dropdown-item>
+            >我的帐号</el-dropdown-item>
+            <el-dropdown-item
+              icon="el-icon-star-on"
+              class="size"
+              @click.native="goToPost"
+            >我的稿件
+            </el-dropdown-item>
             <el-dropdown-item
               icon="el-icon-star-on"
               class="size"

+ 22 - 8
src/components/layout/SearchBox.vue

@@ -15,7 +15,7 @@
 </template>
 
 <script>
-import { keywordSuggest } from '@/api/search'
+import { hotKeyword, keywordSuggest } from '@/api/search'
 
 export default {
   name: 'SearchBox',
@@ -33,19 +33,33 @@ export default {
       timer: null
     }
   },
+  created() {
+    /*hotKeyword().then(res => {
+      if (res.code === 0) {
+        console.log(res.data)
+      } else {
+      }
+    })*/
+  },
   methods: {
     // 重点:当框中的改变时触发该方法,elementui自动设置了防抖,参见debounce属性
     // queryString 为输入框中的值。cb为返回显示列表的回调函数
     querySearchAsync(queryString, cb) {
-      console.log('queryString')
-      const res = ['哈1', '哈2', '哈3', '哈4', '哈5']
-      this.restaurants = res.map((item) => {
-        return {
-          value: item
+      if (queryString === '') {
+        return
+      }
+
+      keywordSuggest(queryString).then(res => {
+        if (res.code === 0) {
+          this.restaurants = res.data.map((item) => {
+            return {
+              value: item
+            }
+          })
+          cb(this.restaurants)
+        } else {
         }
       })
-      cb(this.restaurants)
-
       /*setTimeout(() => {
         // cb函数如果返回一个空数组的话,那个模糊搜索输入建议的下拉选项因为length为0就会消失了
         // cb([])

+ 21 - 3
src/router/index.js

@@ -12,7 +12,9 @@ const ImageIndex = () => import('views/home/Image')
 const ImagePage = () => import('views/home/ImagePage')
 const ArticleIndex = () => import('views/home/Article')
 const Search = () => import('views/home/Search')
-const HomeIndex = () => import('views/user/Home')
+const UserHome = () => import('views/user/Home')
+const UserFollowing = () => import('views/user/Home')
+const UserFollower = () => import('views/user/Home')
 const ProfileIndex = () => import('views/user/Profile')
 const AvatarIndex = () => import('views/user/Avatar')
 const VipIndex = () => import('views/user/Vip')
@@ -22,6 +24,7 @@ const PostList = () => import('views/post/PostList')
 const PostPublish = () => import('views/post/PostPublish')
 const PostAnalysis = () => import('views/post/PostAnalysis')
 const MessageIndex = () => import('views/message/Message')
+const DiscoverIndex = () => import('views/home/Discover')
 
 // 使用安装路由插件
 Vue.use(VueRouter)
@@ -111,6 +114,11 @@ const routes = [
     name: 'ArticleIndex',
     component: ArticleIndex
   },
+  {
+    path: '/discover',
+    name: 'DiscoverIndex',
+    component: DiscoverIndex
+  },
   {
     path: '/search',
     name: 'search',
@@ -118,8 +126,18 @@ const routes = [
   },
   {
     path: '/user/:id',
-    name: 'HomeIndex',
-    component: HomeIndex
+    name: 'UserHome',
+    component: UserHome
+  },
+  {
+    path: '/user/:id/following',
+    name: 'UserFollowing',
+    component: UserFollowing
+  },
+  {
+    path: '/user/:id/follower',
+    name: 'UserFollower',
+    component: UserFollower
   },
   {
     path: '/u/profile',

+ 2 - 0
src/views/home/Article.vue

@@ -34,6 +34,8 @@ export default {
     }
   },
   created() {
+    document.title = '文章'
+
     this.currentPage = 1
     videoRecommend(this.currentPage).then(res => {
       if (res.code === 0) {

+ 3 - 33
src/views/home/Audio.vue

@@ -1,11 +1,5 @@
 <template>
   <div>
-    <el-row>
-      <el-col :md="12">
-        <!--猜您喜欢-->
-        <recommend />
-      </el-col>
-    </el-row>
     <!--电影列表,与推荐列表-->
     <el-row id="movie-list">
       <!--电影列表-->
@@ -28,27 +22,19 @@
             :current-page="$store.state.activePage"
             :page-size="6"
             :total="$store.state.pageBean.totalCount"
-            @current-change="handleCurrentChange"
           />
         </el-col>
       </el-col>
-      <!--热播列表-->
-      <el-col :md="6">
-        <hot-list />
-      </el-col>
     </el-row>
   </div>
 </template>
 
 <script>
 import VideoCard from 'components/card/VideoCard'
-import Recommend from 'components/recommend/Recommend'
-import HotList from 'components/hotlist/HotList'
-import { videoRecommend } from '@/api/video'
 
 export default {
-  name: 'Index',
-  components: { VideoCard, Recommend, CategoryBtn, HotList },
+  name: 'Audio',
+  components: { VideoCard},
   data() {
     return {
       // 屏幕宽度, 为了控制分页条的大小
@@ -58,16 +44,7 @@ export default {
     }
   },
   created() {
-    this.currentPage = 1
-    videoRecommend(this.currentPage).then(res => {
-      if (res.code === 0) {
-        const resData = res.data
-        this.videoList = resData.list
-      }
-    })
-    // console.log(this.$store.state.videos);
-    // 当页面挂载时,页码变为1
-    this.$store.commit('updatePage', 1)
+    document.title = '音频'
   },
   mounted() {
     // 当窗口宽度改变时获取屏幕宽度
@@ -79,13 +56,6 @@ export default {
     }
   },
   methods: {
-    handleCurrentChange(currentPage) {
-      this.currentPage = currentPage
-      this.$store.commit('updatePage', currentPage)
-      this.$store.dispatch('getPageBean')
-      // 回到顶部
-      scrollTo(0, 0)
-    }
   }
 }
 </script>

+ 102 - 0
src/views/home/Discover.vue

@@ -0,0 +1,102 @@
+<template>
+  <div>
+    <!--电影列表,与推荐列表-->
+    <el-row id="movie-list">
+      <!--电影列表-->
+      <el-col :md="24">
+        <el-col v-for="(video, index) in videoList" :key="index" :md="6" :sm="12" :xs="12">
+          <image-card :video="video" />
+        </el-col>
+        <!--
+          分页按钮:
+          page-size:每页显示条数
+          total:总条数
+          hide-on-single-page: 页数为一时隐藏
+        -->
+        <el-col :span="24" class="pagination">
+          <el-pagination
+              background
+              :small="screenWidth <= 768"
+              hide-on-single-page
+              layout="prev, pager, next"
+              :current-page="$store.state.activePage"
+              :page-size="6"
+              :total="$store.state.pageBean.totalCount"
+              @current-change="handleCurrentChange"
+          />
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import ImageCard from 'components/card/ImageCard'
+import { videoRecommend } from '@/api/video'
+
+export default {
+  name: 'Discover',
+  components: { ImageCard },
+  data() {
+    return {
+      // 屏幕宽度, 为了控制分页条的大小
+      screenWidth: document.body.clientWidth,
+      currentPage: 1,
+      videoList: []
+    }
+  },
+  created() {
+    document.title = '发现'
+    this.currentPage = 1
+    videoRecommend(this.currentPage).then(res => {
+      if (res.code === 0) {
+        const resData = res.data
+        this.videoList = resData.list
+      }
+    })
+    // console.log(this.$store.state.videos);
+    // 当页面挂载时,页码变为1
+    this.$store.commit('updatePage', 1)
+  },
+  mounted() {
+    // 当窗口宽度改变时获取屏幕宽度
+    window.onresize = () => {
+      return () => {
+        window.screenWidth = document.body.clientWidth
+        this.screenWidth = window.screenWidth
+      }
+    }
+  },
+  methods: {
+    handleCurrentChange(currentPage) {
+      this.currentPage = currentPage
+      this.$store.commit('updatePage', currentPage)
+      this.$store.dispatch('getPageBean')
+      // 回到顶部
+      scrollTo(0, 0)
+    }
+  }
+}
+</script>
+
+<style scoped>
+#movie-list {
+  padding-top: 15px;
+  padding-left: 6%;
+  padding-right: 6%;
+}
+
+.pagination {
+  text-align: center;
+  padding: 10px;
+}
+
+/*处于手机屏幕时*/
+@media screen and (max-width: 768px){
+  #movie-list {
+    padding-top: 8px;
+    padding-left: 0.5%;
+    padding-right: 0.5%;
+  }
+}
+</style>

+ 2 - 0
src/views/home/Image.vue

@@ -46,6 +46,8 @@ export default {
     }
   },
   created() {
+    document.title = '图片'
+
     this.currentPage = 1
     videoRecommend(this.currentPage).then(res => {
       if (res.code === 0) {

+ 1 - 0
src/views/home/Video.vue

@@ -108,6 +108,7 @@ export default {
   },
   created() {
     document.title = '视频'
+
     videoCategory().then(res => {
       if (res.code === 0) {
         for (let i = 0; i < res.data.length; i++) {

+ 2 - 2
src/views/sso/login.vue

@@ -142,8 +142,8 @@ export default {
     }
   },
   created() {
-    const token = Vue.$cookies.get('token')
-    if (token !== null) {
+    const userdata = Vue.$cookies.get('USERDATA')
+    if (userdata !== null) {
       this.$router.push('/')
     } else {
       this.getPubkey()

+ 20 - 2
src/views/user/Home.vue

@@ -36,9 +36,13 @@
               <span v-if="user.signature === undefined || user.signature === null">此用户没有签名</span>
             </el-row>
             <el-row>
-              <span class="el-icon-user">关注数: {{ user.followingCount }}</span>
+              <router-link target="_blank" :to="`/user/${user.userId}/following`">
+                <span class="el-icon-user">关注数: {{ user.followingCount }}</span>
+              </router-link>
               <span v-html="'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'" />
-              <span class="el-icon-user">粉丝数: {{ user.followerCount }}</span>
+              <router-link target="_blank" :to="`/user/${user.userId}/follower`">
+                <span class="el-icon-user">粉丝数: {{ user.followerCount }}</span>
+              </router-link>
             </el-row>
           </div>
         </el-card>
@@ -57,6 +61,16 @@
               </el-col>
             </div>
           </el-tab-pane>
+          <el-tab-pane name="image">
+            <span slot="label">
+              相册<el-badge :value="videoCount" :max="9999" class="item" type="warning"/>
+            </span>
+            <div v-if="activeName === 'image'">
+              <el-col v-for="(video, index) in videoList" :key="index" :md="6" :sm="12" :xs="12">
+                <video-card :video="video" />
+              </el-col>
+            </div>
+          </el-tab-pane>
           <el-tab-pane name="status">
             <span slot="label">
               状态<el-badge :value="statusCount" :max="9999" class="item" type="warning"/>
@@ -223,6 +237,10 @@ export default {
         this.currentPage = 1
         this.lastId = 0
         this.userVideoListWrapper(this.currentPage, this.userId, this.lastId)
+      } else if (this.activeName === 'image') {
+        this.currentPage = 1
+        this.lastId = 0
+        this.userVideoListWrapper(this.currentPage, this.userId, this.lastId)
       } else if (this.activeName === 'status') {
         this.currentPage = 1
         this.lastId = 0