fix: 修复搜索选项和显示文件组件的问题
- 修复了 SearchOption 组件中 includeFileName 和 includeFileContent 属性的错误赋值 - 优化了 ShowFile 组件中的搜索历史查询逻辑 - 调整了搜索建议的加载顺序和内容
This commit is contained in:
parent
a2307bd3c2
commit
d46b630841
@ -415,8 +415,8 @@ export default {
|
|||||||
this.searchOverall = !!filterOption.searchOverall
|
this.searchOverall = !!filterOption.searchOverall
|
||||||
this.exactSearch = !!filterOption.exactSearch
|
this.exactSearch = !!filterOption.exactSearch
|
||||||
this.includeTagName = filterOption.includeTagName === undefined ? true : filterOption.includeTagName
|
this.includeTagName = filterOption.includeTagName === undefined ? true : filterOption.includeTagName
|
||||||
this.includeFileName = filterOption.includeFileName === undefined ? true : filterOption.includeTagName
|
this.includeFileName = filterOption.includeFileName === undefined ? true : filterOption.includeFileName
|
||||||
this.includeFileContent = filterOption.includeFileName === undefined ? true : filterOption.includeTagName
|
this.includeFileContent = filterOption.includeFileContent === undefined ? true : filterOption.includeFileContent
|
||||||
|
|
||||||
// 更新过滤条件
|
// 更新过滤条件
|
||||||
this.updateFilterOption()
|
this.updateFilterOption()
|
||||||
|
|||||||
@ -893,41 +893,41 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import SearchOption from '@/components/SearchOption/index.vue'
|
|
||||||
import DialogFileList from '@/components/ShowFile/DialogFileList.vue'
|
|
||||||
import FileClipboard from '@/components/ShowFile/FileClipboard.vue'
|
|
||||||
import store from '@/store'
|
|
||||||
import path from 'path'
|
|
||||||
import { fileOperations } from '@/utils/file-operations'
|
|
||||||
import { mapGetters, mapState } from 'vuex'
|
|
||||||
import { formatSize, formatTime } from '@/utils/number'
|
|
||||||
import { getElementToPageLeft } from '@/utils/dom'
|
|
||||||
import { suffix } from '@/utils/file-type'
|
|
||||||
import { formatExif,formatVideo } from '@/utils/media'
|
|
||||||
import api from '@/api/file-api'
|
import api from '@/api/file-api'
|
||||||
import BreadcrumbFilePath from '@/components/Breadcrumb/BreadcrumbFilePath'
|
import BreadcrumbFilePath from '@/components/Breadcrumb/BreadcrumbFilePath'
|
||||||
import IconFile from '@/components/Icon/IconFile'
|
|
||||||
import EmptyFile from '@/components/EmptyFile'
|
|
||||||
import SimTextPreview from '@/components/preview/SimTextPreview'
|
|
||||||
import ImageViewer from '@/components/preview/ImageViewer'
|
|
||||||
import VideoPreview from '@/components/preview/VideoPreview'
|
|
||||||
import AudioPreview from '@/components/preview/AudioPreview'
|
|
||||||
import ButtonUpload from '@/components/button/ButtonUpload'
|
import ButtonUpload from '@/components/button/ButtonUpload'
|
||||||
import MessageDialog from '@/components/message/MessageDialog'
|
import EmptyFile from '@/components/EmptyFile'
|
||||||
|
|
||||||
import FileTree from '@/components/FileTree'
|
import FileTree from '@/components/FileTree'
|
||||||
|
|
||||||
import '@/utils/directives.js'
|
import '@/utils/directives.js'
|
||||||
|
import IconFile from '@/components/Icon/IconFile'
|
||||||
import _ from "lodash";
|
import MessageDialog from '@/components/message/MessageDialog'
|
||||||
|
import AudioPreview from '@/components/preview/AudioPreview'
|
||||||
|
import FileDetails from '@/components/preview/FileDetails.vue'
|
||||||
|
import IframePreview from '@/components/preview/IframePreview.vue'
|
||||||
|
import ImageViewer from '@/components/preview/ImageViewer'
|
||||||
|
import SimTextPreview from '@/components/preview/SimTextPreview'
|
||||||
|
import VideoPreview from '@/components/preview/VideoPreview'
|
||||||
|
import SearchOption from '@/components/SearchOption/index.vue'
|
||||||
|
import ShareDialog from '@/components/ShareDialog/index.vue'
|
||||||
|
import DialogFileList from '@/components/ShowFile/DialogFileList.vue'
|
||||||
|
import FileClipboard from '@/components/ShowFile/FileClipboard.vue'
|
||||||
|
import TagDialog from '@/components/TagDialog/index.vue'
|
||||||
|
import store from '@/store'
|
||||||
|
import { getElementToPageLeft } from '@/utils/dom'
|
||||||
|
|
||||||
import fileConfig from '@/utils/file-config'
|
import fileConfig from '@/utils/file-config'
|
||||||
|
import { fileOperations } from '@/utils/file-operations'
|
||||||
|
import { suffix } from '@/utils/file-type'
|
||||||
|
import { formatExif, formatVideo } from '@/utils/media'
|
||||||
|
import { formatSize, formatTime } from '@/utils/number'
|
||||||
import EditElement from '@/views/markdown/EditElement'
|
import EditElement from '@/views/markdown/EditElement'
|
||||||
import IframePreview from '@/components/preview/IframePreview.vue'
|
|
||||||
import ShareDialog from '@/components/ShareDialog/index.vue'
|
|
||||||
import Clipboard from 'clipboard'
|
import Clipboard from 'clipboard'
|
||||||
import TagDialog from '@/components/TagDialog/index.vue'
|
|
||||||
import FileDetails from "@/components/preview/FileDetails.vue";
|
import _ from 'lodash'
|
||||||
|
import path from 'path'
|
||||||
|
import { mapGetters, mapState } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ShowFile',
|
name: 'ShowFile',
|
||||||
@ -4649,10 +4649,8 @@ export default {
|
|||||||
id: 'recently_search_id'
|
id: 'recently_search_id'
|
||||||
}
|
}
|
||||||
if (!queryString) {
|
if (!queryString) {
|
||||||
await this.pushSearchHistory(queryString, recentlySearch)
|
this.queryRecentlySearchHistory(queryString, recentlySearch, cb)
|
||||||
} else {
|
} else {
|
||||||
// 用户已输入关键字
|
|
||||||
// 1. 固定操作项
|
|
||||||
const fixedActionItems = [
|
const fixedActionItems = [
|
||||||
{
|
{
|
||||||
sugType: 'action_current_path_search',
|
sugType: 'action_current_path_search',
|
||||||
@ -4668,32 +4666,24 @@ export default {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
this.searchSuggestions.push(...fixedActionItems)
|
this.searchSuggestions.push(...fixedActionItems)
|
||||||
await this.pushSearchHistory(queryString, recentlySearch)
|
this.queryRecentlySearchHistory(queryString, recentlySearch, cb)
|
||||||
}
|
}
|
||||||
cb(this.searchSuggestions)
|
|
||||||
},
|
},
|
||||||
async pushSearchHistory(queryString, recentlySearch) {
|
queryRecentlySearchHistory(queryString = '', recentlySearch, cb) {
|
||||||
const historyItems = await this.queryRecentlySearchHistory(queryString)
|
api.getRecentlySearchHistory({keyword: queryString}).then(res => {
|
||||||
if (historyItems.length > 0) {
|
const historyItems = res.data.map(item => ({
|
||||||
this.searchSuggestions.push(recentlySearch)
|
...item,
|
||||||
}
|
value: item.keyword,
|
||||||
this.searchSuggestions.push(...historyItems)
|
sugType: 'history'
|
||||||
},
|
}))
|
||||||
async queryRecentlySearchHistory(queryString = '') {
|
if (historyItems.length > 0) {
|
||||||
return new Promise(resolve => {
|
this.searchSuggestions.push(recentlySearch)
|
||||||
setTimeout(() => {
|
}
|
||||||
api.getRecentlySearchHistory({keyword: queryString}).then(res => {
|
this.searchSuggestions.push(...historyItems)
|
||||||
const filteredHistory = res.data.map(item => ({
|
cb(this.searchSuggestions)
|
||||||
...item,
|
}).catch(error => {
|
||||||
value: item.keyword,
|
console.error("Error fetching search history:", error)
|
||||||
sugType: 'history'
|
})
|
||||||
}))
|
|
||||||
resolve(filteredHistory)
|
|
||||||
}).catch(error => {
|
|
||||||
console.error("Error fetching search history:", error)
|
|
||||||
})
|
|
||||||
}, 50)
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
handleSelectSuggestion(item) {
|
handleSelectSuggestion(item) {
|
||||||
this._isSuggestionHandledBySelect = true
|
this._isSuggestionHandledBySelect = true
|
||||||
@ -4739,7 +4729,9 @@ export default {
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
api.removeAllSearchHistory({userId: this.$store.getters.userId}).then(() => {
|
api.removeAllSearchHistory({userId: this.$store.getters.userId}).then(() => {
|
||||||
this.searchSuggestions.splice(2, this.searchSuggestions.length - 2)
|
this.searchSuggestions = this.searchSuggestions.filter(
|
||||||
|
item => item.sugType === 'action_current_path_search' || item.sugType === 'action_global_search'
|
||||||
|
);
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user