feat: 添加全文搜索,搜索范围: 文件名、标签名和文件文本内容
This commit is contained in:
parent
5e94997796
commit
7671fdbb96
@ -2678,14 +2678,27 @@ export default {
|
|||||||
searchFile(key, onLoad) {
|
searchFile(key, onLoad) {
|
||||||
if (key) {
|
if (key) {
|
||||||
this.beforeLoadData(onLoad);
|
this.beforeLoadData(onLoad);
|
||||||
this.pathList = [{ folder: "" }];
|
// this.pathList = [{ folder: "" }];
|
||||||
const item1 = {};
|
// 查找this.pathList中是否已经有搜索的路径
|
||||||
item1["folder"] = "搜索: " + '"' + key + '"';
|
let isExist = false;
|
||||||
item1["search"] = true;
|
this.pathList.forEach(item => {
|
||||||
item1["searchKey"] = key;
|
if (item.search) {
|
||||||
this.pathList.push(item1);
|
// 修改搜索的路径
|
||||||
|
item.folder = "搜索: " + '"' + key + '"';
|
||||||
|
isExist = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!isExist) {
|
||||||
|
const item1 = {};
|
||||||
|
item1["folder"] = "搜索: " + '"' + key + '"';
|
||||||
|
item1["search"] = true;
|
||||||
|
item1["searchKey"] = key;
|
||||||
|
this.pathList.push(item1);
|
||||||
|
}
|
||||||
const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : ''
|
const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` : ''
|
||||||
this.$router.push(`?vmode=${this.vmode}&search-file=${key}${queryTagId}`);
|
const keyword = key ? `&keyword=${key}` : ''
|
||||||
|
const path = this.path ? encodeURI(this.path) : "/";
|
||||||
|
this.$router.push(`?vmode=${this.vmode}&path=${path}${keyword}${queryTagId}`);
|
||||||
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,
|
||||||
@ -2693,15 +2706,22 @@ export default {
|
|||||||
sortableProp: this.sortable.prop,
|
sortableProp: this.sortable.prop,
|
||||||
order: this.sortable.order,
|
order: this.sortable.order,
|
||||||
currentDirectory: this.getQueryPath(),
|
currentDirectory: this.getQueryPath(),
|
||||||
|
tagId: this.$route.query.tagId,
|
||||||
|
isFolder: this.queryCondition.isFolder,
|
||||||
|
isFavorite: this.queryCondition.isFavorite,
|
||||||
|
queryFileType: this.queryFileType,
|
||||||
pageIndex: this.pagination.pageIndex,
|
pageIndex: this.pagination.pageIndex,
|
||||||
pageSize: this.pagination.pageSize
|
pageSize: this.pagination.pageSize
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.loadData(res, onLoad);
|
this.loadData(res, onLoad);
|
||||||
this.path = "";
|
|
||||||
this.listModeSearch = true;
|
this.listModeSearch = true;
|
||||||
this.listModeSearchOpenDir = false;
|
this.listModeSearchOpenDir = false;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
if (this.listModeSearch) {
|
||||||
|
this.lastLink()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
searchFileAndOpenDir(row, onLoad) {
|
searchFileAndOpenDir(row, onLoad) {
|
||||||
@ -2743,27 +2763,35 @@ export default {
|
|||||||
this.path = this.path.replace(/\\/g, "/");
|
this.path = this.path.replace(/\\/g, "/");
|
||||||
},
|
},
|
||||||
getFileList(onLoad) {
|
getFileList(onLoad) {
|
||||||
this.getFileListed = true;
|
if (this.$route.query.keyword) {
|
||||||
this.beforeLoadData(onLoad);
|
if (this.$route.query.keyword !== "undefined") {
|
||||||
api
|
this.searchFileName = this.$route.query.keyword;
|
||||||
.fileList({
|
}
|
||||||
userId: this.$store.state.user.userId,
|
this.searchFile(this.searchFileName)
|
||||||
username: this.$store.state.user.name,
|
} else {
|
||||||
currentDirectory: this.getQueryPath(),
|
this.searchFileName = ""
|
||||||
folder: this.$route.query.folder,
|
this.getFileListed = true
|
||||||
queryFileType: this.queryFileType,
|
this.beforeLoadData(onLoad)
|
||||||
sortableProp: this.sortable.prop,
|
api
|
||||||
order: this.sortable.order,
|
.fileList({
|
||||||
isFolder: this.queryCondition.isFolder,
|
userId: this.$store.state.user.userId,
|
||||||
isFavorite: this.queryCondition.isFavorite,
|
username: this.$store.state.user.name,
|
||||||
tagId: this.queryCondition.tagId,
|
currentDirectory: this.getQueryPath(),
|
||||||
queryCondition: this.queryCondition,
|
folder: this.$route.query.folder,
|
||||||
pageIndex: this.pagination.pageIndex,
|
queryFileType: this.queryFileType,
|
||||||
pageSize: this.pagination.pageSize
|
sortableProp: this.sortable.prop,
|
||||||
})
|
order: this.sortable.order,
|
||||||
.then(res => {
|
isFolder: this.queryCondition.isFolder,
|
||||||
this.loadData(res, onLoad);
|
isFavorite: this.queryCondition.isFavorite,
|
||||||
});
|
tagId: this.queryCondition.tagId,
|
||||||
|
queryCondition: this.queryCondition,
|
||||||
|
pageIndex: this.pagination.pageIndex,
|
||||||
|
pageSize: this.pagination.pageSize
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
this.loadData(res, onLoad);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getFileListBySearchMode(onLoad) {
|
getFileListBySearchMode(onLoad) {
|
||||||
this.beforeLoadData(onLoad);
|
this.beforeLoadData(onLoad);
|
||||||
@ -4025,7 +4053,9 @@ export default {
|
|||||||
item["row"] = row;
|
item["row"] = row;
|
||||||
this.pathList.push(item);
|
this.pathList.push(item);
|
||||||
this.pagination.pageIndex = 1;
|
this.pagination.pageIndex = 1;
|
||||||
this.$router.push(`?vmode=${this.vmode}&search-file=${row.id}${queryTagId}`);
|
const keyword = this.$route.query.keyword ? `&keyword=${this.$route.query.keyword}` : ''
|
||||||
|
const folder = row.id ? `&folder=${row.id}` : ''
|
||||||
|
this.$router.push(`?vmode=${this.vmode}${keyword}${folder}${queryTagId}`);
|
||||||
this.searchFileAndOpenDir(row);
|
this.searchFileAndOpenDir(row);
|
||||||
} else {
|
} else {
|
||||||
let notHomePage = this.$route.path.length > 1
|
let notHomePage = this.$route.path.length > 1
|
||||||
|
|||||||
@ -936,7 +936,7 @@ export default {
|
|||||||
searchFile(key, onLoad) {
|
searchFile(key, onLoad) {
|
||||||
if (key) {
|
if (key) {
|
||||||
this.beforeLoadData(onLoad)
|
this.beforeLoadData(onLoad)
|
||||||
this.$router.push(`?vmode=${this.vmode}&search-file=${key}`)
|
this.$router.push(`?vmode=${this.vmode}&keyword=${key}`)
|
||||||
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,
|
||||||
@ -1660,6 +1660,8 @@ input {
|
|||||||
.search-result {
|
.search-result {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
height: unset;
|
||||||
|
margin-top: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-result-no {
|
.search-result-no {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user