feat(login): 增加 release 包服务端设置入口的开关控制
添加环境变量控制 release 包是否显示服务端设置入口,默认关闭,调试版仍直接显示。同时调整部分代码格式以保持一致性。
This commit is contained in:
1 parent
cc6dc6385a
commit
66013ee069
1 file changed
+20
-12
@@ -14,6 +14,12 @@ import '../../../shared/widgets/x_common.dart';
|
|||||||
import '../../../shared/widgets/x_icon.dart';
|
import '../../../shared/widgets/x_icon.dart';
|
||||||
import '../application/session_controller.dart';
|
import '../application/session_controller.dart';
|
||||||
|
|
||||||
|
/// 是否在 release 包里也显示「服务端设置」入口。
|
||||||
|
///
|
||||||
|
/// 默认关闭,因此正式交付包不会暴露改地址的口子;打包内部测试包时用
|
||||||
|
/// `--dart-define=ENABLE_SERVER_SETTINGS=true` 打开,测试同事即可自行切换后端。
|
||||||
|
const _serverSettingsEnabled = bool.fromEnvironment('ENABLE_SERVER_SETTINGS');
|
||||||
|
|
||||||
/// 登录页,对应 `pages/login/index.vue`。
|
/// 登录页,对应 `pages/login/index.vue`。
|
||||||
class LoginPage extends ConsumerStatefulWidget {
|
class LoginPage extends ConsumerStatefulWidget {
|
||||||
const LoginPage({super.key});
|
const LoginPage({super.key});
|
||||||
@@ -90,7 +96,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 40),
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 40),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
minHeight: (constraints.maxHeight - 80).clamp(0, double.infinity),
|
minHeight: (constraints.maxHeight - 80).clamp(
|
||||||
|
0,
|
||||||
|
double.infinity,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -111,8 +120,8 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// 测试用「服务端设置」入口,仅调试版可见
|
// 测试用「服务端设置」入口:调试版常显,release 需显式开关
|
||||||
if (kDebugMode)
|
if (kDebugMode || _serverSettingsEnabled)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 0,
|
top: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
@@ -142,9 +151,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: AppColors.surface,
|
backgroundColor: AppColors.surface,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.vertical(
|
borderRadius: BorderRadius.vertical(top: Radius.circular(AppRadius.lg)),
|
||||||
top: Radius.circular(AppRadius.lg),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
builder: (_) => const _ServerSettingsSheet(),
|
builder: (_) => const _ServerSettingsSheet(),
|
||||||
);
|
);
|
||||||
@@ -160,7 +167,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
begin: Alignment.topLeft,
|
begin: Alignment.topLeft,
|
||||||
end: Alignment.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
colors: [AppColors.brandGradientStart, AppColors.brandGradientEnd],
|
colors: [
|
||||||
|
AppColors.brandGradientStart,
|
||||||
|
AppColors.brandGradientEnd,
|
||||||
|
],
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
boxShadow: const [
|
boxShadow: const [
|
||||||
@@ -307,9 +317,7 @@ class _SoftBlob extends StatelessWidget {
|
|||||||
height: size,
|
height: size,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
gradient: RadialGradient(
|
gradient: RadialGradient(colors: [color, color.withValues(alpha: 0)]),
|
||||||
colors: [color, color.withValues(alpha: 0)],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -405,7 +413,7 @@ class _ServerSettingsSheetState extends ConsumerState<_ServerSettingsSheet> {
|
|||||||
Text('服务端设置', style: AppTypography.titleSm),
|
Text('服务端设置', style: AppTypography.titleSm),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
const Text(
|
const Text(
|
||||||
'仅调试版可见。保存后立即生效,无需重启 App。',
|
'保存后立即生效,无需重启 App。',
|
||||||
style: TextStyle(fontSize: 13, color: AppColors.textMuted),
|
style: TextStyle(fontSize: 13, color: AppColors.textMuted),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
@@ -512,4 +520,4 @@ class _ServerSettingsSheetState extends ConsumerState<_ServerSettingsSheet> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user