refactor: plugin detail page

Signed-off-by: Ryan Wang <i@ryanc.cc>
pull/590/head
Ryan Wang 2 years ago
parent 99c6caa788
commit 2925775c9a

@ -1,5 +1,6 @@
export * from "./types/plugin"; export * from "./types/plugin";
export * from "./types/menus"; export * from "./types/menus";
export * from "./types/formkit";
export * from "./core/plugins"; export * from "./core/plugins";
export * from "./states/pages"; export * from "./states/pages";
export * from "./layouts"; export * from "./layouts";

@ -0,0 +1,135 @@
<script lang="ts" setup>
import { VButton, VCard, VPageHeader, VTabbar } from "@halo-dev/components";
import type { RouteLocationRaw } from "vue-router";
import { RouterView, useRoute, useRouter } from "vue-router";
import type { Ref } from "vue";
import { onMounted, provide, ref, watch } from "vue";
import type { Plugin } from "@halo-dev/api-client";
import type {
FormKitSetting,
FormKitSettingSpec,
} from "@halo-dev/admin-shared";
import { apiClient, BasicLayout } from "@halo-dev/admin-shared";
interface PluginTab {
id: string;
label: string;
route: RouteLocationRaw;
}
const route = useRoute();
const router = useRouter();
const plugin = ref<Plugin>({} as Plugin);
const tabs = ref<PluginTab[]>([
{
id: "detail",
label: "详情",
route: {
name: "PluginDetail",
},
},
]);
const activeTab = ref<string>();
provide<Ref<Plugin>>("plugin", plugin);
provide<Ref<string | undefined>>("activeTab", activeTab);
const handleFetchPlugin = async () => {
try {
const response =
await apiClient.extension.plugin.getpluginHaloRunV1alpha1Plugin(
route.params.name as string
);
plugin.value = response.data;
await handleFetchSettings();
} catch (e) {
console.error(e);
}
};
const handleFetchSettings = async () => {
if (!plugin.value.spec.settingName) {
return;
}
try {
const response = await apiClient.extension.setting.getv1alpha1Setting(
plugin.value.spec.settingName as string
);
const settings = response.data as FormKitSetting;
const { spec } = settings;
if (spec) {
spec.forEach((item: FormKitSettingSpec) => {
tabs.value.push({
id: item.group,
label: item.label || "",
route: {
name: "PluginSetting",
params: {
group: item.group,
},
},
});
});
}
} catch (e) {
console.error(e);
}
};
const handleTabChange = (id: string) => {
const tab = tabs.value.find((item) => item.id === id);
if (tab) {
router.push(tab.route);
}
};
onMounted(async () => {
await handleFetchPlugin();
// @ts-ignore
const tab = tabs.value.find((tab) => tab.route.name === route.name);
activeTab.value = tab ? tab.id : tabs.value[0].id;
});
watch(
() => route.name,
async (newRouteName) => {
// @ts-ignore
const tab = tabs.value.find((tab) => tab.route.name === newRouteName);
activeTab.value = tab ? tab.id : tabs.value[0].id;
}
);
</script>
<template>
<BasicLayout>
<VPageHeader :title="plugin?.spec?.displayName">
<template #icon>
<img :src="plugin?.spec?.logo" class="mr-2 h-8 w-8" />
</template>
<template #actions>
<VButton class="opacity-0" type="secondary">安装</VButton>
</template>
</VPageHeader>
<div class="m-0 md:m-4">
<VCard :body-class="['!p-0']">
<template #header>
<VTabbar
v-model:active-id="activeTab"
:items="tabs"
class="w-full !rounded-none"
type="outline"
@change="handleTabChange"
></VTabbar>
</template>
</VCard>
<div>
<RouterView :key="activeTab" />
</div>
</div>
</BasicLayout>
</template>

@ -2,3 +2,4 @@ export { default as BlankLayout } from "./BlankLayout.vue";
export { default as BasicLayout } from "./BasicLayout.vue"; export { default as BasicLayout } from "./BasicLayout.vue";
export { default as SystemSettingsLayout } from "./SystemSettingsLayout.vue"; export { default as SystemSettingsLayout } from "./SystemSettingsLayout.vue";
export { default as UserProfileLayout } from "./UserProfileLayout.vue"; export { default as UserProfileLayout } from "./UserProfileLayout.vue";
export { default as PluginLayout } from "./PluginLayout.vue";

