-
新增功能,磁盘格式化,层级面包屑跳转,视频预览优化
-
主要记录一下面包屑的实现思路
2.1 面包屑渲染
<el-breadcrumb separator-class="el-icon-arrow-right"> <el-breadcrumb-item> <el-link :underline="false" @click="skipCrumbs(0)">根目录</el-link> </el-breadcrumb-item> <el-breadcrumb-item v-for="(item,index) in crumbsList":key="index"> <el-link :underline="false" @click="skipCrumbs(item.id)">{{item.name}}</el-link> </el-breadcrumb-item> </el-breadcrumb>
定义vue dataallCrumbsList: [],crumbsList: [],
js 代码
4.
checkboxOndblclick(disk) { console.log(disk); if (disk.isDir===1) { this.queryParams.parentId = disk.id; const skip = { id: disk.id, parentId: disk.parentId, name: disk.name } this.allCrumbsList.push(skip); this.allCrumbsList = this.uniqueObjects(this.allCrumbsList); this.crumbsList=[]; this.generateCrumbs(disk.id); this.skipList.push(disk.id); this.skipList = [...new Set(this.skipList)]; this.uploadFileUrl = process.env.VUE_APP_BASE_API + "/disk/file/upload/"+disk.id this.getList(); } }, handleSkip(skip) { if(skip===0) { let index = this.skipList.indexOf(this.queryParams.parentId); this.skip(index-1) }else { let index = this.skipList.indexOf(this.queryParams.parentId); this.skip(index+1) } }, skip(nextIndex) { this.crumbsList=[]; if (nextIndex<0) { this.queryParams.parentId=0; this.allCrumbsList=[]; this.getList(); }else if (nextIndex>=this.skipList.length) { this.queryParams.parentId =0; this.allCrumbsList=[]; this.getList(); } else { this.queryParams.parentId = this.skipList[nextIndex]; this.generateCrumbs(this.queryParams.parentId); this.getList(); } }, uniqueObjects(arr) { const unique = []; const seen = new Set(); arr.forEach(item => { const stringifiedItem = JSON.stringify(item); if (!seen.has(stringifiedItem)) { unique.push(item); seen.add(stringifiedItem); } }); return unique; }, generateCrumbs(id) { if (id===0) { this.crumbsList = this.crumbsList.reverse(); return; } const crumbs = this.getCrumbsListById(id); if (crumbs!=null&&crumbs!=undefined) { this.crumbsList.push(crumbs); this.generateCrumbs(crumbs.parentId); } }, getCrumbsListById(id) { return this.allCrumbsList.find(item => { return item.id === id; }); }, skipCrumbs(id) { this.queryParams.parentId = id; this.crumbsList = []; this.generateCrumbs(this.queryParams.parentId); this.getList(); },
体验地址 鸿枫网盘