skyouc
10 小时以前 6166b702c4cf716302e44cc118bc8e5fc8e909b3
rsf-admin/src/page/system/menu/MenuList.jsx
@@ -199,7 +199,6 @@
                                onClick={() => column.id === 'name' && toggleNode(row.id)}
                                sx={{
                                    opacity: column.id === 'icon' ? 0.6 : (depth > 0 ? opacity : 1),
                                    color: depth > 0 ? `rgba(0, 0, 0, ${opacity})` : 'inherit',
                                    fontWeight: 400,
                                    // 使用字体大小或颜色来区分层级
                                    fontSize: depth === 0 ? '0.95rem' : '0.9rem',
@@ -267,6 +266,14 @@
    const [editRecord, setEditRecord] = React.useState(null);
    const [openNodes, setOpenNodes] = React.useState({});
    const [expandAll, setExpandAll] = React.useState(false);
    const notifyState = React.useRef({ last: '', at: 0 });
    const pushNotify = React.useCallback((type, msg) => {
        const text = typeof msg === 'string' ? msg : (msg || '');
        const now = Date.now();
        if (notifyState.current.last === text && now - notifyState.current.at < 1500) return;
        notifyState.current = { last: text, at: now };
        notify(text, { type, messageArgs: { _: text } });
    }, [notify]);
    const http = async () => {
        const res = await request.post(RESOURCE + '/tree', {
@@ -275,7 +282,8 @@
        if (res?.data?.code === 200) {
            setTreeData(res.data.data);
        } else {
            notify(res.data.msg);
            const msg = translate('ra.notification.http_error', { _: res?.data?.msg || 'Request failed' });
            pushNotify('warning', msg);
        }
    }
@@ -305,10 +313,12 @@
                {
                    onSuccess: () => {
                        handleRefresh();
                        notify('Department deleted successfully', { type: 'info', messageArgs: { _: 'Department deleted successfully' } });
                        const msg = translate('ra.message.delete_success', { _: 'Deleted successfully' });
                        pushNotify('success', msg);
                    },
                    onError: (error) => {
                        notify(`Error: ${error.message}`, { type: 'warning', messageArgs: { _: `Error: ${error.message}` } });
                        const msg = translate('ra.notification.http_error', { _: error?.message || 'Network error' });
                        pushNotify('error', msg);
                    },
                }
            );
@@ -320,6 +330,7 @@
            const newExpandAll = !prevExpandAll;
            const newOpenNodes = {};
            const updateOpenNodes = (nodes) => {
                if (!nodes) return;
                nodes.forEach(node => {
                    newOpenNodes[node.id] = newExpandAll;
                    if (node.children) {
@@ -442,4 +453,4 @@
    );
};
export default MenuList;
export default MenuList;