Compare commits
2
Commits
17799af2e7
...
9dea31f76e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9dea31f76e | ||
|
|
7faa8e5c47 |
@@ -30,15 +30,20 @@ class AuthServer {
|
|||||||
|
|
||||||
/// 获取赛事列表
|
/// 获取赛事列表
|
||||||
/// [path] 赛事目录
|
/// [path] 赛事目录
|
||||||
|
/// [nasIpAddr] NAS IP,由调用方传入,避免在 authProvider 内部再 read(authProvider)。
|
||||||
static Future<GetRecordListResModel?> getRecordList(
|
static Future<GetRecordListResModel?> getRecordList(
|
||||||
Ref ref,
|
Ref ref, {
|
||||||
String path,
|
required String path,
|
||||||
) async {
|
required String nasIpAddr,
|
||||||
|
}) async {
|
||||||
try {
|
try {
|
||||||
|
if (nasIpAddr.isEmpty) {
|
||||||
|
throw const FormatException('无法获取NAS IP地址');
|
||||||
|
}
|
||||||
final apiClient = ref.read(apiClientProvider);
|
final apiClient = ref.read(apiClientProvider);
|
||||||
// NAS /api/files 直接返回 {path, items},不是业务网关的 {code,message,data} 包装。
|
// NAS /api/files 直接返回 {path, items},不是业务网关的 {code,message,data} 包装。
|
||||||
final data = await apiClient.get<GetRecordListResModel>(
|
final data = await apiClient.get<GetRecordListResModel>(
|
||||||
'http://sheling.local:9001/${AuthApi.getRecordList.path}',
|
'http://$nasIpAddr:9001/${AuthApi.getRecordList.path}',
|
||||||
queryParameters: {'path': path},
|
queryParameters: {'path': path},
|
||||||
wrapResponse: false,
|
wrapResponse: false,
|
||||||
parser: (json) {
|
parser: (json) {
|
||||||
|
|||||||
@@ -71,7 +71,13 @@ class AuthViewModel extends StateNotifier<AuthState> {
|
|||||||
/// 获取赛事列表
|
/// 获取赛事列表
|
||||||
Future<bool> getRecordList(String eventName) async {
|
Future<bool> getRecordList(String eventName) async {
|
||||||
if (eventName.isEmpty) return false;
|
if (eventName.isEmpty) return false;
|
||||||
final data = await AuthServer.getRecordList(_ref, eventName);
|
final nasIpAddr = state.jwtDecodedData?.nasIpAddr?.trim() ?? '';
|
||||||
|
if (nasIpAddr.isEmpty) return false;
|
||||||
|
final data = await AuthServer.getRecordList(
|
||||||
|
_ref,
|
||||||
|
path: eventName,
|
||||||
|
nasIpAddr: nasIpAddr,
|
||||||
|
);
|
||||||
if (data == null) return false;
|
if (data == null) return false;
|
||||||
if (data.items == null) return false;
|
if (data.items == null) return false;
|
||||||
state = state.copyWith(recordList: data.items);
|
state = state.copyWith(recordList: data.items);
|
||||||
@@ -81,7 +87,13 @@ class AuthViewModel extends StateNotifier<AuthState> {
|
|||||||
/// 获取指定目录的录像列表(不更新 state,用于目录下钻)
|
/// 获取指定目录的录像列表(不更新 state,用于目录下钻)
|
||||||
Future<List<RecordListItem>?> fetchRecordList(String path) async {
|
Future<List<RecordListItem>?> fetchRecordList(String path) async {
|
||||||
if (path.isEmpty) return null;
|
if (path.isEmpty) return null;
|
||||||
final data = await AuthServer.getRecordList(_ref, path);
|
final nasIpAddr = state.jwtDecodedData?.nasIpAddr?.trim() ?? '';
|
||||||
|
if (nasIpAddr.isEmpty) return null;
|
||||||
|
final data = await AuthServer.getRecordList(
|
||||||
|
_ref,
|
||||||
|
path: path,
|
||||||
|
nasIpAddr: nasIpAddr,
|
||||||
|
);
|
||||||
return data?.items;
|
return data?.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user