@abler/ats-vuex-plugin 中文文档教程

发布于 3年前 浏览 22 项目主页 更新于 3年前

Vuex Plugin for Nuxt.js

用法示例

import { GetterTree, ActionTree, MutationTree } from 'vuex'
import Plugin, { IConfig } from '@abler/ats-vuex-plugin'
import { Audience } from '@abler/ats-front-resources-api/lib/support'

export const state = () => ({})

export const plugins = [Plugin]

export type RootState = ReturnType<typeof state>

export const getters: GetterTree<RootState, RootState> = {}

export const mutations: MutationTree<RootState> = {}

export const actions: ActionTree<RootState, RootState> = {
  async nuxtServerInit ({ dispatch }, { req }) {
    const config: IConfig  = {
      apiBaseURL: 'http://localhost:3000/api',
      cookie: req.headers.cookie,
      audience: Audience.CANDIDATE,
      referrerSource: 'someSource',
      hostname: '.localhost'
    }
    await dispatch('root/setConfig', config, { root: true })
  }
}

Docs

Vuex Plugin for Nuxt.js

Example usage

import { GetterTree, ActionTree, MutationTree } from 'vuex'
import Plugin, { IConfig } from '@abler/ats-vuex-plugin'
import { Audience } from '@abler/ats-front-resources-api/lib/support'

export const state = () => ({})

export const plugins = [Plugin]

export type RootState = ReturnType<typeof state>

export const getters: GetterTree<RootState, RootState> = {}

export const mutations: MutationTree<RootState> = {}

export const actions: ActionTree<RootState, RootState> = {
  async nuxtServerInit ({ dispatch }, { req }) {
    const config: IConfig  = {
      apiBaseURL: 'http://localhost:3000/api',
      cookie: req.headers.cookie,
      audience: Audience.CANDIDATE,
      referrerSource: 'someSource',
      hostname: '.localhost'
    }
    await dispatch('root/setConfig', config, { root: true })
  }
}

Docs

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文