2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2021-02-06 06:05:00 -06:00
|
|
|
<template>
|
2023-01-05 22:40:17 -06:00
|
|
|
<div class="_gaps_m">
|
2022-12-19 04:01:30 -06:00
|
|
|
<FormLink to="/settings/plugin/install"><template #icon><i class="ti ti-download"></i></template>{{ i18n.ts._plugin.install }}</FormLink>
|
2022-01-04 02:52:44 -06:00
|
|
|
|
|
|
|
<FormSection>
|
2022-05-03 20:11:35 -05:00
|
|
|
<template #label>{{ i18n.ts.manage }}</template>
|
2023-02-24 17:58:51 -06:00
|
|
|
<div class="_gaps_s">
|
2023-09-22 19:08:14 -05:00
|
|
|
<div v-for="plugin in plugins" :key="plugin.id" class="_panel _gaps_m" style="padding: 20px;">
|
|
|
|
<div class="_gaps_s">
|
|
|
|
<span style="display: flex; align-items: center;"><b>{{ plugin.name }}</b><span style="margin-left: auto;">v{{ plugin.version }}</span></span>
|
|
|
|
<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>
|
2023-02-24 17:58:51 -06:00
|
|
|
|
|
|
|
<div class="_buttons">
|
|
|
|
<MkButton v-if="plugin.config" inline @click="config(plugin)"><i class="ti ti-settings"></i> {{ i18n.ts.settings }}</MkButton>
|
|
|
|
<MkButton inline danger @click="uninstall(plugin)"><i class="ti ti-trash"></i> {{ i18n.ts.uninstall }}</MkButton>
|
|
|
|
</div>
|
2023-09-22 19:08:14 -05:00
|
|
|
|
|
|
|
<MkFolder>
|
|
|
|
<template #icon><i class="ti ti-code"></i></template>
|
|
|
|
<template #label>{{ i18n.ts._plugin.viewSource }}</template>
|
|
|
|
|
|
|
|
<div class="_gaps_s">
|
|
|
|
<div class="_buttons">
|
|
|
|
<MkButton inline @click="copy(plugin)"><i class="ti ti-copy"></i> {{ i18n.ts.copy }}</MkButton>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<MkCode :code="plugin.src ?? ''"/>
|
|
|
|
</div>
|
|
|
|
</MkFolder>
|
2022-01-04 02:52:44 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2021-02-06 06:05:00 -06:00
|
|
|
</template>
|
|
|
|
|
2022-05-03 20:11:35 -05:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 03:38:49 -05:00
|
|
|
import { nextTick, ref } from 'vue';
|
2022-01-04 02:52:44 -06:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
2023-01-06 23:59:54 -06:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2022-01-04 02:52:44 -06:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-22 19:08:14 -05:00
|
|
|
import MkCode from '@/components/MkCode.vue';
|
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
2022-08-30 10:24:33 -05:00
|
|
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
2023-09-19 02:37:43 -05:00
|
|
|
import * as os from '@/os.js';
|
2023-09-22 19:08:14 -05:00
|
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { ColdDeviceStorage } from '@/store.js';
|
|
|
|
import { unisonReload } from '@/scripts/unison-reload.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2022-05-03 20:11:35 -05:00
|
|
|
|
|
|
|
const plugins = ref(ColdDeviceStorage.get('plugins'));
|
|
|
|
|
|
|
|
function uninstall(plugin) {
|
|
|
|
ColdDeviceStorage.set('plugins', plugins.value.filter(x => x.id !== plugin.id));
|
|
|
|
os.success();
|
|
|
|
nextTick(() => {
|
|
|
|
unisonReload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-09-22 19:08:14 -05:00
|
|
|
function copy(plugin) {
|
|
|
|
copyToClipboard(plugin.src ?? '');
|
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
2022-05-03 20:11:35 -05:00
|
|
|
// TODO: この処理をstore側にactionとして移動し、設定画面を開くAiScriptAPIを実装できるようにする
|
|
|
|
async function config(plugin) {
|
|
|
|
const config = plugin.config;
|
|
|
|
for (const key in plugin.configData) {
|
|
|
|
config[key].default = plugin.configData[key];
|
|
|
|
}
|
|
|
|
|
|
|
|
const { canceled, result } = await os.form(plugin.name, config);
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
const coldPlugins = ColdDeviceStorage.get('plugins');
|
|
|
|
coldPlugins.find(p => p.id === plugin.id)!.configData = result;
|
|
|
|
ColdDeviceStorage.set('plugins', coldPlugins);
|
|
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeActive(plugin, active) {
|
|
|
|
const coldPlugins = ColdDeviceStorage.get('plugins');
|
|
|
|
coldPlugins.find(p => p.id === plugin.id)!.active = active;
|
|
|
|
ColdDeviceStorage.set('plugins', coldPlugins);
|
|
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.plugins,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-plug',
|
2021-02-06 06:05:00 -06:00
|
|
|
});
|
|
|
|
</script>
|