reghao 3 лет назад
Родитель
Сommit
0c6641c7a1

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

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

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

@@ -10,5 +10,5 @@ export function getMyInfo() {
 }
 
 export function getUserInfo(userId) {
-  return $axios.get(userApi.userInfoApi + '?userId' + userId)
+  return $axios.get(userApi.userInfoApi + '?userId=' + userId)
 }

+ 21 - 12
src/components/player/player.vue

@@ -11,6 +11,12 @@ const DPlayer = require('dplayer')
 
 export default {
   name: 'Play',
+  props: {
+    videoCover: {
+      type: String,
+      default: () => ''
+    }
+  },
   data() {
     return {
       hls,
@@ -32,18 +38,19 @@ export default {
     videoUrl(this.$route.params.id)
       .then(res => {
         if (res.code === 0) {
-          // TODO 返回一个 dplayer 播放器对象,包含一些常用的属性
-          var coverUrl = res.data.coverUrl
-          var videoUrl = res.data.videoUrl
-          var urlType = res.data.urlType
+          const urlType = res.data.type
           if (urlType === 'mp4') {
-            this.initMp4Player(this.userId, this.videoId, coverUrl, videoUrl)
+            const urls = res.data.urls
+            for (const url of urls) {
+              url.type = 'normal'
+            }
+            this.initMp4Player(this.userId, this.videoId, this.videoCover, urls)
           } else if (urlType === 'hls') {
-            this.initHlsPlayer(this.videoId, coverUrl, videoUrl)
+            // this.initHlsPlayer(this.videoId, coverUrl, urls)
           } else if (urlType === 'dash') {
-            this.initDashPlayer(this.videoId, coverUrl, videoUrl)
+            // this.initDashPlayer(this.videoId, coverUrl, urls)
           } else if (urlType === 'flv') {
-            this.initFlvPlayer(this.videoId, coverUrl, videoUrl)
+            // this.initFlvPlayer(this.videoId, coverUrl, urls)
           } else {
             console.log('无法识别 url 类型')
           }
@@ -75,17 +82,19 @@ export default {
           console.error(error.message)
         })
     },
-    initMp4Player(userId, videoId, coverUrl, videoUrl) {
+    initMp4Player(userId, videoId, coverUrl, urls) {
       const player = new DPlayer({
         container: document.querySelector('#dplayer'),
         lang: 'zh-cn',
         logo: '/logo.png',
         autoplay: false,
-        screenshot: true,
+        screenshot: false,
         video: {
           pic: coverUrl,
-          url: videoUrl,
-          type: 'auto'
+          defaultQuality: 0,
+          quality: urls
+          // url: videoUrl
+          // type: 'auto',
         },
         danmaku: {
           id: videoId,

+ 4 - 2
src/layout/index.vue

@@ -100,12 +100,14 @@ export default {
     items: [
       { icon: 'mdi-youtube-subscription', text: '直播', link: '/live' },
       { icon: 'mdi-trending-up', text: '状态', link: '/mblog' },
-      { icon: 'mdi-trending-up', text: '知乎', link: '/zhihu' }
+      { icon: 'mdi-trending-up', text: '知乎', link: '/zhihu' },
+      { icon: 'mdi-trending-up', text: '草榴', link: '/t66y' }
     ],
     links: [
       '直播',
       '状态',
-      '知乎'
+      '知乎',
+      '草榴'
     ]
     /*,
     headItem: [

+ 12 - 0
src/router/index.js

@@ -306,6 +306,18 @@ const routes = [
         component: () => import('@/views/home/zhihu.vue'),
         meta: { title: 'bili 知乎' }
       },
+      {
+        path: '/t66y',
+        name: 'T66y',
+        component: () => import('@/views/home/t66y.vue'),
+        meta: { title: 'bili 草榴' }
+      },
+      {
+        path: '/t66y/page',
+        name: 'T66yPage',
+        component: () => import('@/views/home/t66ypage.vue'),
+        meta: { title: 'bili 草榴页面' }
+      },
       {
         path: '/search/result',
         name: 'SearchResult',

+ 2 - 2
src/views/home/mblog.vue

@@ -188,7 +188,7 @@ export default {
   data() {
     return {
       statusPost: {
-        uploadIds: [],
+        imageFileIds: [],
         content: ''
       },
       cardType: null,
@@ -328,7 +328,7 @@ export default {
     },
     uploadCallback(resp) {
       if (resp.code === 0) {
-        this.statusPost.uploadIds.push(resp.data.uploadId)
+        this.statusPost.imageFileIds.push(resp.data.uploadId)
       } else {
         if (resp.msg != null) {
           this.message = '上传文件出现异常,请重新上传!' + resp.msg

+ 119 - 0
src/views/home/t66y.vue

@@ -0,0 +1,119 @@
+<template>
+  <v-container>
+    <v-tabs>
+      <v-tab @click="selectTab(0)">视频</v-tab>
+      <v-tab @click="selectTab(1)">图片</v-tab>
+    </v-tabs>
+    <v-simple-table>
+      <template v-slot:default>
+        <thead>
+          <tr>
+            <th class="text-left">
+              author
+            </th>
+            <th class="text-left">
+              pub date
+            </th>
+            <th class="text-left">
+              title
+            </th>
+          </tr>
+        </thead>
+        <tbody>
+          <tr
+            v-for="item in pageList"
+            :key="item.pageUrl"
+            @click="jumpPage(item.pageUrl)"
+          >
+            <td>{{ item.author }}</td>
+            <td>{{ item.pubDate }}</td>
+            <td>{{ item.title }}</td>
+          </tr>
+        </tbody>
+      </template>
+    </v-simple-table>
+    <v-pagination
+        v-model="page"
+        :length="length"
+        :total-visible="7"
+        @input="pageChange"
+    />
+  </v-container>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      type: 0,
+      page: 1,
+      length: 0,
+      pageList: []
+    }
+  },
+  created() {
+    this.getPageList('video', 1)
+  },
+  methods: {
+    selectTab(type) {
+      console.log(type)
+      if (type === this.type) {
+        return
+      }
+
+      this.type = type
+      this.page = 1
+      if (type === 0) {
+        this.$vuetify.goTo(type)
+        this.getPageList('video', 1)
+      } else if (type === 1) {
+        this.$vuetify.goTo(type)
+        this.getPageList('image', 1)
+      }
+    },
+    pageChange(page) {
+      this.page = page
+      if (page !== this.currentPage) {
+        if (this.type === 0) {
+          this.getPageList('video', page)
+        } else if (this.type === 1) {
+          this.getPageList('image', page)
+        }
+      }
+    },
+    getPageList(pageType, page) {
+      const url = 'http://localhost:9988/api/t66y/page/list/' + pageType + '?page=' + page
+      fetch(url, {
+        method: 'GET'
+      }).then(response => response.json())
+        .then(json => {
+          if (json.code === 0) {
+            const dataList = json.data
+            this.pageList.splice(0, this.pageList.length)
+            for (const item of dataList.list) {
+              this.pageList.push(item)
+            }
+            this.currentPage = dataList.currentPage
+            this.length = dataList.totalPages
+          }
+        })
+        .catch(e => {
+          return null
+        })
+    },
+    jumpPage(pageUrl) {
+      console.log('跳转页面 + ' + pageUrl)
+      const routeUrl = this.$router.resolve({
+        path: '/t66y/page',
+        query: {
+          pageUrl: pageUrl
+        }
+      })
+      window.open(routeUrl.href, '_blank')
+    }
+  }
+}
+</script>
+
+<style lang="scss">
+</style>

+ 39 - 0
src/views/home/t66ypage.vue

@@ -0,0 +1,39 @@
+<template>
+  <div>
+    <span v-html="videoPage" />
+  </div>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      videoPage: ''
+    }
+  },
+  created() {
+    const pageUrl = this.$route.query.pageUrl
+    console.log(pageUrl)
+    this.getPage(pageUrl)
+  },
+  methods: {
+    getPage(pageUrl) {
+      console.log('跳转页面 + ' + pageUrl)
+      fetch(`http://localhost:9988/api/t66y/page/?pageUrl=` + pageUrl, {
+        method: 'GET'
+      }).then(response => response.json())
+        .then(json => {
+          if (json.code === 0) {
+            this.videoPage = json.data
+          }
+        })
+        .catch(e => {
+          return null
+        })
+    }
+  }
+}
+</script>
+
+<style lang="scss">
+</style>

+ 7 - 8
src/views/studio/upload.vue

@@ -167,12 +167,12 @@ export default {
       ],
       // 提交给后端的数据
       videoPost: {
-        fileId: '',
-        videoUrl: '',
+        videoFileId: '',
+        duration: 0,
+        horizontal: false,
         coverUrl: '',
         title: '',
         description: '',
-        duration: 0,
         categoryId: -1,
         tags: []
       },
@@ -218,7 +218,6 @@ export default {
               this.showMessage = true
               file.cancel()
             } else {
-              this.videoPost.videoId = uploadId
               file.uniqueIdentifier = uploadId
               file.resume()
             }
@@ -235,10 +234,10 @@ export default {
       if (res.code === 0) {
         const resData = res.data
         if (resData.merged) {
-          this.videoPost.fileId = resData.uploadId
-          this.videoPost.videoUrl = resData.videoUrl
-          this.videoPost.coverUrl = resData.coverUrl
+          this.videoPost.videoFileId = resData.videoFileId
+          this.videoPost.horizontal = resData.horizontal
           this.videoPost.duration = resData.duration
+          this.videoPost.coverUrl = resData.coverUrl
         }
       }
     },
@@ -246,7 +245,7 @@ export default {
       console.log('文件上传错误')
     },
     publish() {
-      if (!this.videoPost.fileId) {
+      if (!this.videoPost.videoFileId) {
         this.message = '你还没有上传视频'
         this.showMessage = true
         return

+ 3 - 3
src/views/user/home.vue

@@ -113,7 +113,7 @@
 
 <script>
 import { userVideoList } from '@/api/media/video'
-import { getUserInfo } from '@/api/user/account'
+import { getUserInfo } from '@/api/user/user'
 import Power from '@/utils/check-power.vue'
 import StatusCard from '@/components/card/status-card'
 import VideoCard from '@/components/card/video-card.vue'
@@ -150,7 +150,7 @@ export default {
       document.title = '我的主页'
     } else {
       this.userId = parseInt(userIdStr)
-      this.getUserInfo(this.userId)
+      this.getUserInfo1(this.userId)
     }
 
     const jumpPage = this.$route.query.page
@@ -186,7 +186,7 @@ export default {
       this.page = 1
       this.length = 0
     },
-    getUserInfo(userId) {
+    getUserInfo1(userId) {
       getUserInfo(userId).then(res => {
         if (res.code === 0) {
           this.userInfo = res.data

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

@@ -19,7 +19,7 @@
     <v-container>
       <v-row>
         <v-col>
-          <VideoPlayer />
+          <VideoPlayer :videoCover="videoData.coverUrl" />
         </v-col>
       </v-row>
     </v-container>