重整多余的UI组件和未定功能的逻辑链路的修正
This commit is contained in:
@@ -11,7 +11,6 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/domain/tab_config.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/cubit/float_bar_setting_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/update/update_cubit.dart';
|
||||
@@ -38,6 +37,7 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
Future<void> _loadVersion() async {
|
||||
try {
|
||||
final String versionString = await rootBundle.loadString('pubspec.yaml');
|
||||
if (!mounted) return;
|
||||
final versionMatch = RegExp(r'version:\s*(\d+\.\d+\.\d+)\+(\d+)').firstMatch(versionString);
|
||||
setState(() {
|
||||
_currentVersion = versionMatch?.group(1) ?? '1.0.0';
|
||||
@@ -47,6 +47,8 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = context.watch<AppUserCubit>().state.user;
|
||||
final isAdmin = user?.isAdmin == true;
|
||||
return Scaffold(
|
||||
backgroundColor: context.appColors.pageBackground,
|
||||
appBar: AppBar(
|
||||
@@ -69,16 +71,17 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// Tab 设置
|
||||
_buildTabSettingsSection(),
|
||||
_buildTabSettingsSection(user?.roleKey, isAdmin: isAdmin),
|
||||
const SizedBox(height: 12),
|
||||
// 悬浮条设置
|
||||
_buildFloatBarSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 语言设置
|
||||
if (isAdmin) ...[
|
||||
_buildFloatBarSection(),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_buildLanguageSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 版本更新
|
||||
_buildUpdateSection(),
|
||||
if (isAdmin) ...[
|
||||
const SizedBox(height: 12),
|
||||
_buildUpdateSection(),
|
||||
],
|
||||
const SizedBox(height: 12),
|
||||
// 退出登录(已挪至“我的”页面最下边,此处注释掉)
|
||||
// _buildLogoutButton(context),
|
||||
@@ -148,10 +151,7 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
}
|
||||
|
||||
/// Tab 设置
|
||||
Widget _buildTabSettingsSection() {
|
||||
// 🔥 个人角色(roleKey == 'personal'):Tab 设置只列出「设备 + 我的」,且开关常开锁定
|
||||
final roleKey = context.watch<AppUserCubit>().state.user?.roleKey;
|
||||
final isPersonal = roleKey == TabConfig.personalRoleKey;
|
||||
Widget _buildTabSettingsSection(String? roleKey, {required bool isAdmin}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -177,9 +177,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
BlocBuilder<TabConfigCubit, dynamic>(
|
||||
BlocBuilder<TabConfigCubit, TabConfigState>(
|
||||
builder: (context, state) {
|
||||
if (state.runtimeType.toString() != 'TabConfigLoaded') {
|
||||
if (state is! TabConfigLoaded) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
@@ -208,13 +208,10 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
// 个人角色:设备/我的 强制常开且不可关闭
|
||||
value: isPersonal ? true : tab.isEnabled,
|
||||
onChanged: isPersonal
|
||||
? null
|
||||
: (value) {
|
||||
context.read<TabConfigCubit>().toggleTab(tab.id);
|
||||
},
|
||||
value: tab.isEnabled,
|
||||
onChanged: isAdmin
|
||||
? (_) => context.read<TabConfigCubit>().toggleTab(tab.id)
|
||||
: null,
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user