123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- // The Vue build version to load with the `import` command
- // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
- import Vue from 'vue'
- import App from './App'
- import router from './router'
- import store from './config/config'
- import { Loading } from 'element-ui';
- // Message,
- import { myMessage } from './components/tools/message';
- import ajax from './common/axios.config'
- import qs from 'qs'
- import './common/player.css'
- import VideoPlayer from 'vue-video-player'
- import 'video.js/dist/video-js.css' //videoJs的样式
- import 'vue-video-player/src/custom-theme.css' //vue-video-player的样式
- import VueCookies from 'vue-cookies'
- import Viewer from 'v-viewer'
- import 'viewerjs/dist/viewer.css'
- import Clipboard from "clipboard";
- import hevueImgPreview from './components/tools/hevue-img-preview'
- import './assets/css/button.css'
- import './assets/css/dialog.css'
- import './assets/css/markdownCss.css'
- import VueAudio from 'vue-audio-better'
- const echarts = require('echarts');
- //
- Vue.use(VideoPlayer).use(VueAudio).use(VueCookies).use(Viewer).use(hevueImgPreview, {
- clickMaskCLose: true
- })
- Vue.config.productionTip = false
- Vue.prototype.$store = store; // 将store实例挂在vue原型上
- Vue.prototype.ajax = ajax
- Vue.prototype.Clipboard = Clipboard
- // Vue.prototype.$message = Message
- Vue.prototype.$message = myMessage
- Vue.prototype.$loading = Loading
- Vue.prototype.$echarts = echarts
- 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
- Viewer.setDefaults({
- 'inline': false, //启用inline模式
- 'button': false, //显示右上角关闭按钮
- 'navbar': false, //显示缩略图导航
- 'title': false, //显示当前图片的标题
- 'toolbar': true, //显示工具栏
- 'tooltip': true, //显示缩略百分比
- 'movable': true, //图片是否可移动
- 'zoomable': true, //图片是否可缩放
- 'rotatable': true, //图片是否可旋转
- 'scalable': true, //图片是否可反转
- 'transition': true, //使用css3过度
- 'fullscreen': false, //播放时是否全屏
- 'keyboard': true, //
- })
- /* eslint-disable no-new */
- new Vue({
- 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]);
- // 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()被调用
- }
- })
|