1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
8 |
|
9 | var _axios = require('axios');
|
10 |
|
11 | var _axios2 = _interopRequireDefault(_axios);
|
12 |
|
13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | var slice = [].slice;
|
20 |
|
21 |
|
22 | function isFunction(val) {
|
23 | return typeof val === 'function';
|
24 | }
|
25 |
|
26 | var isArray = Array.isArray;
|
27 |
|
28 | function isPlainObject(obj) {
|
29 | return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
|
30 | }
|
31 |
|
32 | function isObject(obj) {
|
33 | return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
|
34 | }
|
35 |
|
36 | function _merge(target, source, deep) {
|
37 | for (var key in source) {
|
38 | if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
|
39 | if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
|
40 | target[key] = {};
|
41 | }
|
42 | if (isArray(source[key]) && !isArray(target[key])) {
|
43 | target[key] = [];
|
44 | }
|
45 | _merge(target[key], source[key], deep);
|
46 | } else if (source[key] !== undefined) {
|
47 | target[key] = source[key];
|
48 | }
|
49 | }
|
50 | }
|
51 |
|
52 | function merge(target) {
|
53 |
|
54 | var args = slice.call(arguments, 1);
|
55 |
|
56 | args.forEach(function (source) {
|
57 | _merge(target, source, true);
|
58 | });
|
59 |
|
60 | return target;
|
61 | }
|
62 |
|
63 | function options(fn, obj, opts) {
|
64 |
|
65 | opts = opts || {};
|
66 |
|
67 | if (isFunction(opts)) {
|
68 | opts = opts.call(obj);
|
69 | }
|
70 |
|
71 | return merge(fn.bind({ $vm: obj, $options: opts }), fn, { $options: opts });
|
72 | }
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | function plugin(Vue) {
|
80 |
|
81 | if (plugin.installed) {
|
82 | return;
|
83 | }
|
84 |
|
85 | Vue.axios = _axios2.default;
|
86 |
|
87 | Object.defineProperties(Vue.prototype, {
|
88 |
|
89 | axios: {
|
90 | get: function get() {
|
91 | return options(Vue.axios, this, this.$options.axios);
|
92 | }
|
93 | }
|
94 |
|
95 | });
|
96 | }
|
97 |
|
98 | if (typeof window !== 'undefined' && window.Vue) {
|
99 | window.Vue.use(plugin);
|
100 | }
|
101 |
|
102 | exports.default = plugin; |
\ | No newline at end of file |