2021-02-06 12:05:00 +00:00
|
|
|
<template>
|
2023-01-06 04:40:17 +00:00
|
|
|
<div class="_gaps_m">
|
2022-12-19 10:01:30 +00:00
|
|
|
<FormLink to="/settings/plugin/install"><template #icon><i class="ti ti-download"></i></template>{{ i18n.ts._plugin.install }}</FormLink>
|
2022-01-04 08:52:44 +00:00
|
|
|
|
|
|
|
<FormSection>
|
2022-05-04 01:11:35 +00:00
|
|
|
<template #label>{{ i18n.ts.manage }}</template>
|
2023-02-24 23:58:51 +00:00
|
|
|
<div class="_gaps_s">
|
|
|
|
<div v-for="plugin in plugins" :key="plugin.id" class="_panel _gaps_s" style="padding: 20px;">
|
|
|
|
<span style="display: flex;"><b>{{ plugin.name }}</b><span style="margin-left: auto;">v{{ plugin.version }}</span></span>
|
|
|
|
|
|
|
|
<MkSwitch :model-value="plugin.active" @update:model-value="changeActive(plugin, $event)">{{ i18n.ts.makeActive }}</MkSwitch>
|
|
|
|
|
|
|
|
<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>{{ plugin.permission }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
|
|
|
|
<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>
|
2022-01-04 08:52:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2021-02-06 12:05:00 +00:00
|
|
|
</template>
|
|
|
|
|
2022-05-04 01:11:35 +00:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 08:38:49 +00:00
|
|
|
import { nextTick, ref } from 'vue';
|
2022-01-04 08:52:44 +00:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
2023-01-07 05:59:54 +00:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2022-01-04 08:52:44 +00:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2022-09-06 09:21:49 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2022-08-30 15:24:33 +00:00
|
|
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { ColdDeviceStorage } from '@/store';
|
2022-05-04 01:11:35 +00:00
|
|
|
import { unisonReload } from '@/scripts/unison-reload';
|
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 08:38:49 +00:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-05-04 01:11:35 +00: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();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 08:38:49 +00:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.plugins,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-plug',
|
2021-02-06 12:05:00 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2022-12-27 09:29:39 +00:00
|
|
|
<style lang="scss" scoped>
|
2021-02-06 12:05:00 +00:00
|
|
|
|
|
|
|
</style>
|