From 1f9b7c5c6a00cbc4e6d81c0c44708dba0797ed2a Mon Sep 17 00:00:00 2001 From: shuai Date: Tue, 26 Sep 2023 18:11:24 +0800 Subject: [PATCH 1/4] fix: search plugin icon add max-width --- ui/src/index.scss | 8 ++------ ui/src/plugins/builtin/SearchInfo/index.tsx | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ui/src/index.scss b/ui/src/index.scss index 1b1a358e..1664965a 100644 --- a/ui/src/index.scss +++ b/ui/src/index.scss @@ -322,10 +322,6 @@ img[src=""] { vertical-align: -0.125em; } -.algoliaSvg { - display: inline-block; - width: 92px; - height: 24px; - fill: currentColor; - vertical-align: -0.125em; +.max-width-200 { + max-width: 200px; } diff --git a/ui/src/plugins/builtin/SearchInfo/index.tsx b/ui/src/plugins/builtin/SearchInfo/index.tsx index 28ef2517..e03ca7eb 100644 --- a/ui/src/plugins/builtin/SearchInfo/index.tsx +++ b/ui/src/plugins/builtin/SearchInfo/index.tsx @@ -31,7 +31,7 @@ const Index: FC = () => { target="_blank" rel="noopener noreferrer"> {t('search_by')} - + ); }; From 0c42207403b6e744e573a3ce1883c521963bc52f Mon Sep 17 00:00:00 2001 From: shuai Date: Tue, 26 Sep 2023 18:21:45 +0800 Subject: [PATCH 2/4] fix: delete logs --- ui/src/plugins/builtin/SearchInfo/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/src/plugins/builtin/SearchInfo/index.tsx b/ui/src/plugins/builtin/SearchInfo/index.tsx index e03ca7eb..218d6ca5 100644 --- a/ui/src/plugins/builtin/SearchInfo/index.tsx +++ b/ui/src/plugins/builtin/SearchInfo/index.tsx @@ -15,13 +15,11 @@ const pluginInfo: PluginInfo = { }; const Index: FC = () => { - console.log(111111); const { t } = useTranslation(getTransNs(), { keyPrefix: getTransKeyPrefix(pluginInfo), }); const { data } = useGetSearchPLuginInfo(); - console.log(data); // if (!data?.icon) return null; return ( From 7f3d0a5abb310d876edee20bab340af9a5017687 Mon Sep 17 00:00:00 2001 From: robin Date: Wed, 27 Sep 2023 14:53:36 +0800 Subject: [PATCH 3/4] fix: Solve the problem of abnormal hooks values caused by closures --- ui/src/components/Editor/index.tsx | 59 +++++++++++-------------- ui/src/components/Editor/utils/index.ts | 12 +++-- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/ui/src/components/Editor/index.tsx b/ui/src/components/Editor/index.tsx index 8fe0616e..fcc2d6ec 100644 --- a/ui/src/components/Editor/index.tsx +++ b/ui/src/components/Editor/index.tsx @@ -1,7 +1,6 @@ import { useEffect, useRef, - useState, ForwardRefRenderFunction, forwardRef, useImperativeHandle, @@ -74,14 +73,6 @@ const MDEditor: ForwardRefRenderFunction = ( autoFocus, }); - const [markdown, setMarkdown] = useState(value || ''); - - useEffect(() => { - if (value !== markdown) { - setMarkdown(value); - } - }, [value]); - const getHtml = () => { return previewRef.current?.getHtml(); }; @@ -103,29 +94,31 @@ const MDEditor: ForwardRefRenderFunction = ( <>
- - - - -
- - -
- - -
-
    -
      - - -
      -
      - - + {editor && ( + + + + +
      + + +
      + +
+
+
    +
      + + +
      +
      + + + )}
      @@ -135,7 +128,7 @@ const MDEditor: ForwardRefRenderFunction = ( />
      - + ); }; diff --git a/ui/src/components/Editor/utils/index.ts b/ui/src/components/Editor/utils/index.ts index 480ed0eb..e0630566 100644 --- a/ui/src/components/Editor/utils/index.ts +++ b/ui/src/components/Editor/utils/index.ts @@ -127,7 +127,8 @@ export const useEditor = ({ onFocus, onBlur, }) => { - const [editor, setEditor] = useState(); + const [editor, setEditor] = useState(null); + const [value, setValue] = useState(''); const onEnter = (cm) => { const cursor = cm.getCursor(); @@ -168,13 +169,13 @@ export const useEditor = ({ placeholder, focus: autoFocus, }); - setEditor(cm); + setEditor(cm); createEditorUtils(codeMirror, cm); cm.on('change', (e) => { const newValue = e.getValue(); - onChange?.(newValue); + setValue(newValue); }); cm.on('focus', () => { @@ -187,8 +188,13 @@ export const useEditor = ({ cm.addKeyMap({ Enter: onEnter, }); + return cm; }; + useEffect(() => { + onChange?.(value); + }, [value]); + useEffect(() => { if (!(editorRef.current instanceof HTMLElement)) { return; From d0409afd30df5bed1d93700cf034eed23ae39436 Mon Sep 17 00:00:00 2001 From: shuai Date: Tue, 10 Oct 2023 11:55:24 +0800 Subject: [PATCH 4/4] feat: add 403 pages --- ui/src/pages/403/index.tsx | 7 +++++++ ui/src/router/routes.ts | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 ui/src/pages/403/index.tsx diff --git a/ui/src/pages/403/index.tsx b/ui/src/pages/403/index.tsx new file mode 100644 index 00000000..ebef9045 --- /dev/null +++ b/ui/src/pages/403/index.tsx @@ -0,0 +1,7 @@ +import { HttpErrorContent } from '@/components'; + +const Index = () => { + return ; +}; + +export default Index; diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.ts index 7407dce2..c63cbff0 100644 --- a/ui/src/router/routes.ts +++ b/ui/src/router/routes.ts @@ -394,6 +394,10 @@ const routes: RouteNode[] = [ path: '50x', page: 'pages/50X', }, + { + path: '403', + page: 'pages/403', + }, ], }, {