Compare commits

...

2 Commits

Author SHA1 Message Date
8725f28caf 更改文件 2026-03-19 00:08:49 +08:00
fef9041a97 在本地开发环境保证 typst 二进制存在 2026-03-18 17:53:45 +08:00

View File

@ -15,7 +15,7 @@ from nonebot.adapters.onebot.v11.event import MessageEvent as OB11MessageEvent
from nonebot.adapters.onebot.v11.bot import Bot as OB11Bot
from nonebot.adapters.onebot.v11.message import Message as OB11Message
from konabot.common.artifact import ArtifactDepends, register_artifacts
from konabot.common.artifact import ArtifactDepends, ensure_artifact, register_artifacts
from konabot.common.longtask import DepLongTaskTarget
from konabot.common.path import BINARY_PATH, TMP_PATH
@ -44,7 +44,7 @@ async def _(downloaded: bool):
global bin_path
tar_path = arti_typst_linux.target
bin_path = tar_path.with_name("typst")
bin_path = BINARY_PATH / "typst"
if downloaded or not bin_path.exists():
bin_path.unlink(missing_ok=True)
@ -96,6 +96,8 @@ TEMPLATE = TEMPLATE_PATH.read_text()
def render_sync(code: str) -> bytes | None:
global bin_path
if bin_path is None:
return
@ -153,7 +155,13 @@ async def _(
msg: UniMsg,
target: DepLongTaskTarget,
):
if bin_path is None:
global bin_path
# 对于本地机器,一般不会在应用启动时自动下载,这里再保证存在
await ensure_artifact(arti_typst_linux)
await ensure_artifact(arti_typst_windows)
if bin_path is None or not bin_path.exists():
logger.warning("当前环境不存在 Typst但仍然调用了")
return
typst_code = ""