mirror of https://github.com/halo-dev/halo
refactor: removal of plugin batch operation
Signed-off-by: Ryan Wang <i@ryanc.cc>pull/3445/head
parent
728dab4b74
commit
75b76ec919
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@halo-dev/components",
|
"name": "@halo-dev/components",
|
||||||
"version": "0.0.0-alpha.0",
|
"version": "0.0.0-alpha.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@halo-dev/admin-shared",
|
"name": "@halo-dev/admin-shared",
|
||||||
"version": "0.0.0-alpha.1",
|
"version": "0.0.0-alpha.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|
|
@ -13,6 +13,7 @@ importers:
|
||||||
'@formkit/vue': 1.0.0-beta.9
|
'@formkit/vue': 1.0.0-beta.9
|
||||||
'@halo-dev/admin-api': ^1.1.0
|
'@halo-dev/admin-api': ^1.1.0
|
||||||
'@halo-dev/admin-shared': workspace:*
|
'@halo-dev/admin-shared': workspace:*
|
||||||
|
'@halo-dev/api-client': ^0.0.0
|
||||||
'@halo-dev/components': workspace:*
|
'@halo-dev/components': workspace:*
|
||||||
'@rushstack/eslint-patch': ^1.1.4
|
'@rushstack/eslint-patch': ^1.1.4
|
||||||
'@tailwindcss/aspect-ratio': ^0.4.0
|
'@tailwindcss/aspect-ratio': ^0.4.0
|
||||||
|
@ -76,6 +77,7 @@ importers:
|
||||||
'@formkit/vue': 1.0.0-beta.9_jly5jqkcc2zgnt3crhnp3znzv4
|
'@formkit/vue': 1.0.0-beta.9_jly5jqkcc2zgnt3crhnp3znzv4
|
||||||
'@halo-dev/admin-api': 1.1.0
|
'@halo-dev/admin-api': 1.1.0
|
||||||
'@halo-dev/admin-shared': link:packages/shared
|
'@halo-dev/admin-shared': link:packages/shared
|
||||||
|
'@halo-dev/api-client': 0.0.0
|
||||||
'@halo-dev/components': link:packages/components
|
'@halo-dev/components': link:packages/components
|
||||||
'@vueuse/core': 8.9.2_vue@3.2.37
|
'@vueuse/core': 8.9.2_vue@3.2.37
|
||||||
axios: 0.27.2
|
axios: 0.27.2
|
||||||
|
@ -149,10 +151,12 @@ importers:
|
||||||
|
|
||||||
packages/shared:
|
packages/shared:
|
||||||
specifiers:
|
specifiers:
|
||||||
|
'@halo-dev/api-client': ^0.0.0
|
||||||
'@halo-dev/components': workspace:*
|
'@halo-dev/components': workspace:*
|
||||||
axios: ^0.27.2
|
axios: ^0.27.2
|
||||||
vite-plugin-dts: ^1.2.1
|
vite-plugin-dts: ^1.2.1
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@halo-dev/api-client': 0.0.0
|
||||||
'@halo-dev/components': link:../components
|
'@halo-dev/components': link:../components
|
||||||
axios: 0.27.2
|
axios: 0.27.2
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
@ -1781,6 +1785,10 @@ packages:
|
||||||
- debug
|
- debug
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@halo-dev/api-client/0.0.0:
|
||||||
|
resolution: {integrity: sha512-DC+0MsnX3e5IkqFFya3gz8JK893hGH+9ohKzLp1b7QqYj1Hvxxc1Nbr77IxvVbktZ14LUZTeHOdWHdqFAFQdvw==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@halo-dev/logger/1.1.0:
|
/@halo-dev/logger/1.1.0:
|
||||||
resolution: {integrity: sha512-y0jVivYwF8MCVi/OdW2D0LN+GTM5rzMsR/ZmQVfgmKQw7Q7Q+EXPijxON6iCMZnWANGa4NaAcOO9k3ggG8oRwg==}
|
resolution: {integrity: sha512-y0jVivYwF8MCVi/OdW2D0LN+GTM5rzMsR/ZmQVfgmKQw7Q7Q+EXPijxON6iCMZnWANGa4NaAcOO9k3ggG8oRwg==}
|
||||||
engines: {node: '>=12.0.0'}
|
engines: {node: '>=12.0.0'}
|
||||||
|
|
|
@ -126,7 +126,11 @@ async function loadPluginModules() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stylesheet) {
|
if (stylesheet) {
|
||||||
await loadStyle(`http://localhost:8090${stylesheet}`);
|
try {
|
||||||
|
await loadStyle(`http://localhost:8090${stylesheet}`);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginStore.registerPlugin(plugin);
|
pluginStore.registerPlugin(plugin);
|
||||||
|
|
|
@ -13,26 +13,17 @@ import {
|
||||||
VSwitch,
|
VSwitch,
|
||||||
VTag,
|
VTag,
|
||||||
} from "@halo-dev/components";
|
} from "@halo-dev/components";
|
||||||
import { onMounted, ref, watch } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { apiClient } from "@halo-dev/admin-shared";
|
import { apiClient } from "@halo-dev/admin-shared";
|
||||||
import type { Plugin } from "@halo-dev/api-client";
|
import type { Plugin } from "@halo-dev/api-client";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
|
|
||||||
const checkedAll = ref(false);
|
|
||||||
const plugins = ref<Plugin[]>([] as Plugin[]);
|
const plugins = ref<Plugin[]>([] as Plugin[]);
|
||||||
const selectedPlugins = ref<string[]>([]);
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const dialog = useDialog();
|
const dialog = useDialog();
|
||||||
|
|
||||||
watch(
|
|
||||||
() => selectedPlugins.value,
|
|
||||||
(newValue) => {
|
|
||||||
checkedAll.value = newValue.length === plugins.value?.length;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleRouteToDetail = (plugin: Plugin) => {
|
const handleRouteToDetail = (plugin: Plugin) => {
|
||||||
router.push({
|
router.push({
|
||||||
name: "PluginDetail",
|
name: "PluginDetail",
|
||||||
|
@ -75,46 +66,6 @@ const handleChangeStatus = (plugin: Plugin) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCheckedAllChange = () => {
|
|
||||||
if (checkedAll.value) {
|
|
||||||
selectedPlugins.value = plugins.value.map((plugin) => plugin.metadata.name);
|
|
||||||
} else {
|
|
||||||
selectedPlugins.value.length = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleChangeStatusInBatch = (enable: boolean) => {
|
|
||||||
const pluginsToUpdate = plugins.value.filter(
|
|
||||||
(plugin) =>
|
|
||||||
selectedPlugins.value.includes(plugin.metadata.name) &&
|
|
||||||
plugin.spec.enabled !== enable
|
|
||||||
);
|
|
||||||
|
|
||||||
if (pluginsToUpdate.length === 0) {
|
|
||||||
alert("没有需要更新的插件");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.warning({
|
|
||||||
title: `确定要${enable ? "启动" : "停止"}所选插件吗?`,
|
|
||||||
onConfirm: async () => {
|
|
||||||
try {
|
|
||||||
for (const plugin of pluginsToUpdate) {
|
|
||||||
plugin.spec.enabled = enable;
|
|
||||||
await apiClient.extension.plugin.updatepluginHaloRunV1alpha1Plugin(
|
|
||||||
plugin.metadata.name,
|
|
||||||
plugin
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
} finally {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(handleFetchPlugins);
|
onMounted(handleFetchPlugins);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
@ -139,35 +90,8 @@ onMounted(handleFetchPlugins);
|
||||||
<div
|
<div
|
||||||
class="relative flex flex-col items-start sm:flex-row sm:items-center"
|
class="relative flex flex-col items-start sm:flex-row sm:items-center"
|
||||||
>
|
>
|
||||||
<div class="mr-4 hidden items-center sm:flex">
|
|
||||||
<input
|
|
||||||
v-model="checkedAll"
|
|
||||||
class="h-4 w-4 rounded border-gray-300 text-indigo-600"
|
|
||||||
type="checkbox"
|
|
||||||
@change="handleCheckedAllChange"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex w-full flex-1 sm:w-auto">
|
<div class="flex w-full flex-1 sm:w-auto">
|
||||||
<FormKit
|
<FormKit placeholder="输入关键词搜索" type="text"></FormKit>
|
||||||
v-if="!selectedPlugins.length"
|
|
||||||
placeholder="输入关键词搜索"
|
|
||||||
type="text"
|
|
||||||
></FormKit>
|
|
||||||
<VSpace v-else>
|
|
||||||
<VButton
|
|
||||||
type="default"
|
|
||||||
@click="handleChangeStatusInBatch(true)"
|
|
||||||
>
|
|
||||||
启用
|
|
||||||
</VButton>
|
|
||||||
<VButton
|
|
||||||
type="default"
|
|
||||||
@click="handleChangeStatusInBatch(false)"
|
|
||||||
>
|
|
||||||
禁用
|
|
||||||
</VButton>
|
|
||||||
<VButton type="danger">卸载</VButton>
|
|
||||||
</VSpace>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4 flex sm:mt-0">
|
<div class="mt-4 flex sm:mt-0">
|
||||||
<VSpace spacing="lg">
|
<VSpace spacing="lg">
|
||||||
|
@ -294,24 +218,9 @@ onMounted(handleFetchPlugins);
|
||||||
<ul class="box-border h-full w-full divide-y divide-gray-100" role="list">
|
<ul class="box-border h-full w-full divide-y divide-gray-100" role="list">
|
||||||
<li v-for="(plugin, index) in plugins" :key="index">
|
<li v-for="(plugin, index) in plugins" :key="index">
|
||||||
<div
|
<div
|
||||||
:class="{
|
|
||||||
'bg-gray-100': selectedPlugins.includes(plugin.metadata.name),
|
|
||||||
}"
|
|
||||||
class="relative block cursor-pointer px-4 py-3 transition-all hover:bg-gray-50"
|
class="relative block cursor-pointer px-4 py-3 transition-all hover:bg-gray-50"
|
||||||
>
|
>
|
||||||
<div
|
|
||||||
v-show="selectedPlugins.includes(plugin.metadata.name)"
|
|
||||||
class="absolute inset-y-0 left-0 w-0.5 bg-themeable-primary"
|
|
||||||
></div>
|
|
||||||
<div class="relative flex flex-row items-center">
|
<div class="relative flex flex-row items-center">
|
||||||
<div class="mr-4 hidden items-center sm:flex">
|
|
||||||
<input
|
|
||||||
v-model="selectedPlugins"
|
|
||||||
:value="plugin.metadata.name"
|
|
||||||
class="h-4 w-4 rounded border-gray-300 text-indigo-600"
|
|
||||||
type="checkbox"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div v-if="plugin.spec.logo" class="mr-4">
|
<div v-if="plugin.spec.logo" class="mr-4">
|
||||||
<div
|
<div
|
||||||
class="h-12 w-12 rounded border bg-white p-1 hover:shadow-sm"
|
class="h-12 w-12 rounded border bg-white p-1 hover:shadow-sm"
|
||||||
|
|
Loading…
Reference in New Issue