You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2019/12/27 10:02:19 UTC
[incubator-echarts-doc] branch release updated: fix search error
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch release
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-doc.git
The following commit(s) were added to refs/heads/release by this push:
new d657daa fix search error
d657daa is described below
commit d657daae5ad3c455b3e7c7a93c7f5f57b009afe0
Author: pissang <bm...@gmail.com>
AuthorDate: Fri Dec 27 18:02:05 2019 +0800
fix search error
---
src/components/DocContent.vue | 4 ++--
src/docHelper.js | 33 +++++++++++----------------------
2 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/src/components/DocContent.vue b/src/components/DocContent.vue
index 9eae169..ae91073 100644
--- a/src/components/DocContent.vue
+++ b/src/components/DocContent.vue
@@ -27,7 +27,6 @@
import {
getPageTotalDescAsync,
- getRootPageTotalDescAsync,
getPageOutlineAsync,
getOutlineAsync,
convertPathToId,
@@ -90,7 +89,8 @@ export default {
},
created() {
- getRootPageTotalDescAsync().then(rootPageDescMap => {
+ // Root page.
+ getPageTotalDescAsync('').then(rootPageDescMap => {
this.rootPageDescMap = rootPageDescMap;
});
diff --git a/src/docHelper.js b/src/docHelper.js
index 0d1e89b..3d057d0 100644
--- a/src/docHelper.js
+++ b/src/docHelper.js
@@ -20,7 +20,7 @@ let descStorage = {};
let pageOutlines;
let outlineNodesMap = {};
-let allNodesPathes = [];
+let allNodesPaths = [];
function stripHtml(str) {
@@ -92,7 +92,7 @@ function processOutlines(json) {
json.isRoot = true;
- allNodesPathes = Object.keys(outlineNodesMap);
+ allNodesPaths = Object.keys(outlineNodesMap);
return json;
}
@@ -128,17 +128,6 @@ export function getPageOutlineAsync(targetPath) {
});
}
-export function getRootPageTotalDescAsync() {
- let partionKey = rootName;
- if (!descStorage[partionKey]) {
- let url = `${baseUrl}/${partionKey}.json?${docVersion}`;
- descStorage[partionKey] = {
- fetcher: fetch(url).then(response => response.json())
- };
- }
- return descStorage[partionKey].fetcher;
-}
-
function createIndexer(map, pagePath) {
let list = [];
for (let path in map) {
@@ -262,11 +251,11 @@ export function searchOutlineAsync(queryString, numberLimit = 50) {
return getOutlineAsync().then(() => {
let lists = [];
- for (let i = 0; i < allNodesPathes.length; i++) {
+ for (let i = 0; i < allNodesPaths.length; i++) {
if (lists.length >= numberLimit) {
return lists;
}
- let p = allNodesPathes[i];
+ let p = allNodesPaths[i];
if (p.indexOf(queryString) >= 0) {
lists.push(getOutlineNode(p));
}
@@ -274,11 +263,11 @@ export function searchOutlineAsync(queryString, numberLimit = 50) {
if (lists.length < numberLimit) {
if (!querySearchScores) {
- querySearchScores = new Uint8Array(allNodesPathes.length);
+ querySearchScores = new Uint8Array(allNodesPaths.length);
}
let matchScoreCount = 0;
- for (let i = 0; i < allNodesPathes.length; i++) {
- querySearchScores[i] = stringSimilarity(allNodesPathes[i], queryString) * 255;
+ for (let i = 0; i < allNodesPaths.length; i++) {
+ querySearchScores[i] = stringSimilarity(allNodesPaths[i], queryString) * 255;
if (querySearchScores[i] > 50) {
matchScoreCount++;
}
@@ -298,7 +287,7 @@ export function searchOutlineAsync(queryString, numberLimit = 50) {
}
if (maxScore > 50) { // Threshold
picked[maxIndex] = true;
- lists.push(getOutlineNode(allNodesPathes[maxIndex]));
+ lists.push(getOutlineNode(allNodesPaths[maxIndex]));
matchScoreCount--;
}
safeCount++;
@@ -318,7 +307,7 @@ export function getOutlineNode(path) {
export function getDefaultPage(wrongPath) {
if (!wrongPath) {
- return Object.keys(outlineNodesMap)[0];
+ return Object.keys(pageOutlines)[0];
}
// Compatitable with series-line.data[i]
if (getOutlineNode(wrongPath.replace('[i]', ''))) {
@@ -341,8 +330,8 @@ export function getDefaultPage(wrongPath) {
// Else find the nearest
let mostLikeKey;
let maxSimilarity = -Infinity;
- for (let i = 0; i < allNodesPathes.length; i++) {
- let p = allNodesPathes[i];
+ for (let i = 0; i < allNodesPaths.length; i++) {
+ let p = allNodesPaths[i];
let similarity = stringSimilarity(wrongPath, p);
if (similarity > maxSimilarity) {
maxSimilarity = similarity;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org