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