diff --git a/frontend/src/request/plugin.ts b/frontend/src/request/plugin.ts index ecde4700a079c6157c9c1774fd64f46a7f29cfe6..1b1f56ca9ac2da2a34b6518294a1a23e715018ad 100644 --- a/frontend/src/request/plugin.ts +++ b/frontend/src/request/plugin.ts @@ -1,60 +1,60 @@ -/* +/* * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. - * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. * See LICENSE file for more details. * Author: Gzx1999 * Date: Wed Jan 3 18:00:12 2024 +0800 */ -import request from './request' +import request from "./request"; // 分页查询插件列表 export function getPluginsPaged(data: any) { return request({ - url: '/plugins_paged', - method: 'get', + url: "/plugins_paged", + method: "get", params: data, - }) + }); } // 获取插件列表 export function getPlugins() { return request({ - url: '/plugins', - method: 'get', - }) + url: "/plugins", + method: "get", + }); } export function addPlugin(data: any) { return request({ - url: '/plugins', - method: 'put', - data - }) + url: "/plugins", + method: "put", + data, + }); } // 启用/停用插件 -export function togglePlugin(data: any) { +export function togglePlugin(data: { serviceName: string; enable: boolean }) { return request({ - url: '/plugins/' + data.uuid, - method: 'post', - data - }) + url: "/plugins/toggle/", + method: "post", + data, + }); } //删除插件 export function deletePlugins(data: any) { return request({ - url: '/plugins/' + data.UUID, - method: 'delete', - data - }) + url: "/plugins/" + data.UUID, + method: "delete", + data, + }); } // 插件扩展方法 -export function pluginExtAPI(data: { url: string, uuids: string[] }) { +export function pluginExtAPI(data: { url: string; uuids: string[] }) { return request({ url: data.url, - method: 'post', - data: data.uuids - }) -} \ No newline at end of file + method: "post", + data: data.uuids, + }); +} diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 986be7510fd0582e30ea9851c1a52e416e491a63..8551dccb02b8a85e8d10cd489d0c879b3550d015 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -224,10 +224,10 @@ let sidebarRoutes = [ name: "Plugin", component: () => import("../views/Plugin/Plugin.vue"), meta: { - title: "插件管理", + title: "插件服务管理", panel: "plugin", icon: "Menu", - breadcrumb: [{ name: "插件管理" }], + breadcrumb: [{ name: "插件服务管理" }], }, }, ], diff --git a/frontend/src/views/Home/Home.vue b/frontend/src/views/Home/Home.vue index 004a38478ff897671db57373ea50549a344e1c10..e5f0a0e74f657ea28276a72591fad1b4541a2aa7 100644 --- a/frontend/src/views/Home/Home.vue +++ b/frontend/src/views/Home/Home.vue @@ -68,7 +68,7 @@ - + diff --git a/frontend/src/views/Home/components/changePwd.vue b/frontend/src/views/Home/components/changePwd.vue index e51a113769df68e4b89af9fb5d0f98a168135848..542b34ddd2bb62a31cba59490a91e449ae33bff1 100644 --- a/frontend/src/views/Home/components/changePwd.vue +++ b/frontend/src/views/Home/components/changePwd.vue @@ -6,7 +6,7 @@ * Date: Wed Mar 13 11:12:44 2024 +0800 --> - \ No newline at end of file + diff --git a/frontend/src/views/Plugin/Plugin.vue b/frontend/src/views/Plugin/Plugin.vue index d264f170d090c95664f518484fbe00db1fd3eb1c..89d2580dc5786bb0009630c27b2807ceb097d0c2 100644 --- a/frontend/src/views/Plugin/Plugin.vue +++ b/frontend/src/views/Plugin/Plugin.vue @@ -7,48 +7,31 @@ --> @@ -57,15 +40,12 @@ import { ref, onMounted, watch } from "vue"; import { ElMessage } from "element-plus"; import PGTable from "@/components/PGTable.vue"; -import AddPlugin from "./components/AddPlugin.vue"; import AuthButton from "@/components/AuthButton.vue"; import { updatePlugins } from "./plugin"; -import { getPluginsPaged, togglePlugin, deletePlugins } from "@/request/plugin"; +import { getPluginsPaged, togglePlugin } from "@/request/plugin"; import { RespCodeOK } from "@/request/request"; -const displayDialog = ref(false); - const plugins = ref([]); const total = ref(0); const page = ref({ pageSize: 10, currentPage: 1 }); @@ -104,22 +84,7 @@ watch( ); function togglePluginState(item: any) { - let targetEnabled = item.enabled === 1 ? 0 : 1; - togglePlugin({ uuid: item.uuid, enable: targetEnabled }).then((res: any) => { - if (res.code === RespCodeOK) { - ElMessage.success(res.msg); - // 更新插件列表 - updatePluginList(); - // 更新页面插件路由、sidebar等 - updatePlugins(); - } else { - ElMessage.error(res.msg); - } - }); -} - -function onDeletePlugin(item: any) { - deletePlugins({ UUID: item.uuid }).then((res: any) => { + togglePlugin({ serviceName: item.serviceName, enable: !item.status }).then((res: any) => { if (res.code === RespCodeOK) { ElMessage.success(res.msg); // 更新插件列表 diff --git a/frontend/src/views/Plugin/PluginFrame.vue b/frontend/src/views/Plugin/PluginFrame.vue index 8a0b089c4921bea47ead3e039b59a1c101c61d25..73a1dbf27c138e35219f2880588fdef719d2ced4 100644 --- a/frontend/src/views/Plugin/PluginFrame.vue +++ b/frontend/src/views/Plugin/PluginFrame.vue @@ -34,13 +34,14 @@ import microApp from "@micro-zoe/micro-app"; const showFrame = ref(false); const route: any = useRoute(); +console.log(route); let props = reactive({ url: "", plugin_type: "", name: "", }); watchEffect(() => { - if (route.meta.plugin_type) { + if (route.meta.name.includes("plugin")) { // 如果是插件 if (route.meta.subRoute) { // 插件的子路由 @@ -48,12 +49,12 @@ watchEffect(() => { props.plugin_type = plugin_type; props.name = name; - showFrame.value = props.plugin_type === "iframe" ? true : false; - if (props.plugin_type === "micro-app") { - props.url = window.location.origin + subRoute; - } else { - props.url = url; - } + props.url = window.location.origin + subRoute; + // showFrame.value = props.plugin_type === "iframe" ? true : false; + // if (props.plugin_type === "micro-app") { + // } else { + // props.url = url; + // } } else { // 插件只有一级路由 } diff --git a/frontend/src/views/Plugin/plugin.ts b/frontend/src/views/Plugin/plugin.ts index 799c3c68d952ac6c258ef1193d94fb5d0c983077..f1c1db01297a5e4e52fc465a5341f78580a0e126 100644 --- a/frontend/src/views/Plugin/plugin.ts +++ b/frontend/src/views/Plugin/plugin.ts @@ -28,23 +28,22 @@ export function updatePlugins() { res.data.forEach((item: any, index: number) => { // 删除插件tagview、增删全局扩展点 let pluginExt = item.extentions.filter((item: Extention) => item.type === "machine"); - if (item.enabled === 0) { + if (item.status === false) { clearTagview(item); // usePluginStore().delExtention(pluginExt); } else { usePluginStore().addExtention(pluginExt); } - if (item.enabled === 0 || item.status === false) { + if (item.status === false) { // 0:禁用,1:启用 return; } // 创建组件 let iframeObj: any = { - path: "/plugin-" + item.name, - name: "plugin-" + item.name, + path: "/plugin-" + item.serviceName, + name: "plugin-" + item.serviceName, menuName: item.menuName, - url: item.url, - plugin_type: item.plugin_type, + url: item.address, icon: item.icon || "Menu", }; @@ -69,7 +68,7 @@ export function updatePlugins() { function clearTagview(item: any) { for (let i = 0; i < tagviewStore().taginfos.length; i++) { - if (tagviewStore().taginfos[i].path === "/plugin-" + item.name) { + if (tagviewStore().taginfos[i].path === "/plugin-" + item.serviceName) { tagviewStore().taginfos.splice(i, 1); } } diff --git a/frontend/src/views/Role/components/authData.ts b/frontend/src/views/Role/components/authData.ts index dd14e0115998ce4e74dabd49449d91888eec0234..64d9ded45e47b3601707305989c54f4c9d0b4ad9 100644 --- a/frontend/src/views/Role/components/authData.ts +++ b/frontend/src/views/Role/components/authData.ts @@ -211,7 +211,7 @@ export let authData = [ }, { id: "8", - label: "插件管理", + label: "插件服务管理", isMenu: true, display: true, menuName: "plugin",