feat 插件跳转Github

This commit is contained in:
jxxghp
2023-11-30 16:57:01 +08:00
parent 366fe34d6f
commit 5566ef87f8
3 changed files with 87 additions and 11 deletions

View File

@@ -89,6 +89,45 @@ const iconPath: Ref<string> = computed(() => {
return `/plugin_icon/${props.plugin?.plugin_icon}`
})
// 访问插件页面
function visitPluginPage() {
// 将raw.githubusercontent.com转换为项目地址
let repoUrl = props.plugin?.repo_url
if (repoUrl) {
if (repoUrl.includes('raw.githubusercontent.com')) {
if (!repoUrl.endsWith('/'))
repoUrl += '/'
if (repoUrl.split('/').length < 6)
repoUrl = `${repoUrl}main/`
try {
const [user, repo] = repoUrl.split('/').slice(-4, -2)
repoUrl = `https://github.com/${user}/${repo}`
}
catch (error) {
return
}
}
}
else {
repoUrl = props.plugin?.author_url
}
window.open(repoUrl, '_blank')
}
// 弹出菜单
const dropdownItems = ref([
{
title: '查看详情',
value: 1,
props: {
prependIcon: 'mdi-information-outline',
click: visitPluginPage,
},
},
])
</script>
<template>
@@ -101,9 +140,32 @@ const iconPath: Ref<string> = computed(() => {
class="relative pa-4 text-center card-cover-blurred"
:style="{ background: `${backgroundColor}` }"
>
<div class="me-n3 absolute top-0 right-3">
<IconBtn>
<VIcon icon="mdi-dots-vertical" class="text-white" />
<VMenu
activator="parent"
close-on-content-click
>
<VList>
<VListItem
v-for="(item, i) in dropdownItems"
:key="i"
variant="plain"
@click="item.props.click"
>
<template #prepend>
<VIcon :icon="item.props.prependIcon" />
</template>
<VListItemTitle v-text="item.title" />
</VListItem>
</VList>
</VMenu>
</IconBtn>
</div>
<div
v-if="props.plugin?.has_update"
class="me-n3 absolute top-0 right-5"
class="me-n3 absolute top-0 left-1"
>
<VIcon
icon="mdi-new-box"

View File

@@ -43,10 +43,10 @@ const pluginConfigForm = ref({})
// 插件表单配置项
let pluginFormItems = reactive([])
// 插件详情页面
// 插件数据页面
const pluginInfoDialog = ref(false)
// 插件详情页面配置项
// 插件数据页面配置项
let pluginPageItems = reactive([])
// 图片是否加载完成
@@ -113,7 +113,7 @@ async function loadPluginForm() {
}
}
// 调用API读取详情页面
// 调用API读取数据页面
async function loadPluginPage() {
try {
const result: [] = await api.get(`plugin/page/${props.plugin?.id}`)
@@ -156,9 +156,9 @@ async function savePluginConf() {
}
}
// 显示插件详情
// 显示插件数据
async function showPluginInfo() {
// 加载详情
// 加载数据
await loadPluginPage()
pluginConfigDialog.value = false
pluginInfoDialog.value = true
@@ -220,10 +220,15 @@ async function resetPlugin() {
}
}
// 访问作者主页
function visitAuthorPage() {
window.open(props.plugin?.author_url, '_blank')
}
// 弹出菜单
const dropdownItems = ref([
{
title: '查看详情',
title: '查看数据',
value: 1,
show: props.plugin?.has_page,
props: {
@@ -232,7 +237,7 @@ const dropdownItems = ref([
},
},
{
title: '置',
title: '置',
value: 2,
show: true,
props: {
@@ -260,6 +265,15 @@ const dropdownItems = ref([
click: uninstallPlugin,
},
},
{
title: '作者主页',
value: 4,
show: true,
props: {
prependIcon: 'mdi-home-circle-outline',
click: visitAuthorPage,
},
},
])
</script>
@@ -350,7 +364,7 @@ const dropdownItems = ref([
</VCardText>
<VCardActions>
<VBtn v-if="pluginPageItems.length > 0" @click="showPluginInfo">
查看详情
查看数据
</VBtn>
<VSpacer />
<VBtn
@@ -363,7 +377,7 @@ const dropdownItems = ref([
</VCard>
</VDialog>
<!-- 插件详情页面 -->
<!-- 插件数据页面 -->
<VDialog
v-model="pluginInfoDialog"
scrollable