// store.js

import Vue from 'vue';
import Vuex from 'vuex';
import user from './modules/user';
import notifyService from "@/api/notify/notifyService";

Vue.use(Vuex);

export default new Vuex.Store({
	modules: {
		user
	},
	state: {
		messageDataList: [],
		triggerShowOpen: false // 新增状态
	},
	mutations: {
		setMessageDataList(state, dataList) {
			state.messageDataList = dataList;
		},
		setTriggerShowOpen(state, value) {
			state.triggerShowOpen = value;
		}
	},
	actions: {
		async loadmore({ commit }) {
			const data = await notifyService.getUnreadCountByIsSelf({
				isSelf: true
			});
			return data;
		},
		triggerShowOpen({ commit }) {
			commit('setTriggerShowOpen', true); // 触发状态改变
		},
		resetTriggerShowOpen({ commit }) {
			commit('setTriggerShowOpen', false); // 重置状态
		}
	}
});
