How to use the vue.ls function in vue

To help you get started, we’ve selected a few vue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liangfengbo / nodejs-koa-blog / web / src / components / user / Login.vue View on Github external
this.$refs[formName].validate(async (valid) => {
          if (valid) {
            const res = await this.userLogin(this.ruleForm);
            this.showMessage('登录成功!');

            // 关联模态框
            Vue.ls.set('BOBLOG_FE_TOKEN', res.data.token);
            this.$store.commit('user/SHOW_USER_MANAGER_MODEL', false);

            // 登录
            const BOBLOG_FE_TOKEN = Vue.ls.get('BOBLOG_FE_TOKEN');
            await this.$store.dispatch('user/getUserInfo', {
              username: BOBLOG_FE_TOKEN
            });

          } else {
            this.showMessage('请完善表单', 'error');
            return false;
          }
        });
      },
github lumen-cms / lumen-cms / lib / templates / util / authHelpers.js View on Github external
export const getTokenFromStorage = (req) => {
  if (process.server) {
    const cookie = require('cookie') // request parser for the cookie
    const cookies = cookie.parse(req.headers.cookie || '')
    return {
      user: cookies.user_credentials && JSON.parse(cookies.user_credentials)
    }
  }
  const user = Vue.ls.get('user_credentials')
  return {
    user
  }
}
github liangfengbo / nodejs-koa-blog / admin / src / main.js View on Github external
router.beforeEach(async (to, from, next) => {
  iView.LoadingBar.start();
  Util.title(to.meta.title)

  let token = Vue.ls.get("token");
  if (token) {
    store.dispatch('admin/auth').then(() => {
      next()

    }).catch(err => {
      Vue.prototype.$Message.error(err.data.msg || '权限未授权')
      setTimeout(() => {
        next('/login')
      }, 1500);
    })

  } else {
    // 判断是否需要登录
    if (!!to.meta.noAuth) {
      next()
github liangfengbo / nodejs-koa-blog / web / src / api / fetch.js View on Github external
utils.ajax.interceptors.request.use((config) => {
  const isLoading = config.isLoading || config.isLoading === undefined
  if (isLoading) {
    // 开启loading
    store.dispatch('loading/openLoading')
  }

  // 获取token
  config.headers.common.Authorization = `Bearer ${Vue.ls.get('WATCH_CHECK_TOKEN')}`
  return config
}, error => Promise.reject(error))
github RobinCK / vue-ls / test / unit / ava / eventWindow.js View on Github external
test('Add/Remove event', (t) => {
  t.plan(2);

  Vue.ls.on('item_one_test', () => {});
  Vue.ls.on('item_two_test', () => {});
  Vue.ls.on('item_two_test', () => {});
  Vue.ls.on('item_three_test', (val, oldVal) => {
    t.is(val, 'val');
    t.is(oldVal, 'old_val');
  });
  Vue.ls.off('item_two_test', () => {});
  Vue.ls.off('item_one_test', () => {});

  StorageEvent.emit({
    key: 'item_three_test',
    newValue: JSON.stringify({ value: 'val', expire: null }),
    oldValue: JSON.stringify({ value: 'old_val', expire: null }),
  });
  StorageEvent.emit({
    key: 'item_undefined_test',
    newValue: JSON.stringify({ value: 'val', expire: null }),
github RobinCK / vue-ls / test / unit / ava / events.js View on Github external
test('Add/Remove event', (t) => {
  t.plan(4);

  Vue.ls.on('item_one_test', () => {});
  Vue.ls.on('item_two_test', () => {});
  Vue.ls.on('item_two_test', () => {});
  Vue.ls.on('item_three_test', (val, oldVal) => {
    t.is(val, 'val');
    t.is(oldVal, 'old_val');
  });
  Vue.ls.off('item_two_test', () => {});
  Vue.ls.off('item_one_test', () => {});
  Vue.ls.off('item_one_test', () => {});

  StorageEvent.emit({
    key: 'item_three_test',
    newValue: JSON.stringify({ value: 'val', expire: null }),
    oldValue: JSON.stringify({ value: 'old_val', expire: null }),
  });
  StorageEvent.emit({
github pycook / cmdb / cmdb-ui / src / store / modules / user.js View on Github external
login(userInfo).then(response => {
          Vue.ls.set(ACCESS_TOKEN, response.token, 7 * 24 * 60 * 60 * 1000)
          commit('SET_TOKEN', response.token)
          resolve()
        }).catch(error => {
          reject(error)
github pycook / cmdb / ui / src / store / modules / app.js View on Github external
SET_SIDEBAR_TYPE: (state, type) => {
      state.sidebar = type
      Vue.ls.set(SIDEBAR_TYPE, type)
    },
    CLOSE_SIDEBAR: (state) => {
github zhangdaiscott / jeecg-boot / ant-design-vue-jeecg / src / utils / request.js View on Github external
store.dispatch('Logout').then(() => {
                Vue.ls.remove(ACCESS_TOKEN)
                window.location.reload()
              })
            }
github zhangdaiscott / jeecg-boot / ant-design-vue-jeecg / src / store / modules / app.js View on Github external
TOGGLE_FIXED_SIDERBAR: (state, fixed) => {
      Vue.ls.set(DEFAULT_FIXED_SIDEMENU, fixed)
      state.fixSiderbar = fixed
    },
    TOGGLE_FIXED_HEADER_HIDDEN: (state, show) => {