diff --git a/docs/components/ResStore.vue b/docs/components/ResStore.vue index e8a1da67..d192b9c8 100644 --- a/docs/components/ResStore.vue +++ b/docs/components/ResStore.vue @@ -48,7 +48,7 @@ function closePublishWindow() { const submitForm = () => { const title = encodeURI(`Resource: ${newRes.value.name}`) let body = encodeURI(`---\nname: ${newRes.value.name}\ndesc: ${newRes.value.desc}\nauthor: ${newRes.value.author}\nhomepage: ${newRes.value.homepage}\nlink: ${newRes.value.link}\n---\n`) - const issueURL = `${RepoUrl}/issues/new?labels=Resource&title=${title}&body=${body}` + const issueURL = `${RepoUrl}/issues/new?title=${title}&body=${body}` window.open(issueURL, '_blank') } diff --git a/liteyuki_flow/markdown_parser.py b/liteyuki_flow/markdown_parser.py index 1e77e44a..faf1cfcc 100644 --- a/liteyuki_flow/markdown_parser.py +++ b/liteyuki_flow/markdown_parser.py @@ -78,6 +78,9 @@ class MarkdownParser: self.front_matters[key.strip()] = value.strip() return nil + def build_front_matters(self) -> str: + return "---\n" + str(self.front_matters) + "\n---" + def _parse_content(self) -> tuple[list[Any], err]: content: list[Any] = [] while self.lineno < len(self.content_lines): diff --git a/liteyuki_flow/resource_handler.py b/liteyuki_flow/resource_handler.py index 3742cfe5..134acb87 100644 --- a/liteyuki_flow/resource_handler.py +++ b/liteyuki_flow/resource_handler.py @@ -26,7 +26,14 @@ headers = { # closed: 审核通过,修改json并提交 # reopened: 重新打开,无操作 def on_first_open(github: Github, issue: Issue, repo: Repository): - issue.create_comment("已收到资源包发布请求,我会马上开始预检. " + edit_tip) + cid = issue.create_comment("已收到资源包发布请求,我会马上开始预检. " + edit_tip).id + parser = MarkdownParser(issue.body) + parser.parse_front_matters() + parser.front_matters["cid"] = str(cid) + + new_issue_body = parser.build_front_matters() + issue.add_to_labels("Resource") + issue.edit(body=new_issue_body) # opened | edited @@ -38,6 +45,7 @@ def pre_check(github: Github, issue: Issue, repo: Repository) -> err: link = parser.front_matters.get("link") homepage = parser.front_matters.get("homepage") # optional author = parser.front_matters.get("author") + cid = parser.front_matters.get("cid") # optional auto if not all((name, desc, link, author)): issue.create_comment("name, desc, link, homepage 及 author 为必填字段.") return ValueError("name, desc, link, homepage 及 author 为必填字段.") @@ -86,7 +94,8 @@ def pre_check(github: Github, issue: Issue, repo: Repository) -> err: if k not in ("name", "description", "version"): new_issue_body += f"**{k}**: {v}\n" - issue.edit(new_issue_body) + issue.edit(body=new_issue_body) + issue.add_to_labels("pre-checked") issue.create_comment("✅ 预检查通过\n## 元数据\n" + metadata_markdown) return nil