reghao 3 gadi atpakaļ
vecāks
revīzija
c675329b03

+ 6 - 1
src/api/user/account.js

@@ -5,7 +5,8 @@ const accountApi = {
   selectUsernameApi: '/api/user/account/select/username',
   checkEmailApi: '/api/user/account/check/email',
   regVerifyCodeApi: '/api/user/verifyCode',
-  registerApi: '/api/user/account/register'
+  registerApi: '/api/user/account/register',
+  userInfoApi: '/api/user/info'
 }
 
 export function getBase64Captcha(captchaUrl) {
@@ -32,3 +33,7 @@ export function getRegVerifyCode(verifyCode) {
 export function register(userRegistry) {
   return $axios.post(accountApi.registerApi, userRegistry)
 }
+
+export function getUserInfo(userId) {
+  return $axios.get(accountApi.userInfoApi + '/' + userId)
+}

+ 1 - 1
src/components/comment/video-comment.vue

@@ -7,7 +7,7 @@
     </v-row>
     <v-row>
       <v-col cols="2" style="padding-top: 0px;">
-        <router-link v-if="this.$store.state.user.userInfo" :to="`/user/${this.$store.state.user.userInfo.userId}`">
+        <router-link v-if="this.$store.state.user.userInfo" :to="`/u/${this.$store.state.user.userInfo.userId}`">
           <v-avatar size="62">
             <v-img
               :src="this.$store.state.user.userInfo.avatarUrl"

+ 2 - 2
src/components/item-card.vue

@@ -10,7 +10,7 @@
     </router-link>
     <v-row>
       <v-col cols="2">
-        <router-link :to="`/user/${videoInfo.userId}`">
+        <router-link :to="`/u/${videoInfo.userId}`">
           <v-avatar size="48">
             <v-img :src="videoInfo.avatarUrl" />
           </v-avatar>
@@ -21,7 +21,7 @@
           <router-link :to="`/video/${videoInfo.videoId}`" style="color: black;"> {{ videoInfo.title }} </router-link>
         </p>
         <p style="font-size: 10px; color: #606060;">
-          <router-link :to="`/user/${videoInfo.userId}`"> {{ videoInfo.username }}</router-link>
+          <router-link :to="`/u/${videoInfo.userId}`"> {{ videoInfo.username }}</router-link>
           <br>
           {{ videoInfo.viewCount }} 观看 <span v-html="`&nbsp;&nbsp;`" />
           <span v-text="TimeUtil.timeToNowStrning(videoInfo.pubDate)" />

+ 2 - 2
src/components/player/video-card.vue

@@ -10,7 +10,7 @@
     </router-link>
     <v-row>
       <v-col cols="2">
-        <router-link :to="`/user/${videoInfo.userId}`">
+        <router-link :to="`/u/${videoInfo.userId}`">
           <v-avatar size="48">
             <v-img :src="videoInfo.avatarUrl" />
           </v-avatar>
@@ -21,7 +21,7 @@
           <router-link :to="`/video/${videoInfo.videoId}`" style="color: black;"> {{ videoInfo.title }} </router-link>
         </p>
         <p style="font-size: 10px; color: #606060;">
-          <router-link :to="`/user/${videoInfo.userId}`"> {{ videoInfo.username }}</router-link>
+          <router-link :to="`/u/${videoInfo.userId}`"> {{ videoInfo.username }}</router-link>
           <br>
           {{ videoInfo.viewCount }} 观看 <span v-html="`&nbsp;&nbsp;`" />
           <span v-text="TimeUtil.timeToNowStrning(videoInfo.pubDate)" />

+ 0 - 1
src/components/player/video-list.vue

@@ -1,5 +1,4 @@
 <template>
-
   <v-row>
     <v-col cols="3">
       <router-link :to="`/video/${video.id}`">

+ 1 - 1
src/views/admin/examine.vue

@@ -24,7 +24,7 @@
                   {{ getType(item.type) }}
                 </template>
                 <template v-slot:item.userId="{ item }">
-                  <a :href="`/user/${item.userId}`" target="_blank"> {{ item.userId }} </a>
+                  <a :href="`/u/${item.userId}`" target="_blank"> {{ item.userId }} </a>
                 </template>
                 <template v-slot:item.imgUrl="{ item }">
                   <v-img :src="item.imgUrl" max-height="200px" aspect-ratio="1.77" />

+ 14 - 38
src/views/user/home.vue

@@ -112,8 +112,9 @@
 
 <script>
 import { userVideoList } from '@/api/media/video'
+import { getUserInfo } from '@/api/user/account'
 import Power from '@/utils/check-power.vue'
-import VideoList from '@/components/player/video-list.vue'
+import VideoList from '@/components/player/video-card.vue'
 import TimeUtil from '@/utils/time-util.vue'
 
 export default {
@@ -138,7 +139,7 @@ export default {
   created() {
     this.userId = parseInt(this.$route.params.userId)
     this.getUserInfo()
-    // this.getVideoList()
+    this.getVideoList()
   },
   methods: {
     getUserInfo() {
@@ -146,24 +147,16 @@ export default {
         this.userInfo = this.$store.state.user.userInfo
         document.title = this.userInfo.username
       } else {
-        /* fetch(`/api/user/info/${this.userId}`, {
-          headers: {
-            'Content-Type': 'application/json; charset=UTF-8',
-            'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
-          },
-          method: 'GET',
-          credentials: 'include'
-        }).then(response => response.json())
-          .then(json => {
-            this.userInfo = json.data
-            document.title = json.data.username
-            if (json.data.id === -1) {
-              this.$router.push('/404')
-            }
-          })
-          .catch(e => {
-            return null
-          })*/
+        console.log('获取用户信息')
+        getUserInfo(this.userId).then(res => {
+          if (res.code === 0) {
+            this.userInfo = res.data
+          } else {
+            alert(res.data)
+          }
+        }).catch(error => {
+          console.error(error.message)
+        })
       }
     },
     getStatusList() {
@@ -173,6 +166,7 @@ export default {
       console.log('获取视频列表')
       userVideoList(this.userId).then(res => {
         if (res.code === 0) {
+          console.log(res.data)
           for (const item of res.data.list) {
             this.videoList.push(item)
           }
@@ -184,24 +178,6 @@ export default {
       }).catch(error => {
         console.error(error.message)
       })
-
-      /* fetch(`/api/article/user/list/${this.userId}?page=${this.page}&limit=${this.size}&type=${this.type}`, {
-        headers: {
-          'Content-Type': 'application/json; charset=UTF-8',
-          'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
-        },
-        method: 'GET',
-        credentials: 'include'
-      }).then(response => response.json())
-        .then(json => {
-          this.videoList = json.data.list
-          this.page = json.data.currPage
-          this.length = json.data.totalPage
-          this.totalCount = json.data.totalCount
-        })
-        .catch(e => {
-          return null
-        })*/
     },
     getCommentList() {
       console.log('获取评论列表')

+ 2 - 2
src/views/video/video.vue

@@ -46,14 +46,14 @@
           <v-divider />
           <v-row>
             <v-col cols="2" align-self="end">
-              <router-link :to="`/user/${videoData.userId}`">
+              <router-link :to="`/u/${videoData.userId}`">
                 <v-avatar size="62">
                   <v-img :src="videoData.avatarUrl" />
                 </v-avatar>
               </router-link>
             </v-col>
             <v-col>
-              <router-link :to="`/user/${videoData.userId}`">
+              <router-link :to="`/u/${videoData.userId}`">
                 <span v-text="videoData.username" />
               </router-link>
               <span v-html="'&nbsp;&nbsp;&nbsp;&nbsp;'" />