Skip to content

Commit ae0390e

Browse files
committed
feat(ui): 添加插件详情
1 parent fc18d34 commit ae0390e

2 files changed

Lines changed: 141 additions & 1 deletion

File tree

core/datacap-ui/src/views/pages/store/StoreHome.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
<ShadcnAvatar class="bg-transparent"
4141
size="large"
4242
:src="plugin.logo"
43-
:alt="plugin.i18nFormat ? $t(plugin.label) : plugin.label"/>
43+
:alt="plugin.i18nFormat ? $t(plugin.label) : plugin.label"
44+
@click="onVisibleInfo(plugin, true)">
45+
</ShadcnAvatar>
4446

4547
<ShadcnText type="h6">
4648
{{ plugin.i18nFormat ? $t(plugin.label) : plugin.label }}
@@ -126,13 +128,20 @@
126128
</ShadcnTabItem>
127129
</ShadcnTab>
128130
</div>
131+
132+
<PluginInfo v-if="infoVisible && info"
133+
:info="info"
134+
:is-visible="infoVisible"
135+
@close="onVisibleInfo(null, false)">
136+
</PluginInfo>
129137
</template>
130138

131139
<script setup lang="ts">
132140
import { computed, getCurrentInstance, onBeforeMount, ref, watch } from 'vue'
133141
import { useI18nHandler } from '@/i18n/I18n'
134142
import { PackageUtils } from '@/utils/package.ts'
135143
import PluginService from '@/services/plugin.ts'
144+
import PluginInfo from '@/views/pages/store/components/PluginInfo.vue'
136145
137146
interface MetadataItem
138147
{
@@ -181,6 +190,8 @@ const { loadingState } = useI18nHandler()
181190
const loading = ref(false)
182191
const metadata = ref<Metadata>(null)
183192
const version = ref(PackageUtils.get('version'))
193+
const info = ref<MetadataItem>(null)
194+
const infoVisible = ref(false)
184195
185196
// Default to first plugin type found
186197
const activeTab = ref('')
@@ -381,6 +392,13 @@ const onSave = async () => {
381392
}
382393
}
383394
395+
const onVisibleInfo = (item: MetadataItem, opened?: boolean) => {
396+
infoVisible.value = opened
397+
if (opened) {
398+
info.value = item
399+
}
400+
}
401+
384402
onBeforeMount(() => {
385403
if (!loadingState.value) {
386404
loadMetadata()
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<template>
2+
<ShadcnModal v-model="visible"
3+
width="50%"
4+
height="60%"
5+
:title="title"
6+
@on-close="onCancel">
7+
<div v-if="info" class="relative w-full h-full flex flex-col items-center p-6">
8+
<div class="flex flex-col items-center mb-6">
9+
<ShadcnAvatar class="mb-4 shadow-lg border-4 border-gray-100"
10+
style="width: 5rem; height: 5rem;"
11+
:src="info.logo || '/static/images/plugin.png'"
12+
:alt="info.label">
13+
</ShadcnAvatar>
14+
15+
<h3 class="text-xl font-semibold text-gray-800 mb-2">{{ info.label }}</h3>
16+
</div>
17+
18+
<div class="w-full max-w-md mb-6">
19+
<div class="bg-gray-50 rounded-lg p-4 text-center">
20+
<ShadcnText class="text-sm text-gray-600 leading-relaxed" type="small">
21+
{{ info.i18nFormat ? $t(info.description) : info.description }}
22+
</ShadcnText>
23+
</div>
24+
</div>
25+
26+
<div class="w-full max-w-md space-y-4">
27+
<div class="flex items-center justify-between p-3 bg-white rounded-lg border border-gray-200">
28+
<span class="text-sm font-medium text-gray-700">{{ $t('common.plugin.version') }}</span>
29+
<ShadcnTag>{{ info.version }}</ShadcnTag>
30+
</div>
31+
32+
<div v-if="info.installed" class="flex items-center justify-between p-3 bg-white rounded-lg border border-gray-200">
33+
<span class="text-sm font-medium text-gray-700">{{ $t('common.installVersion') }}</span>
34+
<ShadcnTag color="#00BFFF">{{ info.installVersion }}</ShadcnTag>
35+
</div>
36+
37+
<div class="flex items-center justify-between p-3 bg-white rounded-lg border border-gray-200">
38+
<span class="text-sm font-medium text-gray-700">{{ $t('common.author') }}</span>
39+
<span class="text-sm text-gray-600">{{ info.author }}</span>
40+
</div>
41+
42+
<div class="flex items-center justify-between p-3 bg-white rounded-lg border border-gray-200">
43+
<span class="text-sm font-medium text-gray-700">{{ $t('common.releasedTime') }}</span>
44+
<span class="text-sm text-gray-600">{{ info.released }}</span>
45+
</div>
46+
47+
<div class="p-3 bg-white rounded-lg border border-gray-200" style="margin-bottom: 1rem;">
48+
<div class="flex items-center justify-between mb-2">
49+
<span class="text-sm font-medium text-gray-700">{{ $t('common.plugin.list.supportVersion') }}</span>
50+
</div>
51+
52+
<div class="flex flex-wrap gap-2">
53+
<ShadcnTag v-for="version in info.supportVersion" type="success" :key="version">
54+
{{ version }}
55+
</ShadcnTag>
56+
</div>
57+
</div>
58+
</div>
59+
</div>
60+
61+
<template #footer>
62+
<ShadcnButton type="default" @click="onCancel">
63+
{{ $t('common.cancel') }}
64+
</ShadcnButton>
65+
</template>
66+
</ShadcnModal>
67+
</template>
68+
69+
<script setup lang="ts">
70+
import { computed, onMounted, ref, watch } from 'vue'
71+
import { useI18n } from 'vue-i18n'
72+
73+
interface Props
74+
{
75+
isVisible: boolean
76+
info: any | null
77+
}
78+
79+
interface Emits
80+
{
81+
(e: 'close', value: boolean): void
82+
}
83+
84+
const props = withDefaults(defineProps<Props>(), {
85+
isVisible: false,
86+
info: null
87+
})
88+
const emit = defineEmits<Emits>()
89+
const { t } = useI18n()
90+
91+
const title = ref<string | null>(null)
92+
93+
const visible = computed({
94+
get(): boolean
95+
{
96+
return props.isVisible
97+
},
98+
set(value: boolean)
99+
{
100+
emit('close', value)
101+
}
102+
})
103+
104+
const handleInitialize = () => {
105+
if (props.info) {
106+
title.value = props.info.label
107+
}
108+
}
109+
110+
const onCancel = () => {
111+
visible.value = false
112+
emit('close', false)
113+
}
114+
115+
onMounted(() => {
116+
handleInitialize()
117+
})
118+
119+
watch(() => props.info, () => {
120+
handleInitialize()
121+
}, { immediate: true })
122+
</script>

0 commit comments

Comments
 (0)