Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/web/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react';

import ReactDOM from 'react-dom/client';

import App from './App';

const rootEl = document.getElementById('root');
if (rootEl) {
const root = ReactDOM.createRoot(rootEl);
// TODO: strict mode
root.render(<App />);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
}
16 changes: 13 additions & 3 deletions packages/client/src/application/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export class Application {
public name: string;
public globalVars: Record<string, any> = {};

loading = true;
loading = false;
loaded = false;
maintained = false;
maintaining = false;
error = null;
Expand All @@ -109,12 +110,20 @@ export class Application {

get adminUrl() {
if (this.name === 'main') {
return '/admin/';
return `/${this.prefix}/`;
} else {
return `/apps/${this.name}/admin/`;
return `/apps/${this.name}/${this.prefix}/`;
}
}

get prefix() {
return 'dashboard';
}

get indexSchema() {
return 'default-admin-menu';
}

constructor(protected options: ApplicationOptions = {}) {
this.initRequireJs();
define(this, {
Expand Down Expand Up @@ -312,6 +321,7 @@ export class Application {
}

this.loading = false;
this.loaded = true;
}

getComponent<T = any>(Component: ComponentTypeAndString<T>, isShowError = true): ComponentType<T> | undefined {
Expand Down
275 changes: 0 additions & 275 deletions packages/client/src/application/CustomRouterContextProvider.tsx

This file was deleted.

5 changes: 1 addition & 4 deletions packages/client/src/application/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ export class Plugin<T = any> {
constructor(
protected options: T,
protected app: Application,
) {
this.options = options;
this.app = app;
}
) {}

get pluginManager() {
return this.app.pluginManager;
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/application/PluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class PluginManager {
protected loadRemotePlugins: boolean,
protected app: Application,
) {
this.app = app;
this.initPlugins = this.init(_plugins);
}

Expand Down
15 changes: 6 additions & 9 deletions packages/client/src/application/RouterManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
import VariablesProvider from '../variables/VariablesProvider';
import { Application } from './Application';
import { BlankComponent, RouterContextCleaner } from './components';
import { CustomRouterContextProvider } from './CustomRouterContextProvider';

export interface BrowserRouterOptions extends Omit<BrowserRouterProps, 'children'> {
type?: 'browser';
Expand Down Expand Up @@ -146,14 +145,12 @@ export class RouterManager {
const Provider = () => {
const BaseLayout = useContext(BaseLayoutContext);
return (
<CustomRouterContextProvider>
<BaseLayout>
<VariablesProvider>
<Outlet />
{children}
</VariablesProvider>
</BaseLayout>
</CustomRouterContextProvider>
<BaseLayout>
<VariablesProvider>
<Outlet />
{children}
</VariablesProvider>
</BaseLayout>
);
};

Expand Down
4 changes: 3 additions & 1 deletion packages/client/src/application/components/AppComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const AppComponent = observer(
console.error(err);
}, []);
useEffect(() => {
app.load();
if (!app.loaded && !app.loading) {
app.load();
}
}, [app]);
const AppError = app.getComponent('AppError');
if (app.loading) return app.renderComponent('AppSpin', { app });
Expand Down
Loading