08f3bb0578
1. 服务端新增eslint 2. 修复所有的lint问题 3. 优化部署,把build命令放到docker构建中
137 lines
2.8 KiB
JavaScript
137 lines
2.8 KiB
JavaScript
import Vue from 'vue';
|
|
import VueRouter from 'vue-router';
|
|
|
|
Vue.use(VueRouter);
|
|
|
|
const routes = [
|
|
{
|
|
path: '/',
|
|
redirect: '/survey',
|
|
},
|
|
{
|
|
path: '/survey',
|
|
name: 'survey',
|
|
component: () =>
|
|
import(/* webpackChunkName: "survey" */ '../pages/list/index.vue'),
|
|
meta: {
|
|
needLogin: true,
|
|
title: '问卷列表',
|
|
},
|
|
},
|
|
{
|
|
path: '/survey/:id/edit',
|
|
name: 'editPage',
|
|
meta: {
|
|
needLogin: true,
|
|
},
|
|
component: () =>
|
|
import(/* webpackChunkName: "editPage" */ '../pages/edit/index.vue'),
|
|
children: [
|
|
{
|
|
path: '',
|
|
name: 'QuestionEditIndex',
|
|
meta: {
|
|
needLogin: true,
|
|
},
|
|
component: () =>
|
|
import(
|
|
/* webpackChunkName: "QuestionEditIndex" */ '../pages/edit/pages/edit.vue'
|
|
),
|
|
},
|
|
{
|
|
path: 'setting',
|
|
name: 'QuestionEditSetting',
|
|
meta: {
|
|
needLogin: true,
|
|
},
|
|
component: () =>
|
|
import(
|
|
/* webpackChunkName: "QuestionEditSetting" */ '../pages/edit/pages/setting.vue'
|
|
),
|
|
},
|
|
{
|
|
path: 'resultConfig',
|
|
name: 'QuestionEditResultConfig',
|
|
meta: {
|
|
needLogin: true,
|
|
},
|
|
component: () =>
|
|
import(
|
|
/* webpackChunkName: "QuestionEditResultConfig" */ '../pages/edit/pages/resultConfig.vue'
|
|
),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: '/survey/:id/analysis',
|
|
name: 'analysisPage',
|
|
meta: {
|
|
needLogin: true,
|
|
},
|
|
component: () =>
|
|
import(
|
|
/* webpackChunkName: "analysisPage" */ '../pages/analysis/index.vue'
|
|
),
|
|
},
|
|
{
|
|
path: '/survey/:id/publishResult',
|
|
name: 'publishResultPage',
|
|
meta: {
|
|
needLogin: true,
|
|
},
|
|
component: () =>
|
|
import(
|
|
/* webpackChunkName: "publishResultPage" */ '../pages/publishResult/index.vue'
|
|
),
|
|
},
|
|
{
|
|
path: '/create',
|
|
name: 'create',
|
|
meta: {
|
|
needLogin: true,
|
|
title: '创建问卷',
|
|
},
|
|
component: () =>
|
|
import(/* webpackChunkName: "create" */ '../pages/create/index.vue'),
|
|
},
|
|
{
|
|
path: '/login',
|
|
name: 'login',
|
|
title: '登陆',
|
|
component: () =>
|
|
import(/* webpackChunkName: "login" */ '../pages/login/index.vue'),
|
|
},
|
|
];
|
|
|
|
const router = new VueRouter({
|
|
mode: 'history',
|
|
base: '/management',
|
|
routes,
|
|
});
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
const store = router.app.$options.store;
|
|
if (!store?.state?.user?.initialized) {
|
|
store.dispatch('user/init');
|
|
}
|
|
if (to.meta.title) {
|
|
document.title = to.meta.title;
|
|
}
|
|
if (to.meta.needLogin) {
|
|
if (store?.state?.user?.hasLogined) {
|
|
next();
|
|
} else {
|
|
next({
|
|
name: 'login',
|
|
query: {
|
|
redirect: encodeURIComponent(to.path),
|
|
},
|
|
});
|
|
}
|
|
} else {
|
|
next();
|
|
}
|
|
});
|
|
|
|
export default router;
|