修复发帖长文布局与手机下拉刷新,发版后自动重载失效 chunk,并整理站务文案。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 18:18:35 +08:00
parent 61b47363e9
commit 2c06eaccb2
20 changed files with 811 additions and 360 deletions

View File

@@ -1,15 +1,19 @@
import { Component, ErrorInfo, ReactNode } from 'react';
import { Button } from '@/components/ui/button';
import { isChunkLoadError, reloadForStaleChunk } from '../utils/chunkLoad';
interface Props { children: ReactNode }
interface State { error: Error | null }
interface State { error: Error | null; reloading: boolean }
/** 捕获渲染异常,避免整页白屏 */
/** 捕获渲染异常;发版 chunk 失效时自动刷新 */
export default class ErrorBoundary extends Component<Props, State> {
state: State = { error: null };
state: State = { error: null, reloading: false };
static getDerivedStateFromError(error: Error) {
return { error };
if (isChunkLoadError(error) && reloadForStaleChunk()) {
return { error, reloading: true };
}
return { error, reloading: false };
}
componentDidCatch(error: Error, info: ErrorInfo) {
@@ -17,6 +21,18 @@ export default class ErrorBoundary extends Component<Props, State> {
}
render() {
if (this.state.reloading) {
return (
<div className="error-page-shell">
<div className="error-page">
<div className="error-page__code" aria-hidden></div>
<h1 className="error-page__title"></h1>
<p className="error-page__desc"></p>
</div>
</div>
);
}
if (this.state.error) {
return (
<div className="error-page-shell">