From c4aa8eb2dbdca2c34f5dcc4c38a4300ae8607efb Mon Sep 17 00:00:00 2001 From: jmal Date: Wed, 22 May 2024 11:42:37 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=94=B6=E8=97=8F?= =?UTF-8?q?=E9=A1=B5=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShowFile/ShowFile.vue | 38 ++++++++++++++++------------ src/views/favorite/index.vue | 36 ++------------------------ 2 files changed, 24 insertions(+), 50 deletions(-) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index af36436..a2246a5 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -1324,7 +1324,7 @@ export default { } }); } - if (this.$route.query.folder && this.path) { + if (this.$route.query.folder && this.path && !this.$route.query.keyword) { localStorage.setItem(this.path, this.$route.query.folder) } if (this.$route.query.highlight) { @@ -2297,6 +2297,7 @@ export default { }, handleLink(item, index, unPushLink, unRefresh, keywordQuery) { this.pathList.splice(this.pathList.findIndex((v, i) => i === index + 1),this.pathList.length - (index + 1)) + console.log('handleLink', item) if (item && item.search) { if (item.searchKey) { this.searchFileByKeyword(item.searchKey); @@ -2313,8 +2314,7 @@ export default { } this.path = this.path.replace(/\\/g, "/"); }) - let queryFolder = localStorage.getItem(this.path) - + let queryFolder = localStorage.getItem("mountFileOwner") ? localStorage.getItem(this.path) : this.$route.query.folder if (!unPushLink) { const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : '' const basePath = this.getBasePath() @@ -2773,6 +2773,14 @@ export default { }, searchFileAndOpenDir(fileId, onLoad) { this.beforeLoadData(onLoad); + + const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : '' + const path = this.$route.query.path ? `&path=${this.$route.query.path}` : '' + const keyword = this.$route.query.keyword ? `&keyword=${this.$route.query.keyword}` : '' + const basePath = this.getBasePath() + const folder = `&folder=${fileId}` + this.$router.push(`?vmode=${this.vmode}${path}${keyword}${queryTagId}${basePath}${folder}`) + api.searchFileAndOpenDir({ userId: this.$store.state.user.userId, username: this.$store.getters.name, @@ -3102,7 +3110,7 @@ export default { this.rowContextData = row; } const isFavorite = this.rowContextData.isFavorite; - this.highlightFavorite(this.isCollectView ? true : isFavorite, false); + this.highlightFavorite(isFavorite, false); }, // 单元格hover进入时事件 cellMouseEnter(row) { @@ -3356,7 +3364,7 @@ export default { ) { this.menusIsMultiple = true; this.menus = this.multipleRightMenus; - this.highlightFavorite(this.isCollectView, false); + this.highlightFavorite(false, false); } else { this.$refs.fileListTable.clearSelection(); this.$refs.fileListTable.toggleRowSelection([{ row: row }]); @@ -3394,10 +3402,10 @@ export default { } }, menuFavoriteOver(index, isFavorite) { - this.highlightFavorite(this.isCollectView ? true : isFavorite, false); + this.highlightFavorite(isFavorite, false); }, menuFavoriteLeave(index, isFavorite) { - this.highlightFavorite(this.isCollectView ? true : isFavorite, false); + this.highlightFavorite(isFavorite, false); }, // 是否高亮收藏图标 highlightFavorite(isFavorite, isHover) { @@ -3911,19 +3919,17 @@ export default { const fileIds = this.getSelectIdList(); this.rowContextData.isFavorite = isFavorite; this.highlightFavorite(isFavorite, true); - api - .favoriteUrl({ + api.favoriteUrl({ fileIds: fileIds, isFavorite: isFavorite - }) - .then(res => { + }).then(() => { // 收藏页面 - if (!isFavorite && this.isCollectView) { + const homePage = !this.$route.query.path || this.$route.query.length <= 1 + if (!isFavorite && this.isCollectView && homePage) { // 移除列表 this.removeSelectItme(); } - }) - .catch(() => { + }).catch(() => { this.rowContextData.isFavorite = !isFavorite; }); }, @@ -4118,8 +4124,8 @@ export default { if (row.mountFileId) { localStorage.setItem(this.path, row.mountFileId) } - const basePath = this.basePath ? `&basePath=${this.basePath}` : '' - this.$router.push(`?vmode=${this.vmode}&path=${encodeURI(path)}${row.mountFileId ? '&folder='+row.mountFileId : ''}${queryTagId}${basePath}${keyword}`); + const basePath = this.basePath && this.basePath.length > 1 ? `&basePath=${this.basePath}` : '' + this.$router.push(`?vmode=${this.vmode}&path=${path}${row.mountFileId ? '&folder='+row.mountFileId : ''}${queryTagId}${basePath}${keyword}`); this.openDir(row); } } else { diff --git a/src/views/favorite/index.vue b/src/views/favorite/index.vue index aedb13a..d61eaa1 100644 --- a/src/views/favorite/index.vue +++ b/src/views/favorite/index.vue @@ -7,10 +7,6 @@ :orderCustom="true" :defaultSort="sortable" :queryCondition="queryCondition" - :singleMenus="singleMenus" - :singleMenusEdit="singleMenusEdit" - :multipleMenus="multipleMenus" - :multipleRightMenus="multipleRightMenus" :contextMenus="contextMenus" > @@ -45,7 +41,7 @@ }, { label: '刷新', operation: 'refresh'}, { divider: true, operation: 'divider' }, - { label: '新建', operation: 'create' , homeDisable: true ,child: [ + { label: '新建', operation: 'create' , homeDisable: true, child: [ { label: '文件夹', operation: 'createFolder', iconClass: 'folder'}, { divider: true, operation: 'divider' }, { label: '文本', operation: 'createTextFile', iconClass: 'file-txt'}, @@ -58,35 +54,7 @@ }, { divider: true, operation: 'divider' }, { label: '写文章', operation: 'createMarkdownFile'}, - ], - singleMenus: [ - { iconClass: 'menu-open', label: '打开', operation: 'open' }, - { iconClass: 'share', label: '分享', operation: 'share' }, - { iconClass: 'menu-favorite', label: '收藏', operation: 'favorite' }, - { iconClass: 'menu-details', label: '详细信息', operation: 'details' }, - { iconClass: 'menu-rename', label: '重命名', operation: 'rename' }, - { iconClass: 'menu-copy', label: '移动或复制', operation: 'copy' }, - { iconClass: 'menu-download', label: '下载', operation: 'download' }, - // { iconClass: 'menu-favorite-hover', label: '取消收藏', operation: 'unFavorite' } - ], - singleMenusEdit: [ - { iconClass: 'menu-open', label: '打开', operation: 'open' }, - { iconClass: 'share', label: '分享', operation: 'share' }, - { iconClass: 'menu-favorite', label: '收藏', operation: 'favorite' }, - { iconClass: 'menu-edit1', label: '编辑', operation: 'edit' }, - { iconClass: 'menu-details', label: '详细信息', operation: 'details' }, - { iconClass: 'menu-rename', label: '重命名', operation: 'rename' }, - { iconClass: 'menu-download', label: '下载', operation: 'download' }, - // { iconClass: 'menu-favorite-hover', label: '取消收藏', operation: 'unFavorite' } - ], - multipleMenus: [ - { iconClass: 'menu-download', label: '下载', operation: 'download' }, - { iconClass: 'menu-favorite-hover', label: '取消收藏', operation: 'unFavorite' } - ], - multipleRightMenus: [ - { iconClass: 'menu-download', label: '下载', operation: 'download' }, - { iconClass: 'menu-favorite-hover', label: '取消收藏', operation: 'unFavorite' } - ], + ] } }, }