feat: AI 意图路由/草稿存储 + Prompts 模块化 + UI 视觉统一 + AI 同意门 + 资源更新
后端: - 新增 ai_intent_router 意图路由 - 新增 AiEntryDraft 草稿存储 + EF 迁移 - 新增 Prompts 模块化(global/modules/rag/router) - AI Agent handlers 扩展 前端: - 新增 AI 同意门 (ai_consent_gate/provider/details_page) - HealthMetricVisuals 视觉统一 - 设备扫描/管理页面优化 - agent 插图替换 + 趋势指标图标 配置: - DeepSeek 模型改 deepseek-v4-flash - .gitignore 加 artifacts/audit - build.gradle.kts 签名配置调整
This commit is contained in:
@@ -7,6 +7,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../core/api_client.dart' show baseUrl;
|
||||
import '../providers/auth_provider.dart';
|
||||
|
||||
const int _maxProtectedImageCacheEntries = 32;
|
||||
final Map<String, Uint8List> _protectedImageBytesCache = {};
|
||||
|
||||
String protectedMediaUrl(String value) {
|
||||
final trimmed = value.trim();
|
||||
if (trimmed.isEmpty) return trimmed;
|
||||
@@ -58,6 +61,7 @@ class _AuthenticatedNetworkImageState
|
||||
extends ConsumerState<AuthenticatedNetworkImage> {
|
||||
late String _resolvedUrl;
|
||||
Future<Uint8List>? _bytes;
|
||||
Uint8List? _cachedBytes;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -73,11 +77,21 @@ class _AuthenticatedNetworkImageState
|
||||
|
||||
void _configure() {
|
||||
_resolvedUrl = protectedMediaUrl(widget.imageUrl);
|
||||
_bytes = mediaRequiresAuthentication(_resolvedUrl)
|
||||
? _loadProtectedBytes(_resolvedUrl)
|
||||
_cachedBytes = _protectedImageBytesCache[_resolvedUrl];
|
||||
_bytes = mediaRequiresAuthentication(_resolvedUrl) && _cachedBytes == null
|
||||
? _loadAndCacheProtectedBytes(_resolvedUrl)
|
||||
: null;
|
||||
}
|
||||
|
||||
Future<Uint8List> _loadAndCacheProtectedBytes(String url) async {
|
||||
final data = await _loadProtectedBytes(url);
|
||||
if (_protectedImageBytesCache.length >= _maxProtectedImageCacheEntries) {
|
||||
_protectedImageBytesCache.remove(_protectedImageBytesCache.keys.first);
|
||||
}
|
||||
_protectedImageBytesCache[url] = data;
|
||||
return data;
|
||||
}
|
||||
|
||||
Future<Uint8List> _loadProtectedBytes(String url) async {
|
||||
final response = await ref
|
||||
.read(apiClientProvider)
|
||||
@@ -91,6 +105,18 @@ class _AuthenticatedNetworkImageState
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cachedBytes = _cachedBytes;
|
||||
if (cachedBytes != null) {
|
||||
return Image.memory(
|
||||
cachedBytes,
|
||||
fit: widget.fit,
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
gaplessPlayback: true,
|
||||
errorBuilder: widget.errorBuilder,
|
||||
);
|
||||
}
|
||||
|
||||
final bytes = _bytes;
|
||||
if (bytes == null) {
|
||||
return Image.network(
|
||||
@@ -98,6 +124,7 @@ class _AuthenticatedNetworkImageState
|
||||
fit: widget.fit,
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
gaplessPlayback: true,
|
||||
loadingBuilder: widget.loadingBuilder,
|
||||
errorBuilder: widget.errorBuilder,
|
||||
);
|
||||
@@ -123,6 +150,7 @@ class _AuthenticatedNetworkImageState
|
||||
fit: widget.fit,
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
gaplessPlayback: true,
|
||||
errorBuilder: widget.errorBuilder,
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user