perf: 优化标签页的搜索

This commit is contained in:
jmal 2025-04-27 17:30:26 +08:00
parent 4de190a106
commit a0993eaf0f
2 changed files with 14 additions and 8 deletions

View File

@ -3,7 +3,7 @@
<div class="search-option-wrapper"> <div class="search-option-wrapper">
<div class="search-option-result"> <div class="search-option-result">
<div> <div>
<span>搜索:</span> <span>搜索 <span class="search-scope">{{searchScope}}</span>:</span>
<span>{{ keyword }}</span> <span>{{ keyword }}</span>
</div> </div>
<div> <div>
@ -122,7 +122,7 @@
</div> </div>
<!-- 搜索条件标签 --> <!-- 搜索条件标签 -->
<div class="search-tags"> <div class="search-tags">
<div v-if="searchPath.length > 1 && !searchOverall"> <div v-if="searchPath !== 'undefined' && searchPath.length > 1 && !searchOverall">
<el-tag <el-tag
@close="resetSearchPath"> @close="resetSearchPath">
路径: {{ searchPath }} 路径: {{ searchPath }}
@ -210,6 +210,14 @@ export default {
} }
}, },
computed: { computed: {
searchScope() {
const queryTagId = this.$route.query.tagId
const path = this.$route.query.path;
if (queryTagId && path === '/') {
return '(当前标签)'
}
return ''
},
hasSearchConditions() { hasSearchConditions() {
return this.fileType !== 'all' || this.timeRange || this.hasSizeRange || this.searchMount || this.searchOverall return this.fileType !== 'all' || this.timeRange || this.hasSizeRange || this.searchMount || this.searchOverall
}, },
@ -255,7 +263,6 @@ export default {
}, },
watch: { watch: {
filterOption(newValue) { filterOption(newValue) {
console.log('filterOption changed', newValue)
} }
}, },
methods: { methods: {
@ -279,7 +286,6 @@ export default {
clearFilterOption() { clearFilterOption() {
this.filterOption = this.emptyFilterOption this.filterOption = this.emptyFilterOption
console.log('clearFilterOption')
this.setFilterOption(this.filterOption) this.setFilterOption(this.filterOption)
}, },
@ -311,7 +317,6 @@ export default {
this.searchOverall = !!filterOption.searchOverall this.searchOverall = !!filterOption.searchOverall
// 更新过滤条件 // 更新过滤条件
console.log('setFilterOption')
this.updateFilterOption() this.updateFilterOption()
}, },

View File

@ -90,7 +90,7 @@
<div class="search-class"> <div class="search-class">
<el-popover <el-popover
v-if="showUploadButton" v-if="showUploadButton"
v-show="!(pathList.length < 2 && homeHidden)" v-show="!(isRootPath && homeHidden)"
v-model="isShowNewFolder" v-model="isShowNewFolder"
placement="bottom" placement="bottom"
trigger="hover" trigger="hover"
@ -1222,6 +1222,9 @@ export default {
cmdKey() { cmdKey() {
return navigator.platform.startsWith('Mac') ? '⌘' : 'Ctrl' return navigator.platform.startsWith('Mac') ? '⌘' : 'Ctrl'
}, },
isRootPath() {
return !this.$route.query.path || this.$route.query.path.length < 2
},
fileClipboard() { fileClipboard() {
return store.getters.fileClipboard return store.getters.fileClipboard
}, },
@ -2963,7 +2966,6 @@ export default {
this.vmode this.vmode
}&path=${path}${keyword}${searchOpenFolder}${queryTagId}${basePath}${folder}` }&path=${path}${keyword}${searchOpenFolder}${queryTagId}${basePath}${folder}`
) )
console.log('this.filterOption', this.filterOption)
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,
@ -4547,7 +4549,6 @@ export default {
} }
api.recentlySearchHistory({keyword: queryString}).then(res => { api.recentlySearchHistory({keyword: queryString}).then(res => {
this.searchHistoryList = res.data || [] this.searchHistoryList = res.data || []
console.log('clearSearchHistory1', this.searchHistoryList)
cb(this.searchHistoryList) cb(this.searchHistoryList)
}).catch(error => { }).catch(error => {
console.error("Error fetching search history:", error) console.error("Error fetching search history:", error)