index.js 1.4 KB

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