#I636K1 全局搜索优化

This commit is contained in:
暮光:城中城
2022-12-07 20:23:38 +08:00
parent c62d733869
commit f7cfce0bd8
12 changed files with 556 additions and 188 deletions

View File

@@ -1880,6 +1880,44 @@
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"dev": true
},
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"optional": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"optional": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"optional": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"optional": true
},
"debug": {
"version": "4.3.3",
"resolved": "https://registry.npmmirror.com/debug/download/debug-4.3.3.tgz",
@@ -1889,6 +1927,25 @@
"ms": "2.1.2"
}
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"optional": true
},
"loader-utils": {
"version": "2.0.4",
"resolved": "https://registry.npmmirror.com/loader-utils/-/loader-utils-2.0.4.tgz",
"integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==",
"dev": true,
"optional": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^2.1.2"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmmirror.com/ms/download/ms-2.1.2.tgz",
@@ -1903,6 +1960,28 @@
"requires": {
"minipass": "^3.1.1"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"optional": true,
"requires": {
"has-flag": "^4.0.0"
}
},
"vue-loader-v16": {
"version": "npm:vue-loader@16.8.3",
"resolved": "https://registry.npmmirror.com/vue-loader/-/vue-loader-16.8.3.tgz",
"integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
"dev": true,
"optional": true,
"requires": {
"chalk": "^4.1.0",
"hash-sum": "^2.0.0",
"loader-utils": "^2.0.0"
}
}
}
},
@@ -11791,87 +11870,6 @@
}
}
},
"vue-loader-v16": {
"version": "npm:vue-loader@16.8.3",
"resolved": "https://registry.npmmirror.com/vue-loader/download/vue-loader-16.8.3.tgz",
"integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
"dev": true,
"optional": true,
"requires": {
"chalk": "^4.1.0",
"hash-sum": "^2.0.0",
"loader-utils": "^2.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmmirror.com/ansi-styles/download/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"optional": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmmirror.com/chalk/download/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"optional": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmmirror.com/color-convert/download/color-convert-2.0.1.tgz",
"integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=",
"dev": true,
"optional": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmmirror.com/color-name/download/color-name-1.1.4.tgz",
"integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=",
"dev": true,
"optional": true
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmmirror.com/has-flag/download/has-flag-4.0.0.tgz",
"integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=",
"dev": true,
"optional": true
},
"loader-utils": {
"version": "2.0.2",
"resolved": "https://registry.npmmirror.com/loader-utils/download/loader-utils-2.0.2.tgz",
"integrity": "sha1-1uO0+4GHByGuTghoqxHdY4NowSk=",
"dev": true,
"optional": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^2.1.2"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmmirror.com/supports-color/download/supports-color-7.2.0.tgz",
"integrity": "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=",
"dev": true,
"optional": true,
"requires": {
"has-flag": "^4.0.0"
}
}
}
},
"vue-router": {
"version": "3.5.3",
"resolved": "https://registry.npmmirror.com/vue-router/download/vue-router-3.5.3.tgz",

View File

@@ -17,9 +17,22 @@
<div align="center">
<el-button v-on:click="createWiki" icon="el-icon-plus" style="width: 100%;">创建文档</el-button>
</div>
<el-input v-model="searchKeywords" @input="searchByKeywords" @keyup.enter.native="searchByKeywords" placeholder="搜索文档" style="margin: 10px 0;">
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywordsNewPage"></el-button>
</el-input>
<el-autocomplete
style="width: 100%;margin: 10px 0;" popper-class="search-autocomplete"
v-model="searchKeywords"
:fetch-suggestions="doSearchByKeywords"
placeholder="在当前空间搜索"
@select="handleSearchKeywordsSelect"
>
<template slot-scope="{ item }">
<div class="search-option-item">
<div class="title">
<span v-html="item.pageTitle || '-'"></span>
</div>
<span class="content" v-html="item.previewContent || '-'"></span>
</div>
</template>
</el-autocomplete>
<div style="overflow: auto; padding-bottom: 30px;">
<el-tree :props="defaultProps" :data="wikiPageList" @node-click="handleNodeClick"
@node-expand="handleNodeExpand" draggable @node-drop="handlePageDrop"
@@ -96,13 +109,13 @@
</template>
<script>
import userApi from '../../common/api/user'
import pageApi from '../../common/api/page'
import CreateSpace from '../space/CreateSpace'
import RightResize from './RightResize.vue'
import aboutDialog from "../../views/common/AboutDialog";
import userApi from '../../common/api/user'
import pageApi from '../../common/api/page'
import CreateSpace from '../space/CreateSpace'
import RightResize from './RightResize.vue'
import aboutDialog from "../../views/common/AboutDialog";
export default {
export default {
data() {
return {
leftCollapse: true,
@@ -176,6 +189,20 @@
changeWikiPageExpandedKeys(pageId) {
// 展开没有触发子节点的加载如果去加载子节点有还找不到当前的node暂不展开
// this.wikiPageExpandedKeys = [pageId];
},
doSearchByKeywords(queryString, callback) {
if (!queryString || !queryString.trim()) {
callback([]);
return;
}
pageApi.pageNews({spaceId: this.choiceSpace, keywords: queryString}).then(json => {
let spacePageNews = json.data || [];
callback(spacePageNews);
});
},
handleSearchKeywordsSelect(item) {
this.searchKeywords = '';
this.$router.push({path: '/page/show', query: {pageId: item.pageId}});
},
searchByKeywords() {
this.$refs.wikiPageTree.filter(this.searchKeywords);
@@ -305,32 +332,9 @@
});
},
doGetPageList(parentId, node) {
let param = {spaceId: this.choiceSpace, parentId: parentId || 0};
if (this.nowSpaceShow.treeLazyLoad === 0) {
param.parentId = null;
}
let param = {spaceId: this.choiceSpace};
pageApi.pageList(param).then(json => {
let result = json.data || [];
let treeData = [];
if (this.nowSpaceShow.treeLazyLoad === 0) {
treeData = result;
} else {
for (let i = 0; i < result.length; i++) {
let item = result[i];
item.parentId = item.parentId || 0;
item.children = [{name: '加载中...', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
treeData.push(item);
}
}
if (parentId > 0) {
node.children = treeData;
} else {
this.wikiPageList = treeData;
}
}).catch(() => {
if (parentId > 0) {
node.children = [];
}
this.wikiPageList = json.data || [];
});
},
userSettingDropdown(command) {
@@ -401,4 +405,24 @@
.head-icon{margin-right: 15px; font-size: 16px;cursor: pointer;color: #fff;}
.header-user-message .page-info-box{text-align: right;margin-top: 10px;}
.upgrade-info{max-height: 150px;overflow-y: auto;word-break: break-all; white-space: pre-wrap; line-height: 26px;}
.search-option-item {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.search-option-item .title {
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.search-option-item .content {
font-size: 12px;
color: #888;
}
.search-autocomplete {
width: 600px !important;
}
</style>

View File

@@ -12,9 +12,6 @@
<el-form-item label="空间开放:">
<el-switch v-model="newSpaceForm.openDoc" inactive-text="需要登录" :inactive-value="0" active-text="开放访问" :active-value="1"></el-switch>
</el-form-item>
<el-form-item label="目录加载:">
<el-switch v-model="newSpaceForm.treeLazyLoad" inactive-text="预先加载" :inactive-value="0" active-text="延迟加载" :active-value="1"></el-switch>
</el-form-item>
<el-form-item label="空间类型:">
<el-select v-model="newSpaceForm.type" filterable placeholder="选择类型" style="width: 100%;">
<el-option :key="1" label="公共空间" :value="1">

View File

@@ -31,7 +31,6 @@
<a target="_blank" href="https://github.com/alibaba/fastjson">Fastjson</a>
<a target="_blank" href="https://alibaba-easyexcel.github.io">Easy Excel</a>
<a target="_blank" href="https://swagger.io">Swagger</a>
<a target="_blank" href="https://dubbo.io">Dubbo</a>
<a target="_blank" href="http://www.eclipse.org/jgit">JGit</a>...
</div>
<el-divider content-position="left">前端</el-divider>

View File

@@ -1,9 +1,6 @@
<template>
<div style="padding: 10px;" class="home-vue">
<div style="max-width: 800px;margin: 0 auto;">
<el-select v-model="searchParam.newsType" v-on:change="getSpacePageNews" placeholder="请选择查看方式" style="float: right;z-index: 1;">
<el-option :label="item.val" :value="item.key" :key="item.key" v-for="item in newsTypesArr"></el-option>
</el-select>
<el-tabs value="first">
<el-tab-pane :label="newsTypesMap[searchParam.newsType]" name="first">
<div v-if="spacePageNews.length <= 0" class="empty-news">暂无数据</div>
@@ -23,18 +20,6 @@
</div>
</el-tab-pane>
</el-tabs>
<div class="page-info-box">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:page-sizes="[20, 50, 100]"
:page-size="20"
:current-page="searchParam.pageNum"
layout="prev, pager, next, jumper, sizes, total"
:total="totalCount"
>
</el-pagination>
</div>
</div>
</div>
</template>
@@ -72,7 +57,6 @@
getSpacePageNews() {
pageApi.pageNews(this.searchParam).then(json => {
this.spacePageNews = json.data || [];
this.totalCount = json.total;
});
},
handleSizeChange(val) {