diff --git a/src/accounts.js b/src/accounts.js new file mode 100644 index 0000000..93d0bc3 --- /dev/null +++ b/src/accounts.js @@ -0,0 +1,8 @@ +export function sortAccounts(accounts) { + accounts.value.sort((a, b) => { + const va = `${a.localPart}@${a.domain}`; + const vb = `${b.localPart}@${b.domain}`; + return va.localeCompare(vb); + }); + return accounts; +} diff --git a/src/components/NavBarComponent.vue b/src/components/NavBarComponent.vue index 96776cc..1f479fd 100644 --- a/src/components/NavBarComponent.vue +++ b/src/components/NavBarComponent.vue @@ -23,6 +23,7 @@ const toggleBurger = () => { diff --git a/src/router/index.js b/src/router/index.js index a6b9d4b..6068e97 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,8 +5,14 @@ import MainView from '../views/MainView.vue'; import AboutView from '../views/AboutView.vue'; import AddAccountView from '../views/AddAccountView.vue'; import DeleteAccountView from '../views/DeleteAccountView.vue'; +import ManageAccountsView from '../views/ManageAccountsView.vue'; const accounts = useStorage('sake-accounts', []); +const requireAccounts = () => { + if (!accounts.value.length) { + return '/add-account'; + } +}; const router = createRouter({ history: createMemoryHistory(), routes: [ @@ -14,11 +20,7 @@ const router = createRouter({ path: '/', name: 'main', component: MainView, - beforeEnter: (to, from) => { - if (!accounts.value.length) { - return '/add-account'; - } - } + beforeEnter: requireAccounts }, { path: '/about', @@ -35,6 +37,12 @@ const router = createRouter({ name: 'delete-account', component: DeleteAccountView, }, + { + path: '/manage-accounts', + name: 'manage-accounts', + component: ManageAccountsView, + beforeEnter: requireAccounts + }, ] }); diff --git a/src/views/MainView.vue b/src/views/MainView.vue index d35a0a1..256a654 100644 --- a/src/views/MainView.vue +++ b/src/views/MainView.vue @@ -1,4 +1,5 @@ + +