76f266645d
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
2.6 KiB
Dart
82 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../api/oa_client.dart';
|
|
import '../desk_theme.dart';
|
|
import '../widgets/desk_widgets.dart';
|
|
|
|
class DeskLegalPage extends StatefulWidget {
|
|
const DeskLegalPage({super.key, required this.api, required this.kind});
|
|
final OaClient api;
|
|
final String kind;
|
|
|
|
@override
|
|
State<DeskLegalPage> createState() => _DeskLegalPageState();
|
|
}
|
|
|
|
class _DeskLegalPageState extends State<DeskLegalPage> {
|
|
String _title = '';
|
|
List<Map<String, String>> _sections = [];
|
|
String _error = '';
|
|
bool _loading = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_load();
|
|
}
|
|
|
|
Future<void> _load() async {
|
|
try {
|
|
final raw = await widget.api.get('/legal/${widget.kind}');
|
|
if (!mounted) return;
|
|
if (raw is Map) {
|
|
final data = Map<String, dynamic>.from(raw);
|
|
final paras = asMaps(data['paragraphs']);
|
|
setState(() {
|
|
_title = '${data['title'] ?? ''}';
|
|
_sections = paras.isNotEmpty
|
|
? paras.map((e) => {'title': '${e['heading'] ?? e['title'] ?? ''}', 'body': '${e['body'] ?? ''}'}).toList()
|
|
: [{'title': '', 'body': '${data['body'] ?? data['content'] ?? ''}'}];
|
|
_loading = false;
|
|
});
|
|
}
|
|
} catch (e) {
|
|
if (mounted) setState(() {
|
|
_error = '$e';
|
|
_loading = false;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ColoredBox(
|
|
color: kDeskBg,
|
|
child: Column(
|
|
children: [
|
|
DeskPaneHeader(
|
|
title: _title.isEmpty ? (widget.kind == 'privacy' ? '隐私政策' : '用户协议') : _title,
|
|
leading: IconButton(icon: const Icon(Icons.arrow_back, size: 20), onPressed: () => Navigator.pop(context)),
|
|
),
|
|
if (_loading) const LinearProgressIndicator(minHeight: 2, color: kDeskBind),
|
|
Expanded(
|
|
child: _error.isNotEmpty
|
|
? Center(child: Text(_error, style: const TextStyle(color: kDeskMute)))
|
|
: ListView(
|
|
padding: const EdgeInsets.all(24),
|
|
children: [
|
|
for (final s in _sections) ...[
|
|
Text(s['title'] ?? '', style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600)),
|
|
const SizedBox(height: 8),
|
|
Text(s['body'] ?? '', style: const TextStyle(fontSize: 14, height: 1.6, color: kDeskInk)),
|
|
const SizedBox(height: 20),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|