2021-02-06 13:05:00 +01:00
|
|
|
<template>
|
|
|
|
<FormBase>
|
|
|
|
<FormGroup v-for="plugin in plugins" :key="plugin.id">
|
2021-02-07 10:11:56 +01:00
|
|
|
<template #label><span style="display: flex;"><b>{{ plugin.name }}</b><span style="margin-left: auto;">v{{ plugin.version }}</span></span></template>
|
2021-02-06 13:05:00 +01:00
|
|
|
|
2021-11-18 16:38:20 +01:00
|
|
|
<FormSwitch :modelValue="plugin.active" @update:modelValue="changeActive(plugin, $event)">{{ $ts.makeActive }}</FormSwitch>
|
2021-09-29 17:50:45 +02:00
|
|
|
<div class="_debobigegoItem">
|
|
|
|
<div class="_debobigegoPanel" style="padding: 16px;">
|
2021-02-06 13:05:00 +01:00
|
|
|
<div class="_keyValue">
|
|
|
|
<div>{{ $ts.author }}:</div>
|
|
|
|
<div>{{ plugin.author }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="_keyValue">
|
|
|
|
<div>{{ $ts.description }}:</div>
|
|
|
|
<div>{{ plugin.description }}</div>
|
|
|
|
</div>
|
2021-02-07 10:11:56 +01:00
|
|
|
<div class="_keyValue">
|
|
|
|
<div>{{ $ts.permission }}:</div>
|
|
|
|
<div>{{ plugin.permissions }}</div>
|
|
|
|
</div>
|
2021-02-06 13:05:00 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-29 17:50:45 +02:00
|
|
|
<div class="_debobigegoItem">
|
|
|
|
<div class="_debobigegoPanel" style="padding: 16px;">
|
2021-11-19 11:36:12 +01:00
|
|
|
<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>
|
2021-02-06 13:05:00 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</FormGroup>
|
|
|
|
</FormBase>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkTextarea from '@/components/form/textarea.vue';
|
|
|
|
import MkSelect from '@/components/form/select.vue';
|
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormBase from '@/components/debobigego/base.vue';
|
|
|
|
import FormGroup from '@/components/debobigego/group.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { ColdDeviceStorage } from '@/store';
|
|
|
|
import * as symbols from '@/symbols';
|
2021-11-18 16:38:20 +01:00
|
|
|
import { unisonReload } from '@/scripts/unison-reload';
|
2021-02-06 13:05:00 +01:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkTextarea,
|
|
|
|
MkSelect,
|
|
|
|
FormSwitch,
|
|
|
|
FormBase,
|
|
|
|
FormGroup,
|
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 05:54:12 +02:00
|
|
|
[symbols.PAGE_INFO]: {
|
2021-02-06 13:05:00 +01:00
|
|
|
title: this.$ts._plugin.manage,
|
2021-09-29 17:50:45 +02:00
|
|
|
icon: 'fas fa-plug',
|
|
|
|
bg: 'var(--bg)',
|
2021-02-06 13:05:00 +01:00
|
|
|
},
|
|
|
|
plugins: ColdDeviceStorage.get('plugins'),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-04-10 05:54:12 +02:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2021-02-06 13:05:00 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
uninstall(plugin) {
|
|
|
|
ColdDeviceStorage.set('plugins', this.plugins.filter(x => x.id !== plugin.id));
|
|
|
|
os.success();
|
|
|
|
this.$nextTick(() => {
|
2021-02-17 13:36:56 +01:00
|
|
|
unisonReload();
|
2021-02-06 13:05:00 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
</style>
|