feat 在线插件市场

This commit is contained in:
jxxghp
2023-11-01 21:05:31 +08:00
parent 2a8aeb5041
commit 21bc8edbd8
4 changed files with 58 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "moviepilot", "name": "moviepilot",
"version": "1.3.9-1", "version": "1.3.9-2",
"private": true, "private": true,
"bin": "dist/service.js", "bin": "dist/service.js",
"scripts": { "scripts": {
+9
View File
@@ -541,6 +541,15 @@ export interface Plugin {
// 是否有详情页面 // 是否有详情页面
has_page?: boolean has_page?: boolean
// 是否有新版本
has_update?: boolean
// 是否本地插件
is_local?: boolean
// 插件仓库地址
repo_url?: string
} }
// 种子信息 // 种子信息
+47
View File
@@ -16,16 +16,35 @@ const emit = defineEmits(['install'])
// 提示框 // 提示框
const $toast = useToast() const $toast = useToast()
// 进度框
const progressDialog = ref(false)
// 进度框文本
const progressText = ref('正在安装插件...')
// 图片是否加载完成 // 图片是否加载完成
const isImageLoaded = ref(false) const isImageLoaded = ref(false)
// 安装插件 // 安装插件
async function installPlugin() { async function installPlugin() {
try { try {
// 显示等待提示框
progressDialog.value = true
progressText.value = `正在安装 ${props.plugin?.plugin_name} 插件...`
const result: { [key: string]: any } = await api.get( const result: { [key: string]: any } = await api.get(
`plugin/install/${props.plugin?.id}`, `plugin/install/${props.plugin?.id}`,
{
params: {
repo_url: props.plugin?.repo_url,
force: props.plugin?.has_update,
},
},
) )
// 隐藏等待提示框
progressDialog.value = false
if (result.success) { if (result.success) {
$toast.success(`插件 ${props.plugin?.plugin_name} 安装成功!`) $toast.success(`插件 ${props.plugin?.plugin_name} 安装成功!`)
@@ -52,6 +71,15 @@ async function installPlugin() {
class="relative pa-4 text-center card-cover-blurred" class="relative pa-4 text-center card-cover-blurred"
:style="{ background: `${props.plugin?.plugin_color}` }" :style="{ background: `${props.plugin?.plugin_color}` }"
> >
<div
v-if="props.plugin?.has_update"
class="me-n3 absolute top-0 right-5"
>
<VIcon
icon="mdi-new-box"
class="text-white"
/>
</div>
<VAvatar <VAvatar
size="8rem" size="8rem"
:class="{ shadow: isImageLoaded }" :class="{ shadow: isImageLoaded }"
@@ -80,6 +108,25 @@ async function installPlugin() {
版本{{ props.plugin?.plugin_version }} 版本{{ props.plugin?.plugin_version }}
</VCardText> </VCardText>
</VCard> </VCard>
<!-- 安装插件进度框 -->
<VDialog
v-model="progressDialog"
:scrim="false"
width="25rem"
>
<VCard
color="primary"
>
<VCardText class="text-center">
{{ progressText }}
<VProgressLinear
indeterminate
color="white"
class="mb-0 mt-1"
/>
</VCardText>
</VCard>
</VDialog>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
+1 -1
View File
@@ -226,7 +226,7 @@ const dropdownItems = ref([
<VCardItem class="py-2"> <VCardItem class="py-2">
<VCardTitle class="flex items-center flex-row"> <VCardTitle class="flex items-center flex-row">
<VBadge v-if="props.plugin?.state" dot inline color="success" class="me-1 mb-1" /> <VBadge v-if="props.plugin?.state" dot inline color="success" class="me-1 mb-1" />
{{ props.plugin?.plugin_name }} {{ props.plugin?.plugin_name }}<span class="text-sm ms-2 mt-1 text-gray-500">{{ props.plugin?.plugin_version }}</span>
</VCardTitle> </VCardTitle>
</VCardItem> </VCardItem>
<VCardText> <VCardText>