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