build: fix build and add examples
This commit is contained in:
26
examples/react-tanstack-router/src/App.css
Normal file
26
examples/react-tanstack-router/src/App.css
Normal file
@@ -0,0 +1,26 @@
|
||||
body {
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
||||
background-image: linear-gradient(to bottom, #020917, #101725);
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
line-height: 1.1;
|
||||
text-align: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.content h1 {
|
||||
font-size: 3.6rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.content p {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 400;
|
||||
opacity: 0.5;
|
||||
}
|
||||
15
examples/react-tanstack-router/src/App.tsx
Normal file
15
examples/react-tanstack-router/src/App.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { useOidcClient } from 'oidc-client-rx/adapters/react';
|
||||
import './App.css';
|
||||
|
||||
const App = () => {
|
||||
const { oidcSecurityService } = useOidcClient();
|
||||
|
||||
return (
|
||||
<div className="content">
|
||||
<h1>Rsbuild with React</h1>
|
||||
<p>Start building amazing things with Rsbuild.</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
1
examples/react-tanstack-router/src/env.d.ts
vendored
Normal file
1
examples/react-tanstack-router/src/env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="@rsbuild/core/types" />
|
||||
40
examples/react-tanstack-router/src/index.tsx
Normal file
40
examples/react-tanstack-router/src/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { type Injector, ReflectiveInjector } from '@outposts/injection-js';
|
||||
import { LogLevel, OidcSecurityService, provideAuth } from 'oidc-client-rx';
|
||||
import { InjectorProvider } from 'oidc-client-rx/adapters/react';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
|
||||
const rootEl = document.getElementById('root');
|
||||
|
||||
if (rootEl) {
|
||||
const injector = ReflectiveInjector.resolveAndCreate(
|
||||
provideAuth({
|
||||
config: {
|
||||
authority: '<your authority address here>',
|
||||
redirectUrl: window.location.origin,
|
||||
postLogoutRedirectUri: window.location.origin,
|
||||
clientId: '<your clientId>',
|
||||
scope: 'openid profile email offline_access',
|
||||
responseType: 'code',
|
||||
silentRenew: true,
|
||||
useRefreshToken: true,
|
||||
logLevel: LogLevel.Debug,
|
||||
},
|
||||
})
|
||||
) as Injector;
|
||||
|
||||
// if needed, check when init
|
||||
const oidcSecurityService = injector.get(OidcSecurityService);
|
||||
oidcSecurityService.checkAuthMultiple();
|
||||
|
||||
const root = ReactDOM.createRoot(rootEl);
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<InjectorProvider injector={injector}>
|
||||
<App />
|
||||
</InjectorProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user