From d9858b03c93c57b3cb7b0cec19e8b0b3c0572334 Mon Sep 17 00:00:00 2001
From: syuilo <4439005+syuilo@users.noreply.github.com>
Date: Mon, 10 Mar 2025 09:28:07 +0900
Subject: enhance(frontend): improve plugin management
---
.../frontend/src/pages/settings/plugin.install.vue | 8 ++-
packages/frontend/src/pages/settings/plugin.vue | 62 +++++++++++++++-------
.../frontend/src/pages/settings/theme.install.vue | 8 ++-
3 files changed, 56 insertions(+), 22 deletions(-)
(limited to 'packages/frontend/src/pages')
diff --git a/packages/frontend/src/pages/settings/plugin.install.vue b/packages/frontend/src/pages/settings/plugin.install.vue
index cf0d7a74c2..915eb8031c 100644
--- a/packages/frontend/src/pages/settings/plugin.install.vue
+++ b/packages/frontend/src/pages/settings/plugin.install.vue
@@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
- {{ i18n.ts.install }}
+ {{ i18n.ts.install }}
@@ -23,11 +23,12 @@ import MkCodeEditor from '@/components/MkCodeEditor.vue';
import MkButton from '@/components/MkButton.vue';
import FormInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js';
-import { unisonReload } from '@/utility/unison-reload.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/utility/page-metadata.js';
import { installPlugin } from '@/plugin.js';
+import { useRouter } from '@/router/supplier.js';
+const router = useRouter();
const code = ref(null);
async function install() {
@@ -36,6 +37,9 @@ async function install() {
try {
await installPlugin(code.value);
os.success();
+ code.value = null;
+
+ router.push('/settings/plugin');
} catch (err) {
os.alert({
type: 'error',
diff --git a/packages/frontend/src/pages/settings/plugin.vue b/packages/frontend/src/pages/settings/plugin.vue
index efe1fdc20d..32c35e3670 100644
--- a/packages/frontend/src/pages/settings/plugin.vue
+++ b/packages/frontend/src/pages/settings/plugin.vue
@@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -59,23 +59,27 @@ SPDX-License-Identifier: AGPL-3.0-only
-
-
- {{ i18n.ts._plugin.viewLog }}
-
-
-
-
-
-
-
-
- {{ i18n.ts._plugin.viewSource }}
-
-
-
-
-
+
+
+
+ {{ i18n.ts.logs }}
+
+
+
+
{{ timeToHhMmSs(log.at) }} {{ log.message }}
+
+
+
+
+
+
+ {{ i18n.ts._plugin.viewSource }}
+
+
+
+
+
+
@@ -98,11 +102,20 @@ import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/utility/page-metadata.js';
import { changePluginActive, configPlugin, pluginLogs, uninstallPlugin, reloadPlugin } from '@/plugin.js';
import { prefer } from '@/preferences.js';
+import * as os from '@/os.js';
const plugins = prefer.r.plugins;
async function uninstall(plugin: Plugin) {
+ const { canceled } = await os.confirm({
+ type: 'warning',
+ text: i18n.tsx.removeAreYouSure({ x: plugin.name }),
+ });
+ if (canceled) return;
+
await uninstallPlugin(plugin);
+
+ os.success();
}
function reload(plugin: Plugin) {
@@ -117,6 +130,10 @@ function changeActive(plugin: Plugin, active: boolean) {
changePluginActive(plugin, active);
}
+function timeToHhMmSs(unixtime: number) {
+ return new Date(unixtime).toTimeString().split(' ')[0];
+}
+
const headerActions = computed(() => []);
const headerTabs = computed(() => []);
@@ -126,3 +143,12 @@ definePageMetadata(() => ({
icon: 'ti ti-plug',
}));
+
+
diff --git a/packages/frontend/src/pages/settings/theme.install.vue b/packages/frontend/src/pages/settings/theme.install.vue
index c731f343e2..92f4893f1a 100644
--- a/packages/frontend/src/pages/settings/theme.install.vue
+++ b/packages/frontend/src/pages/settings/theme.install.vue
@@ -10,8 +10,8 @@ SPDX-License-Identifier: AGPL-3.0-only
- previewTheme(installThemeCode)"> {{ i18n.ts.preview }}
- install(installThemeCode)"> {{ i18n.ts.install }}
+ previewTheme(installThemeCode)"> {{ i18n.ts.preview }}
+ install(installThemeCode)"> {{ i18n.ts.install }}
@@ -24,7 +24,9 @@ import { parseThemeCode, previewTheme, installTheme } from '@/theme.js';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/utility/page-metadata.js';
+import { useRouter } from '@/router/supplier.js';
+const router = useRouter();
const installThemeCode = ref(null);
async function install(code: string): Promise {
@@ -35,6 +37,8 @@ async function install(code: string): Promise {
type: 'success',
text: i18n.tsx._theme.installed({ name: theme.name }),
});
+ installThemeCode.value = null;
+ router.push('/settings/theme');
} catch (err) {
switch (err.message.toLowerCase()) {
case 'this theme is already installed':
--
cgit v1.2.3-freya