Esempio n. 1
0
function parseToken (token) {
  let path = store.state.baseURL
  if (path === '') path = '/'
  document.cookie = `auth=${token}; max-age=86400; path=${path}`
  let res = token.split('.')
  let user = JSON.parse(Base64.decode(res[1]))
  if (!user.commands) {
    user.commands = []
  }

  store.commit('setJWT', token)
  store.commit('setUser', user)
}
Esempio n. 2
0
 window.addEventListener('message', (event) => {
   const eventType = event.data.event
   if (eventType !== undefined && typeof this['on' + eventType] === 'function') {
     this['on' + eventType](event.data)
   } else if (event.data.show !== undefined) {
     store.commit('SET_PHONE_VISIBILITY', event.data.show)
   }
 })
router.beforeEach((to, from, next) => {
  Store.commit('ui/SET_PAGE_LOADING', true)
  setTimeout(() => {
    Store.commit('ui/SET_PAGE_LOADING', false)
  }, 2000)

  return next()
})
Esempio n. 4
0
router.beforeEach((to, from, next) => {
  if (store.state.show_burger_menu) {
    store.commit(types.SHOW_BURGER_MENU, false)
    next(false)
  } else {
    next()
  }
})
Esempio n. 5
0
 onwaitingCall (data) {
   store.commit('SET_APPELS_INFO_IF_EMPTY', {
     ...data.infoCall,
     initiator: data.initiator
   })
   // this.voiceRTC.addEventListener('onCandidate', (candidates) => {
   //   this.post('onCandidates', { id: data.infoCall.id, candidates })
   // })
 }
Esempio n. 6
0
 onacceptCall (data) {
   if (USE_VOICE_RTC === true) {
     if (data.initiator === true) {
       this.voiceRTC.onReceiveAnswer(data.infoCall.rtcAnswer)
     }
     this.voiceRTC.addEventListener('onCandidate', (candidates) => {
       this.post('onCandidates', { id: data.infoCall.id, candidates })
     })
   }
   store.commit('SET_APPELS_INFO_IS_ACCEPTS', true)
 }
Esempio n. 7
0
router.beforeEach((to, from, next) => {
  // always use the expression in the url query parameter if the navigation
  // was initiated from anything not in the moloch UI (browser forward/back btns)
  if (!to.params.nav && store.state.expression !== to.query.expression) {
    store.commit('setExpression', to.query.expression);
  }

  let page = to.name || 'Moloch - ';
  let view = to.query.view ? ` - ${to.query.view}` : '';
  let expression = to.query.expression ? ` - ${to.query.expression}` : '';

  /* eslint-disable no-undef */
  let title = MOLOCH_TITLE_CONFIG.replace(/_page_/g, page)
    .replace(/( *_-expression|_expression)_/g, expression)
    .replace(/( *_-view|_view)_/g, view);

  document.title = title;

  next();
});
Esempio n. 8
0
 saveToken: function (token) {
   localStorage.setItem('token', token);
   store.commit('setLoggedIn', !!token);
 },
Esempio n. 9
0
File: auth.js Progetto: aihua/moloch
 .then((response) => {
   store.commit('setHasAuth', response.data.hasAuth);
 })
Esempio n. 10
0
File: auth.js Progetto: aihua/moloch
 .catch((error) => {
   store.commit('setHasAuth', false);
 });
Esempio n. 11
0
 onupdateBankbalance (data) {
   store.commit('SET_BANK_AMONT', data.banking)
 }
Esempio n. 12
0
router.afterEach(function (to) {
    store.commit('updateLoadingStatus', {isLoading: false})
})
Esempio n. 13
0
 .then((response) => {
   store.commit('setHasAuth', response.data.hasAuth);
   store.commit('setDashboardOnly', response.data.dashboardOnly);
 })
Esempio n. 14
0
 .then((response) => {
   store.commit('setHasAuth', true);
   this.saveToken(response.data.token);
   resolve(response.data);
 })
Esempio n. 15
0
router.beforeEach((to, from, next) => {
    document.title = to.meta.title || document.title;
    //移动端如果使用异步组件加载那么还是需要一点等待时间的,在网络慢时等待时间会更长。显示Loading状态缓解一下用户等待情绪就十分重要。
    store.commit('updateLoadingStatus', {isLoading: true})
    next();
});
Esempio n. 16
0
 onupdateMessages (data) {
   store.commit('SET_MESSAGES', data.messages)
 }
Esempio n. 17
0
 onrejectCall (data) {
   if (this.voiceRTC !== null) {
     this.voiceRTC.close()
   }
   store.commit('SET_APPELS_INFO', null)
 }
Esempio n. 18
0
 ontchat_channel (data) {
   store.commit('TCHAT_SET_MESSAGES', data)
 }
Esempio n. 19
0
 onnewMessage (data) {
   store.commit('ADD_MESSAGE', data.message)
 }
