import Vue from 'vue'
|
import App from './App.vue'
|
import './assets/tailwind.css'
|
import router from './router'
|
import store from './store'
|
import ElementUI from 'element-ui';
|
import cookies from 'vue-cookies'
|
import apiConfig from './utils/baseurl'
|
import {
|
Message
|
} from 'element-ui'
|
import PlayLive from '@/components/PlayLive'
|
|
Vue.use(ElementUI)
|
Vue.prototype.$cookies = cookies;
|
Vue.prototype.$baseURL = apiConfig.baseURL
|
Vue.prototype.$mapKey = apiConfig.mapKey
|
Vue.prototype.$secretKey = apiConfig.secretKey
|
Vue.prototype.$store = store
|
Vue.config.productionTip = false
|
Vue.component('PlayLive', PlayLive)
|
/* 全局TableHeight */
|
Vue.prototype.$baseTableHeight = (formType) => {
|
let height = window.innerHeight
|
let paddingHeight = 200
|
const formHeight = 50
|
|
if ('number' == typeof formType) {
|
height = height - paddingHeight - formHeight * formType
|
} else {
|
height = height - paddingHeight
|
}
|
return height
|
}
|
|
Vue.prototype.msgsuccess = function (msg) {
|
Message({
|
message: msg,
|
type: "success"
|
});
|
}
|
|
Vue.prototype.msgerror = function (msg) {
|
Message({
|
message: msg,
|
type: "error"
|
});
|
}
|
|
Vue.prototype.msgwarning = function (msg) {
|
Message({
|
message: msg,
|
type: "warning"
|
});
|
}
|
|
Vue.prototype.msginfo = function (msg) {
|
Message({
|
message: msg,
|
});
|
}
|
|
Vue.prototype.$checkPermission = function(permissionId) {
|
const permissions = store.state.permissions || [];
|
if (!permissions.includes(permissionId)) {
|
this.$router.push('/404');
|
return false;
|
}
|
return true;
|
};
|
|
Vue.directive('permission', {
|
inserted: function (el, binding) {
|
const permissions = store.state.permissions || [];
|
if (!permissions.includes(binding.value)) {
|
el.style.display = 'none';
|
}
|
},
|
update: function (el, binding) {
|
const permissions = store.state.permissions || [];
|
if (!permissions.includes(binding.value)) {
|
el.style.display = 'none';
|
} else {
|
el.style.display = '';
|
}
|
}
|
});
|
|
new Vue({
|
router,
|
store,
|
render: h => h(App)
|
}).$mount('#app')
|