feat(auth): 登录页改为 ymb 品牌并支持后台配置背景图
This commit is contained in:
1 parent
22cc669bbe
commit
e7399fa3fd
24 files changed
+378
-188
No files matched your search
@@ -2,8 +2,9 @@
|
||||
|
||||
/// 开发环境配置。
|
||||
///
|
||||
/// 本机联调用:换 Wi-Fi、换网段后只改这里的 [baseUrl],地址不要带结尾斜杠。
|
||||
/// 本机联调用:模拟器与桌面端可直接用回环地址,但 iOS/Android 真机必须用
|
||||
/// 开发机的局域网 IP(真机上的 127.0.0.1 指向手机自己)。地址不要带结尾斜杠。
|
||||
abstract final class DevConfig {
|
||||
/// 开发机后端地址。
|
||||
/// 开发机后端地址(Mac 当前 Wi-Fi 地址,换网络后需要同步修改)。
|
||||
static const String baseUrl = 'http://192.168.31.243:8081';
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'api_client.dart';
|
||||
|
||||
/// 启动配置:`GET /app/config`(匿名,后台只下发白名单键)。
|
||||
class ConfigApi {
|
||||
const ConfigApi(this._client);
|
||||
|
||||
final ApiClient _client;
|
||||
|
||||
/// 白名单配置表;结构异常时返回空表,调用方按本地默认处理。
|
||||
Future<Map<String, dynamic>> appConfig() async {
|
||||
final data = await _client.get('/app/config');
|
||||
return data is Map<String, dynamic> ? data : const <String, dynamic>{};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../remote/config_api.dart';
|
||||
|
||||
/// 后台下发的启动配置。
|
||||
///
|
||||
/// 失败一律静默:拿不到就用 App 内置默认,不阻塞启动、不弹错。
|
||||
class AppConfigController extends ChangeNotifier {
|
||||
AppConfigController(this._api);
|
||||
|
||||
final ConfigApi _api;
|
||||
|
||||
String _loginBackgroundUrl = '';
|
||||
|
||||
/// 登录页整屏背景图;空串表示用本地默认图。
|
||||
String get loginBackgroundUrl => _loginBackgroundUrl;
|
||||
|
||||
Future<void> load() async {
|
||||
try {
|
||||
final config = await _api.appConfig();
|
||||
final url = (config['loginBackgroundUrl'] as String? ?? '').trim();
|
||||
if (url == _loginBackgroundUrl) return;
|
||||
_loginBackgroundUrl = url;
|
||||
notifyListeners();
|
||||
} catch (error) {
|
||||
debugPrint('[config] load failed: $error');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ class RemoteImage extends StatelessWidget {
|
||||
this.fallbackIconKey,
|
||||
this.fallbackAspectRatio,
|
||||
this.fallbackColor = AppColors.raised,
|
||||
this.fallbackWidget,
|
||||
this.decodeWidth,
|
||||
this.decodeHeight,
|
||||
});
|
||||
@@ -47,6 +48,9 @@ class RemoteImage extends StatelessWidget {
|
||||
final Key? fallbackIconKey;
|
||||
final double? fallbackAspectRatio;
|
||||
final Color fallbackColor;
|
||||
|
||||
/// 自定义兜底:地址为空、加载中、加载失败时都显示它(优先于 [fallbackColor])。
|
||||
final Widget? fallbackWidget;
|
||||
final int? decodeWidth;
|
||||
final int? decodeHeight;
|
||||
|
||||
@@ -77,9 +81,9 @@ class RemoteImage extends StatelessWidget {
|
||||
// cover/contain 本身会保持宽高比,此时若同时强制 cacheWidth 和
|
||||
// cacheHeight,解码会把竖版图强行拉成横版像素。只在显式指定了
|
||||
// decodeHeight、或 fit 不保持宽高比时才限定解码高度。
|
||||
final keepsAspectRatio =
|
||||
fit == BoxFit.cover || fit == BoxFit.contain;
|
||||
final cacheHeight = decodeHeight ??
|
||||
final keepsAspectRatio = fit == BoxFit.cover || fit == BoxFit.contain;
|
||||
final cacheHeight =
|
||||
decodeHeight ??
|
||||
(keepsAspectRatio || inferredHeight == null
|
||||
? null
|
||||
: resolveImageDecodePixels(inferredHeight, pixelRatio));
|
||||
@@ -106,6 +110,8 @@ class RemoteImage extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _fallback({required bool brand}) {
|
||||
final custom = fallbackWidget;
|
||||
if (custom != null) return custom;
|
||||
final mark = brand
|
||||
? LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
|
||||
Reference in new issue
Block a user