mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 03:04:29 +08:00
- 新增CacheEvictionPolicy枚举定义LRU和LFU缓存淘汰策略 - 在GodotUiFactory中实现缓存淘汰机制支持LRU/LFU策略 - 将IUiCacheStatistics接口从IUiFactory中分离到独立文件 - 移除UiAnimationPolicy类及相关动画策略参数配置 - 移除GodotUiTransition类中的UI过渡动画实现 - 移除UiTransitionAnimation枚举类型 - 更新UiRouterBase中路由方法移除动画策略参数 - 重构路由守卫注册方法位置优化代码结构 - 更新UiCacheConfig配置类适配新的缓存策略枚举值 -[skip ci]
87 lines
2.4 KiB
C#
87 lines
2.4 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using GFramework.Core.Abstractions.utility;
|
||
|
||
namespace GFramework.Game.Abstractions.ui;
|
||
|
||
/// <summary>
|
||
/// UI工厂接口,用于创建UI页面实例
|
||
/// </summary>
|
||
public interface IUiFactory : IContextUtility
|
||
{
|
||
/// <summary>
|
||
/// 创建或获取UI页面实例
|
||
/// </summary>
|
||
/// <param name="uiKey">UI标识键</param>
|
||
/// <param name="policy">实例管理策略</param>
|
||
/// <returns>UI页面实例</returns>
|
||
IUiPageBehavior GetOrCreate(string uiKey, UiInstancePolicy policy = UiInstancePolicy.AlwaysCreate);
|
||
|
||
/// <summary>
|
||
/// 仅创建新实例(不使用缓存)
|
||
/// </summary>
|
||
IUiPageBehavior Create(string uiKey);
|
||
|
||
/// <summary>
|
||
/// 预加载UI资源到缓存池
|
||
/// </summary>
|
||
/// <param name="uiKey">UI标识键</param>
|
||
/// <param name="count">预加载数量,默认1个</param>
|
||
void Preload(string uiKey, int count = 1);
|
||
|
||
/// <summary>
|
||
/// 批量预加载
|
||
/// </summary>
|
||
void PreloadBatch(params string[] uiKeys);
|
||
|
||
/// <summary>
|
||
/// 回收实例到缓存池
|
||
/// </summary>
|
||
/// <param name="page">要回收的页面实例</param>
|
||
void Recycle(IUiPageBehavior page);
|
||
|
||
/// <summary>
|
||
/// 清理指定UI的缓存实例
|
||
/// </summary>
|
||
void ClearCache(string uiKey);
|
||
|
||
/// <summary>
|
||
/// 清理所有缓存
|
||
/// </summary>
|
||
void ClearAllCache();
|
||
|
||
/// <summary>
|
||
/// 检查是否有缓存的实例
|
||
/// </summary>
|
||
bool HasCached(string uiKey);
|
||
|
||
#region 缓存策略管理
|
||
|
||
/// <summary>
|
||
/// 获取UI的缓存配置
|
||
/// </summary>
|
||
/// <param name="uiKey">UI标识符</param>
|
||
/// <returns>缓存配置,如果未设置则返回默认配置</returns>
|
||
UiCacheConfig GetCacheConfig(string uiKey);
|
||
|
||
/// <summary>
|
||
/// 设置UI的缓存配置
|
||
/// </summary>
|
||
/// <param name="uiKey">UI标识符</param>
|
||
/// <param name="config">缓存配置</param>
|
||
void SetCacheConfig(string uiKey, UiCacheConfig config);
|
||
|
||
/// <summary>
|
||
/// 移除UI的缓存配置,恢复默认配置
|
||
/// </summary>
|
||
/// <param name="uiKey">UI标识符</param>
|
||
void RemoveCacheConfig(string uiKey);
|
||
|
||
/// <summary>
|
||
/// 获取所有UI的缓存统计信息
|
||
/// </summary>
|
||
/// <returns>缓存统计字典</returns>
|
||
IDictionary<string, IUiCacheStatistics> GetCacheStatistics();
|
||
|
||
#endregion
|
||
} |