diff --git a/GFramework.Game.Abstractions/data/DataRepositoryOptions.cs b/GFramework.Game.Abstractions/data/DataRepositoryOptions.cs
index 5ae6b08..8ba1944 100644
--- a/GFramework.Game.Abstractions/data/DataRepositoryOptions.cs
+++ b/GFramework.Game.Abstractions/data/DataRepositoryOptions.cs
@@ -23,11 +23,6 @@ public class DataRepositoryOptions
///
public string BasePath { get; set; } = "";
- ///
- /// 键名前缀(如 "Game",生成的键为 "Game_SettingsData")
- ///
- public string KeyPrefix { get; set; } = "";
-
///
/// 是否在保存时自动备份
///
diff --git a/GFramework.Game/data/DataRepository.cs b/GFramework.Game/data/DataRepository.cs
index e6e0181..e4a53fd 100644
--- a/GFramework.Game/data/DataRepository.cs
+++ b/GFramework.Game/data/DataRepository.cs
@@ -162,7 +162,7 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options =
///
/// 数据类型
/// 生成的存储键
- private string GetKey() where T : IData
+ protected virtual string GetKey() where T : IData
{
return GetKey(typeof(T));
}
@@ -172,13 +172,9 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options =
///
/// 数据类型
/// 生成的存储键
- private string GetKey(Type type)
+ protected virtual string GetKey(Type type)
{
- var fileName = $"{_options.KeyPrefix}_{type.Name}";
-
- if (string.IsNullOrEmpty(_options.BasePath))
- return fileName;
- var basePath = _options.BasePath.TrimEnd('/');
- return $"{basePath}/{fileName}";
+ var fileName = type.FullName!;
+ return string.IsNullOrEmpty(_options.BasePath) ? fileName : $"{_options.BasePath}/{fileName}";
}
}
\ No newline at end of file
diff --git a/GFramework.Game/data/UnifiedSettingsRepository.cs b/GFramework.Game/data/UnifiedSettingsRepository.cs
index fbc5d99..c3dffd4 100644
--- a/GFramework.Game/data/UnifiedSettingsRepository.cs
+++ b/GFramework.Game/data/UnifiedSettingsRepository.cs
@@ -219,10 +219,9 @@ public class UnifiedSettingsRepository(
/// 获取统一文件的存储键名
///
/// 完整的存储键名
- private string GetUnifiedKey()
+ protected virtual string GetUnifiedKey()
{
- var name = string.IsNullOrEmpty(_options.KeyPrefix) ? fileName : $"{_options.KeyPrefix}_{fileName}";
- return string.IsNullOrEmpty(_options.BasePath) ? name : $"{_options.BasePath.TrimEnd('/')}/{name}";
+ return string.IsNullOrEmpty(_options.BasePath) ? fileName : $"{_options.BasePath}/{fileName}";
}
///
@@ -230,9 +229,8 @@ public class UnifiedSettingsRepository(
///
/// 要获取键的类型
/// 类型的全名作为键
- private static string GetTypeKey(Type type)
+ protected virtual string GetTypeKey(Type type)
{
return type.FullName!;
- // ⚠️ 刻意不用 AssemblyQualifiedName
}
}
\ No newline at end of file