adapter-vue-web.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* eslint-disable @typescript-eslint/no-unused-vars */
  2. import * as _Vue from 'vue';
  3. import * as VueApi from '@vue/composition-api';
  4. let VueBasic: any = {
  5. default: {},
  6. };
  7. VueBasic = _Vue ? _Vue : VueBasic;
  8. let vueVersion: number;
  9. let createVNode = (
  10. arg1: any,
  11. arg2: any,
  12. ): { component: any; props: any; data: any } => {
  13. return {} as { component: any; props: any; data: any };
  14. };
  15. let render = (arg1: any, arg2: any) => {
  16. return;
  17. };
  18. let defineProps = () => {
  19. return;
  20. };
  21. let defineEmits = () => {
  22. return;
  23. };
  24. let withDefaults = (arg: any) => {
  25. return arg;
  26. };
  27. try {
  28. if (
  29. (VueBasic as any)?.default?.version
  30. && (VueBasic as any)?.default?.version?.startsWith('2.7.')
  31. ) {
  32. // >= Vue 2.7.0
  33. vueVersion = 2.7;
  34. } else if (
  35. (VueBasic as any)?.default?.version
  36. && (VueBasic as any)?.default?.version?.startsWith('2.')
  37. ) {
  38. // < Vue 2.7.0
  39. vueVersion = 2;
  40. } else {
  41. // >= Vue 3.0.0
  42. vueVersion = 3;
  43. createVNode = (VueBasic as any)?.createVNode;
  44. render = (VueBasic as any)?.render;
  45. defineProps = (VueBasic as any)?.defineProps;
  46. defineEmits = (VueBasic as any)?.defineEmits;
  47. withDefaults = (VueBasic as any)?.withDefaults;
  48. // exportedAPIOrigin = Vue;
  49. }
  50. } catch (error: any) {
  51. // >= Vue 3.0.0
  52. vueVersion = 3;
  53. createVNode = (VueBasic as any)?.createVNode;
  54. render = (VueBasic as any)?.render;
  55. defineProps = (VueBasic as any)?.defineProps;
  56. defineEmits = (VueBasic as any)?.defineEmits;
  57. withDefaults = (VueBasic as any)?.withDefaults;
  58. }
  59. console.warn(`[adapter-vue]: vue version is ${vueVersion}`);
  60. let vue: any = VueBasic;
  61. if (vueVersion === 2) {
  62. vue = VueApi;
  63. }
  64. export { vueVersion, render, createVNode, defineProps, defineEmits, withDefaults };
  65. export { vue };