2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2021-11-28 20:07:37 +09:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormTextarea v-model="items" tall manual-save class="_formBlock">
|
2022-07-14 17:42:12 +09:00
|
|
|
<template #label>{{ i18n.ts.navbar }}</template>
|
2022-05-04 10:12:40 +09:00
|
|
|
<template #caption><button class="_textButton" @click="addItem">{{ i18n.ts.addItem }}</button></template>
|
2020-11-25 21:31:34 +09:00
|
|
|
</FormTextarea>
|
|
|
|
|
2021-11-28 20:07:37 +09:00
|
|
|
<FormRadios v-model="menuDisplay" class="_formBlock">
|
2022-05-04 10:12:40 +09: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 21:31:34 +09:00
|
|
|
</FormRadios>
|
|
|
|
|
2022-11-07 11:30:26 +09:00
|
|
|
<FormButton danger class="_formBlock" @click="reset()"><i class="ph-arrow-clockwise-bold"></i> {{ i18n.ts.default }}</FormButton>
|
2021-11-28 20:07:37 +09:00
|
|
|
</div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</template>
|
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 17:38:49 +09:00
|
|
|
import { computed, ref, watch } from 'vue';
|
2021-11-28 20:07:37 +09:00
|
|
|
import FormTextarea from '@/components/form/textarea.vue';
|
|
|
|
import FormRadios from '@/components/form/radios.vue';
|
2022-09-06 18:21:49 +09:00
|
|
|
import FormButton from '@/components/MkButton.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2022-07-14 17:42:12 +09:00
|
|
|
import { navbarItemDef } from '@/navbar';
|
2021-11-12 02:02:25 +09:00
|
|
|
import { defaultStore } from '@/store';
|
|
|
|
import { unisonReload } from '@/scripts/unison-reload';
|
2022-05-04 10:12:40 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
const items = ref(defaultStore.state.menu.join('\n'));
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
const split = computed(() => items.value.trim().split('\n').filter(x => x.trim() !== ''));
|
|
|
|
const menuDisplay = computed(defaultStore.makeGetterSetter('menuDisplay'));
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
async function reloadAsk() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'info',
|
2022-06-20 17:38:49 +09:00
|
|
|
text: i18n.ts.reloadToApplySetting,
|
2022-05-04 10:12:40 +09:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
unisonReload();
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
async function addItem() {
|
2022-07-14 17:42:12 +09:00
|
|
|
const menu = Object.keys(navbarItemDef).filter(k => !defaultStore.state.menu.includes(k));
|
2022-05-04 10:12:40 +09:00
|
|
|
const { canceled, result: item } = await os.select({
|
|
|
|
title: i18n.ts.addItem,
|
|
|
|
items: [...menu.map(k => ({
|
2022-07-14 17:42:12 +09:00
|
|
|
value: k, text: i18n.ts[navbarItemDef[k].title],
|
2022-05-04 10:12:40 +09:00
|
|
|
})), {
|
2022-06-20 17:38:49 +09:00
|
|
|
value: '-', text: i18n.ts.divider,
|
|
|
|
}],
|
2022-05-04 10:12:40 +09:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
items.value = [...split.value, item].join('\n');
|
|
|
|
}
|
2021-07-19 11:36:35 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
async function save() {
|
|
|
|
defaultStore.set('menu', split.value);
|
|
|
|
await reloadAsk();
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
function reset() {
|
|
|
|
defaultStore.reset('menu');
|
|
|
|
items.value = defaultStore.state.menu.join('\n');
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
watch(items, async () => {
|
|
|
|
await save();
|
|
|
|
});
|
2020-12-29 21:08:16 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
watch(menuDisplay, async () => {
|
|
|
|
await reloadAsk();
|
|
|
|
});
|
2020-12-29 21:08:16 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
2022-07-14 17:42:12 +09:00
|
|
|
title: i18n.ts.navbar,
|
2022-11-07 11:30:26 +09:00
|
|
|
icon: 'ph-list-bullets-bold',
|
2020-10-17 20:12:00 +09:00
|
|
|
});
|
|
|
|
</script>
|