2020-10-17 06:12:00 -05:00
|
|
|
<template>
|
2021-11-28 05:07:37 -06:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormTextarea v-model="items" tall manual-save class="_formBlock">
|
|
|
|
<template #label>{{ $ts.menu }}</template>
|
|
|
|
<template #caption><button class="_textButton" @click="addItem">{{ $ts.addItem }}</button></template>
|
2020-11-25 06:31:34 -06:00
|
|
|
</FormTextarea>
|
|
|
|
|
2021-11-28 05:07:37 -06:00
|
|
|
<FormRadios v-model="menuDisplay" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.display }}</template>
|
2021-07-18 21:36:35 -05: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 06:31:34 -06:00
|
|
|
</FormRadios>
|
|
|
|
|
2021-11-28 05:07:37 -06:00
|
|
|
<FormButton danger class="_formBlock" @click="reset()"><i class="fas fa-redo"></i> {{ $ts.default }}</FormButton>
|
|
|
|
</div>
|
2020-10-17 06:12:00 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-11-28 05:07:37 -06:00
|
|
|
import FormTextarea from '@/components/form/textarea.vue';
|
|
|
|
import FormRadios from '@/components/form/radios.vue';
|
|
|
|
import FormButton from '@/components/ui/button.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { menuDef } from '@/menu';
|
|
|
|
import { defaultStore } from '@/store';
|
|
|
|
import * as symbols from '@/symbols';
|
|
|
|
import { unisonReload } from '@/scripts/unison-reload';
|
2020-10-17 06:12:00 -05:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 06:31:34 -06:00
|
|
|
FormButton,
|
|
|
|
FormTextarea,
|
|
|
|
FormRadios,
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 22:54:12 -05:00
|
|
|
[symbols.PAGE_INFO]: {
|
2021-07-18 21:36:35 -05:00
|
|
|
title: this.$ts.menu,
|
2021-09-29 10:50:45 -05:00
|
|
|
icon: 'fas fa-list-ul',
|
|
|
|
bg: 'var(--bg)',
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
2021-07-18 21:36:35 -05:00
|
|
|
menuDef: menuDef,
|
|
|
|
items: defaultStore.state.menu.join('\n'),
|
2020-10-17 06:12:00 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
splited(): string[] {
|
|
|
|
return this.items.trim().split('\n').filter(x => x.trim() !== '');
|
|
|
|
},
|
|
|
|
|
2021-07-18 21:36:35 -05:00
|
|
|
menuDisplay: defaultStore.makeGetterSetter('menuDisplay')
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
|
2021-07-18 21:36:35 -05:00
|
|
|
watch: {
|
|
|
|
menuDisplay() {
|
|
|
|
this.reloadAsk();
|
|
|
|
},
|
|
|
|
|
|
|
|
items() {
|
|
|
|
this.save();
|
|
|
|
},
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-04-09 22:54:12 -05:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async addItem() {
|
2020-12-18 19:55:52 -06:00
|
|
|
const menu = Object.keys(this.menuDef).filter(k => !this.$store.state.menu.includes(k));
|
2021-11-18 03:45:58 -06:00
|
|
|
const { canceled, result: item } = await os.select({
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.addItem,
|
2021-11-18 03:45:58 -06:00
|
|
|
items: [...menu.map(k => ({
|
|
|
|
value: k, text: this.$ts[this.menuDef[k].title]
|
|
|
|
})), ...[{
|
|
|
|
value: '-', text: this.$ts.divider
|
|
|
|
}]]
|
2020-10-17 06:12:00 -05:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
this.items = [...this.splited, item].join('\n');
|
|
|
|
},
|
|
|
|
|
|
|
|
save() {
|
2020-12-18 19:55:52 -06:00
|
|
|
this.$store.set('menu', this.splited);
|
2020-12-29 06:08:16 -06:00
|
|
|
this.reloadAsk();
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
reset() {
|
2020-12-18 19:55:52 -06:00
|
|
|
this.$store.reset('menu');
|
|
|
|
this.items = this.$store.state.menu.join('\n');
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
2020-12-29 06:08:16 -06:00
|
|
|
|
|
|
|
async reloadAsk() {
|
2021-11-18 03:45:58 -06:00
|
|
|
const { canceled } = await os.confirm({
|
2020-12-29 06:08:16 -06:00
|
|
|
type: 'info',
|
|
|
|
text: this.$ts.reloadToApplySetting,
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2021-07-13 09:30:36 -05:00
|
|
|
unisonReload();
|
2020-12-29 06:08:16 -06:00
|
|
|
}
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|