hookehuyr

fix(api): 将错误提示从toast改为抛出异常

修改错误处理逻辑,将静默模式下的toast提示改为直接抛出异常,以便调用方能够捕获并处理错误
/*
* @Date: 2022-05-18 22:56:08
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-16 21:56:59
* @LastEditTime: 2025-09-19 13:12:14
* @FilePath: /lls_program/src/api/fn.js
* @Description: 文件描述
*/
......@@ -28,11 +28,12 @@ export const fn = (api, options = {}) => {
console.warn(res);
// 只有在非静默模式下才显示错误提示
if (!silent) {
Taro.showToast({
title: res?.data?.msg || '请求失败',
icon: 'none',
duration: 2000
});
// Taro.showToast({
// title: res?.data?.msg || '请求失败',
// icon: 'none',
// duration: 2000
// });
throw new Error(res?.data?.msg || '请求失败');
}
return false;
}
......