76f266645d
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
1.9 KiB
Dart
68 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../api/oa_client.dart';
|
|
import '../widgets/common.dart';
|
|
import 'notice_detail_page.dart';
|
|
|
|
class NoticesPage extends StatefulWidget {
|
|
const NoticesPage({super.key, required this.api});
|
|
final OaClient api;
|
|
|
|
@override
|
|
State<NoticesPage> createState() => _NoticesPageState();
|
|
}
|
|
|
|
class _NoticesPageState extends State<NoticesPage> {
|
|
List<Map<String, dynamic>> _items = [];
|
|
bool _loading = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_load();
|
|
}
|
|
|
|
Future<void> _load() async {
|
|
try {
|
|
final data = await widget.api.get('/office/notices');
|
|
if (!mounted) return;
|
|
setState(() {
|
|
_items = asMaps(data);
|
|
_loading = false;
|
|
});
|
|
} catch (_) {
|
|
if (mounted) setState(() => _loading = false);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('公司公告')),
|
|
body: _loading
|
|
? const Center(child: CircularProgressIndicator())
|
|
: _items.isEmpty
|
|
? const EmptyHint('暂无公告')
|
|
: RefreshIndicator(
|
|
onRefresh: _load,
|
|
child: ListView(
|
|
children: [
|
|
for (final r in _items)
|
|
KvTile(
|
|
title: '${r['title'] ?? ''}',
|
|
subtitle: '${r['excerpt'] ?? ''} ${fmtTime(r['createdAt'])}',
|
|
onTap: () => Navigator.of(context).push(MaterialPageRoute(
|
|
builder: (_) => NoticeDetailPage(
|
|
api: widget.api,
|
|
id: '${r['id']}',
|
|
title: '${r['title'] ?? '公告'}',
|
|
),
|
|
)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|