// 获取账号和密码
export const getLoginInfo = () => {
	return uni.getStorageSync('login_info')
}

//清除账号和密码
export const clearLoginInfo = () => {
	uni.removeStorageSync('login_info')
}

// 获取存储的 token（用于其他请求）
export const getToken = () => {
	return uni.getStorageSync('token')
}

// 清除 token（退出登录）
export const clearToken = () => {
	uni.removeStorageSync('token')
}

// 获取会话id
export const getCurrentSessionId = () => {
	const sessionId = uni.getStorageSync('currentSessionId')
	// 如果是纯数字 → 直接返回
	if (!isNaN(Number(sessionId))) {
		return sessionId
	}

	// 如果是 uuid 带横杠 → 去掉横杠
	return sessionId.replace(/-/g, '')
}

// 清除会话id
export const clearCurrentSessionId = () => {
	uni.removeStorageSync('currentSessionId')
}

// 获取socket连接成功返回时的task_call_id
export const getTaskCallId = () => {
	return uni.getStorageSync('taskCallId')
}

// 清除socket连接成功返回时的task_call_id
export const clearTaskCallId = () => {
	uni.removeStorageSync('taskCallId')
}

// 获取用户id
export const getUserId = () => {
	console.log("用户Id（UserId）", uni.getStorageSync('userId'));
	return uni.getStorageSync('userId')
}

// 清除用户id
export const clearUserId = () => {
	uni.removeStorageSync('userId')
}

// 获取聊天type
export const getChatType = () => {
	return uni.getStorageSync('chatType')
}

// 清除聊天type
export const clearChatType = () => {
	uni.removeStorageSync('chatType')
}

// 获取正在聊天的好友的receiverId
export const getReceiverId = () => {
	return uni.getStorageSync('receiverId')
}

// 清除正在聊天的好友的receiverId
export const clearReceiverId = () => {
	uni.removeStorageSync('receiverId')
}

// 获取当前ai会话的工作区id
export const getWorkspaceId = () => {
	return uni.getStorageSync('workspace_id')
}

// 清除当前ai会话的工作区id
export const clearWorkspaceId = () => {
	uni.removeStorageSync('workspace_id')
}