diff --git a/packages/core/client/src/api-client/APIClient.ts b/packages/core/client/src/api-client/APIClient.ts index aa2c019c0..53b50c7ef 100644 --- a/packages/core/client/src/api-client/APIClient.ts +++ b/packages/core/client/src/api-client/APIClient.ts @@ -64,6 +64,7 @@ export class APIClient extends APIClientSDK { } if (this.app.maintaining) { this.app.error = error?.response?.data?.error; + throw error; return; } else if (this.app.error) { this.app.error = null; diff --git a/packages/core/client/src/application/Application.tsx b/packages/core/client/src/application/Application.tsx index c91535a7d..c213ecbe3 100644 --- a/packages/core/client/src/application/Application.tsx +++ b/packages/core/client/src/application/Application.tsx @@ -126,6 +126,7 @@ export class Application { } async load() { + let loadFailed = false; this.ws.on('message', (event) => { const data = JSON.parse(event.data); console.log(data.payload); @@ -142,6 +143,10 @@ export class Application { this.maintaining = true; this.error = data.payload; } else { + console.log('loadFailed', loadFailed); + if (loadFailed) { + window.location.reload(); + } this.maintaining = false; this.maintained = true; this.error = null; @@ -155,6 +160,7 @@ export class Application { this.loading = true; await this.pm.load(); } catch (error) { + loadFailed = true; this.error = { code: 'LOAD_ERROR', message: error.message, diff --git a/packages/core/client/src/application/hooks/useAppPluginLoad.ts b/packages/core/client/src/application/hooks/useAppPluginLoad.ts index 6302a0c11..09cb971c6 100644 --- a/packages/core/client/src/application/hooks/useAppPluginLoad.ts +++ b/packages/core/client/src/application/hooks/useAppPluginLoad.ts @@ -5,9 +5,6 @@ export function useAppPluginLoad(app: Application) { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { - app.ws.on('message', (event) => { - console.log(event.data); - }); async function run() { try { await app.load(); diff --git a/packages/core/client/src/nocobase-buildin-plugin/index.tsx b/packages/core/client/src/nocobase-buildin-plugin/index.tsx index 78ea9904f..3ea6b00d9 100644 --- a/packages/core/client/src/nocobase-buildin-plugin/index.tsx +++ b/packages/core/client/src/nocobase-buildin-plugin/index.tsx @@ -141,6 +141,8 @@ const getProps = (app: Application) => { }; return { ...props, ...commands[app.error?.command?.name] }; } + + return {}; }; const AppMaintaining: FC<{ app: Application; error: Error }> = observer(({ app }) => {