2020-10-17 11:12:00 +00:00
|
|
|
<template>
|
2020-11-25 12:31:34 +00:00
|
|
|
<FormBase>
|
|
|
|
<FormTextarea v-model:value="items" tall>
|
|
|
|
<span>{{ $t('sidebar') }}</span>
|
|
|
|
<template #desc><button class="_textButton" @click="addItem">{{ $t('addItem') }}</button></template>
|
|
|
|
</FormTextarea>
|
|
|
|
|
|
|
|
<FormRadios v-model="sidebarDisplay">
|
|
|
|
<template #desc>{{ $t('display') }}</template>
|
|
|
|
<option value="full">{{ $t('_sidebar.full') }}</option>
|
|
|
|
<option value="icon">{{ $t('_sidebar.icon') }}</option>
|
|
|
|
<!-- <MkRadio v-model="sidebarDisplay" value="hide" disabled>{{ $t('_sidebar.hide') }}</MkRadio>--> <!-- TODO: サイドバーを完全に隠せるようにすると、別途ハンバーガーボタンのようなものをUIに表示する必要があり面倒 -->
|
|
|
|
</FormRadios>
|
|
|
|
|
|
|
|
<FormButton @click="save()" primary><Fa :icon="faSave"/> {{ $t('save') }}</FormButton>
|
|
|
|
<FormButton @click="reset()" danger><Fa :icon="faRedo"/> {{ $t('default') }}</FormButton>
|
|
|
|
</FormBase>
|
2020-10-17 11:12:00 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { faListUl, faSave, faRedo } from '@fortawesome/free-solid-svg-icons';
|
2020-11-25 12:31:34 +00:00
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormTextarea from '@/components/form/textarea.vue';
|
|
|
|
import FormRadios from '@/components/form/radios.vue';
|
|
|
|
import FormBase from '@/components/form/base.vue';
|
|
|
|
import FormGroup from '@/components/form/group.vue';
|
|
|
|
import FormButton from '@/components/form/button.vue';
|
2020-10-17 11:12:00 +00:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { sidebarDef } from '@/sidebar';
|
2020-12-19 01:55:52 +00:00
|
|
|
import { defaultStore } from '@/store';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 12:31:34 +00:00
|
|
|
FormBase,
|
|
|
|
FormButton,
|
|
|
|
FormTextarea,
|
|
|
|
FormRadios,
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
INFO: {
|
2020-11-03 11:36:12 +00:00
|
|
|
title: this.$t('sidebar'),
|
|
|
|
icon: faListUl
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
menuDef: sidebarDef,
|
|
|
|
items: '',
|
|
|
|
faSave, faRedo
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
splited(): string[] {
|
|
|
|
return this.items.trim().split('\n').filter(x => x.trim() !== '');
|
|
|
|
},
|
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
sidebarDisplay: defaultStore.makeGetterSetter('sidebarDisplay')
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-12-19 01:55:52 +00:00
|
|
|
this.items = this.$store.state.menu.join('\n');
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async addItem() {
|
2020-12-19 01:55:52 +00:00
|
|
|
const menu = Object.keys(this.menuDef).filter(k => !this.$store.state.menu.includes(k));
|
2020-10-17 11:12:00 +00:00
|
|
|
const { canceled, result: item } = await os.dialog({
|
|
|
|
type: null,
|
|
|
|
title: this.$t('addItem'),
|
|
|
|
select: {
|
|
|
|
items: [...menu.map(k => ({
|
|
|
|
value: k, text: this.$t(this.menuDef[k].title)
|
|
|
|
})), ...[{
|
|
|
|
value: '-', text: this.$t('divider')
|
|
|
|
}]]
|
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
this.items = [...this.splited, item].join('\n');
|
|
|
|
this.save();
|
|
|
|
},
|
|
|
|
|
|
|
|
save() {
|
2020-12-19 01:55:52 +00:00
|
|
|
this.$store.set('menu', this.splited);
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
reset() {
|
2020-12-19 01:55:52 +00:00
|
|
|
this.$store.reset('menu');
|
|
|
|
this.items = this.$store.state.menu.join('\n');
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|