修复工作人员端令牌失效后的登录恢复
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
// 功能描述:展示工作人员资料、钱包和草稿状态,并安全处理刷新与退出。
|
||||
// 版本:1.1.0
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../app/dependencies.dart';
|
||||
import '../../../data/offline/encrypted_draft_store.dart';
|
||||
import '../../../data/repositories/service_repository.dart';
|
||||
import '../../../data/services/api_client.dart';
|
||||
import '../../../domain/models/service_models.dart';
|
||||
import '../../core/widgets.dart';
|
||||
|
||||
@@ -38,6 +41,14 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||
await widget.drafts.count(widget.session.identity),
|
||||
);
|
||||
|
||||
/// 创建新的加载任务,并在同步状态回调中替换页面 Future。
|
||||
void _reload() {
|
||||
final future = _load();
|
||||
setState(() {
|
||||
_future = future;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _logout(int draftCount) async {
|
||||
if (draftCount > 0) {
|
||||
final discard = await showDialog<bool>(
|
||||
@@ -66,10 +77,13 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
if (snapshot.hasError) {
|
||||
if (snapshot.error is SessionExpiredException) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
return MessageState(
|
||||
title: '工作台信息加载失败',
|
||||
description: '请检查网络后重新加载',
|
||||
onRetry: () => setState(() => _future = _load()),
|
||||
onRetry: _reload,
|
||||
);
|
||||
}
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
|
||||
Reference in New Issue
Block a user