diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-10 09:28:07 +0900 |
|---|---|---|
| committer | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-10 09:28:07 +0900 |
| commit | d9858b03c93c57b3cb7b0cec19e8b0b3c0572334 (patch) | |
| tree | 0c90a0754c6a424a2d9ce122854938b67f6be4b1 /packages/frontend/src/pages | |
| parent | fix(dev): 検索インデックス対象ファイルでHMRが効かない問... (diff) | |
| download | sharkey-d9858b03c93c57b3cb7b0cec19e8b0b3c0572334.tar.gz sharkey-d9858b03c93c57b3cb7b0cec19e8b0b3c0572334.tar.bz2 sharkey-d9858b03c93c57b3cb7b0cec19e8b0b3c0572334.zip | |
enhance(frontend): improve plugin management
Diffstat (limited to 'packages/frontend/src/pages')
| -rw-r--r-- | packages/frontend/src/pages/settings/plugin.install.vue | 8 | ||||
| -rw-r--r-- | packages/frontend/src/pages/settings/plugin.vue | 56 | ||||
| -rw-r--r-- | packages/frontend/src/pages/settings/theme.install.vue | 8 |
3 files changed, 53 insertions, 19 deletions
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 </MkCodeEditor> <div> - <MkButton :disabled="code == null" primary inline @click="install"><i class="ti ti-check"></i> {{ i18n.ts.install }}</MkButton> + <MkButton :disabled="code == null || code.trim() === ''" primary inline @click="install"><i class="ti ti-check"></i> {{ i18n.ts.install }}</MkButton> </div> </div> </template> @@ -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<string | null>(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 <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"> + <MkFolder> + <template #icon><i class="ti ti-terminal-2"></i></template> + <template #label>{{ i18n.ts.logs }}</template> - <div class="_gaps_s"> - <MkCode :code="pluginLogs.get(plugin.installId)?.join('\n') ?? ''"/> - </div> - </MkFolder> + <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> - <template #icon><i class="ti ti-code"></i></template> - <template #label>{{ i18n.ts._plugin.viewSource }}</template> + <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 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> 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 </MkCodeEditor> <div class="_buttons"> - <MkButton :disabled="installThemeCode == null" inline @click="() => previewTheme(installThemeCode)"><i class="ti ti-eye"></i> {{ i18n.ts.preview }}</MkButton> - <MkButton :disabled="installThemeCode == null" primary inline @click="() => install(installThemeCode)"><i class="ti ti-check"></i> {{ i18n.ts.install }}</MkButton> + <MkButton :disabled="installThemeCode == null || installThemeCode.trim() === ''" inline @click="() => previewTheme(installThemeCode)"><i class="ti ti-eye"></i> {{ i18n.ts.preview }}</MkButton> + <MkButton :disabled="installThemeCode == null || installThemeCode.trim() === ''" primary inline @click="() => install(installThemeCode)"><i class="ti ti-check"></i> {{ i18n.ts.install }}</MkButton> </div> </div> </template> @@ -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<string | null>(null); async function install(code: string): Promise<void> { @@ -35,6 +37,8 @@ async function install(code: string): Promise<void> { 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': |