import $store from '@/store/index'
export default {
    timer: null,
    timeout: 10,
    show(title) {
        clearTimeout(this.timer);
        $store.commit('loading/show', true);
        if (title) {
            $store.commit('loading/title', title);
        }
        // 10秒后自动hide
        let that = this;
        this.timer = setTimeout(() => {
            that.hide();
        }, this.timeout * 1000);
    },
    hide() {
        clearTimeout(this.timer);
        $store.commit('loading/show', false);
        $store.commit('loading/title', "");
    }
}