feat: 实验性连接信息导出与会话恢复,重写关于页

- SessionShare:把 userId / JSESSIONID / token 打成 Base64(JSON),Cookie 只保留
  JSESSIONID 一项,粘贴时容忍换行与空白,QR 令牌与乱码解不出来
- 主页底部新增「导出连接信息」卡片,标记实验性:内容未加密,字符串在手即可操作账号
- 登录页识别到连接信息时把登录按钮换成「恢复会话」,不必再扫 QR 令牌
- 恢复优先沿用导入的 JSESSIONID(不重发 UserLoginApi,免得顶掉机台上的登录),
  Cookie 失效才退回用 token 登录;验证 Cookie 时顺手拉到的 GetUserDataApi 结果
  直接交给主页展示,省一次请求
- 仅凭 Cookie 恢复的会话没有 loginId / loginDateTime,_gameLogin 保持 null,
  票据与风险页照旧提示「尚未登录游戏服务器」,主页顶部给出说明横幅
- 关于页改用 AppCard / SectionTitle 脚手架,补基本信息与风险提示,把过时的
  「jsQR (web)」致谢换成原生 MethodChannel(QR 解码早已不走 web 库)
This commit is contained in:
Cookiues committed 2026-09-29 02:43:39 +08:00
1 parent 4dddfdc00c
commit 5d16984e4e
9 files changed
+772 -190

No files matched your search

+146
View File
@@ -0,0 +1,146 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show Clipboard, ClipboardData;
import '../config/strings.dart';
import '../models/session_model.dart';
import '../models/session_share.dart';
import 'app_card.dart';
import 'app_notice.dart';
/// 实验性:把当前会话打包成 Base64「连接信息」,在别的设备粘贴即可恢复。
class ConnectionShareCard extends StatefulWidget {
final int userId;
final String token;
const ConnectionShareCard({
super.key,
required this.userId,
required this.token,
});
@override
State<ConnectionShareCard> createState() => _ConnectionShareCardState();
}
class _ConnectionShareCardState extends State<ConnectionShareCard> {
String? _encoded;
SessionShare get _share => SessionModel.instance.exportConnectionInfo(
userId: widget.userId,
token: widget.token,
);
Future<void> _copy() async {
final share = _share;
if (!share.hasCookie && !share.hasToken) {
context.showSnack(AppStrings.connectionShareEmpty);
return;
}
final text = share.encode();
await Clipboard.setData(ClipboardData(text: text));
if (!mounted) return;
setState(() => _encoded = text);
context.showSnack(AppStrings.connectionShareCopied);
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return AppCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: SectionTitle(
icon: Icons.link,
title: AppStrings.connectionShareTitle,
),
),
const _ExperimentalBadge(),
],
),
const SizedBox(height: 10),
Text(
AppStrings.connectionShareDesc,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 14),
SizedBox(
width: double.infinity,
child: FilledButton.tonalIcon(
onPressed: _copy,
icon: const Icon(Icons.copy_all, size: 20),
label: const Text(AppStrings.connectionShareCopy),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 13),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
if (_encoded != null) ...[
const SizedBox(height: 12),
Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest.withValues(
alpha: 0.5,
),
borderRadius: BorderRadius.circular(8),
),
child: SingleChildScrollView(
child: SelectableText(
_encoded!,
style: theme.textTheme.bodySmall?.copyWith(
fontFamily: 'monospace',
fontSize: 11,
),
),
),
),
const SizedBox(height: 10),
Text(
AppStrings.connectionShareSecurity,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.error,
),
),
],
],
),
);
}
}
class _ExperimentalBadge extends StatelessWidget {
const _ExperimentalBadge();
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final tint = theme.colorScheme.tertiary;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: tint.withValues(alpha: 0.14),
borderRadius: BorderRadius.circular(6),
border: Border.all(color: tint.withValues(alpha: 0.5)),
),
child: Text(
AppStrings.experimentalBadge,
style: theme.textTheme.labelSmall?.copyWith(
color: tint,
fontWeight: FontWeight.w600,
),
),
);
}
}