diff --git a/src/api/file-api.js b/src/api/file-api.js index 6f729e7..e6c881a 100644 --- a/src/api/file-api.js +++ b/src/api/file-api.js @@ -137,6 +137,22 @@ export default { params }) }, + // 最近搜索记录🔍 + recentlySearchHistory: function(params) { + return request({ + url: '/search/recentlySearchHistory', + method: 'get', + params + }) + }, + // 删除搜索记录🔍 + deleteSearchHistory: function(params) { + return request({ + url: '/search/deleteSearchHistory', + method: 'delete', + params + }) + }, // 搜索文件🔍 searchFile: function(params) { return request({ diff --git a/src/components/SearchOption/index.vue b/src/components/SearchOption/index.vue index 66c813c..1d9e7b8 100644 --- a/src/components/SearchOption/index.vue +++ b/src/components/SearchOption/index.vue @@ -15,6 +15,22 @@
-
+
路径: {{ searchPath }}
+
+ + 全盘搜索 + +
+
+ + 包含挂载目录 + +
-
- - 包含挂载目录 - -
@@ -187,19 +205,24 @@ export default { sizeRange: [0, -1], // 默认范围:0 到 1GB fileTypeText: '全部文件', searchMount: false, - filterOption: { - type: null, - modifyStart: null, - searchMount: false, - modifyEnd: null, - sizeMin: null, - sizeMax: null - } + searchOverall: false, + filterOption: this.emptyFilterOption } }, computed: { hasSearchConditions() { - return this.fileType !== 'all' || this.timeRange || this.hasSizeRange || this.searchMount + return this.fileType !== 'all' || this.timeRange || this.hasSizeRange || this.searchMount || this.searchOverall + }, + emptyFilterOption() { + return { + type: null, + modifyStart: null, + modifyEnd: null, + sizeMin: null, + sizeMax: null, + searchMount: false, + searchOverall: false, + } }, hasSizeRange () { return this.sizeRange[0] >= 0 && this.sizeRange[1] > 0 @@ -231,6 +254,9 @@ export default { } }, watch: { + filterOption(newValue) { + console.log('filterOption changed', newValue) + } }, methods: { // 更新筛选条件并通知父组件 @@ -241,12 +267,52 @@ export default { modifyEnd: this.timeRange ? new Date(this.timeRange[1]).getTime() : null, sizeMin: this.hasSizeRange ? this.sizeRange[0] : null, sizeMax: this.hasSizeRange ? this.sizeRange[1] : null, - searchMount: this.searchMount + searchMount: this.searchMount, + searchOverall: this.searchOverall } this.$emit('filter-change') this.$emit('update:filter-option-param', this.filterOption) this.$emit('update:has-search-conditions-param', this.hasSearchConditions) + localStorage.setItem('searchFilterOption', JSON.stringify(this.filterOption)) + }, + + clearFilterOption() { + this.filterOption = this.emptyFilterOption + console.log('clearFilterOption') + this.setFilterOption(this.filterOption) + }, + + setFilterOption(filterOption) { + if (!filterOption) return + + // 设置文件类型 + this.handleFileType(filterOption.type || 'all') + + // 设置时间范围 + if (filterOption.modifyStart && filterOption.modifyEnd) { + this.timeRange = [ + new Date(filterOption.modifyStart), + new Date(filterOption.modifyEnd) + ] + } else { + this.timeRange = null + } + + // 设置文件大小范围 + if (filterOption.sizeMin !== null && filterOption.sizeMax !== null) { + this.sizeRange = [filterOption.sizeMin, filterOption.sizeMax] + } else { + this.sizeRange = [-1, -1] + } + + // 设置搜索选项 + this.searchMount = !!filterOption.searchMount + this.searchOverall = !!filterOption.searchOverall + + // 更新过滤条件 + console.log('setFilterOption') + this.updateFilterOption() }, handleFileType(command) { @@ -298,9 +364,8 @@ export default { this.updateFilterOption() }, - resetKeyword() { - this.$emit('update:keyword', '') - this.$emit('update:visible', false) + resetSearchOverall() { + this.searchOverall = false this.updateFilterOption() }, @@ -376,12 +441,15 @@ export default { handleSearchMountChange() { this.updateFilterOption() + }, + handleSearchOverallChange() { + this.updateFilterOption() } } } - diff --git a/src/styles/custom-ui.scss b/src/styles/custom-ui.scss new file mode 100644 index 0000000..889caaf --- /dev/null +++ b/src/styles/custom-ui.scss @@ -0,0 +1,31 @@ +>>> .el-checkbox { + + &:hover { + background-color: #f5f7fa; + border-radius: 6px; + } + + .el-checkbox__inner { + background-color: #f0f0f0; /* 浅灰色背景 */ + border-color: #dcdcdc; /* 浅灰色边框 */ + border-radius: 4px; /* 圆角 */ + } + + .el-checkbox__input.is-checked .el-checkbox__inner { + background-color: #a0a0a0; /* 深灰色背景 */ + border-color: #a0a0a0; /* 深灰色边框 */ + } + + .el-checkbox__input.is-checked .el-checkbox__inner::after { + border-color: #ffffff; /* 白色勾号 */ + } + + .el-checkbox__inner:hover { + //border-color: #b0b0b0; /* hover 时边框颜色 */ + cursor: pointer; + } + + .el-checkbox__input.is-checked+.el-checkbox__label { + color: #606266; + } +}