nonebot2/docs/.vuepress/components/PublishCard.vue

85 lines
1.7 KiB
Vue
Raw Normal View History

2021-03-05 16:27:43 +08:00
<template>
<v-card>
<v-card-title>
{{ name }}
<v-spacer></v-spacer>
<a
class="repo-link"
v-if="repoLink(link)"
rel="noopener noreferrer"
target="_blank"
:title="link"
:href="repoLink(link)"
>
<v-icon>fab fa-github</v-icon>
</a>
</v-card-title>
<v-card-text>{{ desc }}</v-card-text>
<v-card-text>
<template v-if="id">
<v-icon x-small>fa-fingerprint</v-icon>
{{ id }}
</template>
<v-icon x-small class="ml-2">fa-user</v-icon>
{{ author }}
</v-card-text>
<v-card-actions v-if="showCommand">
<v-btn block depressed class="btn-copy" @click="copyCommand()">
{{ text }}
<v-icon right small>fa-copy</v-icon>
</v-btn>
2021-04-05 13:32:36 +08:00
<v-snackbar v-model="snackbar">复制成功</v-snackbar>
2021-03-05 16:27:43 +08:00
</v-card-actions>
</v-card>
</template>
<script>
2021-04-05 16:35:29 +08:00
import copy from "copy-to-clipboard";
2021-03-05 16:27:43 +08:00
export default {
props: {
name: String,
desc: String,
id: String,
author: String,
link: String,
text: String,
2021-04-05 13:44:19 +08:00
command: String,
2021-03-05 16:27:43 +08:00
},
data() {
return {
2021-04-05 13:44:19 +08:00
snackbar: false,
2021-04-05 16:35:29 +08:00
};
2021-03-05 16:27:43 +08:00
},
computed: {
showCommand() {
2021-04-05 16:35:29 +08:00
return this.text && this.command;
2021-04-05 13:44:19 +08:00
},
2021-03-05 16:27:43 +08:00
},
methods: {
repoLink(repo) {
if (repo) {
2021-04-05 16:35:29 +08:00
return /^https?:/.test(repo) ? repo : `https://github.com/${repo}`;
2021-03-05 16:27:43 +08:00
}
2021-04-05 16:35:29 +08:00
return null;
2021-03-05 16:27:43 +08:00
},
copyCommand() {
copy(this.command, {
2021-04-05 16:35:29 +08:00
format: "text/plain",
});
this.snackbar = true;
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>
<style scoped>
.repo-link {
text-decoration: none !important;
display: inline-block;
}
.repo-link:hover i {
color: #ea5252;
}
</style>