Skip to content

Commit

Permalink
🐛 docs: 添加发布插件表单
Browse files Browse the repository at this point in the history
  • Loading branch information
snowykami committed Sep 21, 2024
1 parent aa4d930 commit b469c94
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 21 deletions.
59 changes: 59 additions & 0 deletions .github/ISSUE_TEMPLATE/resource_publish_en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish Resource
title: "Resource: {name}"
description: Publish the resource to the Qingxue Bot official store
labels: [ "Resource" ]
body:
- type: input
id: name
attributes:
label: Name
description: The readable name of the resource pack
placeholder: e.g. Cute UI Resource Pack
validations:
required: true

- type: input
id: description
attributes:
label: Description
description: A brief description of the resource
placeholder: e.g. Makes the rendering card style more beautiful
validations:
required: true

- type: input
id: author
attributes:
label: Author
description: The GitHub username of the author
placeholder: e.g. snowykami
validations:
required: true

- type: input
id: link
attributes:
label: Download Link
description: Direct download link of the resource pack
placeholder: e.g. https://aaa.com/r.zip
validations:
required: true

- type: input
id: homepage
attributes:
label: Homepage
description: Homepage of the resource pack
placeholder: e.g. https://github.com/user/repo
validations:
required: false

- type: input
id: tags
attributes:
label: Tags
description: Tags
placeholder: 'e.g. [{"label": "Tag Name", "color": "#ea5252"}]'
value: [ { "label": "Tag Name", "color": "#a2d8f4" } ]
validations:
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/resource_publish_zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ body:
label: 标签
description: 标签
placeholder: 'e.g. [{"label": "标签名", "color": "#ea5252"}]'
value: "[]"
value: [ { "label": "标签名", "color": "#a2d8f4" } ]
validations:
required: true
45 changes: 26 additions & 19 deletions docs/components/ResStore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
import {computed, ref} from 'vue'
import ItemCard from './ResItemCard.vue'
import ResPubWindow from "./ResPubWindow.vue";
import {getTextRef} from "./scripts/i18n";
import {getTextRef, formatLang} from "./scripts/i18n";
import {RepoUrl} from "./scripts/statsApi";
import resourcesJson from "../public/resources.json"
import {useData} from "vitepress";
// formLang
const lang = computed(
() => formatLang(useData().lang.value)
)
// 从public/assets/resources.json加载插件
let filteredItems = computed(() => {
Expand All @@ -28,10 +33,6 @@ const isPublishWindowOpen = ref(false)
let newRes = ref({
name: '',
desc: '',
author: '',
homepage: '',
link: '',
})
function openPublishWindow() {
Expand All @@ -42,10 +43,17 @@ function closePublishWindow() {
isPublishWindowOpen.value = false
}
const submitForm = () => {
function 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?title=${title}&body=${body}`
let submitLang = ""
if (lang.value === "zh") {
submitLang = "zh"
} else {
submitLang = "en"
}
const issueURL = `${RepoUrl}/issues/new?assignees=&labels=Resource&template=resource_publish_${submitLang}.yml&title=${title}`
console.log(issueURL)
window.open(issueURL, '_blank')
}
Expand All @@ -54,7 +62,8 @@ const submitForm = () => {
<template>
<div class="market">
<h1>{{ getTextRef('resourceStore') }}</h1>
<div class="search-box-div"><input class="item-search-box" type="text" :placeholder="getTextRef('search')" v-model="search"/></div>
<div class="search-box-div"><input class="item-search-box" type="text" :placeholder="getTextRef('search')"
v-model="search"/></div>
<div class="store-tabs" style="display: flex">
<button class="store-button publish-button" @click="openPublishWindow">{{ getTextRef('publishRes') }}</button>
</div>
Expand All @@ -67,17 +76,15 @@ const submitForm = () => {
<form @submit.prevent="submitForm">
<label for="name">{{ getTextRef("resName") }}</label>
<input type="text" id="name" v-model="newRes.name" :placeholder="getTextRef('resNameText')"/>
<label for="desc">{{ getTextRef("resDesc") }}</label>
<input type="text" id="desc" v-model="newRes.desc" :placeholder="getTextRef('resDescText')"/>
<label for="author">{{ getTextRef("resAuthor") }}</label>
<input type="text" id="author" v-model="newRes.author" :placeholder="getTextRef('resAuthorText')"/>
<label for="link">{{ getTextRef("resLink") }}</label>
<input type="text" id="link" v-model="newRes.link" :placeholder="getTextRef('resLinkText')"/>
<label for="homepage">{{ getTextRef("resHomepage") }}</label>
<input type="text" id="homepage" v-model="newRes.homepage" :placeholder="getTextRef('resHomepageText')"/>
<div class="pub-options" style="display: flex; justify-content: center">
<button class="pub-option close" type="button" @click="closePublishWindow">{{ getTextRef("closeButtonText") }}</button>
<button class="pub-option submit" type="submit">{{ getTextRef("submitButtonText") }}</button>
<button class="pub-option close" type="button" @click="closePublishWindow">{{
getTextRef("closeButtonText")
}}
</button>
<button class="pub-option submit" type="submit" @click="submitForm">{{
getTextRef("submitButtonText")
}}
</button>
</div>
</form>
</ResPubWindow>
Expand Down
2 changes: 1 addition & 1 deletion docs/components/scripts/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function getText(lang: string, key: string): string {
return i18nData[lang][key];
}

function formatLang(lang: string): string {
export function formatLang(lang: string): string {
if (lang.includes('-')) {
return lang.split('-')[0];
}
Expand Down

0 comments on commit b469c94

Please sign in to comment.