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

---
 packages/frontend/src/pages/settings/plugin.vue | 62 ++++++++++++++++++-------
 1 file changed, 44 insertions(+), 18 deletions(-)

(limited to 'packages/frontend/src/pages/settings/plugin.vue')

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
 				<MkFolder v-for="plugin in plugins" :key="plugin.installId">
 					<template #icon><i class="ti ti-plug"></i></template>
 					<template #suffix>
-						<i v-if="plugin.active" class="ti ti-player-play" style="color: var(--MI_THEME-accent);"></i>
+						<i v-if="plugin.active" class="ti ti-player-play" style="color: var(--MI_THEME-success);"></i>
 						<i v-else class="ti ti-player-pause" style="opacity: 0.7;"></i>
 					</template>
 					<template #label>
@@ -59,23 +59,27 @@ SPDX-License-Identifier: AGPL-3.0-only
 							</MkKeyValue>
 						</div>
 
-						<MkFolder>
-							<template #icon><i class="ti ti-terminal-2"></i></template>
-							<template #label>{{ i18n.ts._plugin.viewLog }}</template>
-
-							<div class="_gaps_s">
-								<MkCode :code="pluginLogs.get(plugin.installId)?.join('\n') ?? ''"/>
-							</div>
-						</MkFolder>
-
-						<MkFolder>
-							<template #icon><i class="ti ti-code"></i></template>
-							<template #label>{{ i18n.ts._plugin.viewSource }}</template>
-
-							<div class="_gaps_s">
-								<MkCode :code="plugin.src ?? ''" lang="ais"/>
-							</div>
-						</MkFolder>
+						<div class="_gaps_s">
+							<MkFolder>
+								<template #icon><i class="ti ti-terminal-2"></i></template>
+								<template #label>{{ i18n.ts.logs }}</template>
+
+								<div>
+									<div v-for="log in pluginLogs.get(plugin.installId)" :class="[$style.log, { [$style.isSystemLog]: log.isSystem }]">
+										<div class="_monospace">{{ timeToHhMmSs(log.at) }} {{ log.message }}</div>
+									</div>
+								</div>
+							</MkFolder>
+
+							<MkFolder :withSpacer="false">
+								<template #icon><i class="ti ti-code"></i></template>
+								<template #label>{{ i18n.ts._plugin.viewSource }}</template>
+
+								<div class="_gaps_s">
+									<MkCode :code="plugin.src ?? ''" lang="ais"/>
+								</div>
+							</MkFolder>
+						</div>
 					</div>
 				</MkFolder>
 			</div>
@@ -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',
 }));
 </script>
+
+<style module>
+.log {
+}
+
+.isSystemLog {
+	opacity: 0.5;
+}
+</style>
-- 
cgit v1.2.3-freya

