idList) {
89 | return R.ok(this.customerTableService.removeByIds(idList));
90 | }
91 | }
--------------------------------------------------------------------------------
/前端代码/static/css/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: Microsoft YaHei, Helvitica, Verdana, Arial, san-serif;
3 | font-size: 12px;
4 |
5 | }
6 | /*刷新*/
7 | .el-refresh{
8 | position:absolute;
9 | width:30px;
10 | height:30px;
11 | right:5px;
12 | top:20px;
13 | z-index:100;
14 | }
15 | .el-icon-refresh{
16 | width: 32px;
17 | height: 32px;
18 | cursor: pointer;
19 | }
20 | /*搜索*/
21 | .seachClass{
22 | display: flex;
23 | flex-wrap: wrap;
24 | padding-top: 25px;
25 | }
26 |
27 | /*==================表单页面的样式=================*/
28 | .el-steps {
29 | margin: 20px;
30 | }
31 |
32 | .el-form {
33 | /*margin-right: 10px;*/
34 | background-color: #fbfbfb;
35 | border-radius: 4px;
36 | padding: 8px;
37 | /*padding-right: 20px;*/
38 | /*box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)*/
39 | }
40 |
41 | .buttonSpan {
42 | z-index: 100;
43 | line-height: 25px;
44 | position: fixed;
45 | left: 30%;
46 | bottom: 0px;
47 | }
48 |
49 | .el-backtop {
50 | position: fixed;
51 | background-color: #fff;
52 | width: 40px;
53 | height: 40px;
54 | border-radius: 50%;
55 | color: #409eff;
56 | display: flex;
57 | align-items: center;
58 | justify-content: center;
59 | font-size: 20px;
60 | box-shadow: 0 0 6px rgba(0, 0, 0, .12);
61 | cursor: pointer;
62 | z-index: 5;
63 | }
64 |
65 | /*================上传图片相关=====================*/
66 |
67 | /*图片box*/
68 | .imgBox {
69 | display: flex;
70 | flex-wrap: wrap;
71 | padding-bottom: 60px;
72 | }
73 | /*图片*/
74 | .imgItem {
75 | width: 145px;
76 | height: 145px;
77 | display: flex;
78 | flex-direction: column;
79 | justify-content: center;
80 | text-align: center;
81 | cursor: pointer;
82 | border-style: solid;
83 | border-color: #c6e2ff;
84 | border-width: 1px;
85 | border-radius: 6px;
86 | margin: 15px 15px 0px 15px;
87 | padding: 2px;
88 | }
89 | /*图片显示(背景)*/
90 | .imageShow{
91 | height:145px;
92 | position: relative;
93 | background-repeat: no-repeat;
94 | background-size: cover;
95 | background-position: center center;
96 | border-radius: 6px;
97 | }
98 |
99 | .showHide {
100 | position: relative;
101 | left: 50px;
102 | color: #000000;
103 | }
104 |
105 | /*图片名称效果*/
106 | .nameSpan{
107 | width: 100%;
108 | height: 20px;
109 | line-height: 20px;
110 | font-size: 12px;
111 | text-align: center;
112 | background-color: #ffffff;
113 | color: #000000;
114 | margin-top: 106px;
115 | opacity:0.7;
116 | }
117 | /*选中遮住效果*/
118 | .selectCheck {
119 | position: relative;
120 | width: 100%;
121 | height: 100%;
122 | top: 0;
123 | bottom: 0;
124 | left: 0;
125 | right: 0;
126 | background: rgba(0, 0, 0, 0.45);
127 | text-align: center;
128 | border-radius: 6px;
129 | }
--------------------------------------------------------------------------------
/前端代码/views/test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | 保存
45 | 取消
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/customerProject/customerProject.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | SpringBoot+ElementUI—客户信息展示的示例,这个示例使用 前后端分离的开发模式来完成.
2 |
3 | **学习目的:**
4 | 了解前端、后端、相关工具使用,以及完整的项目实例,帮助新手快速入门。
5 |
6 | > ### 开发环境和相关工具:
7 | >
8 | > 前端:Element UI + VUE
9 | >
10 | > 后端:SpringBoot、MybatisPlus、Lombok、EasyCode代码生成器
11 | >
12 | > 后端开发工具:IDEA
13 | >
14 | > API测试工具:PostMan
15 | >
16 | > 前端开发工具:VSCode
17 |
18 |
19 | # 第1节:建立数据库表
20 |
21 | mysql,
22 |
23 | customer_db
24 |
25 | customer_table
26 |
27 | # 第2节:创建一个后端项目
28 |
29 | 工具:IDEA。用快速创建方式创建一个SpringBoot项目
30 |
31 | ## 1)、创建一个SpringBoot项目
32 |
33 | ## 2)、引入所需依赖jar包
34 |
35 | ```xml
36 |
37 | org.springframework.boot
38 | spring-boot-starter-parent
39 | 2.1.9.RELEASE
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-starter
48 |
49 |
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-starter-web
54 |
55 |
56 |
57 |
58 | org.springframework.boot
59 | spring-boot-starter-test
60 | test
61 |
62 |
63 |
64 |
65 | org.projectlombok
66 | lombok
67 | true
68 |
69 |
70 |
71 |
72 | com.baomidou
73 | mybatis-plus-boot-starter
74 | 3.1.0
75 |
76 |
77 |
78 |
79 | mysql
80 | mysql-connector-java
81 | runtime
82 |
83 |
84 |
85 |
86 |
87 |
88 | org.springframework.boot
89 | spring-boot-maven-plugin
90 |
91 |
92 |
93 | ```
94 |
95 |
96 |
97 | 如果用maven创建项目,需要手工创建程序启动类:
98 |
99 | ```java
100 | @SpringBootApplication
101 | public static void main(String[] args) {
102 | SpringApplication.run (xx.class, args);
103 | }
104 | ```
105 |
106 | 如果用maven创建项目,默认是没有测试类的,如果需要创建测试类,需要在测试类头增加注解:
107 |
108 | ```java
109 | @RunWith(SpringRunner.class)
110 | @SpringBootTest
111 | ```
112 |
113 | ## 3)、配置数据源连接
114 |
115 | 新建application.yml配置文件
116 |
117 | ```yaml
118 | server:
119 | port: 8088
120 | spring:
121 | datasource:
122 | driver-class-name: com.mysql.cj.jdbc.Driver
123 | url: jdbc:mysql://localhost:3309/XXXX
124 | username: root
125 | password: 8888
126 | mybatis-plus:
127 | #信息输出设置
128 | configuration:
129 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
130 | ```
131 |
132 |
133 |
134 |
135 |
136 | # 第3节:编写API接口程序
137 |
138 | 为了高效, 使用EasyCode工具来生成后台java代码,也就是API接口程序。
139 |
140 |
141 |
142 | # 第4节:配置接口映射和分页插件的注册
143 |
144 | 1)、在主程序添加注解 @MapperScan,作用是:一次性扫描Mapper映射接口的包路径;
145 |
146 | 2)、在项目中加入配置类,在类中用@bean注解来注册分页插件;
147 |
148 | ```java
149 | //Spring boot方式
150 | @EnableTransactionManagement
151 | @Configuration
152 | public class MybatisPlusConfig {
153 | @Bean
154 | public PaginationInterceptor paginationInterceptor() {
155 | PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
156 | // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
157 | // paginationInterceptor.setOverflow(false);
158 | // 设置最大单页限制数量,默认 500 条,-1 不受限制
159 | // paginationInterceptor.setLimit(500);
160 | return paginationInterceptor;
161 | }
162 | }
163 | ```
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 | # 第5节:启动后台项目,测试API接口程序
172 |
173 | 开启 PostMan工具测试。get、post
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 | # 第6节:创建一个前端项目,并新建页面
182 |
183 | 前端用:Element UI+VUE。手工简单创建项目(不使用vue-cli)
184 |
185 | 用vsCode工具编辑
186 |
187 | ## 1)、基础的准备
188 |
189 | ## 2)、模拟列表数据
190 |
191 | # 第7节:绑定后台列表数据
192 |
193 | vue基本方法框架:
194 |
195 | ```html
196 |
217 | ```
218 |
219 |
220 |
221 | ```javascript
222 | // 用ajax去请求服务端数据
223 | getData() {
224 | let that = this;
225 | let url = "http://localhost:8089/customerTable";
226 | that.$http.get(url, null, { emulateJSON: true })
227 | .then(res => {
228 | let rs = JSON.parse(res.body);
229 | if (rs.code == 0) {
230 | that.tableData = rs.data.records;
231 | }
232 | });
233 |
234 | }
235 | ```
236 |
237 | ```javascript
238 | 获取远程数据:
239 |
240 | this.$http.get(url, data,{emulateJSON:true})
241 | .then( res => {
242 | let rs = JSON.parse(res.body);
243 | });
244 | ```
245 |
246 | **封装好的ajax:**
247 |
248 | ```javascript
249 | /**
250 | * 简单封装了ajax对象
251 | */
252 | class Ajax {
253 |
254 | vueObj = null;
255 |
256 | baseUrl = "http://localhost:8099/";
257 |
258 | /**
259 | * 构造方法
260 | * @param {*} vueObj
261 | */
262 | constructor(vueObj) {
263 |
264 | this.vueObj = vueObj;
265 | }
266 |
267 | /**
268 | * get方法
269 | * @param {*} api
270 | * @param {*} callback
271 | * @param {*} params
272 | */
273 | get(api,callback,params){
274 | let url = this.baseUrl + api ;
275 | let data = JSON.stringify(params);
276 | this.vueObj.$http.get(url, data,{emulateJSON:true})
277 | .then( res => {
278 | callback(JSON.parse(res.body));
279 | });
280 | }
281 |
282 | /**
283 | * post方法
284 | * @param {*} api
285 | * @param {*} callback
286 | * @param {*} params
287 | */
288 | post(api,callback,params){
289 | let url = this.baseUrl + api ;
290 | let data = JSON.stringify(params);
291 | this.vueObj.$http.post(url, data,{emulateJSON:true})
292 | .then( res => {
293 | callback(JSON.parse(res.body));
294 | });
295 | }
296 |
297 | /**
298 | * put方法
299 | * @param {*} api
300 | * @param {*} callback
301 | * @param {*} params
302 | */
303 | put(api,callback,params){
304 | let url = this.baseUrl + api ;
305 | let data = JSON.stringify(params);
306 | this.vueObj.$http.put(url, data,{emulateJSON:true})
307 | .then( res => {
308 | callback(JSON.parse(res.body));
309 | });
310 | }
311 |
312 | /**
313 | * delete方法
314 | * @param {*} api
315 | * @param {*} callback
316 | * @param {*} params
317 | */
318 | delete(api,callback,params){
319 | let url = this.baseUrl + api ;
320 | let data = JSON.stringify(params);
321 | this.vueObj.$http.delete(url, data ,{emulateJSON:true})
322 | .then( res => {
323 | callback(JSON.parse(res.body));
324 | });
325 | }
326 | }
327 | ```
328 |
329 |
330 |
331 | # 第8节:列表分页设置
332 |
333 | 主要代码:
334 |
335 | ```javascript
336 | //分页点击事件
337 | currentChange(current){
338 | // console.log(current);
339 | this.page.current = current;
340 | this.getData();
341 | }
342 | ```
343 |
344 | ```html
345 |
353 |
354 | ```
355 |
356 |
357 |
358 | # 第9节:删除功能
359 |
360 |
361 |
362 | ```javascript
363 | // 删除数据
364 | del() {
365 | if (this.idList.length > 0) {
366 | let that = this;
367 | let idList = that.idList.toString();
368 | let url = "customerTable?idList=" + idList;
369 | //调用Ajax的delete方法
370 | that.ajax.delete(url, function (rs) {
371 | if (rs.code == 0) {
372 | //重新获取数据
373 | that.getData();
374 | }
375 | });
376 | }
377 | }
378 | ```
379 |
380 |
381 |
382 | # 第10节:新建、编辑功能
383 |
384 |
385 |
386 | ```javascript
387 | onSubmit() {
388 | let that = this;
389 | let url = "customerTable";
390 | let data = that.form;
391 | //调用Ajax的post方法
392 | that.ajax.post(url, function (rs) {
393 | if (rs.code == 0) {
394 | //重新获取数据
395 | that.getData();
396 | }
397 | },data);
398 | }
399 | ```
400 |
401 |
--------------------------------------------------------------------------------
/前端代码/static/vue/vue-resource.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * vue-resource v0.9.3
3 | * https://github.com/vuejs/vue-resource
4 | * Released under the MIT License.
5 | */
6 |
7 | (function (global, factory) {
8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
9 | typeof define === 'function' && define.amd ? define(factory) :
10 | (global.VueResource = factory());
11 | }(this, function () { 'use strict';
12 |
13 | /**
14 | * Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis)
15 | */
16 |
17 | var RESOLVED = 0;
18 | var REJECTED = 1;
19 | var PENDING = 2;
20 |
21 | function Promise$2(executor) {
22 |
23 | this.state = PENDING;
24 | this.value = undefined;
25 | this.deferred = [];
26 |
27 | var promise = this;
28 |
29 | try {
30 | executor(function (x) {
31 | promise.resolve(x);
32 | }, function (r) {
33 | promise.reject(r);
34 | });
35 | } catch (e) {
36 | promise.reject(e);
37 | }
38 | }
39 |
40 | Promise$2.reject = function (r) {
41 | return new Promise$2(function (resolve, reject) {
42 | reject(r);
43 | });
44 | };
45 |
46 | Promise$2.resolve = function (x) {
47 | return new Promise$2(function (resolve, reject) {
48 | resolve(x);
49 | });
50 | };
51 |
52 | Promise$2.all = function all(iterable) {
53 | return new Promise$2(function (resolve, reject) {
54 | var count = 0,
55 | result = [];
56 |
57 | if (iterable.length === 0) {
58 | resolve(result);
59 | }
60 |
61 | function resolver(i) {
62 | return function (x) {
63 | result[i] = x;
64 | count += 1;
65 |
66 | if (count === iterable.length) {
67 | resolve(result);
68 | }
69 | };
70 | }
71 |
72 | for (var i = 0; i < iterable.length; i += 1) {
73 | Promise$2.resolve(iterable[i]).then(resolver(i), reject);
74 | }
75 | });
76 | };
77 |
78 | Promise$2.race = function race(iterable) {
79 | return new Promise$2(function (resolve, reject) {
80 | for (var i = 0; i < iterable.length; i += 1) {
81 | Promise$2.resolve(iterable[i]).then(resolve, reject);
82 | }
83 | });
84 | };
85 |
86 | var p$1 = Promise$2.prototype;
87 |
88 | p$1.resolve = function resolve(x) {
89 | var promise = this;
90 |
91 | if (promise.state === PENDING) {
92 | if (x === promise) {
93 | throw new TypeError('Promise settled with itself.');
94 | }
95 |
96 | var called = false;
97 |
98 | try {
99 | var then = x && x['then'];
100 |
101 | if (x !== null && typeof x === 'object' && typeof then === 'function') {
102 | then.call(x, function (x) {
103 | if (!called) {
104 | promise.resolve(x);
105 | }
106 | called = true;
107 | }, function (r) {
108 | if (!called) {
109 | promise.reject(r);
110 | }
111 | called = true;
112 | });
113 | return;
114 | }
115 | } catch (e) {
116 | if (!called) {
117 | promise.reject(e);
118 | }
119 | return;
120 | }
121 |
122 | promise.state = RESOLVED;
123 | promise.value = x;
124 | promise.notify();
125 | }
126 | };
127 |
128 | p$1.reject = function reject(reason) {
129 | var promise = this;
130 |
131 | if (promise.state === PENDING) {
132 | if (reason === promise) {
133 | throw new TypeError('Promise settled with itself.');
134 | }
135 |
136 | promise.state = REJECTED;
137 | promise.value = reason;
138 | promise.notify();
139 | }
140 | };
141 |
142 | p$1.notify = function notify() {
143 | var promise = this;
144 |
145 | nextTick(function () {
146 | if (promise.state !== PENDING) {
147 | while (promise.deferred.length) {
148 | var deferred = promise.deferred.shift(),
149 | onResolved = deferred[0],
150 | onRejected = deferred[1],
151 | resolve = deferred[2],
152 | reject = deferred[3];
153 |
154 | try {
155 | if (promise.state === RESOLVED) {
156 | if (typeof onResolved === 'function') {
157 | resolve(onResolved.call(undefined, promise.value));
158 | } else {
159 | resolve(promise.value);
160 | }
161 | } else if (promise.state === REJECTED) {
162 | if (typeof onRejected === 'function') {
163 | resolve(onRejected.call(undefined, promise.value));
164 | } else {
165 | reject(promise.value);
166 | }
167 | }
168 | } catch (e) {
169 | reject(e);
170 | }
171 | }
172 | }
173 | });
174 | };
175 |
176 | p$1.then = function then(onResolved, onRejected) {
177 | var promise = this;
178 |
179 | return new Promise$2(function (resolve, reject) {
180 | promise.deferred.push([onResolved, onRejected, resolve, reject]);
181 | promise.notify();
182 | });
183 | };
184 |
185 | p$1.catch = function (onRejected) {
186 | return this.then(undefined, onRejected);
187 | };
188 |
189 | var PromiseObj = window.Promise || Promise$2;
190 |
191 | function Promise$1(executor, context) {
192 |
193 | if (executor instanceof PromiseObj) {
194 | this.promise = executor;
195 | } else {
196 | this.promise = new PromiseObj(executor.bind(context));
197 | }
198 |
199 | this.context = context;
200 | }
201 |
202 | Promise$1.all = function (iterable, context) {
203 | return new Promise$1(PromiseObj.all(iterable), context);
204 | };
205 |
206 | Promise$1.resolve = function (value, context) {
207 | return new Promise$1(PromiseObj.resolve(value), context);
208 | };
209 |
210 | Promise$1.reject = function (reason, context) {
211 | return new Promise$1(PromiseObj.reject(reason), context);
212 | };
213 |
214 | Promise$1.race = function (iterable, context) {
215 | return new Promise$1(PromiseObj.race(iterable), context);
216 | };
217 |
218 | var p = Promise$1.prototype;
219 |
220 | p.bind = function (context) {
221 | this.context = context;
222 | return this;
223 | };
224 |
225 | p.then = function (fulfilled, rejected) {
226 |
227 | if (fulfilled && fulfilled.bind && this.context) {
228 | fulfilled = fulfilled.bind(this.context);
229 | }
230 |
231 | if (rejected && rejected.bind && this.context) {
232 | rejected = rejected.bind(this.context);
233 | }
234 |
235 | return new Promise$1(this.promise.then(fulfilled, rejected), this.context);
236 | };
237 |
238 | p.catch = function (rejected) {
239 |
240 | if (rejected && rejected.bind && this.context) {
241 | rejected = rejected.bind(this.context);
242 | }
243 |
244 | return new Promise$1(this.promise.catch(rejected), this.context);
245 | };
246 |
247 | p.finally = function (callback) {
248 |
249 | return this.then(function (value) {
250 | callback.call(this);
251 | return value;
252 | }, function (reason) {
253 | callback.call(this);
254 | return PromiseObj.reject(reason);
255 | });
256 | };
257 |
258 | var debug = false;
259 | var util = {};
260 | var array = [];
261 | function Util (Vue) {
262 | util = Vue.util;
263 | debug = Vue.config.debug || !Vue.config.silent;
264 | }
265 |
266 | function warn(msg) {
267 | if (typeof console !== 'undefined' && debug) {
268 | console.warn('[VueResource warn]: ' + msg);
269 | }
270 | }
271 |
272 | function error(msg) {
273 | if (typeof console !== 'undefined') {
274 | console.error(msg);
275 | }
276 | }
277 |
278 | function nextTick(cb, ctx) {
279 | return util.nextTick(cb, ctx);
280 | }
281 |
282 | function trim(str) {
283 | return str.replace(/^\s*|\s*$/g, '');
284 | }
285 |
286 | var isArray = Array.isArray;
287 |
288 | function isString(val) {
289 | return typeof val === 'string';
290 | }
291 |
292 | function isBoolean(val) {
293 | return val === true || val === false;
294 | }
295 |
296 | function isFunction(val) {
297 | return typeof val === 'function';
298 | }
299 |
300 | function isObject(obj) {
301 | return obj !== null && typeof obj === 'object';
302 | }
303 |
304 | function isPlainObject(obj) {
305 | return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
306 | }
307 |
308 | function isFormData(obj) {
309 | return typeof FormData !== 'undefined' && obj instanceof FormData;
310 | }
311 |
312 | function when(value, fulfilled, rejected) {
313 |
314 | var promise = Promise$1.resolve(value);
315 |
316 | if (arguments.length < 2) {
317 | return promise;
318 | }
319 |
320 | return promise.then(fulfilled, rejected);
321 | }
322 |
323 | function options(fn, obj, opts) {
324 |
325 | opts = opts || {};
326 |
327 | if (isFunction(opts)) {
328 | opts = opts.call(obj);
329 | }
330 |
331 | return merge(fn.bind({ $vm: obj, $options: opts }), fn, { $options: opts });
332 | }
333 |
334 | function each(obj, iterator) {
335 |
336 | var i, key;
337 |
338 | if (typeof obj.length == 'number') {
339 | for (i = 0; i < obj.length; i++) {
340 | iterator.call(obj[i], obj[i], i);
341 | }
342 | } else if (isObject(obj)) {
343 | for (key in obj) {
344 | if (obj.hasOwnProperty(key)) {
345 | iterator.call(obj[key], obj[key], key);
346 | }
347 | }
348 | }
349 |
350 | return obj;
351 | }
352 |
353 | var assign = Object.assign || _assign;
354 |
355 | function merge(target) {
356 |
357 | var args = array.slice.call(arguments, 1);
358 |
359 | args.forEach(function (source) {
360 | _merge(target, source, true);
361 | });
362 |
363 | return target;
364 | }
365 |
366 | function defaults(target) {
367 |
368 | var args = array.slice.call(arguments, 1);
369 |
370 | args.forEach(function (source) {
371 |
372 | for (var key in source) {
373 | if (target[key] === undefined) {
374 | target[key] = source[key];
375 | }
376 | }
377 | });
378 |
379 | return target;
380 | }
381 |
382 | function _assign(target) {
383 |
384 | var args = array.slice.call(arguments, 1);
385 |
386 | args.forEach(function (source) {
387 | _merge(target, source);
388 | });
389 |
390 | return target;
391 | }
392 |
393 | function _merge(target, source, deep) {
394 | for (var key in source) {
395 | if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
396 | if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
397 | target[key] = {};
398 | }
399 | if (isArray(source[key]) && !isArray(target[key])) {
400 | target[key] = [];
401 | }
402 | _merge(target[key], source[key], deep);
403 | } else if (source[key] !== undefined) {
404 | target[key] = source[key];
405 | }
406 | }
407 | }
408 |
409 | function root (options, next) {
410 |
411 | var url = next(options);
412 |
413 | if (isString(options.root) && !url.match(/^(https?:)?\//)) {
414 | url = options.root + '/' + url;
415 | }
416 |
417 | return url;
418 | }
419 |
420 | function query (options, next) {
421 |
422 | var urlParams = Object.keys(Url.options.params),
423 | query = {},
424 | url = next(options);
425 |
426 | each(options.params, function (value, key) {
427 | if (urlParams.indexOf(key) === -1) {
428 | query[key] = value;
429 | }
430 | });
431 |
432 | query = Url.params(query);
433 |
434 | if (query) {
435 | url += (url.indexOf('?') == -1 ? '?' : '&') + query;
436 | }
437 |
438 | return url;
439 | }
440 |
441 | /**
442 | * URL Template v2.0.6 (https://github.com/bramstein/url-template)
443 | */
444 |
445 | function expand(url, params, variables) {
446 |
447 | var tmpl = parse(url),
448 | expanded = tmpl.expand(params);
449 |
450 | if (variables) {
451 | variables.push.apply(variables, tmpl.vars);
452 | }
453 |
454 | return expanded;
455 | }
456 |
457 | function parse(template) {
458 |
459 | var operators = ['+', '#', '.', '/', ';', '?', '&'],
460 | variables = [];
461 |
462 | return {
463 | vars: variables,
464 | expand: function (context) {
465 | return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
466 | if (expression) {
467 |
468 | var operator = null,
469 | values = [];
470 |
471 | if (operators.indexOf(expression.charAt(0)) !== -1) {
472 | operator = expression.charAt(0);
473 | expression = expression.substr(1);
474 | }
475 |
476 | expression.split(/,/g).forEach(function (variable) {
477 | var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
478 | values.push.apply(values, getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
479 | variables.push(tmp[1]);
480 | });
481 |
482 | if (operator && operator !== '+') {
483 |
484 | var separator = ',';
485 |
486 | if (operator === '?') {
487 | separator = '&';
488 | } else if (operator !== '#') {
489 | separator = operator;
490 | }
491 |
492 | return (values.length !== 0 ? operator : '') + values.join(separator);
493 | } else {
494 | return values.join(',');
495 | }
496 | } else {
497 | return encodeReserved(literal);
498 | }
499 | });
500 | }
501 | };
502 | }
503 |
504 | function getValues(context, operator, key, modifier) {
505 |
506 | var value = context[key],
507 | result = [];
508 |
509 | if (isDefined(value) && value !== '') {
510 | if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
511 | value = value.toString();
512 |
513 | if (modifier && modifier !== '*') {
514 | value = value.substring(0, parseInt(modifier, 10));
515 | }
516 |
517 | result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null));
518 | } else {
519 | if (modifier === '*') {
520 | if (Array.isArray(value)) {
521 | value.filter(isDefined).forEach(function (value) {
522 | result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null));
523 | });
524 | } else {
525 | Object.keys(value).forEach(function (k) {
526 | if (isDefined(value[k])) {
527 | result.push(encodeValue(operator, value[k], k));
528 | }
529 | });
530 | }
531 | } else {
532 | var tmp = [];
533 |
534 | if (Array.isArray(value)) {
535 | value.filter(isDefined).forEach(function (value) {
536 | tmp.push(encodeValue(operator, value));
537 | });
538 | } else {
539 | Object.keys(value).forEach(function (k) {
540 | if (isDefined(value[k])) {
541 | tmp.push(encodeURIComponent(k));
542 | tmp.push(encodeValue(operator, value[k].toString()));
543 | }
544 | });
545 | }
546 |
547 | if (isKeyOperator(operator)) {
548 | result.push(encodeURIComponent(key) + '=' + tmp.join(','));
549 | } else if (tmp.length !== 0) {
550 | result.push(tmp.join(','));
551 | }
552 | }
553 | }
554 | } else {
555 | if (operator === ';') {
556 | result.push(encodeURIComponent(key));
557 | } else if (value === '' && (operator === '&' || operator === '?')) {
558 | result.push(encodeURIComponent(key) + '=');
559 | } else if (value === '') {
560 | result.push('');
561 | }
562 | }
563 |
564 | return result;
565 | }
566 |
567 | function isDefined(value) {
568 | return value !== undefined && value !== null;
569 | }
570 |
571 | function isKeyOperator(operator) {
572 | return operator === ';' || operator === '&' || operator === '?';
573 | }
574 |
575 | function encodeValue(operator, value, key) {
576 |
577 | value = operator === '+' || operator === '#' ? encodeReserved(value) : encodeURIComponent(value);
578 |
579 | if (key) {
580 | return encodeURIComponent(key) + '=' + value;
581 | } else {
582 | return value;
583 | }
584 | }
585 |
586 | function encodeReserved(str) {
587 | return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) {
588 | if (!/%[0-9A-Fa-f]/.test(part)) {
589 | part = encodeURI(part);
590 | }
591 | return part;
592 | }).join('');
593 | }
594 |
595 | function template (options) {
596 |
597 | var variables = [],
598 | url = expand(options.url, options.params, variables);
599 |
600 | variables.forEach(function (key) {
601 | delete options.params[key];
602 | });
603 |
604 | return url;
605 | }
606 |
607 | /**
608 | * Service for URL templating.
609 | */
610 |
611 | var ie = document.documentMode;
612 | var el = document.createElement('a');
613 |
614 | function Url(url, params) {
615 |
616 | var self = this || {},
617 | options = url,
618 | transform;
619 |
620 | if (isString(url)) {
621 | options = { url: url, params: params };
622 | }
623 |
624 | options = merge({}, Url.options, self.$options, options);
625 |
626 | Url.transforms.forEach(function (handler) {
627 | transform = factory(handler, transform, self.$vm);
628 | });
629 |
630 | return transform(options);
631 | }
632 |
633 | /**
634 | * Url options.
635 | */
636 |
637 | Url.options = {
638 | url: '',
639 | root: null,
640 | params: {}
641 | };
642 |
643 | /**
644 | * Url transforms.
645 | */
646 |
647 | Url.transforms = [template, query, root];
648 |
649 | /**
650 | * Encodes a Url parameter string.
651 | *
652 | * @param {Object} obj
653 | */
654 |
655 | Url.params = function (obj) {
656 |
657 | var params = [],
658 | escape = encodeURIComponent;
659 |
660 | params.add = function (key, value) {
661 |
662 | if (isFunction(value)) {
663 | value = value();
664 | }
665 |
666 | if (value === null) {
667 | value = '';
668 | }
669 |
670 | this.push(escape(key) + '=' + escape(value));
671 | };
672 |
673 | serialize(params, obj);
674 |
675 | return params.join('&').replace(/%20/g, '+');
676 | };
677 |
678 | /**
679 | * Parse a URL and return its components.
680 | *
681 | * @param {String} url
682 | */
683 |
684 | Url.parse = function (url) {
685 |
686 | if (ie) {
687 | el.href = url;
688 | url = el.href;
689 | }
690 |
691 | el.href = url;
692 |
693 | return {
694 | href: el.href,
695 | protocol: el.protocol ? el.protocol.replace(/:$/, '') : '',
696 | port: el.port,
697 | host: el.host,
698 | hostname: el.hostname,
699 | pathname: el.pathname.charAt(0) === '/' ? el.pathname : '/' + el.pathname,
700 | search: el.search ? el.search.replace(/^\?/, '') : '',
701 | hash: el.hash ? el.hash.replace(/^#/, '') : ''
702 | };
703 | };
704 |
705 | function factory(handler, next, vm) {
706 | return function (options) {
707 | return handler.call(vm, options, next);
708 | };
709 | }
710 |
711 | function serialize(params, obj, scope) {
712 |
713 | var array = isArray(obj),
714 | plain = isPlainObject(obj),
715 | hash;
716 |
717 | each(obj, function (value, key) {
718 |
719 | hash = isObject(value) || isArray(value);
720 |
721 | if (scope) {
722 | key = scope + '[' + (plain || hash ? key : '') + ']';
723 | }
724 |
725 | if (!scope && array) {
726 | params.add(value.name, value.value);
727 | } else if (hash) {
728 | serialize(params, value, key);
729 | } else {
730 | params.add(key, value);
731 | }
732 | });
733 | }
734 |
735 | function xdrClient (request) {
736 | return new Promise$1(function (resolve) {
737 |
738 | var xdr = new XDomainRequest(),
739 | handler = function (event) {
740 |
741 | var response = request.respondWith(xdr.responseText, {
742 | status: xdr.status,
743 | statusText: xdr.statusText
744 | });
745 |
746 | resolve(response);
747 | };
748 |
749 | request.abort = function () {
750 | return xdr.abort();
751 | };
752 |
753 | xdr.open(request.method, request.getUrl(), true);
754 | xdr.timeout = 0;
755 | xdr.onload = handler;
756 | xdr.onerror = handler;
757 | xdr.ontimeout = function () {};
758 | xdr.onprogress = function () {};
759 | xdr.send(request.getBody());
760 | });
761 | }
762 |
763 | var ORIGIN_URL = Url.parse(location.href);
764 | var SUPPORTS_CORS = 'withCredentials' in new XMLHttpRequest();
765 |
766 | function cors (request, next) {
767 |
768 | if (!isBoolean(request.crossOrigin) && crossOrigin(request)) {
769 | request.crossOrigin = true;
770 | }
771 |
772 | if (request.crossOrigin) {
773 |
774 | if (!SUPPORTS_CORS) {
775 | request.client = xdrClient;
776 | }
777 |
778 | delete request.emulateHTTP;
779 | }
780 |
781 | next();
782 | }
783 |
784 | function crossOrigin(request) {
785 |
786 | var requestUrl = Url.parse(Url(request));
787 |
788 | return requestUrl.protocol !== ORIGIN_URL.protocol || requestUrl.host !== ORIGIN_URL.host;
789 | }
790 |
791 | function body (request, next) {
792 |
793 | if (request.emulateJSON && isPlainObject(request.body)) {
794 | request.body = Url.params(request.body);
795 | request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
796 | }
797 |
798 | if (isFormData(request.body)) {
799 | delete request.headers['Content-Type'];
800 | }
801 |
802 | if (isPlainObject(request.body)) {
803 | request.body = JSON.stringify(request.body);
804 | }
805 |
806 | next(function (response) {
807 |
808 | var contentType = response.headers['Content-Type'];
809 |
810 | if (isString(contentType) && contentType.indexOf('application/json') === 0) {
811 |
812 | try {
813 | response.data = response.json();
814 | } catch (e) {
815 | response.data = null;
816 | }
817 | } else {
818 | response.data = response.text();
819 | }
820 | });
821 | }
822 |
823 | function jsonpClient (request) {
824 | return new Promise$1(function (resolve) {
825 |
826 | var name = request.jsonp || 'callback',
827 | callback = '_jsonp' + Math.random().toString(36).substr(2),
828 | body = null,
829 | handler,
830 | script;
831 |
832 | handler = function (event) {
833 |
834 | var status = 0;
835 |
836 | if (event.type === 'load' && body !== null) {
837 | status = 200;
838 | } else if (event.type === 'error') {
839 | status = 404;
840 | }
841 |
842 | resolve(request.respondWith(body, { status: status }));
843 |
844 | delete window[callback];
845 | document.body.removeChild(script);
846 | };
847 |
848 | request.params[name] = callback;
849 |
850 | window[callback] = function (result) {
851 | body = JSON.stringify(result);
852 | };
853 |
854 | script = document.createElement('script');
855 | script.src = request.getUrl();
856 | script.type = 'text/javascript';
857 | script.async = true;
858 | script.onload = handler;
859 | script.onerror = handler;
860 |
861 | document.body.appendChild(script);
862 | });
863 | }
864 |
865 | function jsonp (request, next) {
866 |
867 | if (request.method == 'JSONP') {
868 | request.client = jsonpClient;
869 | }
870 |
871 | next(function (response) {
872 |
873 | if (request.method == 'JSONP') {
874 | response.data = response.json();
875 | }
876 | });
877 | }
878 |
879 | function before (request, next) {
880 |
881 | if (isFunction(request.before)) {
882 | request.before.call(this, request);
883 | }
884 |
885 | next();
886 | }
887 |
888 | /**
889 | * HTTP method override Interceptor.
890 | */
891 |
892 | function method (request, next) {
893 |
894 | if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) {
895 | request.headers['X-HTTP-Method-Override'] = request.method;
896 | request.method = 'POST';
897 | }
898 |
899 | next();
900 | }
901 |
902 | function header (request, next) {
903 |
904 | request.method = request.method.toUpperCase();
905 | request.headers = assign({}, Http.headers.common, !request.crossOrigin ? Http.headers.custom : {}, Http.headers[request.method.toLowerCase()], request.headers);
906 |
907 | next();
908 | }
909 |
910 | /**
911 | * Timeout Interceptor.
912 | */
913 |
914 | function timeout (request, next) {
915 |
916 | var timeout;
917 |
918 | if (request.timeout) {
919 | timeout = setTimeout(function () {
920 | request.abort();
921 | }, request.timeout);
922 | }
923 |
924 | next(function (response) {
925 |
926 | clearTimeout(timeout);
927 | });
928 | }
929 |
930 | function xhrClient (request) {
931 | return new Promise$1(function (resolve) {
932 |
933 | var xhr = new XMLHttpRequest(),
934 | handler = function (event) {
935 |
936 | var response = request.respondWith('response' in xhr ? xhr.response : xhr.responseText, {
937 | status: xhr.status === 1223 ? 204 : xhr.status, // IE9 status bug
938 | statusText: xhr.status === 1223 ? 'No Content' : trim(xhr.statusText),
939 | headers: parseHeaders(xhr.getAllResponseHeaders())
940 | });
941 |
942 | resolve(response);
943 | };
944 |
945 | request.abort = function () {
946 | return xhr.abort();
947 | };
948 |
949 | xhr.open(request.method, request.getUrl(), true);
950 | xhr.timeout = 0;
951 | xhr.onload = handler;
952 | xhr.onerror = handler;
953 |
954 | if (request.progress) {
955 | if (request.method === 'GET') {
956 | xhr.addEventListener('progress', request.progress);
957 | } else if (/^(POST|PUT)$/i.test(request.method)) {
958 | xhr.upload.addEventListener('progress', request.progress);
959 | }
960 | }
961 |
962 | if (request.credentials === true) {
963 | xhr.withCredentials = true;
964 | }
965 |
966 | each(request.headers || {}, function (value, header) {
967 | xhr.setRequestHeader(header, value);
968 | });
969 |
970 | xhr.send(request.getBody());
971 | });
972 | }
973 |
974 | function parseHeaders(str) {
975 |
976 | var headers = {},
977 | value,
978 | name,
979 | i;
980 |
981 | each(trim(str).split('\n'), function (row) {
982 |
983 | i = row.indexOf(':');
984 | name = trim(row.slice(0, i));
985 | value = trim(row.slice(i + 1));
986 |
987 | if (headers[name]) {
988 |
989 | if (isArray(headers[name])) {
990 | headers[name].push(value);
991 | } else {
992 | headers[name] = [headers[name], value];
993 | }
994 | } else {
995 |
996 | headers[name] = value;
997 | }
998 | });
999 |
1000 | return headers;
1001 | }
1002 |
1003 | function Client (context) {
1004 |
1005 | var reqHandlers = [sendRequest],
1006 | resHandlers = [],
1007 | handler;
1008 |
1009 | if (!isObject(context)) {
1010 | context = null;
1011 | }
1012 |
1013 | function Client(request) {
1014 | return new Promise$1(function (resolve) {
1015 |
1016 | function exec() {
1017 |
1018 | handler = reqHandlers.pop();
1019 |
1020 | if (isFunction(handler)) {
1021 | handler.call(context, request, next);
1022 | } else {
1023 | warn('Invalid interceptor of type ' + typeof handler + ', must be a function');
1024 | next();
1025 | }
1026 | }
1027 |
1028 | function next(response) {
1029 |
1030 | if (isFunction(response)) {
1031 |
1032 | resHandlers.unshift(response);
1033 | } else if (isObject(response)) {
1034 |
1035 | resHandlers.forEach(function (handler) {
1036 | response = when(response, function (response) {
1037 | return handler.call(context, response) || response;
1038 | });
1039 | });
1040 |
1041 | when(response, resolve);
1042 |
1043 | return;
1044 | }
1045 |
1046 | exec();
1047 | }
1048 |
1049 | exec();
1050 | }, context);
1051 | }
1052 |
1053 | Client.use = function (handler) {
1054 | reqHandlers.push(handler);
1055 | };
1056 |
1057 | return Client;
1058 | }
1059 |
1060 | function sendRequest(request, resolve) {
1061 |
1062 | var client = request.client || xhrClient;
1063 |
1064 | resolve(client(request));
1065 | }
1066 |
1067 | var classCallCheck = function (instance, Constructor) {
1068 | if (!(instance instanceof Constructor)) {
1069 | throw new TypeError("Cannot call a class as a function");
1070 | }
1071 | };
1072 |
1073 | /**
1074 | * HTTP Response.
1075 | */
1076 |
1077 | var Response = function () {
1078 | function Response(body, _ref) {
1079 | var url = _ref.url;
1080 | var headers = _ref.headers;
1081 | var status = _ref.status;
1082 | var statusText = _ref.statusText;
1083 | classCallCheck(this, Response);
1084 |
1085 |
1086 | this.url = url;
1087 | this.body = body;
1088 | this.headers = headers || {};
1089 | this.status = status || 0;
1090 | this.statusText = statusText || '';
1091 | this.ok = status >= 200 && status < 300;
1092 | }
1093 |
1094 | Response.prototype.text = function text() {
1095 | return this.body;
1096 | };
1097 |
1098 | Response.prototype.blob = function blob() {
1099 | return new Blob([this.body]);
1100 | };
1101 |
1102 | Response.prototype.json = function json() {
1103 | return JSON.parse(this.body);
1104 | };
1105 |
1106 | return Response;
1107 | }();
1108 |
1109 | var Request = function () {
1110 | function Request(options) {
1111 | classCallCheck(this, Request);
1112 |
1113 |
1114 | this.method = 'GET';
1115 | this.body = null;
1116 | this.params = {};
1117 | this.headers = {};
1118 |
1119 | assign(this, options);
1120 | }
1121 |
1122 | Request.prototype.getUrl = function getUrl() {
1123 | return Url(this);
1124 | };
1125 |
1126 | Request.prototype.getBody = function getBody() {
1127 | return this.body;
1128 | };
1129 |
1130 | Request.prototype.respondWith = function respondWith(body, options) {
1131 | return new Response(body, assign(options || {}, { url: this.getUrl() }));
1132 | };
1133 |
1134 | return Request;
1135 | }();
1136 |
1137 | /**
1138 | * Service for sending network requests.
1139 | */
1140 |
1141 | var CUSTOM_HEADERS = { 'X-Requested-With': 'XMLHttpRequest' };
1142 | var COMMON_HEADERS = { 'Accept': 'application/json, text/plain, */*' };
1143 | var JSON_CONTENT_TYPE = { 'Content-Type': 'application/json;charset=utf-8' };
1144 |
1145 | function Http(options) {
1146 |
1147 | var self = this || {},
1148 | client = Client(self.$vm);
1149 |
1150 | defaults(options || {}, self.$options, Http.options);
1151 |
1152 | Http.interceptors.forEach(function (handler) {
1153 | client.use(handler);
1154 | });
1155 |
1156 | return client(new Request(options)).then(function (response) {
1157 |
1158 | return response.ok ? response : Promise$1.reject(response);
1159 | }, function (response) {
1160 |
1161 | if (response instanceof Error) {
1162 | error(response);
1163 | }
1164 |
1165 | return Promise$1.reject(response);
1166 | });
1167 | }
1168 |
1169 | Http.options = {};
1170 |
1171 | Http.headers = {
1172 | put: JSON_CONTENT_TYPE,
1173 | post: JSON_CONTENT_TYPE,
1174 | patch: JSON_CONTENT_TYPE,
1175 | delete: JSON_CONTENT_TYPE,
1176 | custom: CUSTOM_HEADERS,
1177 | common: COMMON_HEADERS
1178 | };
1179 |
1180 | Http.interceptors = [before, timeout, method, body, jsonp, header, cors];
1181 |
1182 | ['get', 'delete', 'head', 'jsonp'].forEach(function (method) {
1183 |
1184 | Http[method] = function (url, options) {
1185 | return this(assign(options || {}, { url: url, method: method }));
1186 | };
1187 | });
1188 |
1189 | ['post', 'put', 'patch'].forEach(function (method) {
1190 |
1191 | Http[method] = function (url, body, options) {
1192 | return this(assign(options || {}, { url: url, method: method, body: body }));
1193 | };
1194 | });
1195 |
1196 | function Resource(url, params, actions, options) {
1197 |
1198 | var self = this || {},
1199 | resource = {};
1200 |
1201 | actions = assign({}, Resource.actions, actions);
1202 |
1203 | each(actions, function (action, name) {
1204 |
1205 | action = merge({ url: url, params: params || {} }, options, action);
1206 |
1207 | resource[name] = function () {
1208 | return (self.$http || Http)(opts(action, arguments));
1209 | };
1210 | });
1211 |
1212 | return resource;
1213 | }
1214 |
1215 | function opts(action, args) {
1216 |
1217 | var options = assign({}, action),
1218 | params = {},
1219 | body;
1220 |
1221 | switch (args.length) {
1222 |
1223 | case 2:
1224 |
1225 | params = args[0];
1226 | body = args[1];
1227 |
1228 | break;
1229 |
1230 | case 1:
1231 |
1232 | if (/^(POST|PUT|PATCH)$/i.test(options.method)) {
1233 | body = args[0];
1234 | } else {
1235 | params = args[0];
1236 | }
1237 |
1238 | break;
1239 |
1240 | case 0:
1241 |
1242 | break;
1243 |
1244 | default:
1245 |
1246 | throw 'Expected up to 4 arguments [params, body], got ' + args.length + ' arguments';
1247 | }
1248 |
1249 | options.body = body;
1250 | options.params = assign({}, options.params, params);
1251 |
1252 | return options;
1253 | }
1254 |
1255 | Resource.actions = {
1256 |
1257 | get: { method: 'GET' },
1258 | save: { method: 'POST' },
1259 | query: { method: 'GET' },
1260 | update: { method: 'PUT' },
1261 | remove: { method: 'DELETE' },
1262 | delete: { method: 'DELETE' }
1263 |
1264 | };
1265 |
1266 | function plugin(Vue) {
1267 |
1268 | if (plugin.installed) {
1269 | return;
1270 | }
1271 |
1272 | Util(Vue);
1273 |
1274 | Vue.url = Url;
1275 | Vue.http = Http;
1276 | Vue.resource = Resource;
1277 | Vue.Promise = Promise$1;
1278 |
1279 | Object.defineProperties(Vue.prototype, {
1280 |
1281 | $url: {
1282 | get: function () {
1283 | return options(Vue.url, this, this.$options.url);
1284 | }
1285 | },
1286 |
1287 | $http: {
1288 | get: function () {
1289 | return options(Vue.http, this, this.$options.http);
1290 | }
1291 | },
1292 |
1293 | $resource: {
1294 | get: function () {
1295 | return Vue.resource.bind(this);
1296 | }
1297 | },
1298 |
1299 | $promise: {
1300 | get: function () {
1301 | var _this = this;
1302 |
1303 | return function (executor) {
1304 | return new Vue.Promise(executor, _this);
1305 | };
1306 | }
1307 | }
1308 |
1309 | });
1310 | }
1311 |
1312 | if (typeof window !== 'undefined' && window.Vue) {
1313 | window.Vue.use(plugin);
1314 | }
1315 |
1316 | return plugin;
1317 |
1318 | }));
--------------------------------------------------------------------------------