From dac4fbcb1eb5be0ac8d67a642b5aeefd5ea46041 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 20 Mar 2023 20:35:49 +0900 Subject: [PATCH] tweak settings/navbar.vue --- .../frontend/src/pages/settings/navbar.vue | 136 ++++++++---------- 1 file changed, 57 insertions(+), 79 deletions(-) diff --git a/packages/frontend/src/pages/settings/navbar.vue b/packages/frontend/src/pages/settings/navbar.vue index dc13477268..b3b33b8026 100644 --- a/packages/frontend/src/pages/settings/navbar.vue +++ b/packages/frontend/src/pages/settings/navbar.vue @@ -5,27 +5,27 @@
- {{ i18n.ts.addItem }} + {{ i18n.ts.addItem }} {{ i18n.ts.default }} {{ i18n.ts.save }}
@@ -56,7 +56,10 @@ import { deepClone } from '@/scripts/clone'; const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default)); -const items = ref(deepClone(defaultStore.state.menu)); +const items = ref(defaultStore.state.menu.map(x => ({ + id: Math.random().toString(), + type: x, +}))); const menuDisplay = computed(defaultStore.makeGetterSetter('menuDisplay')); @@ -81,7 +84,10 @@ async function addItem() { }], }); if (canceled) return; - items.value = [...items.value, item]; + items.value = [...items.value, { + id: Math.random().toString(), + type: item, + }]; } function removeItem(index: number) { @@ -89,12 +95,15 @@ function removeItem(index: number) { } async function save() { - defaultStore.set('menu', items.value); + defaultStore.set('menu', items.value.map(x => x.type)); await reloadAsk(); } function reset() { - items.value = defaultStore.def.menu.default; + items.value = defaultStore.def.menu.default.map(x => ({ + id: Math.random().toString(), + type: x, + })); } watch(menuDisplay, async () => { @@ -110,75 +119,44 @@ definePageMetadata({ icon: 'ti ti-list', }); -