feat(core): share in workspace link (#7897)

ShareDocsService -> ShareDocsListService
ShareService -> ShareInfoService
(*new) ShareReaderService

`/share/:workspaceId/:docId` -> redirect to -> `/workspace/:workspaceId/:docId`

workspace loading process

1. find workspace in workspace list
2. (if not found) revalidate workspace list
3. (if still not found) try load share page
4. (if share page found) => share page
5. (if share page not found) => 404
6. (if workspace found) => workspace page
This commit is contained in:
EYHN
2024-08-16 09:12:18 +00:00
parent 620d20710a
commit 83716c2fd9
39 changed files with 431 additions and 267 deletions

View File

@@ -1,5 +1,8 @@
export class NetworkError extends Error {
constructor(public readonly originError: Error) {
constructor(
public readonly originError: Error,
public readonly status?: number
) {
super(`Network error: ${originError.message}`);
this.stack = originError.stack;
}
@@ -10,7 +13,10 @@ export function isNetworkError(error: Error): error is NetworkError {
}
export class BackendError extends Error {
constructor(public readonly originError: Error) {
constructor(
public readonly originError: Error,
public readonly status?: number
) {
super(`Server error: ${originError.message}`);
this.stack = originError.stack;
}

View File

@@ -61,7 +61,7 @@ export class FetchService extends Service {
if (res.status === 504) {
const error = new Error('Gateway Timeout');
logger.debug('network error', error);
throw new NetworkError(error);
throw new NetworkError(error, res.status);
}
if (!res.ok) {
logger.warn(
@@ -76,7 +76,10 @@ export class FetchService extends Service {
// ignore
}
}
throw new BackendError(UserFriendlyError.fromAnyError(reason));
throw new BackendError(
UserFriendlyError.fromAnyError(reason),
res.status
);
}
return res;
};