How to use the vuex-module-decorators.getModule function in vuex-module-decorators

To help you get started, we’ve selected a few vuex-module-decorators 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 siegrainwong / ancorazor / src / client.vue / blog.client / src / router.ts View on Github external
component: FormVuex
    },
    {
      path: '/formvuexdec',
      name: 'formvuexdec',
      component: FormVuexDec
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    }
  ],
});

const module: UserModule = getModule(UserModule, store)
/**
 * 路由验证
 */
router.beforeEach((to, from, next) => {
  if (!to.meta.requireAuth) return next();

  // console.log("token:" + module.token)
  if (module.isTokenValid) return next();

  next({
    path: '/login',
    query: { redirect: to.fullPath }
  })
})

export default router;
github Kruptein / PlanarAlly / ts_src / game / store.ts View on Github external
//         updateNote(state, payload: { note: Note; sync: boolean }) {
//             const note = state.notes.find(n => n.uuid === payload.note.uuid);
//             if (note === undefined) return;
//             note.title = payload.note.title;
//             note.text = payload.note.text;
//             if (payload.sync) socket.emit("Note.Update", payload.note);
//         },
//         removeNote(state, payload: { note: Note; sync: boolean }) {
//             state.notes = state.notes.filter(n => n.uuid !== payload.note.uuid);
//             if (payload.sync) socket.emit("Note.Remove", payload.note.uuid);
//         },
//     },
// });

import coreStore from "../store";
export const store = getModule(GameStore, coreStore);
github siegrainwong / ancorazor / src / client.vue / blog.client / src / common / network / api.request.ts View on Github external
export default {
    async get(url: string, query?: any, option?: AxiosRequestConfig) {
        return await handleRequest(Methods.GET, url, null, query, option);
    },
    async post(url: string, body: any, query?: any, option?: AxiosRequestConfig) {
        return await handleRequest(Methods.POST, url, body, query, option);
    },
    async put(url: string, body?: any, query?: any, option?: AxiosRequestConfig) {
        return await handleRequest(Methods.PUT, url, body, query, option);
    },
    async delete(url: string, query?: any, option?: AxiosRequestConfig) {
        return await handleRequest(Methods.DELETE, url, null, query, option);
    },
}

const module: UserModule = getModule(UserModule, store)
/**
 * 鉴权拦截器
 */
axios.interceptors.request.use(
    config => {
        // 判断是否存在token,如果存在的话,则每个http header都加上token
        if (module.isTokenValid) config.headers.Authorization = module.authToken;
        return config;
    },
    err => {
        return Promise.reject(err);
    }
);
axios.interceptors.response.use(
    response => {
        return response;
github EddieAbbondanzio / Updog.in / Updog.Client / src / comment / mixins / comment-finder-mixin.ts View on Github external
public async $findCommentsByUser(params: CommentFinderByUserParams): Promise> {
        const module = getModule(CommentStore, this.$store);
        return module.findByUser(params);
    }
}
github EddieAbbondanzio / Updog.in / Updog.Client / src / comment / mixins / comment-finder-mixin.ts View on Github external
public async $findCommentById(request: number) {
        const module = getModule(CommentStore, this.$store);
        return module.findById(request);
    }
github EddieAbbondanzio / Updog.in / Updog.Client / src / user / mixins / user-finder-mixin.ts View on Github external
public async $findUserByUsername(username: string) {
        const userModule: UserModule = getModule(UserModule, this.$store);
        return userModule.findByUsername(username);
    }
}
github EddieAbbondanzio / Updog.in / Updog.Client / src / user / mixins / authenticated-mixin.ts View on Github external
get $login(): UserLogin | null {
        const userModule: UserModule = getModule(UserModule, this.$store);
        return userModule.userLogin;
    }
github EddieAbbondanzio / Updog.in / Updog.Client / src / user / mixins / user-login-mixin.ts View on Github external
public async $reloginUser(authToken: string): Promise {
        const userStore: UserStore = getModule(UserStore, this.$store);
        return userStore.relogin(authToken);
    }

vuex-module-decorators

Decorators to make class-like Vuex modules

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular vuex-module-decorators functions