fix(session): request aborted error when swtching sessions (cloudreve/cloudreve#2919)

This commit is contained in:
Aaron Liu 2025-09-27 11:03:21 +08:00
parent 0bf85fa0ab
commit 18c4e3d845
2 changed files with 7 additions and 2 deletions

View File

@ -70,7 +70,7 @@ import {
ViewerGroup,
ViewerSessionResponse,
} from "./explorer.ts";
import { AppError, Code, CrHeaders, defaultOpts, send, ThunkResponse } from "./request.ts";
import { AppError, Code, CrHeaders, defaultOpts, isRequestAbortedError, send, ThunkResponse } from "./request.ts";
import { CreateDavAccountService, DavAccount, ListDavAccountsResponse, ListDavAccountsService } from "./setting.ts";
import { ListShareResponse, ListShareService } from "./share.ts";
import { CaptchaResponse, SiteConfig } from "./site.ts";
@ -115,7 +115,7 @@ export function getSiteConfig(section: string): ThunkResponse<SiteConfig> {
},
{
...defaultOpts,
noCredential: section != "basic",
bypassSnackbar: (e) => isRequestAbortedError(e),
errorSnackbarMsg: (e) => i18n.t("errLoadingSiteConfig", { ns: "common" }) + e.message,
},
),
@ -373,6 +373,7 @@ export function sendRenameFile(req: RenameFileService): ThunkResponse<FileRespon
},
{
...defaultOpts,
bypassSnackbar: (e) => isRequestAbortedError(e),
},
),
);

View File

@ -277,3 +277,7 @@ export function send<T = any>(
}
};
}
export const isRequestAbortedError = (e: Error) => {
return e.message == "Request aborted";
};