get_menus.ps1 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Login and get all menu routes via API
  2. $body = '{"tenantCode":"T202605253515","username":"admin","password":"admin123"}'
  3. $loginResp = Invoke-WebRequest -Uri 'http://localhost:8006/login' -Method Post -ContentType 'application/json' -Body $body -UseBasicParsing
  4. $loginJson = $loginResp.Content | ConvertFrom-Json
  5. $token = $loginJson.token
  6. Write-Host "Login OK, token length: $($token.Length)"
  7. # Get routes (menu structure)
  8. Write-Host "`n=== Getting Routes ==="
  9. $routesResp = Invoke-WebRequest -Uri 'http://localhost:8006/getRouters' -Method Get -Headers @{Authorization="Bearer $token"} -UseBasicParsing
  10. $routesJson = $routesResp.Content | ConvertFrom-Json
  11. Write-Host "Routes code: $($routesJson.code)"
  12. # Extract all menu paths
  13. $menuPaths = @()
  14. function ExtractPaths($items, $prefix="") {
  15. foreach ($item in $items) {
  16. $path = $item.path
  17. $component = $item.component
  18. $name = $item.name
  19. $perms = $item.perms
  20. $menuType = $item.menuType
  21. if ($path -and $path -ne '/' -and $path -ne '#') {
  22. $menuPaths += [PSCustomObject]@{
  23. Name=$name
  24. Path=$path
  25. Component=$component
  26. Perms=$perms
  27. MenuType=$menuType
  28. }
  29. }
  30. if ($item.children) {
  31. ExtractPaths $item.children
  32. }
  33. }
  34. }
  35. ExtractPaths $routesJson.data
  36. Write-Host "Total menu items found: $($menuPaths.Count)"
  37. # Print all menu paths
  38. $menuPaths | Format-Table -Property Name, Path, Component, Perms, MenuType -AutoSize
  39. # Save to file for analysis
  40. $menuPaths | ConvertTo-Json -Depth 3 | Out-File -FilePath 'd:\ylrz\saasadminui\menu_data.json' -Encoding UTF8
  41. Write-Host "`nMenu data saved to d:\ylrz\saasadminui\menu_data.json"