2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2020-11-25 13:31:34 +01:00
|
|
|
<FormBase>
|
2021-09-29 17:50:45 +02:00
|
|
|
<FormTextarea v-model="items" tall manual-save>
|
2021-07-19 04:36:35 +02:00
|
|
|
<span>{{ $ts.menu }}</span>
|
2020-12-26 02:47:36 +01:00
|
|
|
<template #desc><button class="_textButton" @click="addItem">{{ $ts.addItem }}</button></template>
|
2020-11-25 13:31:34 +01:00
|
|
|
</FormTextarea>
|
|
|
|
|
2021-07-19 04:36:35 +02:00
|
|
|
<FormRadios v-model="menuDisplay">
|
2020-12-26 02:47:36 +01:00
|
|
|
<template #desc>{{ $ts.display }}</template>
|
2021-07-19 04:36:35 +02:00
|
|
|
<option value="sideFull">{{ $ts._menuDisplay.sideFull }}</option>
|
|
|
|
<option value="sideIcon">{{ $ts._menuDisplay.sideIcon }}</option>
|
|
|
|
<option value="top">{{ $ts._menuDisplay.top }}</option>
|
|
|
|
<!-- <MkRadio v-model="menuDisplay" value="hide" disabled>{{ $ts._menuDisplay.hide }}</MkRadio>--> <!-- TODO: サイドバーを完全に隠せるようにすると、別途ハンバーガーボタンのようなものをUIに表示する必要があり面倒 -->
|
2020-11-25 13:31:34 +01:00
|
|
|
</FormRadios>
|
|
|
|
|
2021-04-20 16:22:59 +02:00
|
|
|
<FormButton @click="reset()" danger><i class="fas fa-redo"></i> {{ $ts.default }}</FormButton>
|
2020-11-25 13:31:34 +01:00
|
|
|
</FormBase>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-09-29 17:50:45 +02:00
|
|
|
import FormTextarea from '@client/components/debobigego/textarea.vue';
|
|
|
|
import FormRadios from '@client/components/debobigego/radios.vue';
|
|
|
|
import FormBase from '@client/components/debobigego/base.vue';
|
|
|
|
import FormButton from '@client/components/debobigego/button.vue';
|
2021-03-23 09:30:14 +01:00
|
|
|
import * as os from '@client/os';
|
2021-07-19 04:36:35 +02:00
|
|
|
import { menuDef } from '@client/menu';
|
2021-03-23 09:30:14 +01:00
|
|
|
import { defaultStore } from '@client/store';
|
2021-04-10 05:54:12 +02:00
|
|
|
import * as symbols from '@client/symbols';
|
2021-07-13 16:30:36 +02:00
|
|
|
import { unisonReload } from '@client/scripts/unison-reload';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 13:31:34 +01:00
|
|
|
FormBase,
|
|
|
|
FormButton,
|
|
|
|
FormTextarea,
|
|
|
|
FormRadios,
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 05:54:12 +02:00
|
|
|
[symbols.PAGE_INFO]: {
|
2021-07-19 04:36:35 +02:00
|
|
|
title: this.$ts.menu,
|
2021-09-29 17:50:45 +02:00
|
|
|
icon: 'fas fa-list-ul',
|
|
|
|
bg: 'var(--bg)',
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
2021-07-19 04:36:35 +02:00
|
|
|
menuDef: menuDef,
|
|
|
|
items: defaultStore.state.menu.join('\n'),
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
splited(): string[] {
|
|
|
|
return this.items.trim().split('\n').filter(x => x.trim() !== '');
|
|
|
|
},
|
|
|
|
|
2021-07-19 04:36:35 +02:00
|
|
|
menuDisplay: defaultStore.makeGetterSetter('menuDisplay')
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
2021-07-19 04:36:35 +02:00
|
|
|
watch: {
|
|
|
|
menuDisplay() {
|
|
|
|
this.reloadAsk();
|
|
|
|
},
|
|
|
|
|
|
|
|
items() {
|
|
|
|
this.save();
|
|
|
|
},
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-04-10 05:54:12 +02:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async addItem() {
|
2020-12-19 02:55:52 +01:00
|
|
|
const menu = Object.keys(this.menuDef).filter(k => !this.$store.state.menu.includes(k));
|
2020-10-17 13:12:00 +02:00
|
|
|
const { canceled, result: item } = await os.dialog({
|
|
|
|
type: null,
|
2020-12-26 02:47:36 +01:00
|
|
|
title: this.$ts.addItem,
|
2020-10-17 13:12:00 +02:00
|
|
|
select: {
|
|
|
|
items: [...menu.map(k => ({
|
2020-12-26 07:38:51 +01:00
|
|
|
value: k, text: this.$ts[this.menuDef[k].title]
|
2020-10-17 13:12:00 +02:00
|
|
|
})), ...[{
|
2020-12-26 02:47:36 +01:00
|
|
|
value: '-', text: this.$ts.divider
|
2020-10-17 13:12:00 +02:00
|
|
|
}]]
|
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
this.items = [...this.splited, item].join('\n');
|
|
|
|
},
|
|
|
|
|
|
|
|
save() {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.$store.set('menu', this.splited);
|
2020-12-29 13:08:16 +01:00
|
|
|
this.reloadAsk();
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
reset() {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.$store.reset('menu');
|
|
|
|
this.items = this.$store.state.menu.join('\n');
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
2020-12-29 13:08:16 +01:00
|
|
|
|
|
|
|
async reloadAsk() {
|
|
|
|
const { canceled } = await os.dialog({
|
|
|
|
type: 'info',
|
|
|
|
text: this.$ts.reloadToApplySetting,
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2021-07-13 16:30:36 +02:00
|
|
|
unisonReload();
|
2020-12-29 13:08:16 +01:00
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|