追加webdav重新登录的button,还在测试边界情况
This commit is contained in:
@@ -7,6 +7,7 @@ import '../widgets/magnetic_scroll_physics.dart';
|
||||
import 'webdav_setup_page.dart';
|
||||
import 'webdav_file_list_page.dart';
|
||||
import '../constants/ui_constants.dart';
|
||||
import '../base/base_state.dart';
|
||||
|
||||
// ==================================================
|
||||
// 歌曲数据模型
|
||||
@@ -149,7 +150,7 @@ class HomePage extends StatefulWidget {
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
class _HomePageState extends BaseState<HomePage> {
|
||||
List<SongItem> _favorites = [];
|
||||
bool _isLoading = true;
|
||||
|
||||
@@ -282,6 +283,52 @@ class _HomePageState extends State<HomePage> {
|
||||
}
|
||||
}
|
||||
|
||||
// ⭐ 退出/重新登录对话框
|
||||
void _showReauthDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: const Color(0xFF1A1F1E),
|
||||
title: const Text(
|
||||
'重新登录 WebDAV',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
content: const Text(
|
||||
'退出当前账号并重新登录?',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
await WebDAVService.instance.clearCredentials();
|
||||
setState(() {
|
||||
_favorites = [];
|
||||
_isLoading = false;
|
||||
});
|
||||
if (mounted) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const WebDAVSetupPage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text(
|
||||
'重新登录',
|
||||
style: TextStyle(color: Colors.redAccent),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _resetSnapState() {
|
||||
if (_scrollController.hasClients) {
|
||||
_scrollController.jumpTo(0.0);
|
||||
@@ -413,6 +460,25 @@ class _HomePageState extends State<HomePage> {
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
// ⭐ 退出按钮(已连接时显示)
|
||||
if (isConnected) ...[
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.logout,
|
||||
color: Colors.grey,
|
||||
size: 18,
|
||||
),
|
||||
tooltip: '重新登录',
|
||||
onPressed: _showReauthDialog,
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 32,
|
||||
minHeight: 32,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
Reference in New Issue
Block a user