index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import Vue from 'vue';
  2. import '@/styles/font/font.css';
  3. import '@/styles/common.scss';
  4. import ElementUI from 'element-ui';
  5. import 'element-ui/lib/theme-chalk/index.css';
  6. import '@/icons';
  7. import '@/utils/directive';
  8. import '@/utils/mathjax'; // 必须在引入mathjax前引入mathjax的配置文件
  9. import 'mathjax/es5/tex-mml-chtml';
  10. import VueSignaturePad from 'vue-signature-pad';
  11. import BookEep from './BookEep.vue';
  12. import pkg from './package.json';
  13. import { setRuntimeServices } from '@/utils/runtime-services';
  14. const components = [BookEep];
  15. const version = pkg.version;
  16. Vue.use(ElementUI, {
  17. size: 'small',
  18. });
  19. Vue.use(VueSignaturePad);
  20. // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
  21. const install = (VueInstance, options = {}) => {
  22. if (install.installed) return;
  23. install.installed = true;
  24. setRuntimeServices({
  25. router: options.router,
  26. store: options.store,
  27. });
  28. components.forEach((component) => {
  29. VueInstance.component(component.name || 'BookEep', component);
  30. });
  31. };
  32. // 判断是否是直接引入文件,如果是,就不用调用 Vue.use()
  33. if (typeof window !== 'undefined' && window.Vue) {
  34. install(window.Vue);
  35. }
  36. if (typeof window !== 'undefined') {
  37. window.__EEP_UI_VERSION__ = version;
  38. }
  39. // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
  40. export default {
  41. install,
  42. version,
  43. };
  44. export { version };