From 25275559455416605f0db18b96b250ae8cbad9c5 Mon Sep 17 00:00:00 2001 From: jialin Date: Tue, 12 May 2026 14:29:55 +0800 Subject: [PATCH] fix: HRM in dev --- config/config.ts | 3 ++- config/mfsu.extensions.ts | 9 +++++++++ src/components/plugin-extra-fields.tsx | 5 +++-- src/layouts/extraRender.tsx | 18 +++--------------- src/pages/login/index.tsx | 8 ++++---- 5 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 config/mfsu.extensions.ts diff --git a/config/config.ts b/config/config.ts index 198e21be..82cae6da 100644 --- a/config/config.ts +++ b/config/config.ts @@ -1,5 +1,6 @@ import { defineConfig } from '@umijs/max'; import keepAlive from './keep-alive'; +import { extraMfsuExclude } from './mfsu.extensions'; import { compressionPluginConfig, monacoPluginConfig } from './plugins'; import proxy from './proxy'; import routes from './routes'; @@ -32,7 +33,7 @@ export default defineConfig({ defaultSizes: 'parsed' // stat // gzip }, mfsu: { - exclude: ['lodash', 'ml-pca'] + exclude: ['lodash', 'ml-pca', ...extraMfsuExclude] }, base: process.env.npm_config_base || '/', ...(isProduction diff --git a/config/mfsu.extensions.ts b/config/mfsu.extensions.ts new file mode 100644 index 00000000..5045114f --- /dev/null +++ b/config/mfsu.extensions.ts @@ -0,0 +1,9 @@ +// Identity hook for build-time mfsu.exclude extensions. Tooling may +// overwrite this file to add package names that must skip MFSU's +// pre-bundling; the original is restored on cleanup. Mirrors +// `src/request.extensions.ts` / `src/access.extensions.ts`. +// +// MFSU bundles node_modules into immutable chunks at dev startup, so +// workspace-linked packages whose source you edit during dev must be +// excluded here or HMR won't pick up changes. +export const extraMfsuExclude: string[] = []; diff --git a/src/components/plugin-extra-fields.tsx b/src/components/plugin-extra-fields.tsx index e8ed1fc4..50ba587a 100644 --- a/src/components/plugin-extra-fields.tsx +++ b/src/components/plugin-extra-fields.tsx @@ -16,12 +16,13 @@ const PluginExtraFields: React.FC<{ // form-specific slot can pass its action / record context if it // needs to. context?: Record; -}> = ({ name, context }) => { + [key: string]: any; +}> = ({ name, context, ...rest }) => { const Slot = getGPUStackPlugin()?.components?.[name]; if (!Slot) { return null; } - return ; + return ; }; export default PluginExtraFields; diff --git a/src/layouts/extraRender.tsx b/src/layouts/extraRender.tsx index 988d0625..98b3afce 100644 --- a/src/layouts/extraRender.tsx +++ b/src/layouts/extraRender.tsx @@ -1,9 +1,9 @@ import { GPUStackVersionAtom, UpdateCheckAtom } from '@/atoms/user'; +import PluginExtraField from '@/components/plugin-extra-fields'; import VersionInfo, { modalConfig } from '@/components/version-info'; import externalLinks from '@/constants/external-links'; import useBodyScroll from '@/hooks/use-body-scroll'; import { logout } from '@/pages/login/apis'; -import { getGPUStackPlugin } from '@/plugins'; import { useModel } from '@@/plugin-model'; import { DiscordOutlined, @@ -19,15 +19,6 @@ import { useMemo } from 'react'; import styled from 'styled-components'; import { DEFAULT_ENTER_PAGE } from '../config/settings'; -const UpdateDot = styled.span` - margin-left: 5px; - display: flex; - width: 8px; - height: 8px; - border-radius: 4px; - background-color: var(--ant-orange-5); -`; - const NewLabel = styled.span` position: relative; top: -4px; @@ -106,7 +97,6 @@ const CustomItem = styled.div` export const ExtraContent = (props: { isDarkTheme?: boolean }) => { const { isDarkTheme } = props; - const pluginManager = getGPUStackPlugin(); const { saveScrollHeight, restoreScrollHeight } = useBodyScroll(); const [modal, contextHolder] = Modal.useModal(); const [version] = useAtom(GPUStackVersionAtom); @@ -119,8 +109,6 @@ export const ExtraContent = (props: { isDarkTheme?: boolean }) => { }; const { initialState } = initialInfo; - const { GlobalSettings, OrgSwitcher } = pluginManager?.components || {}; - console.log('plugin+++++++++', pluginManager); const navigate = useNavigate(); @@ -271,7 +259,7 @@ export const ExtraContent = (props: { isDarkTheme?: boolean }) => { return ( {contextHolder} - {OrgSwitcher && } +
{ /> - {GlobalSettings && } + { const [initialPassword, setInitialPassword] = useAtom(initialPasswordAtom); const { initialState, setInitialState } = useModel('@@initialState') || {}; - const enterprisePlugin = getGPUStackPlugin(); + const plugin = getGPUStackPlugin(); - const CustomLoginComponent = enterprisePlugin?.login?.CustomLoginComponent; - const shouldUseCustomLogin = enterprisePlugin?.login?.shouldUseCustomLogin; + const CustomLoginComponent = plugin?.login?.CustomLoginComponent; + const shouldUseCustomLogin = plugin?.login?.shouldUseCustomLogin; const useCustomLogin = useMemo( () => shouldUseCustomLogin?.(userSettings), @@ -197,7 +197,7 @@ const Login = () => { token: { ...themeData?.token, colorPrimary: - enterprisePlugin?.getPrimaryColor?.(userSettings)?.colorPrimary || + plugin?.getPrimaryColor?.(userSettings)?.colorPrimary || COLOR_PRIMARY } }}