2025-11-03 00:24:36 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using YooAsset;
|
|
|
|
|
|
using static YooAsset.DownloaderOperation;
|
|
|
|
|
|
public class PatchOperationData
|
|
|
|
|
|
{
|
|
|
|
|
|
public string packageName;
|
|
|
|
|
|
public EPlayMode playMode;
|
|
|
|
|
|
public bool useBuildinFileSystem;
|
|
|
|
|
|
public DownloadError downloadError;
|
|
|
|
|
|
public DownloaderFinish downloadFinish;
|
|
|
|
|
|
public DownloadUpdate downloadUpdate;
|
|
|
|
|
|
public int downloadingMaxNum = 10;
|
|
|
|
|
|
public int failedTryAgain = 3;
|
|
|
|
|
|
}
|
|
|
|
|
|
public class PatchOperation
|
|
|
|
|
|
{
|
|
|
|
|
|
public PatchOperationData data;
|
|
|
|
|
|
public ResourcePackage package;
|
|
|
|
|
|
public ResourceDownloaderOperation downloader;
|
|
|
|
|
|
public string packageVersion;
|
|
|
|
|
|
public string PkgVersionKey;
|
|
|
|
|
|
public PatchOperation(PatchOperationData data)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.data = data;
|
|
|
|
|
|
PkgVersionKey = $"{Application.productName}_{data.packageName}";
|
2025-11-04 16:19:53 +08:00
|
|
|
|
#if !UNITY_EDITOR
|
|
|
|
|
|
PkgVersionKey = $"Editor_{Application.productName}_{data.packageName}";
|
|
|
|
|
|
#endif
|
2025-11-03 00:24:36 +08:00
|
|
|
|
}
|
2025-11-03 17:46:28 +08:00
|
|
|
|
#region 初始化相关
|
|
|
|
|
|
public async UniTask<bool> InitializePackage()
|
2025-11-03 00:24:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
package = YooAssets.TryGetPackage(data.packageName);
|
|
|
|
|
|
if (package == null)
|
|
|
|
|
|
package = YooAssets.CreatePackage(data.packageName);
|
|
|
|
|
|
|
|
|
|
|
|
InitializationOperation initializationOperation = null;
|
|
|
|
|
|
switch (data.playMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case EPlayMode.EditorSimulateMode:
|
|
|
|
|
|
initializationOperation = InitializeEditorMode(package);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EPlayMode.OfflinePlayMode:
|
|
|
|
|
|
initializationOperation = InitializeOfflineMode(package);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EPlayMode.HostPlayMode:
|
|
|
|
|
|
initializationOperation = InitializeHostMode(package);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EPlayMode.WebPlayMode:
|
|
|
|
|
|
initializationOperation = InitializeWebPlayMode(package);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EPlayMode.CustomPlayMode:
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
await initializationOperation.ToUniTask();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
if (initializationOperation.Status != EOperationStatus.Succeed)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show()
|
|
|
|
|
|
.SetTitle($"{data.packageName}初始化")
|
|
|
|
|
|
.SetContent($"{initializationOperation.Error}")
|
|
|
|
|
|
.AddButton("退出", (box) => { Application.Quit(); });
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
PatchEvent.UpdateStatus($"初始化成功{data.packageName}");
|
|
|
|
|
|
Debug.Log($"初始化成功{data.packageName}");
|
|
|
|
|
|
}
|
|
|
|
|
|
return initializationOperation.Status == EOperationStatus.Succeed;
|
2025-11-03 00:24:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
private InitializationOperation InitializeEditorMode(ResourcePackage package)
|
|
|
|
|
|
{
|
|
|
|
|
|
var buildResult = EditorSimulateModeHelper.SimulateBuild(data.packageName);
|
|
|
|
|
|
var packageRoot = buildResult.PackageRootDirectory;
|
|
|
|
|
|
var createParameters = new EditorSimulateModeParameters();
|
|
|
|
|
|
createParameters.EditorFileSystemParameters = FileSystemParameters.CreateDefaultEditorFileSystemParameters(packageRoot);
|
|
|
|
|
|
return package.InitializeAsync(createParameters);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private InitializationOperation InitializeOfflineMode(ResourcePackage package)
|
|
|
|
|
|
{
|
|
|
|
|
|
var createParameters = new OfflinePlayModeParameters();
|
|
|
|
|
|
createParameters.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
|
|
|
|
|
|
return package.InitializeAsync(createParameters);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private InitializationOperation InitializeHostMode(ResourcePackage package)
|
|
|
|
|
|
{
|
|
|
|
|
|
FileSystemParameters buildinFileSystemParams = null;
|
|
|
|
|
|
if (data.useBuildinFileSystem)
|
|
|
|
|
|
{
|
2025-11-03 17:46:28 +08:00
|
|
|
|
// 注意:设置参数COPY_BUILDIN_PACKAGE_MANIFEST,可以初始化的时候拷贝内置清单到沙盒目录
|
2025-11-03 00:24:36 +08:00
|
|
|
|
buildinFileSystemParams = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
|
|
|
|
|
|
buildinFileSystemParams.AddParameter(FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
string defaultHostServer = GetHostServerURL();
|
|
|
|
|
|
string fallbackHostServer = GetHostServerURL();
|
|
|
|
|
|
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
2025-11-03 17:46:28 +08:00
|
|
|
|
// 注意:设置参数INSTALL_CLEAR_MODE,可以解决覆盖安装的时候将拷贝的内置清单文件清理的问题。
|
2025-11-03 00:24:36 +08:00
|
|
|
|
var cacheFileSystemParams = FileSystemParameters.CreateDefaultCacheFileSystemParameters(remoteServices);
|
|
|
|
|
|
cacheFileSystemParams.AddParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, EOverwriteInstallClearMode.ClearAllManifestFiles);
|
|
|
|
|
|
|
|
|
|
|
|
var createParameters = new HostPlayModeParameters();
|
|
|
|
|
|
createParameters.BuildinFileSystemParameters = buildinFileSystemParams;
|
|
|
|
|
|
createParameters.CacheFileSystemParameters = cacheFileSystemParams;
|
|
|
|
|
|
return package.InitializeAsync(createParameters);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private InitializationOperation InitializeWebPlayMode(ResourcePackage package)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if UNITY_WEBGL && WEIXINMINIGAME && !UNITY_EDITOR
|
|
|
|
|
|
var createParameters = new WebPlayModeParameters();
|
|
|
|
|
|
string defaultHostServer = GetHostServerURL();
|
|
|
|
|
|
string fallbackHostServer = GetHostServerURL();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
string packageRoot = $"{WeChatWASM.WX.env.USER_DATA_PATH}/__GAME_FILE_CACHE"; //注意:如果有子目录,请修改此处!
|
2025-11-03 00:24:36 +08:00
|
|
|
|
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
|
|
|
|
|
createParameters.WebServerFileSystemParameters = WechatFileSystemCreater.CreateFileSystemParameters(packageRoot, remoteServices);
|
|
|
|
|
|
return package.InitializeAsync(createParameters);
|
|
|
|
|
|
#else
|
|
|
|
|
|
var createParameters = new WebPlayModeParameters();
|
|
|
|
|
|
createParameters.WebServerFileSystemParameters = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
|
|
|
|
|
|
return package.InitializeAsync(createParameters);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
private string GetHostServerURL()
|
|
|
|
|
|
{
|
|
|
|
|
|
string hostServerIP = $"https://home.gtuantuan.online:9444/{Application.productName}";
|
|
|
|
|
|
string appVersion = "v1";
|
|
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
if (UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.Android)
|
|
|
|
|
|
// return $"{hostServerIP}/CDN/Android/{packageName}/{appVersion}";
|
|
|
|
|
|
return $"{hostServerIP}/CDN/PC/{data.packageName}/{appVersion}";
|
|
|
|
|
|
else if (UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.iOS)
|
|
|
|
|
|
return $"{hostServerIP}/CDN/IPhone/{data.packageName}/{appVersion}";
|
|
|
|
|
|
else if (UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.WebGL)
|
|
|
|
|
|
return $"{hostServerIP}/CDN/WebGL/{data.packageName}/{appVersion}";
|
|
|
|
|
|
else
|
|
|
|
|
|
return $"{hostServerIP}/CDN/PC/{data.packageName}/{appVersion}";
|
|
|
|
|
|
#else
|
|
|
|
|
|
if (Application.platform == RuntimePlatform.Android)
|
|
|
|
|
|
return $"{hostServerIP}/CDN/Android/{data.packageName}/{appVersion}";
|
|
|
|
|
|
else if (Application.platform == RuntimePlatform.IPhonePlayer)
|
|
|
|
|
|
return $"{hostServerIP}/CDN/IPhone/{data.packageName}/{appVersion}";
|
|
|
|
|
|
else if (Application.platform == RuntimePlatform.WebGLPlayer)
|
|
|
|
|
|
return $"{hostServerIP}/CDN/WebGL/{data.packageName}/{appVersion}";
|
|
|
|
|
|
else
|
|
|
|
|
|
return $"{hostServerIP}/CDN/PC/{data.packageName}/{appVersion}";
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
private class RemoteServices : IRemoteServices
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly string _defaultHostServer;
|
|
|
|
|
|
private readonly string _fallbackHostServer;
|
|
|
|
|
|
|
|
|
|
|
|
public RemoteServices(string defaultHostServer, string fallbackHostServer)
|
|
|
|
|
|
{
|
|
|
|
|
|
_defaultHostServer = defaultHostServer;
|
|
|
|
|
|
_fallbackHostServer = fallbackHostServer;
|
|
|
|
|
|
}
|
|
|
|
|
|
string IRemoteServices.GetRemoteMainURL(string fileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{_defaultHostServer}/{fileName}";
|
|
|
|
|
|
}
|
|
|
|
|
|
string IRemoteServices.GetRemoteFallbackURL(string fileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{_fallbackHostServer}/{fileName}";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-03 17:46:28 +08:00
|
|
|
|
#endregion 初始化相关
|
|
|
|
|
|
#region 版本和资源清单相关
|
|
|
|
|
|
public async UniTask<bool> RequestPackageVersion(bool showBox = true)
|
2025-11-03 00:24:36 +08:00
|
|
|
|
{
|
2025-11-03 17:46:28 +08:00
|
|
|
|
var operation = package.RequestPackageVersionAsync(true, 5);
|
2025-11-03 00:24:36 +08:00
|
|
|
|
await operation.ToUniTask();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
if (operation.Status != EOperationStatus.Succeed)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (showBox)
|
|
|
|
|
|
{
|
2025-11-04 16:19:53 +08:00
|
|
|
|
if(await CheckUseLocalVersion(operation))
|
|
|
|
|
|
{
|
|
|
|
|
|
string cachedVersion = GetCachedPackageVersion();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cachedVersion))
|
|
|
|
|
|
{
|
|
|
|
|
|
packageVersion = cachedVersion;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-03 17:46:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
packageVersion = operation.PackageVersion;
|
|
|
|
|
|
PatchEvent.UpdateStatus($"获取版本成功{data.packageName}");
|
|
|
|
|
|
Debug.Log($"获取版本成功{data.packageName}:{packageVersion}");
|
|
|
|
|
|
}
|
|
|
|
|
|
return operation.Status == EOperationStatus.Succeed;
|
2025-11-03 00:24:36 +08:00
|
|
|
|
}
|
2025-11-04 16:19:53 +08:00
|
|
|
|
public async UniTask<bool> CheckUseLocalVersion(RequestPackageVersionOperation operation)
|
|
|
|
|
|
{
|
|
|
|
|
|
var completionSource = new UniTaskCompletionSource<bool>();
|
|
|
|
|
|
MessageBox.Show()
|
|
|
|
|
|
.SetTitle($"{data.packageName}请求版本")
|
|
|
|
|
|
.SetContent($"{operation.Error}")
|
|
|
|
|
|
.AddButton("继续", (box) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
completionSource.TrySetResult(true);
|
|
|
|
|
|
})
|
|
|
|
|
|
.AddButton("退出", (box) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
completionSource.TrySetResult(false);
|
|
|
|
|
|
Application.Quit();
|
|
|
|
|
|
});
|
|
|
|
|
|
bool shouldContinue = await completionSource.Task;
|
|
|
|
|
|
return shouldContinue;
|
|
|
|
|
|
}
|
2025-11-03 00:24:36 +08:00
|
|
|
|
public async Task<string> GetBuildinPackageVersion()
|
|
|
|
|
|
{
|
|
|
|
|
|
var operation = new GetBuildinPackageVersionOperation(data.packageName);
|
|
|
|
|
|
YooAssets.StartOperation(operation);
|
|
|
|
|
|
await operation;
|
|
|
|
|
|
if (operation.Status == EOperationStatus.Succeed)
|
|
|
|
|
|
{
|
|
|
|
|
|
return operation.PackageVersion;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public string GetCachedPackageVersion()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (PlayerPrefs.HasKey(PkgVersionKey))
|
|
|
|
|
|
{
|
|
|
|
|
|
return PlayerPrefs.GetString(PkgVersionKey);
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SaveVersionToCache()
|
|
|
|
|
|
{
|
|
|
|
|
|
PlayerPrefs.SetString(PkgVersionKey, packageVersion);
|
|
|
|
|
|
PlayerPrefs.Save();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
PatchEvent.UpdateStatus($"更新完成{data.packageName}");
|
|
|
|
|
|
Debug.Log($"更新{data.packageName}完成,版本号{packageVersion}");
|
|
|
|
|
|
|
2025-11-03 00:24:36 +08:00
|
|
|
|
}
|
2025-11-03 17:46:28 +08:00
|
|
|
|
public async UniTask<bool> UpdatePackageManifest(bool showBox = true)
|
2025-11-03 00:24:36 +08:00
|
|
|
|
{
|
2025-11-03 17:46:28 +08:00
|
|
|
|
var operation = package.UpdatePackageManifestAsync(packageVersion,10);
|
2025-11-03 00:24:36 +08:00
|
|
|
|
await operation.ToUniTask();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
if (operation.Status != EOperationStatus.Succeed)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (showBox)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show()
|
|
|
|
|
|
.SetTitle($"{data.packageName}更新清单")
|
|
|
|
|
|
.SetContent($"{operation.Error}")
|
|
|
|
|
|
.AddButton("退出", (box) => { Application.Quit(); });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
PatchEvent.UpdateStatus($"获取资源清单成功{data.packageName}");
|
|
|
|
|
|
Debug.Log($"获取资源清单成功{data.packageName}");
|
|
|
|
|
|
}
|
|
|
|
|
|
return operation.Status == EOperationStatus.Succeed;
|
2025-11-03 00:24:36 +08:00
|
|
|
|
}
|
2025-11-03 17:46:28 +08:00
|
|
|
|
#endregion 版本和资源清单相关
|
|
|
|
|
|
#region 下载相关
|
|
|
|
|
|
public bool CreateDownloader()
|
2025-11-03 00:24:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
downloader = package.CreateResourceDownloader(data.downloadingMaxNum, data.failedTryAgain);
|
|
|
|
|
|
downloader.DownloadErrorCallback = data.downloadError;
|
|
|
|
|
|
downloader.DownloadFinishCallback = data.downloadFinish;
|
|
|
|
|
|
downloader.DownloadUpdateCallback = data.downloadUpdate;
|
2025-11-03 17:46:28 +08:00
|
|
|
|
if (downloader.TotalDownloadCount == 0) return false;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
public async UniTask<bool> CheckDownloadOrSkip()
|
|
|
|
|
|
{
|
|
|
|
|
|
var completionSource = new UniTaskCompletionSource<bool>();
|
|
|
|
|
|
MessageBox.Show()
|
|
|
|
|
|
.SetTitle($"{data.packageName}发现更新")
|
2025-11-04 16:19:53 +08:00
|
|
|
|
.SetContent($"发现资源更新\n{GetCachedPackageVersion()}=>{packageVersion}: {FormatFileSize(downloader.TotalDownloadBytes)}")
|
2025-11-03 17:46:28 +08:00
|
|
|
|
.AddButton("下载", async (box) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
bool success = await DownloadPackageFiles();
|
|
|
|
|
|
completionSource.TrySetResult(success);
|
|
|
|
|
|
})
|
2025-11-04 16:19:53 +08:00
|
|
|
|
.AddButton("跳过", async (box) =>
|
2025-11-03 17:46:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
downloader.CancelDownload();
|
2025-11-04 16:19:53 +08:00
|
|
|
|
packageVersion = GetCachedPackageVersion();
|
|
|
|
|
|
await UpdatePackageManifest();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
completionSource.TrySetResult(true);
|
|
|
|
|
|
})
|
|
|
|
|
|
.AddButton("退出", (box) =>
|
|
|
|
|
|
{
|
2025-11-04 16:19:53 +08:00
|
|
|
|
downloader.CancelDownload();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
completionSource.TrySetResult(false);
|
2025-11-04 16:19:53 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
|
|
|
|
#else
|
2025-11-03 17:46:28 +08:00
|
|
|
|
Application.Quit();
|
2025-11-04 16:19:53 +08:00
|
|
|
|
#endif
|
2025-11-03 17:46:28 +08:00
|
|
|
|
});
|
|
|
|
|
|
bool shouldContinue = await completionSource.Task;
|
|
|
|
|
|
return shouldContinue;
|
2025-11-03 00:24:36 +08:00
|
|
|
|
}
|
2025-11-03 17:46:28 +08:00
|
|
|
|
public async UniTask<bool> DownloadPackageFiles(bool showBox = true)
|
2025-11-03 00:24:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (downloader.TotalDownloadCount == 0)
|
|
|
|
|
|
return true;
|
|
|
|
|
|
Debug.Log($"{data.packageName} DownloadPackageFiles {downloader.TotalDownloadCount}");
|
|
|
|
|
|
downloader.BeginDownload();
|
|
|
|
|
|
await downloader.ToUniTask();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
if (downloader.Status != EOperationStatus.Succeed)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (showBox)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show()
|
|
|
|
|
|
.SetTitle($"{data.packageName}下载文件")
|
|
|
|
|
|
.SetContent($"{downloader.Error}")
|
|
|
|
|
|
.AddButton("退出", (box) => { Application.Quit(); });
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2025-11-03 00:24:36 +08:00
|
|
|
|
return downloader.Status == EOperationStatus.Succeed;
|
|
|
|
|
|
}
|
2025-11-03 17:46:28 +08:00
|
|
|
|
public async UniTask<bool> ClearCacheBundle(bool showBox = true)
|
2025-11-03 00:24:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
var operation = package.ClearCacheFilesAsync(EFileClearMode.ClearUnusedBundleFiles);
|
|
|
|
|
|
await operation.ToUniTask();
|
2025-11-03 17:46:28 +08:00
|
|
|
|
if (operation.Status != EOperationStatus.Succeed)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (showBox)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show()
|
|
|
|
|
|
.SetTitle($"{data.packageName}清除缓存")
|
|
|
|
|
|
.SetContent($"{operation.Error}")
|
|
|
|
|
|
.AddButton("退出", (box) => { Application.Quit(); });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return operation.Status == EOperationStatus.Succeed;
|
2025-11-03 00:24:36 +08:00
|
|
|
|
}
|
2025-11-04 16:19:53 +08:00
|
|
|
|
public string FormatFileSize(long size)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (size < 1024 * 1024)
|
|
|
|
|
|
return $"{(size / 1024f):F1}KB";
|
|
|
|
|
|
else
|
|
|
|
|
|
return $"{size / 1024f / 1024f:F1}MB";
|
|
|
|
|
|
}
|
2025-11-03 17:46:28 +08:00
|
|
|
|
#endregion 下载相关
|
2025-11-03 00:24:36 +08:00
|
|
|
|
}
|