feat(frontend): add a dedicated 403 forbidden page

Show /403 instead of toasting or staying on the denied screen when
the API returns 403 or a non-admin opens an admin route.
This commit is contained in:
ryan
2026-09-02 18:39:11 +08:00
parent b7e5e811d1
commit 05606dfb56
9 changed files with 129 additions and 9 deletions
+7 -2
View File
@@ -161,10 +161,15 @@ apiClient.interceptors.response.use(
return Promise.reject(new UnauthorizedError(message));
}
/* 403:已登录但权限不足,留在当前页。 */
/* 403:已登录但权限不足,进入独立 403 页,不清 cookie。 */
if (error.response?.status === 403) {
const message = error.response.data?.error_msg || '权限不足';
toast.error(message, { id: 'forbidden-error' });
if (
typeof window !== 'undefined' &&
window.location.pathname !== '/403'
) {
window.location.replace('/403');
}
return Promise.reject(
new ForbiddenError(
message,