@@ -6,6 +6,7 @@ if (typeof process === 'undefined') {
66
77const api = require ( './api' ) ;
88const mothership = require ( './mothership' ) ;
9+ const { routes } = require ( './routes' ) ;
910const vanillatoasts = require ( 'vanillatoasts' ) ;
1011
1112const app = Vue . createApp ( {
@@ -67,7 +68,7 @@ app.component('app-component', {
6768 window . state = this ;
6869
6970 if ( mothership . hasAPIKey ) {
70- const hash = window . location . hash . replace ( / ^ # ? \/ ? \? ? / , '' ) || '' ;
71+ const hash = window . location . hash . replace ( / ^ # ? \/ ? / , '' ) || '' ;
7172 const hashQuery = hash . split ( '?' ) [ 1 ] || '' ;
7273 const hashParams = new URLSearchParams ( hashQuery ) ;
7374 if ( hashParams . has ( 'code' ) ) {
@@ -110,6 +111,7 @@ app.component('app-component', {
110111 const { nodeEnv } = await api . status ( ) ;
111112 this . nodeEnv = nodeEnv ;
112113 }
114+
113115 this . status = 'loaded' ;
114116 } ,
115117 setup ( ) {
@@ -126,7 +128,6 @@ app.component('app-component', {
126128 }
127129} ) ;
128130
129- const { routes } = require ( './routes' ) ;
130131const router = VueRouter . createRouter ( {
131132 history : VueRouter . createWebHashHistory ( ) ,
132133 routes : routes . map ( route => ( {
@@ -136,6 +137,14 @@ const router = VueRouter.createRouter({
136137 } ) )
137138} ) ;
138139
140+ router . beforeEach ( ( to , from , next ) => {
141+ if ( to . name === 'root' && window . state . roles && window . state . roles [ 0 ] === 'dashboards' ) {
142+ return next ( 'dashboards' ) ;
143+ } else {
144+ next ( ) ;
145+ }
146+ } ) ;
147+
139148app . use ( router ) ;
140149
141150app . mount ( '#content' ) ;
0 commit comments