Skip to content

Commit 77e2392

Browse files
authored
Merge pull request #53 from xiaofan9/vue3
Upgrade to vue3
2 parents 78d2c6e + 5f23741 commit 77e2392

File tree

7 files changed

+51
-3434
lines changed

7 files changed

+51
-3434
lines changed

Gulpfile.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1-
const gulp = require('gulp');
1+
const { src, dest, series } = require('gulp');
22
const babel = require('gulp-babel');
33
const uglify = require('gulp-uglifyjs');
44
const rename = require('gulp-rename');
5+
const clean = require('gulp-clean');
56

6-
gulp.task('default', () => {
7-
return gulp.src('src/index.js')
7+
function build() {
8+
return src('src/index.js')
89
.pipe(babel({
9-
presets: ['es2015']
10+
presets: [
11+
'@babel/env'
12+
]
1013
}))
1114
.pipe(rename('vue-axios.es5.js'))
12-
.pipe(gulp.dest('dist'))
15+
.pipe(dest('dist'))
1316
.pipe(uglify())
1417
.pipe(rename('vue-axios.min.js'))
15-
.pipe(gulp.dest('dist'));
16-
});
18+
.pipe(dest('dist'));
19+
}
20+
21+
function clear() {
22+
return src('dist/*').pipe(clean({
23+
force: true
24+
}));
25+
}
26+
27+
exports.default = series(clear, build)

dist/vue-axios.es5.js

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,27 @@
11
"use strict";
22

3-
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; };
3+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
44

55
(function () {
6-
76
/**
87
* Install plugin
9-
* @param Vue
8+
* @param app
109
* @param axios
1110
*/
12-
13-
function plugin(Vue, axios) {
14-
11+
function plugin(app, axios) {
1512
if (plugin.installed) {
1613
return;
1714
}
18-
plugin.installed = true;
1915

2016
if (!axios) {
2117
console.error('You have to install axios');
2218
return;
2319
}
2420

25-
Vue.axios = axios;
26-
27-
Object.defineProperties(Vue.prototype, {
28-
29-
axios: {
30-
get: function get() {
31-
return axios;
32-
}
33-
},
34-
35-
$http: {
36-
get: function get() {
37-
return axios;
38-
}
39-
}
40-
41-
});
21+
plugin.installed = true;
22+
app.axios = axios;
23+
app.config.globalProperties.axios = axios;
24+
app.config.globalProperties.$http = axios;
4225
}
4326

4427
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) == "object") {

dist/vue-axios.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.d.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
import Vue, {PluginFunction, PluginObject} from "vue";
21
import { AxiosStatic } from "axios";
2+
import { App } from "vue";
33

4-
declare module "vue/types/vue" {
5-
6-
interface Vue {
7-
axios: AxiosStatic;
4+
declare module "@vue/runtime-core" {
5+
export interface ComponentCustomProperties {
86
$http: AxiosStatic;
7+
axios: AxiosStatic;
98
}
109

11-
interface VueConstructor {
10+
export interface App {
1211
axios: AxiosStatic;
1312
}
1413
}
1514

16-
declare class VueAxios {
17-
static install: PluginFunction<AxiosStatic>;
18-
}
15+
declare function VueAxios(app: App, axios: AxiosStatic): void;
1916

2017
export default VueAxios;

0 commit comments

Comments
 (0)