plugin page render

This commit is contained in:
jxxghp
2023-07-25 11:41:24 +08:00
parent dbd1315a9e
commit e636b1e225
3 changed files with 55 additions and 5 deletions
+13 -5
View File
@@ -3,6 +3,7 @@ import { useToast } from 'vue-toast-notification'
import api from '@/api' import api from '@/api'
import type { Plugin } from '@/api/types' import type { Plugin } from '@/api/types'
import FormRender from '@/components/render/FormRender.vue' import FormRender from '@/components/render/FormRender.vue'
import PageRender from '@/components/render/PageRender.vue'
import { isNullOrEmptyObject } from '@core/utils' import { isNullOrEmptyObject } from '@core/utils'
// 输入参数 // 输入参数
@@ -112,7 +113,7 @@ async function savePluginConf() {
} }
// 显示插件详情 // 显示插件详情
function showPluginInfo() { async function showPluginInfo() {
pluginConfigDialog.value = false pluginConfigDialog.value = false
pluginInfoDialog.value = true pluginInfoDialog.value = true
} }
@@ -140,7 +141,7 @@ const dropdownItems = ref([
onBeforeMount(async () => { onBeforeMount(async () => {
await loadPluginForm() await loadPluginForm()
await loadPluginConf() await loadPluginConf()
await loadPluginPage() loadPluginPage()
}) })
</script> </script>
@@ -205,7 +206,7 @@ onBeforeMount(async () => {
scrollable scrollable
persistent persistent
> >
<VCard :title="`插件 - ${props.plugin?.plugin_name}`"> <VCard :title="props.plugin?.plugin_name">
<DialogCloseBtn @click="pluginConfigDialog = false" /> <DialogCloseBtn @click="pluginConfigDialog = false" />
<VCardText> <VCardText>
<FormRender <FormRender
@@ -234,9 +235,16 @@ onBeforeMount(async () => {
scrollable scrollable
persistent persistent
> >
<VCard :title="`插件 - ${props.plugin?.plugin_name}`"> <VCard :title="`${props.plugin?.plugin_name} - 详情`">
<DialogCloseBtn @click="pluginInfoDialog = false" /> <DialogCloseBtn @click="pluginInfoDialog = false" />
<VCardText /> <VCardText>
<PageRender
v-for="(item, index) in pluginPageItems"
:key="index"
:config="item"
:handler="pluginInfoDialog"
/>
</VCardText>
<VCardActions> <VCardActions>
<VSpacer /> <VSpacer />
<VBtn @click="pluginInfoDialog = false"> <VBtn @click="pluginInfoDialog = false">
+3
View File
@@ -4,6 +4,7 @@ import { type PropType, ref } from 'vue'
// 组件接口 // 组件接口
interface RenderProps { interface RenderProps {
component: string component: string
text: string
content?: any content?: any
props?: any props?: any
} }
@@ -17,6 +18,7 @@ const elementProps = defineProps({
// 配置元素 // 配置元素
const formItem = ref<RenderProps>(elementProps.config || { const formItem = ref<RenderProps>(elementProps.config || {
component: 'div', component: 'div',
text: '',
props: {}, props: {},
content: [], content: [],
}) })
@@ -31,6 +33,7 @@ const formData = ref<any>(elementProps.form || {})
v-bind="formItem.props" v-bind="formItem.props"
v-model="formData[formItem.props?.model || '']" v-model="formData[formItem.props?.model || '']"
> >
{{ formItem.text }}
<FormRender <FormRender
v-for="(innerItem, innerIndex) in (formItem.content || [])" v-for="(innerItem, innerIndex) in (formItem.content || [])"
:key="innerIndex" :key="innerIndex"
+39
View File
@@ -0,0 +1,39 @@
<script lang="ts" setup>
import { type PropType, ref } from 'vue'
// 组件接口
interface RenderProps {
component: string
text: string
content?: any
props?: any
}
// 输入参数
const elementProps = defineProps({
config: Object as PropType<RenderProps>,
handler: Boolean,
})
// 配置元素
const formItem = ref<RenderProps>(elementProps.config || {
component: 'div',
text: '',
props: {},
content: [],
})
</script>
<template>
<Component
:is="formItem.component"
v-bind="formItem.props"
>
{{ formItem.text }}
<PageRender
v-for="(innerItem, innerIndex) in (formItem.content || [])"
:key="innerIndex"
:config="innerItem"
/>
</Component>
</template>