feat: 可搜索挂载文件夹内的文件

This commit is contained in:
jmal 2024-06-14 18:52:16 +08:00
parent 4389770f71
commit f6aadecca2

View File

@ -168,7 +168,6 @@
@blur="setInputBlur()" @blur="setInputBlur()"
@clear="searchFile(searchFileName)" @clear="searchFile(searchFileName)"
> >
<kbd v-show="!inputting" slot="suffix">f</kbd>
<el-button slot="prepend" @click="searchFile(searchFileName)"> <el-button slot="prepend" @click="searchFile(searchFileName)">
<svg-icon icon-class="search" style="font-size: 22px" /> <svg-icon icon-class="search" style="font-size: 22px" />
</el-button> </el-button>
@ -1286,8 +1285,8 @@ export default {
} }
}) })
} }
if (this.$route.query.folder && this.path && !this.$route.query.keyword) { if (this.$route.query.searchOpenFolder && this.path && !this.$route.query.keyword) {
localStorage.setItem(this.path, this.$route.query.folder) localStorage.setItem(this.path, this.$route.query.searchOpenFolder)
} }
if (this.$route.query.highlight) { if (this.$route.query.highlight) {
this.onCreateFilename = this.$route.query.highlight this.onCreateFilename = this.$route.query.highlight
@ -1299,9 +1298,9 @@ export default {
} }
// remove query.folder // remove query.folder
if (this.$route.query.folder && this.$route.query.keyword) { if (this.$route.query.searchOpenFolder && this.$route.query.keyword) {
const query = { ...this.$route.query } const query = { ...this.$route.query }
delete query.folder delete query.searchOpenFolder
this.$router.replace({ query }) this.$router.replace({ query })
} }
@ -1401,14 +1400,6 @@ export default {
event.stopPropagation() event.stopPropagation()
} }
} }
// f键
if (keyCode === 70) {
if (!this.inputting && this.editingIndex === -1) {
this.$refs.searchInput.focus()
event.preventDefault()
event.stopPropagation()
}
}
}, },
keyup(event) { keyup(event) {
const isMac = navigator.platform.startsWith('Mac') const isMac = navigator.platform.startsWith('Mac')
@ -1418,13 +1409,6 @@ export default {
if (keyCode === 16) { if (keyCode === 16) {
this.selectPin = false this.selectPin = false
} }
// f键
if (keyCode === 70) {
if (!this.inputting && this.editingIndex === -1) {
event.preventDefault()
event.stopPropagation()
}
}
}, },
onmessage(msg) { onmessage(msg) {
let fileDoc = msg.body let fileDoc = msg.body
@ -2318,9 +2302,8 @@ export default {
} }
this.path = this.path.replace(/\\/g, '/') this.path = this.path.replace(/\\/g, '/')
}) })
let queryFolder = localStorage.getItem('mountFileOwner') let queryFolder = localStorage.getItem('mountFileOwner') ? localStorage.getItem(this.path) : this.$route.query.folder
? localStorage.getItem(this.path) const searchOpenFolder = this.$route.query.searchOpenFolder ? `&searchOpenFolder=${this.$route.query.searchOpenFolder}` : ''
: this.$route.query.folder
if (!unPushLink) { if (!unPushLink) {
const queryTagId = this.$route.query.tagId const queryTagId = this.$route.query.tagId
? `&tagId=${this.$route.query.tagId}` ? `&tagId=${this.$route.query.tagId}`
@ -2337,11 +2320,7 @@ export default {
if (searchPathIndex < 0) { if (searchPathIndex < 0) {
keywordQuery = '' keywordQuery = ''
} }
this.$router.push( this.$router.push(`?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder=' + queryFolder : ''}${queryTagId}${basePath}${keywordQuery}${searchOpenFolder}`)
`?vmode=${this.vmode}&path=${encodeURI(this.path)}${
queryFolder ? '&folder=' + queryFolder : ''
}${queryTagId}${basePath}${keywordQuery}`
)
} }
if (!unRefresh) { if (!unRefresh) {
this.pagination.pageIndex = 1 this.pagination.pageIndex = 1
@ -2585,11 +2564,9 @@ export default {
const keyword = this.$route.query.keyword const keyword = this.$route.query.keyword
? `&keyword=${this.$route.query.keyword}` ? `&keyword=${this.$route.query.keyword}`
: '' : ''
this.$router.push( const folder = this.$route.query.folder ? `&folder=${this.$route.query.folder}` : ''
`?vmode=${this.vmode}&path=${this.path}${ const searchOpenFolder = this.$route.query.searchOpenFolder ? `&searchOpenFolder=${this.$route.query.searchOpenFolder}` : ''
this.$route.query.folder ? '&folder=' + this.$route.query.folder : '' this.$router.push(`?vmode=${this.vmode}&path=${this.path}${folder}${queryTagId}${basePath}${keyword}${searchOpenFolder}`)
}${queryTagId}${basePath}${keyword}`
)
// 改变拖拽目标 // 改变拖拽目标
this.rowDrop() this.rowDrop()
// 画矩形选取 // 画矩形选取
@ -2755,18 +2732,21 @@ export default {
item['search'] = true item['search'] = true
item['searchKey'] = key item['searchKey'] = key
let folder = this.$route.query.folder ? `&folder=${this.$route.query.folder}` : '' let searchOpenFolder = this.$route.query.searchOpenFolder ? `&searchOpenFolder=${this.$route.query.searchOpenFolder}` : ''
const searchPathIndex = this.pathList.findIndex(item => item.search) const searchPathIndex = this.pathList.findIndex(item => item.search)
console.log('searchPathIndex', searchPathIndex)
if (searchPathIndex < 0) { if (searchPathIndex < 0) {
this.pathList.push(item) this.pathList.push(item)
} else { } else {
this.pathList.splice(searchPathIndex,this.pathList.length - searchPathIndex) this.pathList.splice(searchPathIndex,this.pathList.length - searchPathIndex)
this.pathList.push(item) this.pathList.push(item)
searchOpenFolder = ''
} }
const queryTagId = this.$route.query.tagId const queryTagId = this.$route.query.tagId
? `&tagId=${this.$route.query.tagId}` ? `&tagId=${this.$route.query.tagId}`
: '' : ''
const folder = this.$route.query.folder ? `&folder=${this.$route.query.folder}` : ''
const basePath = this.getBasePath() const basePath = this.getBasePath()
const keyword = key ? `&keyword=${key}` : '' const keyword = key ? `&keyword=${key}` : ''
const path = this.path const path = this.path
@ -2775,7 +2755,7 @@ export default {
this.$router.push( this.$router.push(
`?vmode=${ `?vmode=${
this.vmode this.vmode
}&path=${path}${keyword}${queryTagId}${basePath}${folder}` }&path=${path}${keyword}${searchOpenFolder}${queryTagId}${basePath}${folder}`
) )
api api
.searchFile({ .searchFile({
@ -2785,6 +2765,7 @@ export default {
sortableProp: this.sortable.prop, sortableProp: this.sortable.prop,
order: this.sortable.order, order: this.sortable.order,
currentDirectory: this.getQueryPath(), currentDirectory: this.getQueryPath(),
folder: this.$route.query.folder,
tagId: this.$route.query.tagId, tagId: this.$route.query.tagId,
isFolder: this.queryCondition.isFolder, isFolder: this.queryCondition.isFolder,
isFavorite: this.queryCondition.isFavorite, isFavorite: this.queryCondition.isFavorite,
@ -2818,10 +2799,9 @@ export default {
? `&keyword=${this.$route.query.keyword}` ? `&keyword=${this.$route.query.keyword}`
: '' : ''
const basePath = this.getBasePath() const basePath = this.getBasePath()
const folder = `&folder=${fileId}` const searchOpenFolder = `&searchOpenFolder=${fileId}`
this.$router.push( const folder = this.$route.query.folder ? `&folder=${this.$route.query.folder}` : ''
`?vmode=${this.vmode}${path}${keyword}${queryTagId}${basePath}${folder}` this.$router.push(`?vmode=${this.vmode}${path}${keyword}${searchOpenFolder}${queryTagId}${basePath}${folder}`)
)
api api
.searchFileAndOpenDir({ .searchFileAndOpenDir({
@ -2865,8 +2845,8 @@ export default {
this.searchFileName = this.$route.query.keyword this.searchFileName = this.$route.query.keyword
} }
const searchPathIndex = this.pathList.findIndex(item => item.search) const searchPathIndex = this.pathList.findIndex(item => item.search)
if (this.$route.query.folder && searchPathIndex > -1) { if (this.$route.query.searchOpenFolder && searchPathIndex > -1) {
this.searchFileAndOpenDir(this.$route.query.folder, onLoad) this.searchFileAndOpenDir(this.$route.query.searchOpenFolder, onLoad)
} else { } else {
this.searchFile(this.searchFileName) this.searchFile(this.searchFileName)
} }
@ -3358,7 +3338,8 @@ export default {
}) })
} }
if (row.isFolder && row.mountFileId) { if (row.isFolder && row.mountFileId) {
const indicesToDelete = [6, 5, 4, 3, 1] console.log('this.menus', this.menus)
const indicesToDelete = [7, 6, 5, 4, 1]
for (let i of indicesToDelete) { for (let i of indicesToDelete) {
this.menus.splice(i, 1) this.menus.splice(i, 1)
} }
@ -4204,12 +4185,8 @@ 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 const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : ''
? `&tagId=${this.$route.query.tagId}` const keyword = this.$route.query.keyword ? `&keyword=${this.$route.query.keyword}` : ''
: ''
const keyword = this.$route.query.keyword
? `&keyword=${this.$route.query.keyword}`
: ''
// 打开文件夹 // 打开文件夹
if (this.listModeSearch) { if (this.listModeSearch) {
const item = {} const item = {}
@ -4218,15 +4195,14 @@ export default {
item['row'] = row item['row'] = row
this.pathList.push(item) this.pathList.push(item)
this.pagination.pageIndex = 1 this.pagination.pageIndex = 1
const folder = row.id ? `&folder=${row.id}` : '' const searchOpenFolder = row.id ? `&searchOpenFolder=${row.id}` : ''
const path = this.$route.query.path const path = this.$route.query.path ? `&path=${this.$route.query.path}` : ''
? `&path=${this.$route.query.path}` const folder = this.$route.query.folder ? `&folder=${this.$route.query.folder}` : ''
: ''
const basePath = this.getBasePath() const basePath = this.getBasePath()
this.$router.push( this.$router.push(
`?vmode=${ `?vmode=${
this.vmode this.vmode
}${path}${keyword}${folder}${queryTagId}${basePath}` }${path}${keyword}${searchOpenFolder}${folder}${queryTagId}${basePath}`
) )
this.searchFileAndOpenDir(row.id) this.searchFileAndOpenDir(row.id)
} else { } else {
@ -4261,15 +4237,9 @@ export default {
if (row.mountFileId) { if (row.mountFileId) {
localStorage.setItem(this.path, row.mountFileId) localStorage.setItem(this.path, row.mountFileId)
} }
const basePath = const basePath = this.basePath && this.basePath.length > 1 ? `&basePath=${this.basePath}` : ''
this.basePath && this.basePath.length > 1 const searchOpenFolder = this.$route.query.searchOpenFolder ? `&searchOpenFolder=${this.$route.query.searchOpenFolder}` : ''
? `&basePath=${this.basePath}` this.$router.push(`?vmode=${this.vmode}&path=${path}${row.mountFileId ? '&folder=' + row.mountFileId : ''}${queryTagId}${basePath}${keyword}${searchOpenFolder}`)
: ''
this.$router.push(
`?vmode=${this.vmode}&path=${path}${
row.mountFileId ? '&folder=' + row.mountFileId : ''
}${queryTagId}${basePath}${keyword}`
)
this.openDir(row) this.openDir(row)
} }
} else { } else {
@ -4336,15 +4306,6 @@ export default {
this.notPreviewDialogVisible = true this.notPreviewDialogVisible = true
} }
}, },
// 强行使用文本编辑器打开
forciblyOpen(file) {
this.textPreviewRow = file
this.textPreviewVisible = true
const that = this
setTimeout(function() {
that.notPreviewDialogVisible = false
}, 100)
},
determineDownload(file) { determineDownload(file) {
this.download(file) this.download(file)
this.notPreviewDialogVisible = false this.notPreviewDialogVisible = false