refactor(client): 往来/设备/登录/关于颜色迁移到 context.tokens

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-25 00:20:11 +08:00
parent 9afe0dcf6e
commit a7298b643c
6 changed files with 99 additions and 97 deletions
@@ -3,7 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/intl.dart';
import '../../core/auth/auth_state.dart';
import '../../core/theme/app_theme.dart';
import '../../core/theme/context_tokens.dart';
import '../../models/session.dart';
import '../../providers/session_provider.dart';
import '../../widgets/data_table_card.dart';
@@ -35,8 +35,8 @@ class DeviceManagementScreen extends ConsumerWidget {
const SizedBox(width: 12),
Text(
canKick ? '管理员可强制下线其他登录设备' : '仅查看,无操作权限',
style: const TextStyle(
fontSize: 12, color: AppTheme.textSecondary),
style: TextStyle(
fontSize: 12, color: context.tokens.muted),
),
const Spacer(),
IconButton(
@@ -56,12 +56,12 @@ class DeviceManagementScreen extends ConsumerWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.error_outline,
size: 40, color: AppTheme.textSecondary),
Icon(Icons.error_outline,
size: 40, color: context.tokens.muted),
const SizedBox(height: 12),
Text('加载失败:$e',
style:
const TextStyle(color: AppTheme.textSecondary)),
TextStyle(color: context.tokens.muted)),
const SizedBox(height: 12),
ElevatedButton(
onPressed: () =>
@@ -86,13 +86,13 @@ class DeviceManagementScreen extends ConsumerWidget {
children: [
Icon(Icons.circle,
size: 9,
color: online ? AppTheme.success : AppTheme.textSecondary),
color: online ? context.tokens.success : context.tokens.muted),
const SizedBox(width: 4),
Text(online ? '在线' : '离线',
style: TextStyle(
fontSize: 13,
color:
online ? AppTheme.success : AppTheme.textSecondary)),
online ? context.tokens.success : context.tokens.muted)),
],
);
@@ -101,15 +101,15 @@ class DeviceManagementScreen extends ConsumerWidget {
Widget? kickButton(DeviceSession s, {bool dense = false}) {
if (!canKick) return null;
if (s.isCurrent) {
return const Text('当前设备',
style: TextStyle(fontSize: 12, color: AppTheme.textSecondary));
return Text('当前设备',
style: TextStyle(fontSize: 12, color: context.tokens.muted));
}
return TextButton(
key: Key('btn_kick_${s.id}'),
onPressed: () => _confirmKick(context, ref, s),
child: Text('强制下线',
style: TextStyle(
fontSize: dense ? 13 : 12, color: AppTheme.danger)),
fontSize: dense ? 13 : 12, color: context.tokens.danger)),
);
}
@@ -144,16 +144,16 @@ class DeviceManagementScreen extends ConsumerWidget {
],
rows: sessions.isEmpty
? [
const DataRow(cells: [
DataRow(cells: [
DataCell(Text('暂无在线设备',
style: TextStyle(color: AppTheme.textSecondary))),
DataCell(SizedBox()),
DataCell(SizedBox()),
DataCell(SizedBox()),
DataCell(SizedBox()),
DataCell(SizedBox()),
DataCell(SizedBox()),
DataCell(SizedBox()),
style: TextStyle(color: context.tokens.muted))),
const DataCell(SizedBox()),
const DataCell(SizedBox()),
const DataCell(SizedBox()),
const DataCell(SizedBox()),
const DataCell(SizedBox()),
const DataCell(SizedBox()),
const DataCell(SizedBox()),
])
]
: sessions.map((s) {
@@ -170,12 +170,12 @@ class DeviceManagementScreen extends ConsumerWidget {
padding: const EdgeInsets.symmetric(
horizontal: 6, vertical: 1),
decoration: BoxDecoration(
color: AppTheme.primary.withAlpha(26),
color: context.tokens.primary.withAlpha(26),
borderRadius: BorderRadius.circular(4),
),
child: const Text('本机',
child: Text('本机',
style: TextStyle(
fontSize: 11, color: AppTheme.primary)),
fontSize: 11, color: context.tokens.primary)),
),
],
],
@@ -183,10 +183,10 @@ class DeviceManagementScreen extends ConsumerWidget {
DataCell(Text('${s.platformLabel} · ${s.platformClassLabel}')),
DataCell(Text(s.deviceName.isEmpty ? '-' : s.deviceName)),
DataCell(Text(s.ip.isEmpty ? '-' : s.ip,
style: const TextStyle(
style: TextStyle(
fontFamily: 'monospace',
fontSize: 12,
color: AppTheme.textSecondary))),
color: context.tokens.muted))),
DataCell(Text(fmt(s.createdAt))),
DataCell(Text(fmt(s.lastSeenAt))),
DataCell(onlineBadge(s.online)),
@@ -213,7 +213,7 @@ class DeviceManagementScreen extends ConsumerWidget {
ElevatedButton(
onPressed: () => Navigator.of(ctx).pop(true),
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.danger,
backgroundColor: context.tokens.danger,
foregroundColor: Colors.white),
child: const Text('强制下线'),
),
@@ -224,13 +224,13 @@ class DeviceManagementScreen extends ConsumerWidget {
try {
await ref.read(sessionListProvider.notifier).forceLogout(s.id);
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('已下线'), backgroundColor: AppTheme.success));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: const Text('已下线'), backgroundColor: context.tokens.success));
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('操作失败:$e'), backgroundColor: AppTheme.danger));
content: Text('操作失败:$e'), backgroundColor: context.tokens.danger));
}
}
}