import user from '$config/user';
import popup, {PopupExportComponent} from "$utils/tool/popup";

export default {

    computed:{
        user:{
            get(){
                return this.$store.state.user.user;
            },
            set(value:Record<string, any>){

                let resultData:Record<string, any> = value;

                if (user.user) {
                  let useUserData = JSON.parse(JSON.stringify(user.user));
                    resultData = {
                        ...useUserData,
                        ...resultData
                    }
                }

                return this.$store.commit('setUserInfo',resultData);
            }
        },
        userShield:{
            get(){
                return this.$store.state.user.shield || {};
            }
        },
        dress:{
            get(){
                return this.user.dress || {};
            },
            set(item){
                let dress = this.dress;
                item = JSON.parse(JSON.stringify(item));
                this.user.dress = {
                    ...dress,
                    ...item
                }
            }
        }
    },

    methods:{

        openLogin(){
            if (!this.$store.getters.isLogin) {
                return popup.$open(PopupExportComponent.login);
            }
        }

    }

}
