UNPKG

drip-ui

Version:

Lightweight Mobile UI Components built on Vue

59 lines (48 loc) 1.23 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import Vue from 'vue'; import DripLoading from './Loading'; import { isServer } from '../utils'; var instance; var initInstance = function initInstance() { instance = new (Vue.extend(DripLoading))({ el: document.createElement('div') }); document.body.appendChild(instance.$el); }; var Loading = function Loading(options) { /* istanbul ignore if */ if (isServer) { return; } if (!instance) { initInstance(); } return _extends.apply(void 0, [instance].concat(options)); }; Loading.defaultOptions = { show: '', text: '请求中', type: 'circle' }; Loading.show = function (options) { return Loading(_extends({}, Loading.currentOptions, { show: true }, options)); }; Loading.hide = function () { if (instance) { instance.show = false; } }; Loading.setDefaultOptions = function (options) { _extends(Loading.currentOptions, options); }; Loading.resetDefaultOptions = function () { Loading.currentOptions = _extends({}, Loading.defaultOptions); }; Loading.install = function () { Vue.use(DripLoading); }; Vue.loading = Vue.prototype.$loading = Loading; Loading.resetDefaultOptions(); export default Loading;