From 944f07045f99f2e30758c32c60dd4ce6b7d862b6 Mon Sep 17 00:00:00 2001
From: dream2023 <1098626505@qq.com>
Date: Wed, 6 Mar 2024 15:25:26 +0800
Subject: [PATCH] fix: settings center dropdown
---
.../core/client/src/pm/PluginManagerLink.tsx | 26 +++++++++++--------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/packages/core/client/src/pm/PluginManagerLink.tsx b/packages/core/client/src/pm/PluginManagerLink.tsx
index 78eb53535d..4af9d0dd89 100644
--- a/packages/core/client/src/pm/PluginManagerLink.tsx
+++ b/packages/core/client/src/pm/PluginManagerLink.tsx
@@ -1,7 +1,7 @@
import { ApiOutlined, SettingOutlined } from '@ant-design/icons';
import { css } from '@emotion/css';
import { Button, Card, Dropdown, Popover, Tooltip } from 'antd';
-import React, { useState } from 'react';
+import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link, useNavigate } from 'react-router-dom';
import { useApp } from '../application';
@@ -29,12 +29,24 @@ export const PluginManagerLink = () => {
export const SettingsCenterDropdown = () => {
const [visible, setVisible] = useState(false);
const compile = useCompile();
- const { t } = useTranslation();
const { token } = useToken();
const navigate = useNavigate();
const app = useApp();
const settings = app.pluginSettingsManager.getList();
const [open, setOpen] = useState(false);
+ const items = useMemo(
+ () =>
+ settings
+ .filter((v) => v.isTopLevel !== false)
+ .map((setting) => {
+ return {
+ key: setting.name,
+ icon: setting.icon,
+ label: {compile(setting.title)},
+ };
+ }),
+ [settings],
+ );
return (
{
maxHeight: '70vh',
overflow: 'auto',
},
- items: settings
- .filter((v) => v.isTopLevel !== false)
- .map((setting) => {
- return {
- key: setting.name,
- icon: setting.icon,
- label: {compile(setting.title)},
- };
- }),
+ items,
}}
>