2020-10-17 11:12:00 +00:00
|
|
|
<template>
|
2021-11-28 11:07:37 +00:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormTextarea v-model="items" tall manual-save class="_formBlock">
|
2022-05-04 01:12:40 +00:00
|
|
|
<template #label>{{ i18n.ts.menu }}</template>
|
|
|
|
<template #caption><button class="_textButton" @click="addItem">{{ i18n.ts.addItem }}</button></template>
|
2020-11-25 12:31:34 +00:00
|
|
|
</FormTextarea>
|
|
|
|
|
2021-11-28 11:07:37 +00:00
|
|
|
<FormRadios v-model="menuDisplay" class="_formBlock">
|
2022-05-04 01:12:40 +00:00
|
|
|
<template #label>{{ i18n.ts.display }}</template>
|
|
|
|
<option value="sideFull">{{ i18n.ts._menuDisplay.sideFull }}</option>
|
|
|
|
<option value="sideIcon">{{ i18n.ts._menuDisplay.sideIcon }}</option>
|
|
|
|
<option value="top">{{ i18n.ts._menuDisplay.top }}</option>
|
|
|
|
<!-- <MkRadio v-model="menuDisplay" value="hide" disabled>{{ i18n.ts._menuDisplay.hide }}</MkRadio>--> <!-- TODO: サイドバーを完全に隠せるようにすると、別途ハンバーガーボタンのようなものをUIに表示する必要があり面倒 -->
|
2020-11-25 12:31:34 +00:00
|
|
|
</FormRadios>
|
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
<FormButton danger class="_formBlock" @click="reset()"><i class="fas fa-redo"></i> {{ i18n.ts.default }}</FormButton>
|
2021-11-28 11:07:37 +00:00
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</template>
|
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 08:38:49 +00:00
|
|
|
import { computed, ref, watch } from 'vue';
|
2021-11-28 11:07:37 +00: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 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { menuDef } from '@/menu';
|
|
|
|
import { defaultStore } from '@/store';
|
|
|
|
import { unisonReload } from '@/scripts/unison-reload';
|
2022-05-04 01:12:40 +00:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 08:38:49 +00:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
const items = ref(defaultStore.state.menu.join('\n'));
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
const split = computed(() => items.value.trim().split('\n').filter(x => x.trim() !== ''));
|
|
|
|
const menuDisplay = computed(defaultStore.makeGetterSetter('menuDisplay'));
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
async function reloadAsk() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'info',
|
2022-06-20 08:38:49 +00:00
|
|
|
text: i18n.ts.reloadToApplySetting,
|
2022-05-04 01:12:40 +00:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
unisonReload();
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
async function addItem() {
|
|
|
|
const menu = Object.keys(menuDef).filter(k => !defaultStore.state.menu.includes(k));
|
|
|
|
const { canceled, result: item } = await os.select({
|
|
|
|
title: i18n.ts.addItem,
|
|
|
|
items: [...menu.map(k => ({
|
2022-06-20 08:38:49 +00:00
|
|
|
value: k, text: i18n.ts[menuDef[k].title],
|
2022-05-04 01:12:40 +00:00
|
|
|
})), {
|
2022-06-20 08:38:49 +00:00
|
|
|
value: '-', text: i18n.ts.divider,
|
|
|
|
}],
|
2022-05-04 01:12:40 +00:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
items.value = [...split.value, item].join('\n');
|
|
|
|
}
|
2021-07-19 02:36:35 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
async function save() {
|
|
|
|
defaultStore.set('menu', split.value);
|
|
|
|
await reloadAsk();
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
function reset() {
|
|
|
|
defaultStore.reset('menu');
|
|
|
|
items.value = defaultStore.state.menu.join('\n');
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
watch(items, async () => {
|
|
|
|
await save();
|
|
|
|
});
|
2020-12-29 12:08:16 +00:00
|
|
|
|
2022-05-04 01:12:40 +00:00
|
|
|
watch(menuDisplay, async () => {
|
|
|
|
await reloadAsk();
|
|
|
|
});
|
2020-12-29 12:08:16 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.menu,
|
|
|
|
icon: 'fas fa-list-ul',
|
2020-10-17 11:12:00 +00:00
|
|
|
});
|
|
|
|
</script>
|