import Vue from 'vue'; import '@/styles/font/font.css'; import '@/styles/common.scss'; import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; import '@/icons'; import '@/utils/mathjax'; // 必须在引入mathjax前引入mathjax的配置文件 import 'mathjax/es5/tex-mml-chtml'; import VueSignaturePad from 'vue-signature-pad'; import BookEep from './BookEep.vue'; import pkg from './package.json'; import { setRuntimeServices } from '@/utils/runtime-services'; const components = [BookEep]; const version = pkg.version; Vue.use(ElementUI, { size: 'small', }); Vue.use(VueSignaturePad); // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册 const install = (VueInstance, options = {}) => { if (install.installed) return; install.installed = true; setRuntimeServices({ router: options.router, store: options.store, }); components.forEach((component) => { VueInstance.component(component.name || 'BookEep', component); }); }; // 判断是否是直接引入文件,如果是,就不用调用 Vue.use() if (typeof window !== 'undefined' && window.Vue) { install(window.Vue); } if (typeof window !== 'undefined') { window.__EEP_UI_VERSION__ = version; } // 导出的对象必须具有 install,才能被 Vue.use() 方法安装 export default { install, version, }; export { version };