This commit is contained in:
jxxghp
2023-07-23 11:38:18 +08:00
parent e3d09cd62d
commit 9dabed99a4
3 changed files with 32 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
import { useToast } from 'vue-toast-notification'
import api from '@/api'
import type { Plugin } from '@/api/types'
import FormRender from '@/components/render/FormRender.vue'
// 输入参数
const props = defineProps({
@@ -56,7 +57,7 @@ async function uninstallPlugin() {
// 调用API读取表单页面
async function loadPluginForm() {
try {
const result: { [key: string]: any } = await api.get(`plugin/form${props.plugin?.id}`)
const result: { [key: string]: any } = await api.get(`plugin/form/${props.plugin?.id}`)
if (result) {
pluginFormItems.value = result.conf
pluginConfigForm.value = result.model
@@ -110,6 +111,7 @@ async function savePluginConf() {
// 显示插件详情
function showPluginInfo() {
pluginConfigDialog.value = false
pluginInfoDialog.value = true
}
@@ -220,7 +222,9 @@ const dropdownItems = ref([
scrollable
>
<VCard :title="`插件 - ${props.plugin?.plugin_name}`">
<VCardText />
<VCardText>
<FormRender v-for="(item, index) in pluginFormItems" :key="index" :config="item" />
</VCardText>
<VCardActions>
<VSpacer />
<VBtn @click="pluginInfoDialog = false">

View File

@@ -0,0 +1,25 @@
<script lang="ts" setup>
import type { PropType } from 'vue'
interface RenderProps {
component: string
content: any
}
// 输入参数
const props = defineProps({
config: Array as PropType<RenderProps[]>,
})
// 配置表单
const formItems = ref(props.config)
</script>
<template>
<Component :is="item.component" v-for="(item, index) in formItems" :key="index" v-bind="$attrs">
<template v-for="(innerItem, innerIndex) in item.content" :key="innerIndex">
<FormRender v-if="innerItem.component" :config="innerItem" v-bind="$attrs" />
<Component :is="innerItem.component" v-else v-bind="innerItem" />
</template>
</Component>
</template>

View File

@@ -20,7 +20,7 @@ const used = ref(0)
// 计算已使用存储空间百分比精确到小数点后1位
const usedPercent = computed(() => {
return Math.round((used.value / storage.value) * 1000) / 10
return Math.round((used.value / (storage.value || 1)) * 1000) / 10
})
// 调用API查询存储空间