2020-10-17 11:12:00 +00:00
|
|
|
<template>
|
2023-01-06 04:40:17 +00:00
|
|
|
<div class="_gaps_m">
|
2023-01-07 06:09:46 +00:00
|
|
|
<MkTextarea v-model="items" tall manual-save>
|
2022-07-14 08:42:12 +00:00
|
|
|
<template #label>{{ i18n.ts.navbar }}</template>
|
2022-05-04 01:12:40 +00:00
|
|
|
<template #caption><button class="_textButton" @click="addItem">{{ i18n.ts.addItem }}</button></template>
|
2023-01-07 06:09:46 +00:00
|
|
|
</MkTextarea>
|
2020-11-25 12:31:34 +00:00
|
|
|
|
2023-01-07 06:09:46 +00:00
|
|
|
<MkRadios v-model="menuDisplay">
|
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に表示する必要があり面倒 -->
|
2023-01-07 06:09:46 +00:00
|
|
|
</MkRadios>
|
2020-11-25 12:31:34 +00:00
|
|
|
|
2023-01-06 00:41:14 +00:00
|
|
|
<MkButton danger @click="reset()"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</MkButton>
|
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';
|
2023-01-07 06:09:46 +00:00
|
|
|
import MkTextarea from '@/components/MkTextarea.vue';
|
|
|
|
import MkRadios from '@/components/MkRadios.vue';
|
2023-01-06 00:41:14 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
2022-07-14 08:42:12 +00:00
|
|
|
import { navbarItemDef } from '@/navbar';
|
2021-11-11 17:02:25 +00:00
|
|
|
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() {
|
2022-07-14 08:42:12 +00:00
|
|
|
const menu = Object.keys(navbarItemDef).filter(k => !defaultStore.state.menu.includes(k));
|
2022-05-04 01:12:40 +00:00
|
|
|
const { canceled, result: item } = await os.select({
|
|
|
|
title: i18n.ts.addItem,
|
|
|
|
items: [...menu.map(k => ({
|
2023-01-05 04:59:48 +00:00
|
|
|
value: k, text: navbarItemDef[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({
|
2022-07-14 08:42:12 +00:00
|
|
|
title: i18n.ts.navbar,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-list',
|
2020-10-17 11:12:00 +00:00
|
|
|
});
|
|
|
|
</script>
|