From e57efd0d7975c6855eae0d1e92867f5b91ee0459 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:31:50 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=20python=20?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=8A=A0=E8=BD=BD=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Python/sample.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Python/sample.py b/src/Python/sample.py index 616d011a96..da9836bdce 100644 --- a/src/Python/sample.py +++ b/src/Python/sample.py @@ -24,9 +24,33 @@ if __name__ == "__main__": # 设置更新器的路径和目标版本并更新 Updater(path, Version.Stable).update() - # 外服需要再额外传入增量资源路径,例如 - # incremental_path=path / 'resource' / 'global' / 'YoStarEN' + # 加载主资源及增量副资源 + # + # 参数说明: + # - path:主资源的路径。 + # - incremental_path:增量副资源的路径。副资源需要在主资源加载后再加载,以下是两种常见的使用场景: + # 1. 加载外服增量资源: + # 传入外服增量资源路径,先加载主资源,再加载增量副资源: + # Asst.load(path=path) # 加载主资源 + # Asst.load(path=path, incremental_path=path / 'resource' / 'global' / 'YoStarEN') # 加载增量副资源 + # 2. 加载活动关卡资源(需先下载): + # 首先下载活动关卡的任务数据: + # import urllib.request + # ota_tasks_url = 'https://ota.maa.plus/MaaAssistantArknights/api/resource/tasks.json' + # ota_tasks_path = path / 'cache' / 'resource' / 'tasks.json' + # ota_tasks_path.parent.mkdir(parents=True, exist_ok=True) + # with open(ota_tasks_path, 'w', encoding='utf-8') as f: + # with urllib.request.urlopen(ota_tasks_url) as u: + # f.write(u.read().decode('utf-8')) + # 然后加载主资源和增量副资源: + # Asst.load(path=path) # 加载主资源 + # Asst.load(path=path, incremental_path=path / 'cache') # 加载下载的增量副资源 + # + # 示例调用: + # 1. 加载主资源: Asst.load(path=path) + # 2. 加载增量副资源: + # Asst.load(path=path, incremental_path=path / 'resource' / 'global' / 'YoStarEN') # 若需要获取详细执行信息,请传入 callback 参数 # 例如 asst = Asst(callback=my_callback)