feat: refine AI navigation and accessibility recovery
This commit is contained in:
@@ -6,12 +6,13 @@ import 'package:miaoji_zhang/shared/theme/app_theme.dart';
|
||||
import 'package:miaoji_zhang/shared/widgets/app_controls.dart';
|
||||
import 'package:miaoji_zhang/shared/widgets/app_icons.dart';
|
||||
|
||||
enum AiAccessState { guest, reauthenticate, cloudDisabled }
|
||||
enum AiAccessState { guest, reauthenticate, aiDisabled, cloudDisabled }
|
||||
|
||||
AiAccessState? currentAiAccessState() {
|
||||
final session = SessionStore.instance;
|
||||
if (session.isGuest) return AiAccessState.guest;
|
||||
if (session.needsReauth) return AiAccessState.reauthenticate;
|
||||
if (!session.aiEnabled) return AiAccessState.aiDisabled;
|
||||
if (!session.cloudSyncEnabled) return AiAccessState.cloudDisabled;
|
||||
return null;
|
||||
}
|
||||
@@ -32,23 +33,27 @@ class _AiAccessGateState extends State<AiAccessGate> {
|
||||
String get _title => switch (widget.state) {
|
||||
AiAccessState.guest => '登录后使用 AI 助手',
|
||||
AiAccessState.reauthenticate => '登录状态已过期',
|
||||
AiAccessState.aiDisabled => 'AI 功能已关闭',
|
||||
AiAccessState.cloudDisabled => 'AI 功能需要云连接',
|
||||
};
|
||||
|
||||
String get _message => switch (widget.state) {
|
||||
AiAccessState.guest => '游客账单会继续安全保存在本机。登录后即可使用 AI 聊天、语音解析和图片识别。',
|
||||
AiAccessState.reauthenticate => '本地记账不受影响。重新登录后可以继续使用 AI 和云同步。',
|
||||
AiAccessState.aiDisabled => '当前账号暂未开通 AI,手动记账和统计不受影响。',
|
||||
AiAccessState.cloudDisabled => '当前账号仅使用本地数据。开启云同步后才能发送 AI 消息。',
|
||||
};
|
||||
|
||||
String get _actionLabel => switch (widget.state) {
|
||||
String? get _actionLabel => switch (widget.state) {
|
||||
AiAccessState.guest => '登录后使用',
|
||||
AiAccessState.reauthenticate => '重新登录',
|
||||
AiAccessState.aiDisabled => null,
|
||||
AiAccessState.cloudDisabled => '开启云同步',
|
||||
};
|
||||
|
||||
Future<void> _act() async {
|
||||
if (_busy) return;
|
||||
if (widget.state == AiAccessState.aiDisabled) return;
|
||||
if (widget.onAction != null) {
|
||||
await widget.onAction!();
|
||||
return;
|
||||
@@ -115,15 +120,17 @@ class _AiAccessGateState extends State<AiAccessGate> {
|
||||
height: 1.6,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 22),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: JzActionButton(
|
||||
label: _actionLabel,
|
||||
loading: _busy,
|
||||
onPressed: _busy ? null : _act,
|
||||
if (_actionLabel case final label?) ...[
|
||||
SizedBox(height: 22),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: JzActionButton(
|
||||
label: label,
|
||||
loading: _busy,
|
||||
onPressed: _busy ? null : _act,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (widget.state == AiAccessState.guest) ...[
|
||||
SizedBox(height: 12),
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user