fix: settings center dropdown

This commit is contained in:
dream2023 2024-03-06 15:25:26 +08:00
parent 989d11da34
commit 944f07045f

View File

@ -1,7 +1,7 @@
import { ApiOutlined, SettingOutlined } from '@ant-design/icons'; import { ApiOutlined, SettingOutlined } from '@ant-design/icons';
import { css } from '@emotion/css'; import { css } from '@emotion/css';
import { Button, Card, Dropdown, Popover, Tooltip } from 'antd'; 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 { useTranslation } from 'react-i18next';
import { Link, useNavigate } from 'react-router-dom'; import { Link, useNavigate } from 'react-router-dom';
import { useApp } from '../application'; import { useApp } from '../application';
@ -29,20 +29,14 @@ export const PluginManagerLink = () => {
export const SettingsCenterDropdown = () => { export const SettingsCenterDropdown = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const compile = useCompile(); const compile = useCompile();
const { t } = useTranslation();
const { token } = useToken(); const { token } = useToken();
const navigate = useNavigate(); const navigate = useNavigate();
const app = useApp(); const app = useApp();
const settings = app.pluginSettingsManager.getList(); const settings = app.pluginSettingsManager.getList();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
return ( const items = useMemo(
<Dropdown () =>
menu={{ settings
style: {
maxHeight: '70vh',
overflow: 'auto',
},
items: settings
.filter((v) => v.isTopLevel !== false) .filter((v) => v.isTopLevel !== false)
.map((setting) => { .map((setting) => {
return { return {
@ -51,6 +45,16 @@ export const SettingsCenterDropdown = () => {
label: <Link to={setting.path}>{compile(setting.title)}</Link>, label: <Link to={setting.path}>{compile(setting.title)}</Link>,
}; };
}), }),
[settings],
);
return (
<Dropdown
menu={{
style: {
maxHeight: '70vh',
overflow: 'auto',
},
items,
}} }}
> >
<Button <Button