-- 添加缺失的"我的设备"和"设备申请"路由到数据库 USE soybean_admin; -- 1. 删除可能存在的旧数据 DELETE FROM sys_route WHERE name LIKE 'my-device%' OR name LIKE 'my-application%'; -- 2. 添加"我的设备"父路由 INSERT INTO sys_route (route_id, name, path, component, meta, status, order_num) VALUES ('my-device', 'my-device', '/my-device', 'layout.base', '{"title":"我的设备","i18nKey":"route.my_device","icon":"mdi:laptop","order":7}', 1, 70); -- 3. 添加"我的设备"子路由 INSERT INTO sys_route (route_id, name, path, component, meta, status, order_num) VALUES ('my-device_status', 'my-device_status', '/my-device/status', 'view.my-device_status', '{"title":"设备状态","i18nKey":"route.my_device_status","icon":"mdi:information","order":1}', 1, 71), ('my-device_remote-control', 'my-device_remote-control', '/my-device/remote-control', 'view.my-device_remote-control', '{"title":"远程控制","i18nKey":"route.my_device_remote","icon":"mdi:remote-desktop","order":3}', 1, 72), ('my-device_power-control', 'my-device_power-control', '/my-device/power-control', 'view.my-device_power-control', '{"title":"电源控制","i18nKey":"route.my_device_power","icon":"mdi:power-settings","order":2}', 1, 73); -- 4. 添加"设备申请"父路由 INSERT INTO sys_route (route_id, name, path, component, meta, status, order_num) VALUES ('my-application', 'my-application', '/my-application', 'layout.base', '{"title":"设备申请","i18nKey":"route.my_application","icon":"mdi:file-document","order":8}', 1, 80); -- 5. 添加"设备申请"子路由 INSERT INTO sys_route (route_id, name, path, component, meta, status, order_num) VALUES ('my-application_apply', 'my-application_apply', '/my-application/apply', 'view.my-application_apply', '{"title":"申请使用","i18nKey":"route.my_application_apply","icon":"mdi:file-plus","order":1}', 1, 81), ('my-application_my-list', 'my-application_my-list', '/my-application/my-list', 'view.my-application_my-list', '{"title":"我的申请","i18nKey":"route.my_application_list","icon":"mdi:format-list-checks","order":2}', 1, 82); -- 6. 验证添加结果 SELECT '=== 我的设备路由 ===' AS info; SELECT route_id, name, path, component FROM sys_route WHERE name LIKE 'my-device%' ORDER BY order_num; SELECT '=== 设备申请路由 ===' AS info; SELECT route_id, name, path, component FROM sys_route WHERE name LIKE 'my-application%' ORDER BY order_num; -- 7. 更新角色权限(确保角色有这些菜单的访问权限) SELECT '=== 更新角色权限 ===' AS info; -- 超级管理员添加这些菜单 UPDATE sys_role SET menus = CONCAT(menus, ',my-device,my-device_status,my-device_remote-control,my-device_power-control,my-application,my-application_apply,my-application_my-list') WHERE role_code = 'R_SUPER' AND menus NOT LIKE '%my-device%'; -- 普通用户添加这些菜单 UPDATE sys_role SET menus = CONCAT(menus, ',my-device,my-device_status,my-device_remote-control,my-device_power-control,my-application,my-application_apply,my-application_my-list') WHERE role_code = 'R_USER' AND menus NOT LIKE '%my-device%'; SELECT '=== 完成 ===' AS info; SELECT '路由已添加到数据库,请重启后端服务!' AS message;