fix: show friendly error message in production
This commit is contained in:
@@ -49,7 +49,11 @@ export default function ScriptCreation() {
|
||||
.catch((err: Error) => {
|
||||
console.error('[分类加载失败]', err);
|
||||
if (!cached) {
|
||||
toast.error(`加载分类列表失败: ${err.message}`);
|
||||
// 生产环境显示友好固定文案,开发环境显示详细错误
|
||||
const msg = import.meta.env.PROD
|
||||
? '加载分类列表失败,请检查网络连接'
|
||||
: `加载分类列表失败: ${err.message}`;
|
||||
toast.error(msg);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user