We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
云端 本地
打包以后出现
和dev 打包的效果一样
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { useEffect(() => { // 请求接口获取标题 const fetchTitle = async () => { const response = await getSysShow(); if (response.success === true) { const datainfo = response.data; const data = datainfo[0]; flushSync(() => { setInitialState((s) => ({ ...s, sysconfg: data, })); }); flushSync(() => { setInitialState((s) => ({ ...s, currentUser: data, })); }); // 打印数据 window.console.log(initialState); } else { return {}; } };
fetchTitle();
}, []); useEffect(() => { // 检查 initialState?.currentUser?.uid 是否存在 if (initialState?.currentUser?.uid) { console.log('当前用户 UID:', initialState.currentUser.uid); } else { // 如果没有 uid, 也可以打印一个提示,表示 uid 还未存在 console.log('当前用户 UID 不存在'); } }, [initialState?.currentUser?.uid]); useEffect(() => { // 检查 initialState?.currentUser?.uid 是否存在 if (initialState) { console.log('当前用户历史数据:', initialState); } else { // 如果没有 uid, 也可以打印一个提示,表示 uid 还未存在 console.log('当前用户历史数据'); } }, [initialState]); return { actionsRender: () => [, ], locale: 'zh-CN', //关闭国际化 menu: { // 每当 initialState?.currentUser?.userid 发生修改时重新执行 request params: { userId: initialState?.currentUser?.uid, }, locale: false, //关闭国际化 // 获取菜单列表 request: async (params, defaultMenuData) => { // initialState.currentUser 中包含了所有用户信息 try { // 获取菜单中 console.log('获取菜单中'); const menuData = await getmenu({}); const defaultMenus = parseMenuData(menuData.data); console.log(defaultMenus); const Menus_list = loopMenuItem(defaultMenus); console.log(Menus_list); return Menus_list; } catch (error) { console.error('获取菜单数据失败:', error); return []; // 在失败的情况下返回一个空数组,防止渲染出错 } }, }, // layout 的左上角的 title // title: initialState?.sysconfg?.system_title ?? '未定义', title: 'nihao', // logo: initialState?.sysconfg?.system_logo, logo: , avatarProps: { src: initialState?.currentUser?.enterprise_icon, title: , render: (_, avatarChildren) => { return {avatarChildren}; }, }, waterMarkProps: { content: initialState?.currentUser?.name, }, footerRender: () =>
The text was updated successfully, but these errors were encountered:
同问:遇到一样的问题,本地开发 menu request 可以触发,发布出来触发不了。
Sorry, something went wrong.
defaultSettings.ts 里面是否有 这个参数 // menu:{ //locale:false // }, 尝试 吧这个 隐藏试下,我是可行的 ,希望帮助你
同问:遇到一样的问题,本地开发 menu request 可以触发,发布出来触发不了。 defaultSettings.ts 里面是否有 这个参数 // menu:{ //locale:false // }, 尝试 吧这个 隐藏试下,我是可行的 ,希望帮助你
我测试结果如下:
注释config.ts
//mako: {},
注释defaultSettings.ts
// menu: { // locale: false, // },
不会报错Cannot read properties of null (reading 'applyPlugins'),menu request 可以触发了
保留defaultSettings.ts
menu: { locale: false, }
不会报错Cannot read properties of null (reading 'applyPlugins'),menu request 触发不了
如果开启config.ts
mako: {},
不管defaultSettings.ts 的 menu locale 是否注释都一样报错 Cannot read properties of null (reading 'applyPlugins')
我也不知道 因为什么 但是触发了 我就没有深究了 你可以深究一下
No branches or pull requests
🐛 bug 描述
云端
本地
📷 复现步骤 | Recurrence steps
打包以后出现
🏞 期望结果 | Expected results
和dev 打包的效果一样
和dev 打包的效果一样
💻 复现代码 | Recurrence code
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
useEffect(() => {
// 请求接口获取标题
const fetchTitle = async () => {
const response = await getSysShow();
if (response.success === true) {
const datainfo = response.data;
const data = datainfo[0];
flushSync(() => {
setInitialState((s) => ({
...s,
sysconfg: data,
}));
});
flushSync(() => {
setInitialState((s) => ({
...s,
currentUser: data,
}));
});
// 打印数据
window.console.log(initialState);
} else {
return {};
}
};
}, []);
,useEffect(() => {
// 检查 initialState?.currentUser?.uid 是否存在
if (initialState?.currentUser?.uid) {
console.log('当前用户 UID:', initialState.currentUser.uid);
} else {
// 如果没有 uid, 也可以打印一个提示,表示 uid 还未存在
console.log('当前用户 UID 不存在');
}
}, [initialState?.currentUser?.uid]);
useEffect(() => {
// 检查 initialState?.currentUser?.uid 是否存在
if (initialState) {
console.log('当前用户历史数据:', initialState);
} else {
// 如果没有 uid, 也可以打印一个提示,表示 uid 还未存在
console.log('当前用户历史数据');
}
}, [initialState]);
return {
actionsRender: () => [, ],
locale: 'zh-CN', //关闭国际化
menu: {
// 每当 initialState?.currentUser?.userid 发生修改时重新执行 request
params: {
userId: initialState?.currentUser?.uid,
},
locale: false, //关闭国际化
// 获取菜单列表
request: async (params, defaultMenuData) => {
// initialState.currentUser 中包含了所有用户信息
try {
// 获取菜单中
console.log('获取菜单中');
const menuData = await getmenu({});
const defaultMenus = parseMenuData(menuData.data);
console.log(defaultMenus);
const Menus_list = loopMenuItem(defaultMenus);
console.log(Menus_list);
return Menus_list;
} catch (error) {
console.error('获取菜单数据失败:', error);
return []; // 在失败的情况下返回一个空数组,防止渲染出错
}
},
},
// layout 的左上角的 title
// title: initialState?.sysconfg?.system_title ?? '未定义',
title: 'nihao',
// logo: initialState?.sysconfg?.system_logo,
logo: ,
avatarProps: {
src: initialState?.currentUser?.enterprise_icon,
title: ,
render: (_, avatarChildren) => {
return {avatarChildren};
},
},
waterMarkProps: {
content: initialState?.currentUser?.name,
},
footerRender: () =>
onPageChange: () => {
const { location } = history;
// 如果没有登录,重定向到 login
if (!initialState?.currentUser && location.pathname !== loginPath) {
history.push(loginPath);
}
},
bgLayoutImgList: [
{
src: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/D2LWSqNny4sAAAAAAAAAAAAAFl94AQBr',
left: 85,
bottom: 100,
height: '303px',
},
{
src: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/C2TWRpJpiC0AAAAAAAAAAAAAFl94AQBr',
bottom: -68,
right: -45,
height: '303px',
},
{
src: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/F6vSTbj8KpYAAAAAAAAAAAAAFl94AQBr',
bottom: 0,
left: 0,
width: '331px',
},
],
links: isDev
? [
OpenAPI 文档
,
]
: [],
menuHeaderRender: undefined,
// 自定义 403 页面
// unAccessible:
// 增加一个 loading 的状态
childrenRender: (children) => {
// if (initialState?.loading) return ;
return (
<>
{children}
{isDev && (
<SettingDrawer
disableUrlParams
enableDarkTheme
settings={initialState?.settings}
onSettingChange={(settings) => {
setInitialState((preInitialState) => ({
...preInitialState,
settings,
}));
}}
/>
)}
</>
);
},
...initialState?.settings,
};
};
© 版本信息
🚑 其他信息
The text was updated successfully, but these errors were encountered: