init project

This commit is contained in:
saeid
2019-04-14 21:13:55 +04:30
commit 9f2acb855c
213 changed files with 124305 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
/**
* Vue Router
*
* @library
*
* https://router.vuejs.org/en/
*/
// Lib imports
import Vue from 'vue'
import VueAnalytics from 'vue-analytics'
import Router from 'vue-router'
import Meta from 'vue-meta'
import { TokenService } from '@/services'
// Routes
import paths from './paths'
function route (options) {
let path = options.path;
let view = options.view;
let name = options.name;
let meta = (path.meta) ? path.meta : '';
return {
name: name || view,
path,
meta,
component: (resovle) => import(
`@/views/${view}.vue`
).then(resovle)
}
}
Vue.use(Router)
// Create a new router
const router = new Router({
mode: 'history',
routes: paths.map(path => route(path)).concat([
{ path: '*', redirect: '/dashboard' }
]),
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
}
if (to.hash) {
return { selector: to.hash }
}
return { x: 0, y: 0 }
}
})
Vue.use(Meta)
router.beforeEach((to, from, next) => {
const isPublic = to.matched.some(record => record.meta.public);
const onlyWhenLoggedOut = to.matched.some(record => record.meta.onlyWhenLoggedOut);
const loggedIn = !!TokenService.getToken();
// if (!isPublic && !loggedIn) {
// return next({
// path:'/login',
// query: {redirect: to.fullPath} // Store the full path to redirect the user to after login
// });
// }
// Do not allow user to visit login page or register page if they are logged in
// if (loggedIn && onlyWhenLoggedOut) {
// return next('/')
// }
next();
});
// Bootstrap Analytics
// Set in .env
// https://github.com/MatteoGabriele/vue-analytics
if (process.env.GOOGLE_ANALYTICS) {
Vue.use(VueAnalytics, {
id: process.env.GOOGLE_ANALYTICS,
router,
autoTracking: {
page: process.env.NODE_ENV !== 'development'
}
})
}
export default router
+67
View File
@@ -0,0 +1,67 @@
/**
* Define all of your application routes here
* for more information on routes, see the
* official documentation https://router.vuejs.org/en/
*/
export default [
{
path: '/dashboard',
// Relative to /src/views
view: 'Dashboard'
},
{
path: '/my-info',
name: 'My Info',
view: 'MyInfo'
},
{
path: '/all-resualttest',
name: 'All Resualt Test',
view: 'AllResualtTest'
},
{
path: '/manage-users',
name: 'Manage Users',
view: 'ManageUsers'
},
{
path: '/test-creator',
name: 'Add New Test',
view: 'TestCreator'
},
{
path: '/manage-medical-center',
name: 'Manage Medical Center',
view: 'ManageMedicalCenter'
},
{
path: '/login',
name: 'Login',
view: 'Login',
meta: {
public: true, // Allow access to even if not logged in
onlyWhenLoggedOut: true
}
},
{
path: '/register',
name: 'Register',
view: 'Register'
},
{
path: '/submit-test-result',
name: 'Submit Test Result',
view: 'SubmitTestResult'
},
{
path: '/test-creator',
name: 'Test Creator',
view: 'TestCreator'
},
{
path: '/test',
name: 'Test',
view: 'Test'
}
]