From 87100e9ae7bc36fce9fbaa39b83a9ebecd87d4b4 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sat, 8 Sep 2018 23:34:12 +0800 Subject: [PATCH] Expose internal function to global for plugins --- resources/assets/src/js/net.js | 2 ++ resources/assets/src/js/notify.js | 6 +++++- resources/assets/src/shims.d.ts | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/assets/src/js/net.js b/resources/assets/src/js/net.js index 09957420..2512c25c 100644 --- a/resources/assets/src/js/net.js +++ b/resources/assets/src/js/net.js @@ -68,3 +68,5 @@ Vue.use(_Vue => { post, }; }); + +window.bsAjax = { get, post }; diff --git a/resources/assets/src/js/notify.js b/resources/assets/src/js/notify.js index ccb7eda0..ef0a7057 100644 --- a/resources/assets/src/js/notify.js +++ b/resources/assets/src/js/notify.js @@ -1,6 +1,6 @@ import $ from 'jquery'; import sweetalert2 from 'sweetalert2'; -import 'toastr'; +import toastr from 'toastr'; import { trans } from './i18n'; /** @@ -77,3 +77,7 @@ export const swal = sweetalert2.mixin({ confirmButtonText: trans('general.confirm'), cancelButtonText: trans('general.cancel') }); + +window.toastr = toastr; +window.showModal = showModal; +window.swal = swal; diff --git a/resources/assets/src/shims.d.ts b/resources/assets/src/shims.d.ts index 433a17dc..d08cbe6c 100644 --- a/resources/assets/src/shims.d.ts +++ b/resources/assets/src/shims.d.ts @@ -18,6 +18,10 @@ interface Window { bsEmitter: { on(eventName: string, listener: Function): void emit(eventName: string, payload: object): void + }, + bsAjax: { + get(url: string, params?: object): Promise + post(url: string, data?: object): Promise } }