mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
fix: window reload after pm load failed (#2605)
This commit is contained in:
parent
2484c8ffb2
commit
3461c29411
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -5,9 +5,6 @@ export function useAppPluginLoad(app: Application) {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
useEffect(() => {
|
||||
app.ws.on('message', (event) => {
|
||||
console.log(event.data);
|
||||
});
|
||||
async function run() {
|
||||
try {
|
||||
await app.load();
|
||||
|
@ -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 }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user