import targetSensitiveApi from "@/js/api/targetSensitiveApi";

const state = {
    words: [],
    count: 0,
    isLoading: true
}
const mutations = {
    setTargets(state, data) {
        state.words = data;
    },
    setCount(state, data) {
        state.count = data;
    },
    setLoading(state, status) {
        state.isLoading = status
    }
}

const actions = {
    queryPageable({commit}, pageData) {
        commit('setLoading', true);
        targetSensitiveApi.queryPageable(pageData.data, pageData.index, pageData.size, (response) => {
            if (response.data.code === 200) {
                commit('setTargets', response.data.content);
                commit('setCount', parseInt(response.data.message));
                commit('setLoading', false);
            } else {
                commit('setLoading', false);
            }
        })
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}