Esempio n. 20
0
 onupdateContacts (data) {
   store.commit('SET_CONTACTS', data.contacts)
 }
Esempio n. 21
0
 onupdateBourse (data) {
   store.commit('SET_BOURSE_INFO', data.bourse)
 }
Esempio n. 22
0
 .then((response) => {
   store.commit('setLoggedIn', response.data.loggedin);
 })
const mountVue = () => {
  // Register the router hooks with their names
  Component.registerHooks([
    'asyncData',
    'beforeRouteEnter',
    'beforeRouteLeave',
    'beforeRouteUpdate', // for vue-router 2.2+
  ]);

  // Init Vue
  Vue.config.productionTip = false;
  Vue.use(StoreUtils);
  Vue.use(TransferDom);
  Vue.use(PreventOverscroll);
  Vue.use(Wechat);
  Vue.use(PhotoSwipe, { wechat: Vue.wechat, pswpOptions: { showShare: false } });
  Vue.use(VueLazyload);

  let lastLocation = null;
  Vue.mixin({
    beforeMount() {
      // Deal with Vue.use() of current component.
      const uses = this.$options.uses;
      if (uses) {
        uses.forEach(entity => Vue.use(entity));
      }
    },
    mounted() {
      const proto = Object.getPrototypeOf(this);
      const options = this.$options.options || get(proto, 'constructor.options.options');
      if (options) {
        if (options.hideTabbar !== void 0) {
          store.commit(`common/${COMMON.SET_TABBAR_VISIBLE}`, { id: this._uid, value: !options.hideTabbar });
        }
        if (options.hideNavbar !== void 0) {
          store.commit(`common/${COMMON.SET_NAVBAR_VISIBLE}`, { id: this._uid, value: !options.hideNavbar });
        }
        if (options.bodyAutoHeight !== void 0) {
          store.commit(`common/${COMMON.SET_BODY_AUTO_HEIGHT}`, { id: this._uid, value: options.bodyAutoHeight });
        }
        if (options.bodyBackground !== void 0) {
          store.commit(`common/${COMMON.SET_BODY_BACKGROUND}`, { id: this._uid, value: options.bodyBackground });
        }
      }
      if (this.$options.onWechatReady) {
        // Init wechat SDK
        const url = window.location.href;
        if (!isLocalhost() && url !== lastLocation) {
          // bind wechat sdk error function.
          Vue.wechat.error((e) => {
            showDialog({
              title: 'Wechat SDK error',
              content: e.errMsg,
            });
            if (e.errMsg === 'config:invalid signature') {
              if (!isDevelop()) {
                window.location.reload();
              }
              console.error(e);
            }
          });
          // start initing wechat sdk.
          Promise.resolve().then(() => {
            store.dispatch(`common/${COMMON.GET_WECHAT_SDK_INFO}`, { url }).then((info) => {
              Vue.wechat.config({
                debug: info.debug,
                appId: info.appId,
                timestamp: info.timestamp,
                nonceStr: info.nonceStr,
                signature: info.signature,
                jsApiList: info.jsApiList,
              });
            });
          });
          lastLocation = url;
        }
        this.$wechat.ready(() => {
          this.$options.onWechatReady.call(this);
        });
      }
    },
    destroyed() {
      const options = this.$options.options;
      if (options) {
        if (options.hideTabbar !== void 0) {
          store.commit(`common/${COMMON.REMOVE_TABBAR_VISIBLE}`, { id: this._uid });
        }
        if (options.hideNavbar !== void 0) {
          store.commit(`common/${COMMON.REMOVE_NAVBAR_VISIBLE}`, { id: this._uid });
        }
        if (options.bodyAutoHeight !== void 0) {
          store.commit(`common/${COMMON.REMOVE_BODY_AUTO_HEIGHT}`, { id: this._uid });
        }
        if (options.bodyBackground !== void 0) {
          store.commit(`common/${COMMON.REMOVE_BODY_BACKGROUND}`, { id: this._uid });
        }
      }
    },
  });

  sync(store, router);
  new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App),
  });
};
Esempio n. 24
0
 .catch((error) => {
   store.commit('setLoggedIn', false);
 });
Esempio n. 25
0
 // ==========================================================================
 //  Gestion des events
 // ==========================================================================
 onupdateMyPhoneNumber (data) {
   store.commit('SET_MY_PHONE_NUMBER', data.myPhoneNumber)
 }
Esempio n. 26
0
 .catch((error) => {
   store.commit('setHasAuth', false);
   store.commit('setDashboardOnly', false);
 });
 setTimeout(() => {
   Store.commit('ui/SET_PAGE_LOADING', false)
 }, 2000)
Esempio n. 28
0
 onautoAcceptCall (data) {
   store.commit('SET_APPELS_INFO', data.infoCall)
   this.acceptCall(data.infoCall)
 }
Esempio n. 29
0
 onhistoriqueCall (data) {
   store.commit('SET_APPELS_HISTORIQUE', data.historique)
 }