mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-11 02:57:23 +08:00
📦 docs: 资源商店新增发布资源功能
This commit is contained in:
parent
fbf906bea7
commit
53a603d4ee
@ -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')
|
||||
}
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user