From ccaeaf9ee170ebdd46c5446f9e625afbc7fec88d Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 27 Jan 2021 20:52:10 +0300 Subject: [PATCH] Generate routes from tabs that are kept in localStorage --- package.json | 2 +- src/router/index.js | 15 ++++++++++++-- .../layout/components/Sidebar/SidebarItem.vue | 20 ++++++++++--------- yarn.lock | 8 ++++---- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 48f9ac1b..4cafe400 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "vue": "^2.6.8", "vue-count-to": "1.0.13", "vue-i18n": "^8.9.0", - "vue-router": "3.0.2", + "vue-router": "^3.5.1", "vue-splitpane": "1.0.2", "vuedraggable": "^2.16.0", "vuex": "3.0.1", diff --git a/src/router/index.js b/src/router/index.js index 4c27af91..c682264d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -8,14 +8,25 @@ import Layout from '@/views/layout/Layout' const disabledFeatures = process.env.DISABLED_FEATURES || [] const settingsDisabled = disabledFeatures.includes('settings') +const settingsChildren = () => { + const items = localStorage.getItem('settingsTabs') || [] + return JSON.parse(items).map(({ label, value }) => { + return { + path: value, + component: () => import(`@/views/settings/components/${label}`), + name: label, + meta: { title: label } + } + }) +} const settings = { path: '/settings', component: Layout, name: 'Settings', hasSubmenu: true, - meta: { title: 'settings', icon: 'settings', noCache: true } + meta: { title: 'settings', icon: 'settings', noCache: true }, + children: settingsChildren() } - const statusesDisabled = disabledFeatures.includes('statuses') const statuses = { path: '/statuses', diff --git a/src/views/layout/components/Sidebar/SidebarItem.vue b/src/views/layout/components/Sidebar/SidebarItem.vue index 3ef7d723..75b3d58c 100644 --- a/src/views/layout/components/Sidebar/SidebarItem.vue +++ b/src/views/layout/components/Sidebar/SidebarItem.vue @@ -1,6 +1,7 @@