|
@@ -15,64 +15,64 @@ import VueCookies from 'vue-cookies'
|
|
|
|
|
|
Vue.use(VideoPlayer).use(VueCookies)
|
|
|
Vue.config.productionTip = false
|
|
|
-Vue.prototype.$store = store;// 将store实例挂在vue原型上
|
|
|
+Vue.prototype.$store = store; // 将store实例挂在vue原型上
|
|
|
Vue.prototype.ajax = ajax
|
|
|
Vue.prototype.$message = Message
|
|
|
Vue.prototype.$loading = Loading
|
|
|
-Vue.prototype.openLoading = function (target) {
|
|
|
- const loading = this.$loading.service({ // 声明一个loading对象
|
|
|
- lock: true, // 是否锁屏
|
|
|
- background: 'rgba(255, 255, 255, 0.7)', // 背景颜色
|
|
|
- target: target?target:document.body, // 需要遮罩的区域
|
|
|
- body: true,
|
|
|
- })
|
|
|
- return loading;
|
|
|
+Vue.prototype.openLoading = function(target) {
|
|
|
+ const loading = this.$loading.service({ // 声明一个loading对象
|
|
|
+ lock: true, // 是否锁屏
|
|
|
+ background: 'rgba(255, 255, 255, 0.7)', // 背景颜色
|
|
|
+ target: target ? target : document.body, // 需要遮罩的区域
|
|
|
+ body: true,
|
|
|
+ })
|
|
|
+ return loading;
|
|
|
}
|
|
|
Vue.prototype.$qs = qs
|
|
|
|
|
|
/* eslint-disable no-new */
|
|
|
new Vue({
|
|
|
- el: '#app',
|
|
|
- router,
|
|
|
- components: { App },
|
|
|
- template: '<App/>'
|
|
|
+ el: '#app',
|
|
|
+ router,
|
|
|
+ components: { App },
|
|
|
+ template: '<App/>'
|
|
|
})
|
|
|
|
|
|
VueCookies.config('30d')
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
- if (to.meta.title) {
|
|
|
- document.title = to.meta.title
|
|
|
- }
|
|
|
- const requireAuth = to.meta.requireAuth
|
|
|
- // 判断该路由是否需要登录权限
|
|
|
- if (requireAuth) {
|
|
|
- var isLogin = VueCookies.get('tlogin')
|
|
|
- // if (isLogin == "1") {
|
|
|
- var userinfo = VueCookies.get('teacherInfo')
|
|
|
- store.commit("update", ["isLogin", true]);
|
|
|
+ if (to.meta.title) {
|
|
|
+ document.title = to.meta.title
|
|
|
+ }
|
|
|
+ const requireAuth = to.meta.requireAuth
|
|
|
+ // 判断该路由是否需要登录权限
|
|
|
+ if (requireAuth) {
|
|
|
+ var isLogin = VueCookies.get('tlogin')
|
|
|
+ if (isLogin == "1") {
|
|
|
+ var userinfo = VueCookies.get('teacherInfo')
|
|
|
+ store.commit("update", ["isLogin", true]);
|
|
|
|
|
|
- // var info = JSON.parse(window.sessionStorage.getItem("userInfo"))
|
|
|
- store.commit("update", ["userInfo", userinfo]);
|
|
|
- store.state.luyou = store.state.luyou + 1
|
|
|
- store.commit("update", ["luyou", store.state.luyou]);
|
|
|
- next()
|
|
|
- // } else {
|
|
|
- // const loading = Loading.service({
|
|
|
- // background: "rgba(255, 255, 255)",
|
|
|
- // target: document.querySelector("body"),
|
|
|
- // });
|
|
|
- // store.commit("update", ["isLogin", false]);
|
|
|
- // Message({
|
|
|
- // message: '未登录,请登录',
|
|
|
- // type: 'warning'
|
|
|
- // });
|
|
|
- // setTimeout(() => {
|
|
|
- // loading.close();
|
|
|
- // next('/login')
|
|
|
- // }, 2000);
|
|
|
- // }
|
|
|
- } else {
|
|
|
- next() // 确保一定要有next()被调用
|
|
|
- }
|
|
|
-})
|
|
|
+ // var info = JSON.parse(window.sessionStorage.getItem("userInfo"))
|
|
|
+ store.commit("update", ["userInfo", userinfo]);
|
|
|
+ store.state.luyou = store.state.luyou + 1
|
|
|
+ store.commit("update", ["luyou", store.state.luyou]);
|
|
|
+ next()
|
|
|
+ } else {
|
|
|
+ const loading = Loading.service({
|
|
|
+ background: "rgba(255, 255, 255)",
|
|
|
+ target: document.querySelector("body"),
|
|
|
+ });
|
|
|
+ store.commit("update", ["isLogin", false]);
|
|
|
+ Message({
|
|
|
+ message: '未登录,请登录',
|
|
|
+ type: 'warning'
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.close();
|
|
|
+ next('/login')
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ next() // 确保一定要有next()被调用
|
|
|
+ }
|
|
|
+})
|