Initial commit: 风影 OA 全栈源码(API/Web/Flutter/IM)
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../api/oa_client.dart';
|
||||
import '../theme.dart';
|
||||
import '../widgets/beian_footer.dart';
|
||||
|
||||
class LegalPage extends StatefulWidget {
|
||||
const LegalPage({super.key, required this.api, required this.kind});
|
||||
final OaClient api;
|
||||
final String kind;
|
||||
|
||||
@override
|
||||
State<LegalPage> createState() => _LegalPageState();
|
||||
}
|
||||
|
||||
class _LegalPageState extends State<LegalPage> {
|
||||
String _title = '';
|
||||
String _meta = '';
|
||||
List<Map<String, String>> _sections = [];
|
||||
String _error = '';
|
||||
bool _loading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_title = widget.kind == 'privacy' ? '隐私政策' : '用户协议';
|
||||
_load();
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final data = await widget.api.get('/legal/${widget.kind}');
|
||||
if (data is! Map) throw ApiException('文档格式错误');
|
||||
final paras = data['paragraphs'];
|
||||
final sections = <Map<String, String>>[];
|
||||
if (paras is List) {
|
||||
for (final row in paras) {
|
||||
if (row is Map) {
|
||||
sections.add({
|
||||
'heading': '${row['heading'] ?? ''}',
|
||||
'body': '${row['body'] ?? ''}',
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_title = '${data['title'] ?? _title}';
|
||||
_meta = '${data['operator'] ?? ''} · 更新日期 ${data['updatedAt'] ?? ''}';
|
||||
_sections = sections;
|
||||
_loading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_error = '$e';
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBar(title: Text(_title)),
|
||||
body: _loading
|
||||
? const Center(child: CircularProgressIndicator(color: kBind))
|
||||
: _error.isNotEmpty
|
||||
? Center(child: Padding(padding: const EdgeInsets.all(24), child: Text(_error, style: const TextStyle(color: kDanger))))
|
||||
: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 12, 20, 40),
|
||||
children: [
|
||||
if (_meta.trim().isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Text(_meta, style: const TextStyle(color: kMute, fontSize: 12, height: 1.5)),
|
||||
),
|
||||
for (final s in _sections) ...[
|
||||
if ((s['heading'] ?? '').isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 8),
|
||||
child: Text(s['heading']!, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
||||
),
|
||||
Text(s['body'] ?? '', style: const TextStyle(fontSize: 14, height: 1.7, color: Color(0xFF334155))),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
const BeianFooter(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user