You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by wa...@apache.org on 2022/12/13 05:29:07 UTC
[dolphinscheduler-website] branch master updated: [Fix] Revise bugs. (#853)
This is an automated email from the ASF dual-hosted git repository.
wanggenhua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler-website.git
The following commit(s) were added to refs/heads/master by this push:
new cbdd4e55ad [Fix] Revise bugs. (#853)
cbdd4e55ad is described below
commit cbdd4e55ade27b4b4ab10051a460e72dee0565e5
Author: Amy0104 <wa...@apache.org>
AuthorDate: Tue Dec 13 13:29:02 2022 +0800
[Fix] Revise bugs. (#853)
* documentation search error
* add cached data
---
public/worker/db.js | 3 ++-
src/api/getDownload.js | 6 +++---
src/api/getLocales.js | 8 ++++----
src/views/Documentation/SearchModal.jsx | 7 ++++++-
src/views/Documentation/index.jsx | 15 +++++----------
src/views/Documentation/useSearch.js | 2 +-
6 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/public/worker/db.js b/public/worker/db.js
index 7c238d536c..00b61c8ad6 100644
--- a/public/worker/db.js
+++ b/public/worker/db.js
@@ -194,6 +194,7 @@ const searchDocVersion = async (value, version) => {
const array = await db.doc
.filter((item) => item.version === version)
.toArray();
+
const result = [];
for (let item of array) {
const titleI = item.content.indexOf(value);
@@ -209,7 +210,7 @@ const searchDocVersion = async (value, version) => {
i,
title: replaceStr(item.title, value, 80, titleI),
desc: replaceStr(item.content, value, 100, contentI),
- location: JSON.parse(item.location),
+ location: item.location,
});
}
}
diff --git a/src/api/getDownload.js b/src/api/getDownload.js
index afb832877f..c5d304ef78 100644
--- a/src/api/getDownload.js
+++ b/src/api/getDownload.js
@@ -9,11 +9,11 @@ export async function getDeployment() {
export async function getDownloadVersions() {
try {
- // const storedData = sessionStorage.getItem("download");
- // if (storedData) return JSON.parse(storedData);
+ const storedData = sessionStorage.getItem("download");
+ if (storedData) return JSON.parse(storedData);
const result = await fetch("/fetch/download.json");
const json = await result.json();
- // sessionStorage.setItem("download", JSON.stringify(json));
+ sessionStorage.setItem("download", JSON.stringify(json));
return json;
} catch (e) {}
return [];
diff --git a/src/api/getLocales.js b/src/api/getLocales.js
index 342f1c26e0..70aa60caab 100644
--- a/src/api/getLocales.js
+++ b/src/api/getLocales.js
@@ -1,9 +1,9 @@
export default async function getLocales(locale) {
try {
- // const storedLocales = sessionStorage.getItem("locales");
- // const storedLocale = sessionStorage.getItem("locale");
- // if (storedLocale === locale && storedLocales)
- // return JSON.parse(storedLocales);
+ const storedLocales = sessionStorage.getItem("locales");
+ const storedLocale = sessionStorage.getItem("locale");
+ if (storedLocale === locale && storedLocales)
+ return JSON.parse(storedLocales);
const result = await fetch(`/locales/${locale}.json`);
const languageMap = await result.json();
sessionStorage.setItem("locales", JSON.stringify(languageMap));
diff --git a/src/views/Documentation/SearchModal.jsx b/src/views/Documentation/SearchModal.jsx
index c1f6967d9c..46b27c8dab 100644
--- a/src/views/Documentation/SearchModal.jsx
+++ b/src/views/Documentation/SearchModal.jsx
@@ -1,4 +1,4 @@
-import { memo, useState } from "react";
+import { memo, useState, useEffect } from "react";
import { Modal, Input, Button, Breadcrumb, Empty, Spin } from "antd";
import { useParams } from "react-router-dom";
import { getLinkFromLocation } from "./helpers";
@@ -6,6 +6,11 @@ import { getLinkFromLocation } from "./helpers";
const SearchModal = ({ open, list, value, onClose, loading, handleSearch }) => {
const params = useParams();
const [searchValue, setSearchValue] = useState(value);
+
+ useEffect(() => {
+ setSearchValue(value);
+ }, [value]);
+
return (
<Modal
title={null}
diff --git a/src/views/Documentation/index.jsx b/src/views/Documentation/index.jsx
index 68240d3fd7..3d53e14a67 100644
--- a/src/views/Documentation/index.jsx
+++ b/src/views/Documentation/index.jsx
@@ -1,4 +1,4 @@
-import { useState } from "react";
+import { useState, useRef } from "react";
import {
Select,
Button,
@@ -28,7 +28,6 @@ const Documentation = () => {
setShowModal,
searchList,
searchValue,
- setSearchValue,
handleSearch,
loading,
} = useSearch(params.version);
@@ -43,6 +42,8 @@ const Documentation = () => {
handleAnchor,
navigate,
} = useDocumentation(params);
+ const searchRef = useRef();
+
if (!versions.includes(params.version)) {
return <Navigate to={`/${locale}/docs/${versions[0]}`} replace={true} />;
}
@@ -103,19 +104,13 @@ const Documentation = () => {
</div>
<div className="documentation-content">
<div className="documentation-content-search">
- <Input
- className="documentation-content-input"
- value={searchValue}
- onChange={(e) => {
- setSearchValue(e.target.value);
- }}
- />
+ <Input className="documentation-content-input" ref={searchRef} />
<Button
type="primary"
shape="round"
onClick={() => {
+ handleSearch(searchRef.current.input.value);
setShowModal(true);
- handleSearch(searchValue);
}}
>
{t("search")}
diff --git a/src/views/Documentation/useSearch.js b/src/views/Documentation/useSearch.js
index 7c93e5dbbd..dabd28bb5c 100644
--- a/src/views/Documentation/useSearch.js
+++ b/src/views/Documentation/useSearch.js
@@ -14,6 +14,7 @@ export const useSearch = (version) => {
value,
version,
});
+ setSearchValue(value);
};
useEffect(() => {
@@ -42,7 +43,6 @@ export const useSearch = (version) => {
setShowModal,
searchList: list,
searchValue,
- setSearchValue,
handleSearch,
loading,
};