import Vue from "vue"; import App from "./App.vue"; import router from "./router"; import store from "./store"; import ElementUI from "element-ui"; import "element-ui/lib/theme-chalk/index.css"; import axios from "axios"; import JsonExcel from "vue-json-excel"; //vue全局导入导出excel import Print from "vue-print-nb"; import Meta from 'vue-meta' import Contextmenu from 'vue-contextmenujs' //'vue-contextmenu' import "./assets/css/global_font.css"; Vue.use(Contextmenu); Vue.use(Meta); Vue.use(ElementUI); Vue.prototype.$axios = axios //全局注册外壳的 peisAPI 对象 try { Vue.prototype.$peisAPI = window.peisAPI; } catch (error) { Vue.prototype.$peisAPI = null; } Vue.use(Print); Vue.component("downloadExcel", JsonExcel); Vue.config.productionTip = false; // Vue.filter('format', function (date) { // var json_date = new Date(date).toJSON() // return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/t/g, '').replace(/\.[\d]{3}Z/, '') // }) Vue.directive('focus', { // 当被绑定的元素插入到 DOM 中时 inserted: function(el) { // 聚焦元素 el.focus() }, update: function(el) { // 聚焦元素 el.focus() } }) Vue.filter("dateFormat", (dataStr) => { if (!dataStr) { return } var time = new Date(dataStr); function timeAdd0(str) { if (str < 10) { str = "0" + str; } return str; } var y = time.getFullYear(); var m = time.getMonth() + 1; var d = time.getDate(); var h = time.getHours(); var mm = time.getMinutes(); var s = time.getSeconds(); return ( y + "-" + timeAdd0(m) + "-" + timeAdd0(d) + " " + timeAdd0(h) + ":" + timeAdd0(mm) + ":" + timeAdd0(s) ); }); new Vue({ router, store, metaInfo() { return { title: '神豚体检管理系统', meta: [{ name: "http-equiv", content: "Content-Security-Policy", //http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline';"> }, { name: "content", content: "default-src 'self' 'unsafe-inline';", //指向data的数据 }] } }, render: (h) => h(App), }).$mount("#app"); //监听页面大小改变 window.addEventListener('resize', onResize); function onResize() { //console.log(document.body.clientHeight,'-document.body.clientHeight-',window.innerHeight) store.commit('setData', { key: 'window.pageHeight', value: window.innerHeight }) store.commit('setData', { key: 'window.pageWidth', value: window.innerWidth }) } onResize(); // 监听keydown:获取键盘按住事件,code返回按住的键信息 (为了省事放在全局,后续优化应考虑放至具体用到界面上) window.addEventListener('keydown', code => { // console.log('keydown', code) if (code.key == "Shift" && code.shiftKey) { store.commit('setData', { key: 'window.shift', value: true }); // 标记按住了shift键 } if (code.key == "Control" && code.ctrlKey) { store.commit('setData', { key: 'window.ctrl', value: true }); // 标记按住了ctrl键 } }); // // 监听keyup:获取键盘松开事件,code返回按住的键信息 window.addEventListener('keyup', code => { // console.log('keyup', code) if (code.key == "Shift") { store.commit('setData', { key: 'window.shift', value: false }); // 标记松开了shift键 } if (code.key == "Control") { store.commit('setData', { key: 'window.ctrl', value: false }); // 标记松开了ctrl键 } });