1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<SearchMarker path="/settings/plugin" :label="i18n.ts.plugins" :keywords="['plugin', 'addon', 'extension']" icon="ti ti-plug">
<div class="_gaps_m">
<MkFeatureBanner icon="/client-assets/electric_plug_3d.png" color="#ffbb00">
<SearchKeyword>{{ i18n.ts._settings.pluginBanner }}</SearchKeyword>
</MkFeatureBanner>
<FormLink to="/settings/plugin/install"><template #icon><i class="ti ti-download"></i></template>{{ i18n.ts._plugin.install }}</FormLink>
<FormSection>
<template #label>{{ i18n.ts.manage }}</template>
<div class="_gaps_s">
<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-success);"></i>
<i v-else class="ti ti-player-pause" style="opacity: 0.7;"></i>
</template>
<template #label>
<div :style="plugin.active ? '' : 'opacity: 0.7;'">
{{ plugin.name }}
<span style="margin-left: 1em; opacity: 0.7;">v{{ plugin.version }}</span>
</div>
</template>
<template #caption>
{{ plugin.description }}
</template>
<template #footer>
<div class="_buttons">
<MkButton :disabled="!plugin.active" @click="reload(plugin)"><i class="ti ti-refresh"></i> {{ i18n.ts.reload }}</MkButton>
<MkButton danger @click="uninstall(plugin)"><i class="ti ti-trash"></i> {{ i18n.ts.uninstall }}</MkButton>
<MkButton v-if="plugin.config" style="margin-left: auto;" @click="config(plugin)"><i class="ti ti-settings"></i> {{ i18n.ts.settings }}</MkButton>
</div>
</template>
<div class="_gaps_m">
<div class="_gaps_s">
<MkSwitch :modelValue="plugin.active" @update:modelValue="changeActive(plugin, $event)">{{ i18n.ts.makeActive }}</MkSwitch>
</div>
<div class="_gaps_s">
<MkKeyValue>
<template #key>{{ i18n.ts.author }}</template>
<template #value>{{ plugin.author }}</template>
</MkKeyValue>
<MkKeyValue>
<template #key>{{ i18n.ts.description }}</template>
<template #value>{{ plugin.description }}</template>
</MkKeyValue>
<MkKeyValue>
<template #key>{{ i18n.ts.permission }}</template>
<template #value>
<ul style="margin-top: 0; margin-bottom: 0;">
<li v-for="permission in plugin.permissions" :key="permission">{{ i18n.ts._permissions[permission] }}</li>
<li v-if="!plugin.permissions || plugin.permissions.length === 0">{{ i18n.ts.none }}</li>
</ul>
</template>
</MkKeyValue>
</div>
<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>
</FormSection>
</div>
</SearchMarker>
</template>
<script lang="ts" setup>
import { nextTick, ref, computed } from 'vue';
import type { Plugin } from '@/plugin.js';
import FormLink from '@/components/form/link.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import FormSection from '@/components/form/section.vue';
import MkButton from '@/components/MkButton.vue';
import MkCode from '@/components/MkCode.vue';
import MkFolder from '@/components/MkFolder.vue';
import MkKeyValue from '@/components/MkKeyValue.vue';
import MkFeatureBanner from '@/components/MkFeatureBanner.vue';
import { i18n } from '@/i18n.js';
import { definePage } from '@/page.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) {
reloadPlugin(plugin);
}
async function config(plugin: Plugin) {
await configPlugin(plugin);
}
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(() => []);
definePage(() => ({
title: i18n.ts.plugins,
icon: 'ti ti-plug',
}));
</script>
<style module>
.log {
}
.isSystemLog {
opacity: 0.5;
}
</style>
|