Explorar o código

更新 disk 相关页面和接口

reghao %!s(int64=2) %!d(string=hai) anos
pai
achega
f65537f6af
Modificáronse 2 ficheiros con 65 adicións e 14 borrados
  1. 13 0
      src/components/layout/NavBar.vue
  2. 52 14
      src/views/disk/FileList.vue

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

@@ -68,6 +68,11 @@
               alt=""
             >
             <el-dropdown-menu v-if="user" slot="dropdown" class="iconsize">
+              <el-dropdown-item
+                icon="el-icon-files"
+                class="size"
+                @click.native="goToDisk"
+              >我的网盘</el-dropdown-item>
               <el-dropdown-item
                 icon="el-icon-user-solid"
                 class="size"
@@ -285,6 +290,14 @@ export default {
       window.open('//account.reghao.cn/login', '_blank')
     },
     // ****************************************************************************************************************
+    goToDisk() {
+      const path = '/disk'
+      if (this.$route.path === path) {
+        this.$router.go(0)
+        return
+      }
+      this.$router.push(path)
+    },
     goToProfile() {
       const path = '/my'
       if (this.$route.path === path) {

+ 52 - 14
src/views/disk/FileList.vue

@@ -5,7 +5,10 @@
         <el-form-item>
           <el-select v-model="searchForm.fileType" placeholder="文件类型" @change="search">
             <el-option label="全部" value="0" />
-            <el-option label="图片" value="1" />
+            <el-option label="图片" value="1001" />
+            <el-option label="视频" value="1002" />
+            <el-option label="音频" value="1003" />
+            <el-option label="文本" value="1004" />
           </el-select>
         </el-form-item>
         <el-form-item>
@@ -25,10 +28,9 @@
         <el-button size="mini" type="danger" @click="share">分享</el-button>
       </el-form>
       <el-breadcrumb separator-class="el-icon-arrow-right" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
-        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
-        <el-breadcrumb-item :to="{ path: '/1' }">图片</el-breadcrumb-item>
-        <el-breadcrumb-item :to="{ path: '/1/2' }">照片</el-breadcrumb-item>
-        <el-breadcrumb-item v-text="this.$router.currentRoute.name" />
+        <el-breadcrumb-item v-for="(item, index) of parentDirs" :key="index">
+          <a href="javascript:void(0)" style="text-decoration-line: none" @click="goTo(item.path)">{{ item.filename }}</a>
+        </el-breadcrumb-item>
       </el-breadcrumb>
       <el-table
         ref="multipleTable"
@@ -201,12 +203,30 @@ export default {
       dataList: [],
       searchForm: {
         page: 1,
+        path: '/',
         fileType: '0',
         filename: null
       },
       currentDir: '/',
       multipleSelection: [],
-      parentDirs: ['图片', '照片', '2023'],
+      parentDirs: [
+        {
+          filename: '/',
+          path: '/'
+        },
+        {
+          filename: '图片',
+          path: '/图片'
+        },
+        {
+          filename: '照片',
+          path: '/图片/照片'
+        },
+        {
+          filename: '2023',
+          path: '/图片/照片/2023'
+        }
+      ],
       createFolderDialog: false,
       createFolderForm: {
         parent: null,
@@ -217,23 +237,30 @@ export default {
     }
   },
   created() {
+    const path = this.$route.query.path
+    if (path !== undefined && path !== null) {
+      this.searchForm.path = path
+    }
+
     document.title = '文件列表'
-    this.getData()
+    this.getData(this.searchForm)
   },
   methods: {
     handleCurrentChange(pageNumber) {
       this.currentPage = pageNumber
       this.searchForm.page = this.currentPage
-      this.getData()
+      this.getData(this.searchForm)
       // 回到顶部
       scrollTo(0, 0)
     },
-    getData() {
+    getData(searchForm) {
       this.dataList = []
-      getFileList(this.searchForm).then(resp => {
+      getFileList(searchForm).then(resp => {
         if (resp.code === 0) {
-          this.dataList = resp.data.list
-          this.totalSize = resp.data.totalSize
+          this.dataList = resp.data.fileList.list
+          this.totalSize = resp.data.fileList.totalSize
+
+          this.parentDirs = resp.data.pathList
         } else {
           this.$notify({
             title: '提示',
@@ -334,17 +361,28 @@ export default {
       const fileType = item.fileType
       if (fileType === 1000) {
         const filename = item.filename
-        console.log(filename)
+        const namePath = this.parentDirs[this.parentDirs.length - 1]
+        let currentPath
+        if (namePath.filename === '/') {
+          currentPath = namePath.path + filename
+        } else {
+          currentPath = namePath.path + '/' + filename
+        }
+        this.searchForm.path = currentPath
+        this.getData(this.searchForm)
       } else {
         const fileId = item.fileId
         this.previewFile(fileType, fileId)
       }
     },
+    goTo(path) {
+      console.log('go to ' + path)
+    },
     previewFile(fileType, fileId) {
-      this.previewFileDialog = true
       getFileUrl(fileType, fileId).then(resp => {
         if (resp.code === 0) {
           this.fileDetail = resp.data
+          this.previewFileDialog = true
         }
       })
     },