perf: 优化标页面和收藏页面

This commit is contained in:
jmal 2024-03-18 15:58:47 +08:00
parent fd88b2d6c1
commit a88df8c76f
5 changed files with 74 additions and 28 deletions

View File

@ -1016,6 +1016,7 @@ export default {
}&name=${this.$store.state.user.name}&id=`, }&name=${this.$store.state.user.name}&id=`,
fileMenuActive: "", fileMenuActive: "",
path: this.$route.query.path, path: this.$route.query.path,
basePath: '/',
showNewFolder: false, showNewFolder: false,
isShowNewFolder: false, isShowNewFolder: false,
listModeSearch: false, listModeSearch: false,
@ -1300,6 +1301,7 @@ export default {
this.pathList.push(item); this.pathList.push(item);
} }
}); });
console.log('this.pathList', this.pathList)
} }
if (this.$route.query.folder && this.path) { if (this.$route.query.folder && this.path) {
localStorage.setItem(this.path, this.$route.query.folder) localStorage.setItem(this.path, this.$route.query.folder)
@ -2237,7 +2239,7 @@ export default {
Bus.$emit("openUploader", { Bus.$emit("openUploader", {
// 传入的参数 // 传入的参数
folder: this.$route.query.folder, folder: this.$route.query.folder,
currentDirectory: this.path, currentDirectory: this.getQueryPath(),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}); });
@ -2248,7 +2250,7 @@ export default {
Bus.$emit("uploadFolder", { Bus.$emit("uploadFolder", {
// 传入的参数 // 传入的参数
folder: this.$route.query.folder, folder: this.$route.query.folder,
currentDirectory: this.path, currentDirectory: this.getQueryPath(),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}); });
@ -2262,7 +2264,8 @@ export default {
// 浏览器的返回事件 // 浏览器的返回事件
goBack() { goBack() {
if (this.pathList.length <= 1) { if (this.pathList.length <= 1) {
this.$router.push(`/?vmode=${this.vmode}&path=${encodeURI(this.path)}`); const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : ''
this.$router.push(`/?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryTagId}`);
return; return;
} }
this.lastLink(); this.lastLink();
@ -2302,14 +2305,11 @@ export default {
let queryFolder = localStorage.getItem(this.path) let queryFolder = localStorage.getItem(this.path)
if (!unPushLink) { if (!unPushLink) {
const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : ''
if (!this.$route.query.path) { if (!this.$route.query.path) {
this.$router.push( this.$router.push(`?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}${queryTagId}`);
`?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`
);
} else { } else {
this.$router.push( this.$router.push(`?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}${queryTagId}`);
`?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`
);
} }
} }
if (!unRefresh) { if (!unRefresh) {
@ -2416,7 +2416,7 @@ export default {
.uploadFolder({ .uploadFolder({
isFolder: true, isFolder: true,
filename: encodeURI(this.newFolderName), filename: encodeURI(this.newFolderName),
currentDirectory: encodeURI(this.path), currentDirectory: this.getQueryPath(),
folder: this.$route.query.folder, folder: this.$route.query.folder,
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
@ -2537,7 +2537,8 @@ export default {
this.path = ""; this.path = "";
} }
this.editingIndex = -1; this.editingIndex = -1;
this.$router.push(`?vmode=${this.vmode}&path=${this.path}${this.$route.query.folder ? '&folder='+this.$route.query.folder : ''}`); const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : ''
this.$router.push(`?vmode=${this.vmode}&path=${this.path}${this.$route.query.folder ? '&folder='+this.$route.query.folder : ''}${queryTagId}`);
// 改变拖拽目标 // 改变拖拽目标
this.rowDrop(); this.rowDrop();
// 画矩形选取 // 画矩形选取
@ -2691,14 +2692,15 @@ export default {
item1["search"] = true; item1["search"] = true;
item1["searchKey"] = key; item1["searchKey"] = key;
this.pathList.push(item1); this.pathList.push(item1);
this.$router.push(`?vmode=${this.vmode}&search-file=${key}`); const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : ''
this.$router.push(`?vmode=${this.vmode}&search-file=${key}${queryTagId}`);
api.searchFile({ api.searchFile({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
keyword: key, keyword: key,
sortableProp: this.sortable.prop, sortableProp: this.sortable.prop,
order: this.sortable.order, order: this.sortable.order,
currentDirectory: encodeURI(this.$route.query.path), currentDirectory: this.getQueryPath(),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
}) })
@ -2717,7 +2719,7 @@ export default {
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.getters.name, username: this.$store.getters.name,
id: row.id, id: row.id,
currentDirectory: encodeURI(this.$route.query.path), currentDirectory: this.getQueryPath(),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize, pageSize: this.pagination.pageSize,
folder: this.$route.query.folder folder: this.$route.query.folder
@ -2737,7 +2739,7 @@ export default {
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.getters.name, username: this.$store.getters.name,
id: row.mountFileId || row.id, id: row.mountFileId || row.id,
currentDirectory: encodeURI(this.$route.query.path), currentDirectory: this.getQueryPath(),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize, pageSize: this.pagination.pageSize,
folder: this.$route.query.folder folder: this.$route.query.folder
@ -2755,7 +2757,7 @@ export default {
.fileList({ .fileList({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
currentDirectory: encodeURI(this.$route.query.path), currentDirectory: this.getQueryPath(),
folder: this.$route.query.folder, folder: this.$route.query.folder,
queryFileType: this.queryFileType, queryFileType: this.queryFileType,
sortableProp: this.sortable.prop, sortableProp: this.sortable.prop,
@ -2777,7 +2779,7 @@ export default {
.fileList({ .fileList({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
currentDirectory: encodeURI(this.$route.query.path), currentDirectory: this.getQueryPath(),
folder: this.$route.query.folder, folder: this.$route.query.folder,
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
@ -2786,6 +2788,16 @@ export default {
this.loadData(res, onLoad); this.loadData(res, onLoad);
}); });
}, },
getQueryPath() {
// 去掉this.$route.query.basePath最后的/
let basePath = this.$route.query.basePath ? this.$route.query.basePath : "/";
if (basePath) {
if (basePath.lastIndexOf("/") === basePath.length - 1) {
basePath = basePath.substring(0, basePath.length - 1);
}
}
return encodeURI(basePath + this.$route.query.path);
},
tableBodyScroll(table, e) { tableBodyScroll(table, e) {
this.fileListScrollTop = e.target.scrollTop; this.fileListScrollTop = e.target.scrollTop;
let scrollBottom = let scrollBottom =
@ -3704,7 +3716,7 @@ export default {
.newFolder({ .newFolder({
isFolder: true, isFolder: true,
filename: encodeURI(newFolderName), filename: encodeURI(newFolderName),
currentDirectory: encodeURI(path), currentDirectory: this.getQueryPath(),
folder: this.$route.query.folder, folder: this.$route.query.folder,
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
@ -3885,7 +3897,7 @@ export default {
}).then(() => { }).then(() => {
api api
.delete({ .delete({
currentDirectory: this.rowContextData.path, currentDirectory: this.getQueryPath(),
username: this.$store.state.user.name, username: this.$store.state.user.name,
fileIds: fileIds fileIds: fileIds
}) })
@ -4013,6 +4025,7 @@ export default {
this.openingFile = row; this.openingFile = row;
if (row.isFolder) { if (row.isFolder) {
this.editingIndex = -1; this.editingIndex = -1;
const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : ''
// 打开文件夹 // 打开文件夹
if (this.listModeSearch) { if (this.listModeSearch) {
const item = {}; const item = {};
@ -4021,14 +4034,20 @@ export default {
item["row"] = row; item["row"] = row;
this.pathList.push(item); this.pathList.push(item);
this.pagination.pageIndex = 1; this.pagination.pageIndex = 1;
this.$router.push(`?vmode=${this.vmode}&search-file=${row.id}`); this.$router.push(`?vmode=${this.vmode}&search-file=${row.id}${queryTagId}`);
this.searchFileAndOpenDir(row); this.searchFileAndOpenDir(row);
} else { } else {
let notHomePage = this.$route.path.length > 1
if (notHomePage && this.basePath.length === 1) {
this.basePath = row.path
}
if (this.path) { if (this.path) {
this.path += "/" + row.name; this.path += "/" + row.name;
} else { } else {
this.path = "/" + row.name; this.path = this.basePath + row.name;
} }
// 去掉this.path开头的this.basePath
this.path = this.path.replace(this.basePath, '/')
const item = { folder: row.name, shareBase: row.shareBase }; const item = { folder: row.name, shareBase: row.shareBase };
this.pathList.push(item); this.pathList.push(item);
this.pagination.pageIndex = 1; this.pagination.pageIndex = 1;
@ -4039,7 +4058,7 @@ export default {
if (row.mountFileId) { if (row.mountFileId) {
localStorage.setItem(this.path, row.mountFileId) localStorage.setItem(this.path, row.mountFileId)
} }
this.$router.push(`?vmode=${this.vmode}&path=${path}${row.mountFileId ? '&folder='+row.mountFileId : ''}`); this.$router.push(`?vmode=${this.vmode}&path=${path}${row.mountFileId ? '&folder='+row.mountFileId : ''}${queryTagId}${this.basePath.length > 1 ? '&basePath='+this.basePath : ''}`);
this.openDir(row); this.openDir(row);
} }
} else { } else {

View File

@ -166,7 +166,6 @@ export default {
isCollapse(val){ isCollapse(val){
}, },
$route(to) { $route(to) {
console.log(to.meta.menuType)
this.showTag = to.meta !== undefined && to.meta.menuType !== undefined && to.meta.menuType === 0; this.showTag = to.meta !== undefined && to.meta.menuType !== undefined && to.meta.menuType === 0;
} }
}, },

View File

@ -24,7 +24,7 @@
data() { data() {
return { return {
sortable: { sortable: {
prop: 'updateDate', order: 'descending' prop: 'name', order: 'ascending'
}, },
queryCondition: { queryCondition: {
isFavorite: true isFavorite: true

View File

@ -19,7 +19,7 @@ export default {
sortable: { sortable: {
prop: 'name', order: 'ascending' prop: 'name', order: 'ascending'
}, },
contextMenus: [ // contextmenuClick contextMenus: [
{ label: '查看', operation: 'viewMode' ,child: [ { label: '查看', operation: 'viewMode' ,child: [
{ iconClass: this.grid?'':'menu-point', label: '列表', operation: 'vmode-list'}, { iconClass: this.grid?'':'menu-point', label: '列表', operation: 'vmode-list'},
{ iconClass: this.grid?'menu-point':'', label: '缩略图', operation: 'vmode-grid'}, { iconClass: this.grid?'menu-point':'', label: '缩略图', operation: 'vmode-grid'},

View File

@ -6,6 +6,7 @@
:orderCustom="true" :orderCustom="true"
:defaultSort="sortable" :defaultSort="sortable"
:queryCondition="queryCondition" :queryCondition="queryCondition"
:contextMenus="contextMenus"
> >
</show-file> </show-file>
</div> </div>
@ -13,18 +14,45 @@
<script> <script>
import ShowFile from "@/components/ShowFile/ShowFile"; import ShowFile from "@/components/ShowFile/ShowFile";
import Bus from "@/assets/js/bus";
export default { export default {
components: {ShowFile}, components: {ShowFile},
data() { data() {
return { return {
sortable: { sortable: {
prop: 'updateDate', order: 'descending' prop: 'name', order: 'ascending'
}, },
queryCondition: { queryCondition: {
tagId: undefined, tagId: undefined,
} },
contextMenus: [
{ label: '查看', operation: 'viewMode' ,child: [
{ iconClass: this.grid?'':'menu-point', label: '列表', operation: 'vmode-list'},
{ iconClass: this.grid?'menu-point':'', label: '缩略图', operation: 'vmode-grid'},
]
},
{ label: '排列方式', operation: 'arrangement' ,child: [
{ label: '名称', operation: 'orderName', orderProp: 'name'},
{ label: '大小', operation: 'orderSize', orderProp: 'size'},
{ label: '日期', operation: 'orderUpdateDate', orderProp: 'updateDate'},
]
},
{ label: '刷新', operation: 'refresh'},
{ divider: true, operation: 'divider' },
{ label: '新建', operation: 'create' ,child: [
{ label: '文件夹', operation: 'createFolder', iconClass: 'folder'},
{ divider: true, operation: 'divider' },
{ label: '文本', operation: 'createTextFile', iconClass: 'file-txt'},
{ label: '思维导图', operation: 'createMinderFile', iconClass: 'file-mind'},
{ label: '流程图', operation: 'createDrawioFile', iconClass: 'file-drawio'},
{ label: 'Word', operation: 'createWordFile', iconClass: 'file-word'},
{ label: 'Excel', operation: 'createExcelFile', iconClass: 'file-excel'},
{ label: 'PPT', operation: 'createPPTFile', iconClass: 'file-ppt'},
]
},
{ divider: true, operation: 'divider' },
{ label: '写文章', operation: 'createMarkdownFile'},
]
} }
}, },
mounted() { mounted() {