perf: 优化移动端搜索状态下打开目录的操作
This commit is contained in:
parent
6418c607c9
commit
93dca9c470
@ -34,7 +34,7 @@
|
|||||||
v-model="loading"
|
v-model="loading"
|
||||||
:finished="finished"
|
:finished="finished"
|
||||||
:finished-text="statistics()"
|
:finished-text="statistics()"
|
||||||
@load="searchStatus && searchValue.length>0?searchFile(searchValue,true):getFileList(true)"
|
@load="getFileList(true)"
|
||||||
>
|
>
|
||||||
<van-checkbox-group v-model="selectRowData" @change="checkboxChange" ref="checkboxGroup">
|
<van-checkbox-group v-model="selectRowData" @change="checkboxChange" ref="checkboxGroup">
|
||||||
<van-cell-group>
|
<van-cell-group>
|
||||||
@ -807,10 +807,13 @@ export default {
|
|||||||
searchAction.style.marginRight = '-44px'
|
searchAction.style.marginRight = '-44px'
|
||||||
searchAction.style.visibility = 'hidden'
|
searchAction.style.visibility = 'hidden'
|
||||||
this.searchValue = ''
|
this.searchValue = ''
|
||||||
|
this.pathList.splice(1, this.pathList.length - 1)
|
||||||
|
this.$router.push(`?vmode=${this.vmode}`)
|
||||||
this.getFileList()
|
this.getFileList()
|
||||||
},
|
},
|
||||||
onSearch() {
|
onSearch() {
|
||||||
if (this.searchValue.length < 1) {
|
if (this.searchValue.length < 1) {
|
||||||
|
this.$router.push(`?vmode=${this.vmode}`)
|
||||||
this.getFileList()
|
this.getFileList()
|
||||||
} else {
|
} else {
|
||||||
this.searchFile(this.searchValue)
|
this.searchFile(this.searchValue)
|
||||||
@ -898,25 +901,53 @@ export default {
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.getFileList();
|
this.getFileList();
|
||||||
},
|
},
|
||||||
getFileList(onLoad) {
|
searchFileAndOpenDir(fileId, onLoad) {
|
||||||
this.beforeLoadData(onLoad)
|
this.beforeLoadData(onLoad);
|
||||||
api.fileList({
|
api.searchFileAndOpenDir({
|
||||||
username: this.$store.state.user.name,
|
|
||||||
userId: this.$store.state.user.userId,
|
userId: this.$store.state.user.userId,
|
||||||
currentDirectory: encodeURI(this.$route.query.path),
|
username: this.$store.getters.name,
|
||||||
folder: this.$route.query.folder,
|
id: fileId,
|
||||||
queryFileType: this.queryFileType,
|
|
||||||
sortableProp: this.sortableProp,
|
|
||||||
order: this.order,
|
|
||||||
isFolder: this.queryCondition.isFolder,
|
|
||||||
isFavorite: this.queryCondition.isFavorite,
|
|
||||||
queryCondition: this.queryCondition,
|
|
||||||
pageIndex: this.pagination.pageIndex,
|
pageIndex: this.pagination.pageIndex,
|
||||||
pageSize: this.pagination.pageSize,
|
pageSize: this.pagination.pageSize,
|
||||||
|
folder: this.$route.query.folder,
|
||||||
|
showFolderSize: localStorage.getItem('showFolderSize')
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.loadData(res, onLoad)
|
this.loadData(res, onLoad)
|
||||||
}).catch(e => {
|
this.listModeSearch = true
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
getFileList(onLoad) {
|
||||||
|
this.beforeLoadData(onLoad)
|
||||||
|
if (this.$route.query.keyword) {
|
||||||
|
if (this.$route.query.keyword !== "undefined") {
|
||||||
|
this.searchValue = this.$route.query.keyword
|
||||||
|
}
|
||||||
|
const searchPathIndex = this.pathList.findIndex(item => item.search)
|
||||||
|
if (this.$route.query.folder && searchPathIndex > -1) {
|
||||||
|
this.searchFileAndOpenDir(this.$route.query.folder, false)
|
||||||
|
} else {
|
||||||
|
this.searchFile(this.searchValue, onLoad)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.beforeLoadData(onLoad)
|
||||||
|
api.fileList({
|
||||||
|
username: this.$store.state.user.name,
|
||||||
|
userId: this.$store.state.user.userId,
|
||||||
|
currentDirectory: encodeURI(this.$route.query.path),
|
||||||
|
folder: this.$route.query.folder,
|
||||||
|
queryFileType: this.queryFileType,
|
||||||
|
sortableProp: this.sortableProp,
|
||||||
|
order: this.order,
|
||||||
|
isFolder: this.queryCondition.isFolder,
|
||||||
|
isFavorite: this.queryCondition.isFavorite,
|
||||||
|
queryCondition: this.queryCondition,
|
||||||
|
pageIndex: this.pagination.pageIndex,
|
||||||
|
pageSize: this.pagination.pageSize,
|
||||||
|
}).then(res => {
|
||||||
|
this.loadData(res, onLoad)
|
||||||
|
}).catch(e => {
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
searchFile(key, onLoad) {
|
searchFile(key, onLoad) {
|
||||||
if (key) {
|
if (key) {
|
||||||
@ -933,7 +964,6 @@ export default {
|
|||||||
this.loadData(res, onLoad)
|
this.loadData(res, onLoad)
|
||||||
this.path = ''
|
this.path = ''
|
||||||
this.listModeSearch = true
|
this.listModeSearch = true
|
||||||
this.listModeSearchOpenDir = false
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -943,9 +973,9 @@ export default {
|
|||||||
this.pagination.pageIndex++
|
this.pagination.pageIndex++
|
||||||
} else {
|
} else {
|
||||||
this.pagination.pageIndex = 1
|
this.pagination.pageIndex = 1
|
||||||
|
this.fileList = []
|
||||||
}
|
}
|
||||||
this.finished = false;
|
this.finished = false;
|
||||||
this.fileList = []
|
|
||||||
},
|
},
|
||||||
// 填充数据
|
// 填充数据
|
||||||
loadData(res, onLoad) {
|
loadData(res, onLoad) {
|
||||||
@ -1087,15 +1117,29 @@ export default {
|
|||||||
item['folder'] = row.name
|
item['folder'] = row.name
|
||||||
item['index'] = this.pathList.length - 1
|
item['index'] = this.pathList.length - 1
|
||||||
this.pathList.push(item)
|
this.pathList.push(item)
|
||||||
const path = encodeURI(this.path);
|
const keyword = this.$route.query.keyword ? `&keyword=${this.$route.query.keyword}` : ''
|
||||||
if (this.$store.getters.userId !== row.userId) {
|
if (this.listModeSearch) {
|
||||||
row.mountFileId = row.id
|
const item = {};
|
||||||
|
item["folder"] = row.name;
|
||||||
|
item["search"] = true;
|
||||||
|
item["row"] = row;
|
||||||
|
this.pathList.push(item);
|
||||||
|
this.pagination.pageIndex = 1;
|
||||||
|
const folder = row.id ? `&folder=${row.id}` : ''
|
||||||
|
const path = this.$route.query.path ? `&path=${this.$route.query.path}` : ''
|
||||||
|
this.$router.push(`?vmode=${this.vmode}${path}${keyword}${folder}`);
|
||||||
|
this.getFileList()
|
||||||
|
} else {
|
||||||
|
const path = encodeURI(this.path);
|
||||||
|
if (this.$store.getters.userId !== row.userId) {
|
||||||
|
row.mountFileId = row.id
|
||||||
|
}
|
||||||
|
if (row.mountFileId) {
|
||||||
|
localStorage.setItem(this.path, row.mountFileId)
|
||||||
|
}
|
||||||
|
this.$router.push(`/_m?vmode=${this.vmode}&path=${path}${keyword}${row.mountFileId ? '&folder='+row.mountFileId : ''}`)
|
||||||
|
this.getFileList()
|
||||||
}
|
}
|
||||||
if (row.mountFileId) {
|
|
||||||
localStorage.setItem(this.path, row.mountFileId)
|
|
||||||
}
|
|
||||||
this.$router.push(`/_m?vmode=${this.vmode}&path=${path}${row.mountFileId ? '&folder='+row.mountFileId : ''}`)
|
|
||||||
this.getFileList()
|
|
||||||
} else {
|
} else {
|
||||||
if (row.contentType.startsWith('image')) {
|
if (row.contentType.startsWith('image')) {
|
||||||
// 图片
|
// 图片
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user