mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 06:35:16 +08:00
feat: implement production cas v1
This commit is contained in:
@@ -79,7 +79,7 @@ impl GameClient {
|
||||
/// 此功能将在 Phase 3 实现
|
||||
pub fn discover() -> crate::Result<Vec<GameClient>> {
|
||||
Err(crate::Error::NotImplemented(
|
||||
"客户端发现功能将在 Phase 3 实现".to_string()
|
||||
"客户端发现功能将在 Phase 3 实现".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ impl GameClient {
|
||||
/// 此功能将在 Phase 3 实现
|
||||
pub fn verify_integrity(&self) -> crate::Result<bool> {
|
||||
Err(crate::Error::NotImplemented(
|
||||
"完整性验证将在 Phase 3 实现".to_string()
|
||||
"完整性验证将在 Phase 3 实现".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -134,10 +134,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_streaming_assets_path() {
|
||||
let client = GameClient::new(
|
||||
PathBuf::from("/game/BlueArchive_JP"),
|
||||
GameRegion::Japan
|
||||
);
|
||||
let client = GameClient::new(PathBuf::from("/game/BlueArchive_JP"), GameRegion::Japan);
|
||||
|
||||
assert_eq!(
|
||||
client.streaming_assets_path(),
|
||||
@@ -147,10 +144,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_asset_bundles_path() {
|
||||
let client = GameClient::new(
|
||||
PathBuf::from("/game/BlueArchive_JP"),
|
||||
GameRegion::Japan
|
||||
);
|
||||
let client = GameClient::new(PathBuf::from("/game/BlueArchive_JP"), GameRegion::Japan);
|
||||
|
||||
assert_eq!(
|
||||
client.asset_bundles_path(),
|
||||
@@ -162,6 +156,9 @@ mod tests {
|
||||
fn test_discover_not_implemented() {
|
||||
let result = GameClient::discover();
|
||||
assert!(result.is_err());
|
||||
assert!(matches!(result.unwrap_err(), crate::Error::NotImplemented(_)));
|
||||
assert!(matches!(
|
||||
result.unwrap_err(),
|
||||
crate::Error::NotImplemented(_)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,22 @@ pub struct UnityVersion {
|
||||
impl UnityVersion {
|
||||
/// 创建新的 Unity 版本
|
||||
pub fn new(year: u32, stream: u32, patch: u32, revision: String) -> Self {
|
||||
Self { year, stream, patch, revision }
|
||||
Self {
|
||||
year,
|
||||
stream,
|
||||
patch,
|
||||
revision,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for UnityVersion {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}.{}.{}{}", self.year, self.stream, self.patch, self.revision)
|
||||
write!(
|
||||
f,
|
||||
"{}.{}.{}{}",
|
||||
self.year, self.stream, self.patch, self.revision
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +53,12 @@ pub struct GameVersion {
|
||||
impl GameVersion {
|
||||
/// 创建新的游戏版本
|
||||
pub fn new(major: u32, minor: u32, patch: u32, unity_version: UnityVersion) -> Self {
|
||||
Self { major, minor, patch, unity_version }
|
||||
Self {
|
||||
major,
|
||||
minor,
|
||||
patch,
|
||||
unity_version,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,4 +8,7 @@ pub mod translation;
|
||||
pub use game_client::{ClientStatus, GameClient, GameRegion};
|
||||
pub use game_version::{GameVersion, UnityVersion};
|
||||
pub use resource::{Resource, ResourceEntry, ResourceType};
|
||||
pub use translation::{ExtractedText, SourceText, TextContext, TextMetadata, TextSource, TranslatedText, TranslationStatus};
|
||||
pub use translation::{
|
||||
ExtractedText, SourceText, TextContext, TextMetadata, TextSource, TranslatedText,
|
||||
TranslationStatus,
|
||||
};
|
||||
|
||||
@@ -298,9 +298,7 @@ pub trait CasRepository: Send + Sync {
|
||||
///
|
||||
/// 默认实现读取整个文件到内存。大文件应考虑流式处理。
|
||||
async fn store_from_file(&self, path: &Path) -> crate::Result<ObjectId> {
|
||||
let data = tokio::fs::read(path).await.map_err(|e| {
|
||||
crate::Error::Io(e)
|
||||
})?;
|
||||
let data = tokio::fs::read(path).await.map_err(crate::Error::Io)?;
|
||||
self.store(&data).await
|
||||
}
|
||||
|
||||
@@ -330,9 +328,9 @@ pub trait CasRepository: Send + Sync {
|
||||
/// - 确保有写入权限
|
||||
async fn export_to_file(&self, id: &ObjectId, path: &Path) -> crate::Result<()> {
|
||||
let data = self.get(id).await?;
|
||||
tokio::fs::write(path, data).await.map_err(|e| {
|
||||
crate::Error::Io(e)
|
||||
})?;
|
||||
tokio::fs::write(path, data)
|
||||
.await
|
||||
.map_err(crate::Error::Io)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,11 +302,7 @@ pub trait TranslationRepository: Send + Sync {
|
||||
/// - 使用 UPDATE 语句,只更新 status 字段
|
||||
/// - 记录状态变更时间
|
||||
/// - 可选:记录状态变更历史
|
||||
async fn update_status(
|
||||
&self,
|
||||
source_id: &str,
|
||||
status: TranslationStatus,
|
||||
) -> crate::Result<()>;
|
||||
async fn update_status(&self, source_id: &str, status: TranslationStatus) -> crate::Result<()>;
|
||||
|
||||
/// 批量保存翻译
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user