11import React from 'react' ;
2- import { Navigate , Route } from 'react-router-dom' ;
2+ import { Route } from 'react-router-dom' ;
33import { apiDocsPlugin , ApiExplorerPage } from '@backstage/plugin-api-docs' ;
44import {
55 CatalogEntityPage ,
@@ -29,16 +29,25 @@ import { Root } from './components/Root';
2929import {
3030 AlertDisplay ,
3131 OAuthRequestDialog ,
32+ ProxiedSignInPage ,
3233 SignInPage ,
3334} from '@backstage/core-components' ;
3435import { createApp } from '@backstage/app-defaults' ;
3536import { AppRouter , FlatRoutes } from '@backstage/core-app-api' ;
3637import { CatalogGraphPage } from '@backstage/plugin-catalog-graph' ;
3738import { RequirePermission } from '@backstage/plugin-permission-react' ;
39+ import { configApiRef , useApi } from '@backstage/core-plugin-api' ;
3840import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha' ;
41+ import { RbacPage } from '@backstage-community/plugin-rbac' ;
42+ import { PlaylistIndexPage , PlaylistPage } from '@backstage-community/plugin-playlist' ;
43+ import { HomepageCompositionRoot } from '@backstage/plugin-home' ;
44+ import { HomePage } from './components/home/HomePage' ;
45+ import * as plugins from './plugins' ;
46+ import { ExplorePage } from '@backstage-community/plugin-explore' ;
3947
4048const app = createApp ( {
4149 apis,
50+ plugins : Object . values ( plugins ) ,
4251 bindRoutes ( { bind } ) {
4352 bind ( catalogPlugin . externalRoutes , {
4453 createComponent : scaffolderPlugin . routes . root ,
@@ -57,13 +66,29 @@ const app = createApp({
5766 } ) ;
5867 } ,
5968 components : {
60- SignInPage : props => < SignInPage { ...props } auto providers = { [ 'guest' ] } /> ,
69+ // SignInPage: props => <SignInPage {...props} auto providers={['guest']} />,
70+ SignInPage : props => {
71+ const configApi = useApi ( configApiRef ) ;
72+ // 开发环境使用guest账号,生产环境使用oauth2Proxy作为登录认证
73+ if ( configApi . getString ( 'auth.environment' ) === 'development' ) {
74+ return (
75+ < SignInPage
76+ { ...props }
77+ providers = { [ 'guest' ] }
78+ />
79+ ) ;
80+ }
81+ return < ProxiedSignInPage { ...props } provider = "oauth2Proxy" /> ;
82+ } ,
6183 } ,
6284} ) ;
6385
6486const routes = (
6587 < FlatRoutes >
66- < Route path = "/" element = { < Navigate to = "catalog" /> } />
88+ { /* <Route path="/" element={<Navigate to="catalog" />} /> */ }
89+ < Route path = "/" element = { < HomepageCompositionRoot /> } >
90+ < HomePage />
91+ </ Route > ;
6792 < Route path = "/catalog" element = { < CatalogIndexPage /> } />
6893 < Route
6994 path = "/catalog/:namespace/:kind/:name"
@@ -94,7 +119,11 @@ const routes = (
94119 { searchPage }
95120 </ Route >
96121 < Route path = "/settings" element = { < UserSettingsPage /> } />
122+ < Route path = "/playlist" element = { < PlaylistIndexPage /> } />
123+ < Route path = "/playlist/:playlistId" element = { < PlaylistPage /> } />
97124 < Route path = "/catalog-graph" element = { < CatalogGraphPage /> } />
125+ < Route path = "/explore" element = { < ExplorePage /> } />
126+ < Route path = "/rbac" element = { < RbacPage /> } /> ;
98127 </ FlatRoutes >
99128) ;
100129
0 commit comments