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