2021-03-05 16:27:43 +08:00
|
|
|
|
<template>
|
|
|
|
|
<v-card flat class="plugins">
|
|
|
|
|
<v-row>
|
2021-04-05 13:32:36 +08:00
|
|
|
|
<v-col cols="12" sm="6">
|
2021-03-05 16:27:43 +08:00
|
|
|
|
<v-text-field
|
|
|
|
|
v-model="filterText"
|
|
|
|
|
dense
|
|
|
|
|
rounded
|
|
|
|
|
outlined
|
|
|
|
|
clearable
|
|
|
|
|
hide-details
|
2021-04-05 13:32:36 +08:00
|
|
|
|
label="搜索插件"
|
2021-03-05 16:27:43 +08:00
|
|
|
|
>
|
|
|
|
|
<template v-slot:prepend-inner>
|
|
|
|
|
<div class="v-input__icon v-input__icon--prepend-inner">
|
|
|
|
|
<v-icon small>fa-filter</v-icon>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</v-text-field>
|
|
|
|
|
</v-col>
|
2021-04-05 13:32:36 +08:00
|
|
|
|
<v-col cols="12" sm="6">
|
2021-03-05 16:27:43 +08:00
|
|
|
|
<v-dialog v-model="dialog" max-width="600px">
|
|
|
|
|
<template v-slot:activator="{ on, attrs }">
|
|
|
|
|
<v-btn dark block color="primary" v-bind="attrs" v-on="on"
|
2021-04-05 13:32:36 +08:00
|
|
|
|
>发布插件
|
2021-03-05 16:27:43 +08:00
|
|
|
|
</v-btn>
|
|
|
|
|
</template>
|
|
|
|
|
<v-card>
|
|
|
|
|
<v-card-title>
|
2021-04-05 13:32:36 +08:00
|
|
|
|
<span class="headline">插件信息</span>
|
2021-03-05 16:27:43 +08:00
|
|
|
|
</v-card-title>
|
|
|
|
|
<v-card-text>
|
|
|
|
|
<v-form ref="newPluginForm" v-model="valid" lazy-validation>
|
|
|
|
|
<v-container>
|
|
|
|
|
<v-row>
|
|
|
|
|
<v-col cols="12">
|
|
|
|
|
<v-text-field
|
|
|
|
|
v-model="newPlugin.name"
|
2021-09-15 21:03:18 +08:00
|
|
|
|
:rules="rules"
|
2021-03-05 16:27:43 +08:00
|
|
|
|
label="插件名称"
|
|
|
|
|
required
|
|
|
|
|
></v-text-field>
|
|
|
|
|
</v-col>
|
|
|
|
|
<v-col cols="12">
|
|
|
|
|
<v-text-field
|
|
|
|
|
v-model="newPlugin.desc"
|
2021-09-15 21:03:18 +08:00
|
|
|
|
:rules="rules"
|
2021-03-05 16:27:43 +08:00
|
|
|
|
label="插件介绍"
|
|
|
|
|
required
|
|
|
|
|
></v-text-field>
|
|
|
|
|
</v-col>
|
|
|
|
|
<v-col cols="12">
|
|
|
|
|
<v-text-field
|
2021-03-07 19:05:53 +08:00
|
|
|
|
v-model="newPlugin.link"
|
2021-09-15 21:03:18 +08:00
|
|
|
|
:rules="rules"
|
2021-03-05 16:27:43 +08:00
|
|
|
|
label="PyPI 项目名"
|
|
|
|
|
required
|
|
|
|
|
></v-text-field>
|
|
|
|
|
</v-col>
|
|
|
|
|
<v-col cols="12">
|
|
|
|
|
<v-text-field
|
2021-03-07 19:05:53 +08:00
|
|
|
|
v-model="newPlugin.id"
|
2021-09-15 21:03:18 +08:00
|
|
|
|
:rules="rules"
|
2021-03-05 16:27:43 +08:00
|
|
|
|
label="插件 import 包名"
|
|
|
|
|
required
|
|
|
|
|
></v-text-field>
|
|
|
|
|
</v-col>
|
|
|
|
|
<v-col cols="12">
|
|
|
|
|
<v-text-field
|
|
|
|
|
v-model="newPlugin.repo"
|
2021-09-15 21:03:18 +08:00
|
|
|
|
:rules="rules"
|
2021-03-05 16:27:43 +08:00
|
|
|
|
label="仓库/主页链接"
|
|
|
|
|
required
|
|
|
|
|
></v-text-field>
|
|
|
|
|
</v-col>
|
|
|
|
|
</v-row>
|
|
|
|
|
</v-container>
|
|
|
|
|
</v-form>
|
|
|
|
|
</v-card-text>
|
|
|
|
|
<v-card-actions>
|
|
|
|
|
<v-spacer></v-spacer>
|
|
|
|
|
<v-btn color="blue darken-1" text @click="dialog = false">
|
2021-04-05 13:32:36 +08:00
|
|
|
|
关闭
|
2021-03-05 16:27:43 +08:00
|
|
|
|
</v-btn>
|
|
|
|
|
<v-btn
|
|
|
|
|
:disabled="!valid"
|
|
|
|
|
color="blue darken-1"
|
|
|
|
|
text
|
2021-09-15 21:03:18 +08:00
|
|
|
|
@click="publishPlugin"
|
2021-03-05 16:27:43 +08:00
|
|
|
|
>
|
2021-04-05 13:32:36 +08:00
|
|
|
|
发布
|
2021-03-05 16:27:43 +08:00
|
|
|
|
</v-btn>
|
|
|
|
|
</v-card-actions>
|
|
|
|
|
</v-card>
|
|
|
|
|
</v-dialog>
|
|
|
|
|
</v-col>
|
2021-04-05 13:32:36 +08:00
|
|
|
|
</v-row>
|
2021-04-05 16:35:29 +08:00
|
|
|
|
<v-row>
|
|
|
|
|
<v-col cols="12">
|
|
|
|
|
<v-pagination
|
|
|
|
|
v-model="page"
|
|
|
|
|
:length="pageNum"
|
|
|
|
|
prev-icon="fa-caret-left"
|
|
|
|
|
next-icon="fa-caret-right"
|
|
|
|
|
></v-pagination>
|
|
|
|
|
</v-col>
|
|
|
|
|
</v-row>
|
2021-03-05 16:27:43 +08:00
|
|
|
|
<v-row>
|
|
|
|
|
<v-col
|
|
|
|
|
cols="12"
|
|
|
|
|
sm="6"
|
|
|
|
|
v-for="(plugin, index) in displayPlugins"
|
|
|
|
|
:key="index"
|
|
|
|
|
>
|
|
|
|
|
<PublishCard
|
|
|
|
|
:name="plugin.name"
|
|
|
|
|
:desc="plugin.desc"
|
|
|
|
|
:id="plugin.id"
|
|
|
|
|
:author="plugin.author"
|
|
|
|
|
:link="plugin.repo"
|
2021-04-05 13:32:36 +08:00
|
|
|
|
text="点此复制安装命令"
|
2021-03-05 16:27:43 +08:00
|
|
|
|
:command="`nb plugin install ${plugin.id}`"
|
|
|
|
|
></PublishCard>
|
|
|
|
|
</v-col>
|
|
|
|
|
</v-row>
|
2021-04-05 16:39:26 +08:00
|
|
|
|
<v-row>
|
|
|
|
|
<v-col cols="12">
|
|
|
|
|
<v-pagination
|
|
|
|
|
v-model="page"
|
|
|
|
|
:length="pageNum"
|
|
|
|
|
prev-icon="fa-caret-left"
|
|
|
|
|
next-icon="fa-caret-right"
|
|
|
|
|
></v-pagination>
|
|
|
|
|
</v-col>
|
|
|
|
|
</v-row>
|
2021-03-05 16:27:43 +08:00
|
|
|
|
</v-card>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-04-05 16:35:29 +08:00
|
|
|
|
import PublishCard from "./PublishCard.vue";
|
|
|
|
|
import plugins from "../public/plugins.json";
|
2021-03-05 16:27:43 +08:00
|
|
|
|
|
|
|
|
|
export default {
|
2021-04-05 16:35:29 +08:00
|
|
|
|
name: "Plugins",
|
2021-03-05 16:27:43 +08:00
|
|
|
|
components: {
|
2021-04-05 13:44:19 +08:00
|
|
|
|
PublishCard,
|
2021-03-05 16:27:43 +08:00
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
plugins: plugins,
|
2021-04-05 16:35:29 +08:00
|
|
|
|
filterText: "",
|
2021-03-05 16:27:43 +08:00
|
|
|
|
page: 1,
|
|
|
|
|
dialog: false,
|
|
|
|
|
valid: false,
|
2021-09-15 21:03:18 +08:00
|
|
|
|
rules: [(v) => !!v || "This field is required"],
|
2021-03-05 16:27:43 +08:00
|
|
|
|
newPlugin: {
|
|
|
|
|
name: null,
|
|
|
|
|
desc: null,
|
|
|
|
|
id: null,
|
|
|
|
|
link: null,
|
2021-04-05 13:44:19 +08:00
|
|
|
|
repo: null,
|
|
|
|
|
},
|
2021-04-05 16:35:29 +08:00
|
|
|
|
};
|
2021-03-05 16:27:43 +08:00
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
pageNum() {
|
2021-04-05 16:35:29 +08:00
|
|
|
|
return Math.ceil(this.filteredPlugins.length / 10);
|
2021-03-05 16:27:43 +08:00
|
|
|
|
},
|
|
|
|
|
filteredPlugins() {
|
2021-04-05 13:44:19 +08:00
|
|
|
|
return this.plugins.filter((plugin) => {
|
2021-03-05 16:27:43 +08:00
|
|
|
|
return (
|
2021-04-05 16:35:29 +08:00
|
|
|
|
plugin.id.indexOf(this.filterText || "") != -1 ||
|
|
|
|
|
plugin.name.indexOf(this.filterText || "") != -1 ||
|
|
|
|
|
plugin.desc.indexOf(this.filterText || "") != -1 ||
|
|
|
|
|
plugin.author.indexOf(this.filterText || "") != -1
|
|
|
|
|
);
|
|
|
|
|
});
|
2021-03-05 16:27:43 +08:00
|
|
|
|
},
|
|
|
|
|
displayPlugins() {
|
2021-04-05 16:35:29 +08:00
|
|
|
|
return this.filteredPlugins.slice((this.page - 1) * 10, this.page * 10);
|
2021-03-05 16:27:43 +08:00
|
|
|
|
},
|
2021-09-15 21:03:18 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2021-03-05 16:27:43 +08:00
|
|
|
|
publishPlugin() {
|
|
|
|
|
if (!this.$refs.newPluginForm.validate()) {
|
2021-04-05 16:35:29 +08:00
|
|
|
|
return;
|
2021-03-05 16:27:43 +08:00
|
|
|
|
}
|
2021-09-15 21:03:18 +08:00
|
|
|
|
this.dialog = false;
|
2021-03-05 16:27:43 +08:00
|
|
|
|
const title = encodeURIComponent(
|
|
|
|
|
`Plugin: ${this.newPlugin.name}`
|
2021-04-05 16:35:29 +08:00
|
|
|
|
).replace(/%2B/gi, "+");
|
2021-03-05 16:27:43 +08:00
|
|
|
|
const body = encodeURIComponent(
|
|
|
|
|
`
|
|
|
|
|
**插件名称:**
|
|
|
|
|
|
|
|
|
|
${this.newPlugin.name}
|
|
|
|
|
|
|
|
|
|
**插件功能:**
|
|
|
|
|
|
|
|
|
|
${this.newPlugin.desc}
|
|
|
|
|
|
|
|
|
|
**PyPI 项目名:**
|
|
|
|
|
|
|
|
|
|
${this.newPlugin.link}
|
|
|
|
|
|
|
|
|
|
**插件 import 包名:**
|
|
|
|
|
|
|
|
|
|
${this.newPlugin.id}
|
|
|
|
|
|
|
|
|
|
**插件项目仓库/主页链接:**
|
|
|
|
|
|
|
|
|
|
${this.newPlugin.repo}
|
|
|
|
|
|
|
|
|
|
<!-- DO NOT EDIT ! -->
|
|
|
|
|
<!--
|
|
|
|
|
- id: ${this.newPlugin.id}
|
|
|
|
|
- link: ${this.newPlugin.link}
|
|
|
|
|
- name: ${this.newPlugin.name}
|
|
|
|
|
- desc: ${this.newPlugin.desc}
|
|
|
|
|
- repo: ${this.newPlugin.repo}
|
|
|
|
|
-->
|
|
|
|
|
`.trim()
|
2021-04-05 16:35:29 +08:00
|
|
|
|
).replace(/%2B/gi, "+");
|
2021-03-05 16:27:43 +08:00
|
|
|
|
window.open(
|
|
|
|
|
`https://github.com/nonebot/nonebot2/issues/new?title=${title}&body=${body}&labels=Plugin`
|
2021-04-05 16:35:29 +08:00
|
|
|
|
);
|
2021-04-05 13:44:19 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
2021-04-05 16:35:29 +08:00
|
|
|
|
};
|
2021-03-05 16:27:43 +08:00
|
|
|
|
</script>
|