@ -0,0 +1,10 @@
import type { Setting, SettingSpec } from "@halo-dev/api-client";
import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core";
export interface FormKitSettingSpec extends Omit<SettingSpec, "formSchema"> {
formSchema: FormKitSchemaCondition | FormKitSchemaNode[];
}
export interface FormKitSetting extends Omit<Setting, "spec"> {
spec: Array<FormKitSettingSpec>;
}

@ -320,7 +320,7 @@ onMounted(handleFetchThemes);
<RouterLink <RouterLink
:to="{ :to="{
name: 'PluginDetail', name: 'PluginDetail',
params: { pluginName: 'PluginLinks' }, params: { name: 'PluginLinks' },
}" }"
class="font-medium text-gray-900 hover:text-blue-400" class="font-medium text-gray-900 hover:text-blue-400"
> >

@ -1,157 +1,17 @@
<script lang="ts" setup> <script lang="ts" setup>
import { import { useDialog, VSwitch, VTag } from "@halo-dev/components";
useDialog, import type { Ref } from "vue";
VButton, import { computed, inject, onMounted, ref } from "vue";
VCard,
VPageHeader,
VSwitch,
VTabbar,
VTag,
} from "@halo-dev/components";
import { useRoute } from "vue-router";
import { computed, onMounted, ref } from "vue";
import { apiClient } from "@halo-dev/admin-shared"; import { apiClient } from "@halo-dev/admin-shared";
import type { import type { Plugin, Role } from "@halo-dev/api-client";
ConfigMap,
Plugin,
Role,
Setting,
SettingSpec,
} from "@halo-dev/api-client";
import cloneDeep from "lodash.clonedeep"; import cloneDeep from "lodash.clonedeep";
import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core";
import { pluginLabels } from "@/constants/labels"; import { pluginLabels } from "@/constants/labels";
import { rbacAnnotations } from "@/constants/annotations"; import { rbacAnnotations } from "@/constants/annotations";
interface FormKitSettingSpec extends Omit<SettingSpec, "formSchema"> { const plugin = inject<Ref<Plugin>>("plugin", ref({} as Plugin));
formSchema: FormKitSchemaCondition | FormKitSchemaNode[];
}
interface FormKitSetting extends Omit<Setting, "spec"> {
spec: Array<FormKitSettingSpec>;
}
const pageTabs = ref([{ id: "detail", label: "详情" }]);
const activeTabId = ref(pageTabs.value[0].id);
const plugin = ref<Plugin>({} as Plugin);
const settings = ref<FormKitSetting>({} as FormKitSetting);
const configmapFormData = ref<Record<string, Record<string, string>>>({});
const configmap = ref<ConfigMap>({
data: {},
apiVersion: "v1alpha1",
kind: "ConfigMap",
metadata: {
name: "",
},
});
const saving = ref(false);
const { params } = useRoute();
const dialog = useDialog(); const dialog = useDialog();
const handleFetchPlugin = async () => {
try {
const response =
await apiClient.extension.plugin.getpluginHaloRunV1alpha1Plugin(
params.pluginName as string
);
plugin.value = response.data;
await handleFetchSettings();
await handleFetchConfigMap();
} catch (e) {
console.error(e);
}
};
const handleFetchSettings = async () => {
if (!plugin.value.spec.settingName) {
return;
}
try {
const response = await apiClient.extension.setting.getv1alpha1Setting(
plugin.value.spec.settingName as string
);
settings.value = response.data as FormKitSetting;
const { spec } = settings.value;
if (spec) {
pageTabs.value = [
...pageTabs.value,
...spec.map((item: FormKitSettingSpec) => {
return {
id: item.group,
label: item.label || "",
};
}),
];
spec.forEach((item: FormKitSettingSpec) => {
configmapFormData.value[item.group] = {};
});
}
} catch (e) {
console.error(e);
}
};
const handleFetchConfigMap = async () => {
if (!plugin.value.spec.configMapName) {
return;
}
try {
const response = await apiClient.extension.configMap.getv1alpha1ConfigMap(
plugin.value.spec.configMapName as string
);
configmap.value = response.data;
const { data } = configmap.value;
if (data) {
Object.keys(data).forEach((key) => {
configmapFormData.value[key] = JSON.parse(data[key]);
});
}
} catch (e) {
console.error(e);
}
};
const handleSaveConfigMap = async () => {
try {
saving.value = true;
if (!configmap.value.metadata.name && plugin.value.spec.configMapName) {
configmap.value.metadata.name = plugin.value.spec.configMapName;
}
settings.value.spec.forEach((item: FormKitSettingSpec) => {
// @ts-ignore
configmap.value.data[item.group] = JSON.stringify(
configmapFormData.value[item.group]
);
});
if (!configmap.value.metadata.creationTimestamp) {
await apiClient.extension.configMap.createv1alpha1ConfigMap(
configmap.value
);
} else {
await apiClient.extension.configMap.updatev1alpha1ConfigMap(
configmap.value.metadata.name,
configmap.value
);
}
} catch (e) {
console.error(e);
} finally {
await handleFetchConfigMap();
saving.value = false;
}
};
const isStarted = computed(() => { const isStarted = computed(() => {
return plugin.value.status?.phase === "STARTED" && plugin.value.spec.enabled; return plugin.value.status?.phase === "STARTED" && plugin.value.spec.enabled;
}); });
@ -197,7 +57,7 @@ const handleFetchRoles = async () => {
const pluginRoleTemplates = computed(() => { const pluginRoleTemplates = computed(() => {
return roles.value.filter((item) => { return roles.value.filter((item) => {
return ( return (
item.metadata.labels?.[pluginLabels.NAME] === plugin.value.metadata.name item.metadata.labels?.[pluginLabels.NAME] === plugin.value.metadata?.name
); );
}); });
}); });
@ -222,219 +82,150 @@ const pluginRoleTemplateGroups = computed<RoleTemplateGroup[]>(() => {
}); });
onMounted(() => { onMounted(() => {
handleFetchPlugin();
handleFetchRoles(); handleFetchRoles();
}); });
</script> </script>
<template> <template>
<VPageHeader :title="plugin?.spec?.displayName"> <div class="flex items-center justify-between bg-white px-4 py-4 sm:px-6">
<template #icon> <div>
<img :src="plugin?.spec?.logo" class="mr-2 h-8 w-8" /> <h3 class="text-lg font-medium leading-6 text-gray-900">插件信息</h3>
</template> <p class="mt-1 flex max-w-2xl items-center gap-2 text-sm text-gray-500">
<template #actions> <span>{{ plugin?.spec?.version }}</span>
<VButton class="opacity-0" type="secondary">安装</VButton> <VTag>
</template> {{ isStarted ? "已启用" : "未启用" }}
</VPageHeader> </VTag>
</p>
<div class="m-0 md:m-4"> </div>
<VCard :body-class="['!p-0']"> <div v-permission="['system:plugins:manage']">
<template #header> <VSwitch :model-value="isStarted" @change="handleChangePluginStatus" />
<VTabbar </div>
v-model:active-id="activeTabId" </div>
:items="pageTabs" <div class="border-t border-gray-200">
class="w-full !rounded-none" <dl class="divide-y divide-gray-100">
type="outline" <div
></VTabbar> class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
</template> >
<dt class="text-sm font-medium text-gray-900">名称</dt>
<div v-if="activeTabId === 'detail'"> <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
<div class="flex items-center justify-between px-4 py-4 sm:px-6"> {{ plugin?.spec?.displayName }}
<div> </dd>
<h3 class="text-lg font-medium leading-6 text-gray-900"> </div>
插件信息 <div
</h3> class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
<p >
class="mt-1 flex max-w-2xl items-center gap-2 text-sm text-gray-500" <dt class="text-sm font-medium text-gray-900">版本</dt>
> <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
<span>{{ plugin?.spec?.version }}</span> {{ plugin?.spec?.version }}
<VTag> </dd>
{{ isStarted ? "已启用" : "未启用" }} </div>
</VTag> <div
</p> class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
</div> >
<div v-permission="['system:plugins:manage']"> <dt class="text-sm font-medium text-gray-900">Halo 版本要求</dt>
<VSwitch <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
:model-value="isStarted" {{ plugin?.spec?.requires }}
@change="handleChangePluginStatus" </dd>
/> </div>
</div> <div
</div> class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
<div class="border-t border-gray-200"> >
<dl class="divide-y divide-gray-100"> <dt class="text-sm font-medium text-gray-900">提供方</dt>
<div <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6" <a :href="plugin?.spec?.homepage" target="_blank">
> {{ plugin?.spec?.author }}
<dt class="text-sm font-medium text-gray-900">名称</dt> </a>
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"> </dd>
{{ plugin?.spec?.displayName }} </div>
</dd> <div
</div> class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
<div >
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6" <dt class="text-sm font-medium text-gray-900">协议</dt>
> <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
<dt class="text-sm font-medium text-gray-900">版本</dt> <ul
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"> v-if="plugin?.spec?.license && plugin?.spec?.license.length"
{{ plugin?.spec?.version }} class="list-inside list-disc"
</dd> >
</div> <li v-for="(license, index) in plugin.spec.license" :key="index">
<div <a v-if="license.url" :href="license.url" target="_blank">
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6" {{ license.name }}
> </a>
<dt class="text-sm font-medium text-gray-900">Halo 版本要求</dt> <span>
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"> {{ license.name }}
{{ plugin?.spec?.requires }} </span>
</dd> </li>
</div> </ul>
<div </dd>
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6" </div>
> <div
<dt class="text-sm font-medium text-gray-900">提供方</dt> class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"> >
<a :href="plugin?.spec?.homepage" target="_blank"> <dt class="text-sm font-medium text-gray-900">模型定义</dt>
{{ plugin?.spec?.author }} <dd class="mt-1 sm:col-span-2 sm:mt-0">
</a> <span></span>
</dd> </dd>
</div> </div>
<div
:class="`${
pluginRoleTemplateGroups.length ? 'bg-gray-50' : 'bg-white'
}`"
class="px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
>
<dt class="text-sm font-medium text-gray-900">权限模板</dt>
<dd class="mt-1 text-sm text-gray-900 sm:col-span-5 sm:mt-0">
<dl
v-if="pluginRoleTemplateGroups.length"
class="divide-y divide-gray-100"
>
<div <div
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6" v-for="(group, groupIndex) in pluginRoleTemplateGroups"
:key="groupIndex"
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"
> >
<dt class="text-sm font-medium text-gray-900">协议</dt> <dt class="text-sm font-medium text-gray-900">
{{ group.module }}
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"> <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
<ul <ul class="space-y-2">
v-if="plugin?.spec?.license && plugin?.spec?.license.length" <li v-for="(role, index) in group.roles" :key="index">
class="list-inside list-disc" <div
> class="inline-flex w-72 cursor-pointer flex-row items-center gap-4 rounded border p-5 hover:border-primary"
<li >
v-for="(license, index) in plugin.spec.license" <div class="inline-flex flex-col gap-y-3">
:key="index" <span class="font-medium text-gray-900">
> {{
<a v-if="license.url" :href="license.url" target="_blank"> role.metadata.annotations?.[
{{ license.name }} rbacAnnotations.DISPLAY_NAME
</a> ]
<span> }}
{{ license.name }} </span>
</span> <span
v-if="
role.metadata.annotations?.[
rbacAnnotations.DEPENDENCIES
]
"
class="text-xs text-gray-400"
>
依赖于
{{
JSON.parse(
role.metadata.annotations?.[
rbacAnnotations.DEPENDENCIES
]
).join(", ")
}}
</span>
</div>
</div>
</li> </li>
</ul> </ul>
</dd> </dd>
</div> </div>
<div
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
>
<dt class="text-sm font-medium text-gray-900">模型定义</dt>
<dd class="mt-1 sm:col-span-2 sm:mt-0">
<span></span>
</dd>
</div>
<div
:class="`${
pluginRoleTemplateGroups.length ? 'bg-gray-50' : 'bg-white'
}`"
class="px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
>
<dt class="text-sm font-medium text-gray-900">权限模板</dt>
<dd class="mt-1 text-sm text-gray-900 sm:col-span-5 sm:mt-0">
<dl
v-if="pluginRoleTemplateGroups.length"
class="divide-y divide-gray-100"
>
<div
v-for="(group, groupIndex) in pluginRoleTemplateGroups"
:key="groupIndex"
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"
>
<dt class="text-sm font-medium text-gray-900">
{{ group.module }}
</dt>
<dd
class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"
>
<ul class="space-y-2">
<li v-for="(role, index) in group.roles" :key="index">
<div
class="inline-flex w-72 cursor-pointer flex-row items-center gap-4 rounded border p-5 hover:border-primary"
>
<div class="inline-flex flex-col gap-y-3">
<span class="font-medium text-gray-900">
{{
role.metadata.annotations?.[
rbacAnnotations.DISPLAY_NAME
]
}}
</span>
<span
v-if="
role.metadata.annotations?.[
rbacAnnotations.DEPENDENCIES
]
"
class="text-xs text-gray-400"
>
依赖于
{{
JSON.parse(
role.metadata.annotations?.[
rbacAnnotations.DEPENDENCIES
]
).join(", ")
}}
</span>
</div>
</div>
</li>
</ul>
</dd>
</div>
</dl>
<span v-else></span>
</dd>
</div>
</dl> </dl>
</div> <span v-else></span>
</dd>
</div> </div>
</dl>
<template v-for="(group, index) in settings.spec">
<div
v-if="activeTabId === group.group"
:key="index"
class="p-4 sm:px-6"
>
<div class="w-1/3">
<FormKit
:id="group.group"
v-model="configmapFormData[group.group]"
:actions="false"
:preserve="true"
type="form"
@submit="handleSaveConfigMap"
>
<FormKitSchema :schema="group.formSchema" />
</FormKit>
</div>
<div class="pt-5">
<div class="flex justify-start">
<VButton
:loading="saving"
type="secondary"
@click="$formkit.submit(group.group)"
>
保存
</VButton>
</div>
</div>
</div>
</template>
</VCard>
</div> </div>
</template> </template>

@ -27,7 +27,7 @@ const dialog = useDialog();
const handleRouteToDetail = (plugin: Plugin) => { const handleRouteToDetail = (plugin: Plugin) => {
router.push({ router.push({
name: "PluginDetail", name: "PluginDetail",
params: { pluginName: plugin.metadata.name }, params: { name: plugin.metadata.name },
}); });
}; };

@ -0,0 +1,149 @@
<script lang="ts" setup>
import { VButton } from "@halo-dev/components";
import type { Ref } from "vue";
import { computed, inject, onMounted, ref, watch } from "vue";
import type { ConfigMap, Plugin } from "@halo-dev/api-client";
import type {
FormKitSetting,
FormKitSettingSpec,
} from "@halo-dev/admin-shared";
import { apiClient } from "@halo-dev/admin-shared";
const plugin = inject<Ref<Plugin>>("plugin", ref({} as Plugin));
const settings = ref<FormKitSetting>({} as FormKitSetting);
const configmapFormData = ref<Record<string, Record<string, string>>>({});
const configmap = ref<ConfigMap>({
data: {},
apiVersion: "v1alpha1",
kind: "ConfigMap",
metadata: {
name: "",
},
});
const saving = ref(false);
const group = inject<Ref<string | undefined>>("activeTab");
const formSchema = computed(() => {
if (!settings.value.spec) {
return;
}
return settings.value.spec.find((item) => item.group === group?.value)
?.formSchema;
});
const handleFetchSettings = async () => {
if (!plugin.value.spec?.settingName) {
return;
}
try {
const response = await apiClient.extension.setting.getv1alpha1Setting(
plugin.value.spec.settingName as string
);
settings.value = response.data as FormKitSetting;
const { spec } = settings.value;
if (spec) {
spec.forEach((item: FormKitSettingSpec) => {
configmapFormData.value[item.group] = {};
});
}
} catch (e) {
console.error(e);
}
};
const handleFetchConfigMap = async () => {
if (!plugin.value.spec?.configMapName) {
return;
}
try {
const response = await apiClient.extension.configMap.getv1alpha1ConfigMap(
plugin.value.spec?.configMapName as string
);
configmap.value = response.data;
const { data } = configmap.value;
if (data) {
Object.keys(data).forEach((key) => {
configmapFormData.value[key] = JSON.parse(data[key]);
});
}
} catch (e) {
console.error(e);
}
};
const handleSaveConfigMap = async () => {
try {
saving.value = true;
if (!configmap.value.metadata.name && plugin.value.spec.configMapName) {
configmap.value.metadata.name = plugin.value.spec.configMapName;
}
settings.value.spec.forEach((item: FormKitSettingSpec) => {
// @ts-ignore
configmap.value.data[item.group] = JSON.stringify(
configmapFormData.value[item.group]
);
});
if (!configmap.value.metadata.creationTimestamp) {
await apiClient.extension.configMap.createv1alpha1ConfigMap(
configmap.value
);
} else {
await apiClient.extension.configMap.updatev1alpha1ConfigMap(
configmap.value.metadata.name,
configmap.value
);
}
} catch (e) {
console.error(e);
} finally {
await handleFetchConfigMap();
saving.value = false;
}
};
onMounted(() => {
handleFetchSettings();
handleFetchConfigMap();
});
watch([() => plugin.value, () => group?.value], () => {
handleFetchConfigMap();
handleFetchConfigMap();
});
</script>
<template>
<div class="bg-white p-4 sm:px-6">
<div class="w-1/3">
<FormKit
v-if="group && formSchema"
:id="group"
v-model="configmapFormData[group]"
:actions="false"
:preserve="true"
type="form"
@submit="handleSaveConfigMap"
>
<FormKitSchema :schema="formSchema" />
</FormKit>
</div>
<div class="pt-5">
<div class="flex justify-start">
<VButton
:loading="saving"
type="secondary"
@click="$formkit.submit(group || '')"
>
保存
</VButton>
</div>
</div>
</div>
</template>

@ -1,5 +1,11 @@
import { BasicLayout, definePlugin } from "@halo-dev/admin-shared"; import {
BasicLayout,
BlankLayout,
definePlugin,
PluginLayout,
} from "@halo-dev/admin-shared";
import PluginList from "./PluginList.vue"; import PluginList from "./PluginList.vue";
import PluginSetting from "./PluginSetting.vue";
import PluginDetail from "./PluginDetail.vue"; import PluginDetail from "./PluginDetail.vue";
import { IconPlug } from "@halo-dev/components"; import { IconPlug } from "@halo-dev/components";
@ -9,23 +15,37 @@ export default definePlugin({
routes: [ routes: [
{ {
path: "/plugins", path: "/plugins",
component: BasicLayout, component: BlankLayout,
children: [ children: [
{ {
path: "", path: "",
name: "Plugins", component: BasicLayout,
component: PluginList, children: [
meta: { {
permissions: ["system:plugins:view"], path: "",
}, name: "Plugins",
component: PluginList,
meta: {
permissions: ["system:plugins:view"],
},
},
],
}, },
{ {
path: ":pluginName", path: ":name",
name: "PluginDetail", component: PluginLayout,
component: PluginDetail, children: [
meta: { {
permissions: ["system:plugins:view"], path: "detail",
}, name: "PluginDetail",
component: PluginDetail,
},
{
path: "settings/:group",
name: "PluginSetting",
component: PluginSetting,
},
],
}, },
], ],
}, },

@ -311,8 +311,9 @@ onMounted(() => {
:to="{ :to="{
name: 'PluginDetail', name: 'PluginDetail',
params: { params: {
pluginName: name: group.roles[0].metadata.labels?.[
group.roles[0].metadata.labels?.[pluginLabels.NAME], pluginLabels.NAME
],
}, },
}" }"
class="hover:text-blue-600" class="hover:text-blue-600"

Loading…
Cancel
Save