import { defineStore } from "pinia"
import { reactive } from 'vue'

export const useLoginUserStore = defineStore(
  "loginUser",
  () => {
    const loginUser = reactive({
      user: {},
      menu: [],
			hospital:[],
      sysName: '',
    });

    // 设置当前登录用户院区
    function setLoginHospital(data) {
      loginUser.hospital = data;
    }
		
		// 设置当前登录用户
		function setLoginUser(data) {
			loginUser.user = data;
		}
				
    // 设置当前登录用户菜单
    function setLoginUserMenu(data) {
      loginUser.menu = data;
    }
    
    // 设置系统名称
    function setLoginUserTitle(data) {
      loginUser.sysName = data;
    }

    return {
      loginUser,
      setLoginUser,
			setLoginHospital,
      setLoginUserMenu,
      setLoginUserTitle,
    };
  },
  {
    unistorage: true, // 开启后对 state 的数据读写都将持久化
  },
);