opt: 媒体库页面登录跳转

This commit is contained in:
guozhigq
2024-05-03 22:58:14 +08:00
parent b89a11dcfb
commit 547fad884f
14 changed files with 157 additions and 51 deletions

View File

@ -17,10 +17,15 @@ class FavController extends GetxController {
int pageSize = 60;
RxBool hasMore = true.obs;
Future<dynamic> queryFavFolder({type = 'init'}) async {
@override
void onInit() {
userInfo = userInfoCache.get('userInfoCache');
super.onInit();
}
Future<dynamic> queryFavFolder({type = 'init'}) async {
if (userInfo == null) {
return {'status': false, 'msg': '账号未登录'};
return {'status': false, 'msg': '账号未登录', 'code': -101};
}
if (!hasMore.value) {
return;

View File

@ -4,6 +4,7 @@ import 'package:get/get.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/pages/fav/index.dart';
import 'package:pilipala/pages/fav/widgets/item.dart';
import 'package:pilipala/utils/route_push.dart';
class FavPage extends StatefulWidget {
const FavPage({super.key});
@ -57,8 +58,8 @@ class _FavPageState extends State<FavPage> {
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data as Map;
if (data['status']) {
Map? data = snapshot.data;
if (data != null && data['status']) {
return Obx(
() => ListView.builder(
controller: scrollController,
@ -74,8 +75,18 @@ class _FavPageState extends State<FavPage> {
physics: const NeverScrollableScrollPhysics(),
slivers: [
HttpError(
errMsg: data['msg'],
fn: () => setState(() {}),
errMsg: data?['msg'] ?? '请求异常',
btnText: data?['code'] == -101 ? '去登录' : null,
fn: () {
if (data?['code'] == -101) {
RoutePush.loginRedirectPush();
} else {
setState(() {
_futureBuilderFuture =
_favController.queryFavFolder();
});
}
},
),
],
);