2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2023-01-06 13:40:17 +09:00
|
|
|
<div class="_gaps_m">
|
2023-03-20 20:21:54 +09:00
|
|
|
<FormSlot>
|
2022-07-14 17:42:12 +09:00
|
|
|
<template #label>{{ i18n.ts.navbar }}</template>
|
2023-03-20 20:21:54 +09:00
|
|
|
<MkContainer :show-header="false">
|
|
|
|
<Sortable
|
|
|
|
v-model="items"
|
|
|
|
:animation="150"
|
|
|
|
class="navbar_items"
|
|
|
|
handle=".item_handle"
|
|
|
|
@start="e=>e.item.classList.add('active')"
|
|
|
|
@end="e=>e.item.classList.remove('active')"
|
|
|
|
>
|
|
|
|
<template #item="{element,index}">
|
|
|
|
<div
|
|
|
|
v-if="element === '-' || navbarItemDef[element]"
|
|
|
|
class="item"
|
|
|
|
>
|
|
|
|
<button class="item_handle _button" ><i class="ti ti-menu"></i></button>
|
|
|
|
<i class="icon ti-fw" :class="navbarItemDef[element]?.icon"></i><span class="text">{{ navbarItemDef[element]?.title ?? i18n.ts.divider }}</span>
|
|
|
|
<button class="navbar_item_remove _button" @click="removeItem(index)"><i class="ti ti-trash"></i></button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Sortable>
|
|
|
|
</MkContainer>
|
|
|
|
</FormSlot>
|
|
|
|
<div class="_buttons">
|
|
|
|
<MkButton @click="addItem">{{ i18n.ts.addItem }}</MkButton>
|
|
|
|
<MkButton danger @click="reset"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</MkButton>
|
|
|
|
<MkButton primary class="save" @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
|
|
|
</div>
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2023-01-07 15:09:46 +09:00
|
|
|
<MkRadios v-model="menuDisplay">
|
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に表示する必要があり面倒 -->
|
2023-01-07 15:09:46 +09:00
|
|
|
</MkRadios>
|
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>
|
2023-03-20 20:21:54 +09:00
|
|
|
import { computed, defineAsyncComponent, ref, watch } from 'vue';
|
2023-01-07 15:09:46 +09:00
|
|
|
import MkRadios from '@/components/MkRadios.vue';
|
2023-01-06 09:41:14 +09:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-03-20 20:21:54 +09:00
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
|
|
|
import MkContainer from '@/components/MkContainer.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';
|
2023-03-20 20:21:54 +09:00
|
|
|
import { deepClone } from '@/scripts/clone';
|
|
|
|
|
|
|
|
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2023-03-20 20:21:54 +09:00
|
|
|
const items = ref(deepClone(defaultStore.state.menu));
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
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 => ({
|
2023-01-05 13:59:48 +09:00
|
|
|
value: k, text: 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;
|
2023-03-20 20:21:54 +09:00
|
|
|
items.value = [...items.value, item];
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeItem(index: number) {
|
|
|
|
items.value.splice(index, 1);
|
2022-05-04 10:12:40 +09:00
|
|
|
}
|
2021-07-19 11:36:35 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
async function save() {
|
2023-03-20 20:21:54 +09:00
|
|
|
defaultStore.set('menu', items.value);
|
2022-05-04 10:12:40 +09:00
|
|
|
await reloadAsk();
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-04 10:12:40 +09:00
|
|
|
function reset() {
|
2023-03-20 20:21:54 +09:00
|
|
|
items.value = defaultStore.def.menu.default;
|
2022-05-04 10:12:40 +09:00
|
|
|
}
|
2020-10-17 20:12:00 +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-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-list',
|
2020-10-17 20:12:00 +09:00
|
|
|
});
|
|
|
|
</script>
|
2023-03-20 20:21:54 +09:00
|
|
|
<style lang="scss">
|
|
|
|
.navbar_items {
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
.item {
|
|
|
|
position: relative;
|
|
|
|
display: block;
|
|
|
|
line-height: 2.85rem;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
width: 100%;
|
|
|
|
text-align: left;
|
|
|
|
box-sizing: border-box;
|
|
|
|
color: var(--navFg);
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
position: relative;
|
|
|
|
width: 32px;
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.text {
|
|
|
|
position: relative;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.navbar_item_remove {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 10000;
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
color: #ff2a2a;
|
|
|
|
right: 8px;
|
|
|
|
opacity: 0.8;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item_handle{
|
|
|
|
cursor: move;
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
margin: 0 8px;
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
text-decoration: none;
|
|
|
|
color: var(--accent);
|
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
aspect-ratio: 1;
|
|
|
|
margin: auto;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
border-radius: 999px;
|
|
|
|
background: var(--accentedBg);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .icon, > .text {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|