1:修复远程遥控控制状态显示不正确的问题
2:更换端口映射为测试服的8081-59003,9001-59004
This commit is contained in:
24
lib/core/utils/image_url_util.dart
Normal file
24
lib/core/utils/image_url_util.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:maibu_satabot_v2/core/consts/http_api_consts.dart';
|
||||
|
||||
/// 图片地址工具:后端返回的图片路径可能是相对路径(如 /profile/avatar/xxx.jpg),
|
||||
/// 直接交给 Image.network 会因缺少 host 抛 "No host specified in URI" 异常。
|
||||
/// 此工具负责将相对路径拼接成完整的服务器地址。
|
||||
class ImageUrlUtil {
|
||||
ImageUrlUtil._();
|
||||
|
||||
/// 补全图片地址
|
||||
/// - 已是完整 http(s) 地址:原样返回
|
||||
/// - 以 / 开头的相对路径:拼接 baseUrl
|
||||
/// - 其他相对路径:拼接 baseUrl + /
|
||||
/// - null 或空:返回 null
|
||||
static String? resolve(String? path) {
|
||||
if (path == null || path.isEmpty) return null;
|
||||
if (path.startsWith('http://') || path.startsWith('https://')) {
|
||||
return path;
|
||||
}
|
||||
if (path.startsWith('/')) {
|
||||
return '${HttpApiConsts.baseUrl}$path';
|
||||
}
|
||||
return '${HttpApiConsts.baseUrl}/$path';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user