Files
pj_supermarket_cloud/lib/common/api/app_api.dart
T
dzc 82800373ca fix:图片访问
fix:权限修改
2026-10-29 14:26:08 +08:00

46 lines
1.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:dio/dio.dart' as dio;
import 'package:pj_supermarket_cloud/common/index.dart';
/// 终端 App 配置与版本接口入口,统一复用 HttpManage 的鉴权、租户和错误处理。
abstract class AppApi {
///
/// 分页获取匹配 App 编码和平台的已发布版本。
///
/// [pa] 包含 appUniqueCode、platform、current 和 size;[silent] 为 true 时后台任务
/// 只记录异常,不弹业务 Toast。
static Future<ServiceAppVersionPage?> openCardList(
dynamic pa, {
bool silent = false,
}) async {
final res = await HttpManage().dio.get(
"/integrated/app-version/ad/page",
queryParameters: pa,
options: dio.Options(
extra: {if (silent) HttpManage.silentRequestKey: true},
),
);
if (res.data == null) return null;
return ServiceAppVersionPage.fromJson(res.data);
}
/// Requery the same published record; never switch APK versions during a retry.
static Future<String> refreshPackageUrl(ServiceAppVersion version) async {
if (version.id == null) throw StateError('缺少版本标识,请刷新版本列表');
final page = await openCardList({
'id': version.id,
'appUniqueCode': version.appUniqueCode,
'platform': version.platform,
'current': 1,
'size': 1,
}, silent: true);
for (final item in page?.records ?? <ServiceAppVersion>[]) {
if (item.id == version.id && item.versionCode == version.versionCode &&
item.appUniqueCode == version.appUniqueCode && item.platform == version.platform) {
return item.downloadUrl ?? '';
}
}
throw StateError('该版本已下架,请刷新版本列表');
}
}