2021-02-06 21:05:00 +09:00
|
|
|
<template>
|
2022-01-04 17:52:44 +09:00
|
|
|
<div class="_formRoot">
|
2021-04-20 23:22:59 +09:00
|
|
|
<FormLink to="/settings/plugin/install"><template #icon><i class="fas fa-download"></i></template>{{ $ts._plugin.install }}</FormLink>
|
2022-01-04 17:52:44 +09:00
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ $ts.manage }}</template>
|
|
|
|
<div v-for="plugin in plugins" :key="plugin.id" class="_formBlock _panel" style="padding: 20px;">
|
|
|
|
<span style="display: flex;"><b>{{ plugin.name }}</b><span style="margin-left: auto;">v{{ plugin.version }}</span></span>
|
|
|
|
|
|
|
|
<FormSwitch class="_formBlock" :modelValue="plugin.active" @update:modelValue="changeActive(plugin, $event)">{{ $ts.makeActive }}</FormSwitch>
|
|
|
|
|
|
|
|
<MkKeyValue class="_formBlock">
|
|
|
|
<template #key>{{ $ts.author }}</template>
|
|
|
|
<template #value>{{ plugin.author }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue class="_formBlock">
|
|
|
|
<template #key>{{ $ts.description }}</template>
|
|
|
|
<template #value>{{ plugin.description }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue class="_formBlock">
|
|
|
|
<template #key>{{ $ts.permission }}</template>
|
|
|
|
<template #value>{{ plugin.permission }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
|
|
|
|
<div style="display: flex; gap: var(--margin); flex-wrap: wrap;">
|
|
|
|
<MkButton v-if="plugin.config" inline @click="config(plugin)"><i class="fas fa-cog"></i> {{ $ts.settings }}</MkButton>
|
|
|
|
<MkButton inline danger @click="uninstall(plugin)"><i class="fas fa-trash-alt"></i> {{ $ts.uninstall }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2021-02-06 21:05:00 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2022-01-04 17:52:44 +09:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkKeyValue from '@/components/key-value.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { ColdDeviceStorage } from '@/store';
|
|
|
|
import * as symbols from '@/symbols';
|
2021-02-06 21:05:00 +09:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
FormLink,
|
2022-01-04 17:52:44 +09:00
|
|
|
FormSwitch,
|
|
|
|
FormSection,
|
|
|
|
MkButton,
|
|
|
|
MkKeyValue,
|
2021-02-06 21:05:00 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 12:54:12 +09:00
|
|
|
[symbols.PAGE_INFO]: {
|
2021-02-06 21:05:00 +09:00
|
|
|
title: this.$ts.plugins,
|
2021-09-30 00:50:45 +09:00
|
|
|
icon: 'fas fa-plug',
|
|
|
|
bg: 'var(--bg)',
|
2021-02-06 21:05:00 +09:00
|
|
|
},
|
2022-01-04 17:52:44 +09:00
|
|
|
plugins: ColdDeviceStorage.get('plugins'),
|
2021-02-06 21:05:00 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-01-04 17:52:44 +09:00
|
|
|
methods: {
|
|
|
|
uninstall(plugin) {
|
|
|
|
ColdDeviceStorage.set('plugins', this.plugins.filter(x => x.id !== plugin.id));
|
|
|
|
os.success();
|
|
|
|
this.$nextTick(() => {
|
|
|
|
unisonReload();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// TODO: この処理をstore側にactionとして移動し、設定画面を開くAiScriptAPIを実装できるようにする
|
|
|
|
async 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 plugins = ColdDeviceStorage.get('plugins');
|
|
|
|
plugins.find(p => p.id === plugin.id).configData = result;
|
|
|
|
ColdDeviceStorage.set('plugins', plugins);
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
changeActive(plugin, active) {
|
|
|
|
const plugins = ColdDeviceStorage.get('plugins');
|
|
|
|
plugins.find(p => p.id === plugin.id).active = active;
|
|
|
|
ColdDeviceStorage.set('plugins', plugins);
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2021-02-06 21:05:00 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
</style>
|