Skip to main content

Tushan

<Tushan /> Component

The <Tushan /> component serves as the entry point for backend management. A simple <Tushan /> component setup might look like this:

<Tushan
basename="/"
dataProvider={dataProvider}
>
{/* ... */}
</Tushan>
  • basename defines the base path for routing, with the default being /. You can change this to /admin or another subpath to integrate with other projects.

  • dataProvider specifies how to interact with backend interfaces. For standard JSON data formats, you can directly use the preset solution from tushan:

    import { jsonServerProvider } from 'tushan';

    const dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com');

    Replace https://jsonplaceholder.typicode.com with your own server's API endpoint.

    You can also implement your own dataProvider. The specific type declaration can refer to the following structure:

    import { DataProvider, fetchJSON, HTTPClient } from 'tushan';

    export function customDataProvider(
    apiUrl: string,
    httpClient: HTTPClient = fetchJSON
    ): DataProvider {
    // ...
    }

Custom Layout

The layout in Tushan, including the overall structure and details like header/footer, is fully customizable.

Here is an example of modifying the layout:

<Tushan
header={'My Admin'}
footer={'Build with MsgByte'}
dashboard={<Dashboard />}
>
</Tushan>

This example customizes the header and the footer.

For information on customizing the dashboard, see Custom Dashboard.

Alternatively, you can replace the entire layout as follows:

<Tushan
layout={<MyLayout />}
>
</Tushan>

You can refer to the default layout implementation in the source code for guidance:

https://github.com/msgbyte/tushan/blob/master/packages/tushan/client/components/layout/index.tsx

Custom Login Page

Similarly, you can customize the login page directly within the Tushan component:

<Tushan
loginPage={<MyLogin />}
>
</Tushan>

The implementation of the login page can refer to the default login page:

https://github.com/msgbyte/tushan/blob/master/packages/tushan/client/components/defaults/LoginPage.tsx