import { defineStore } from 'pinia';
import { computed,ref } from 'vue';
export const useCounterStore = defineStore('counter',()=>{
	//定义数据（state)
	const openId = ref('');
	const nikeName = ref('');
	const key = ref('');
	const phone = ref('');
	const uid = ref('');
	const statusHeight = ref(uni.getMenuButtonBoundingClientRect()['height']);
	const headerHeight = ref(uni.getSystemInfoSync()['statusBarHeight']);
	const statusBartop = ref(uni.getMenuButtonBoundingClientRect()['top']);
	const ButtonWidth = ref(uni.getMenuButtonBoundingClientRect().width);
	const ButtonHeight = ref(uni.getMenuButtonBoundingClientRect().height)
	const storeName = ref('')
	const token = ref(uni.getStorageSync('token') || '');
	// 设置 Token
	const setToken = (tokens,uids,phones,nikeNames) => {
	  token.value = tokens;
	  uid.value = uids;
	  phone.value = phones;
	  nikeName.value = nikeNames;
	  uni.setStorageSync('token', tokens);
	};
	// 清除 Token
	const clearToken = () => {
	  token.value = '';
	  uni.removeStorageSync('token');
	};
	//以对象的形式return供组件调用
	return{
		storeName,
		nikeName,
		key,
		token, 
		setToken, 
		clearToken,
		phone,
		uid,
		ButtonWidth,
		ButtonHeight,
		statusHeight,
		headerHeight,
		statusBartop,
	}
})