Upgrade Playlist Features

This commit is contained in:
2025-12-09 17:20:01 +08:00
parent 577990de69
commit 8bd2780688
683 changed files with 91812 additions and 81260 deletions

63
main/device_manager.h Normal file
View File

@@ -0,0 +1,63 @@
#ifndef DEVICE_MANAGER_H
#define DEVICE_MANAGER_H
#include <string>
class DeviceManager {
public:
static DeviceManager& GetInstance();
// 获取设备MAC地址
std::string GetMACAddress();
// 保存设备Token到NVS
bool SaveDeviceToken(const std::string& token);
// 从NVS读取设备Token
std::string GetDeviceToken();
// 清除设备Token解绑
bool ClearDeviceToken();
// 设备绑定流程
bool BindDevice(const std::string& binding_code, const std::string& device_name = "");
// 验证设备状态
bool VerifyDevice();
// 歌单相关
std::string GetFavorites();
std::string GetUserPlaylists();
// 检查设备是否已绑定
bool IsDeviceBound();
// 获取绑定的用户名
std::string GetBoundUsername();
private:
DeviceManager();
~DeviceManager();
// 禁止拷贝
DeviceManager(const DeviceManager&) = delete;
DeviceManager& operator=(const DeviceManager&) = delete;
std::string mac_address_;
std::string device_token_;
std::string bound_username_;
bool is_bound_;
// NVS命名空间
static constexpr const char* NVS_NAMESPACE = "device";
static constexpr const char* NVS_KEY_TOKEN = "token";
static constexpr const char* NVS_KEY_USERNAME = "username";
// 从NVS加载配置
void LoadFromNVS();
// 尝试从服务器获取 token用于网页端绑定后自动同步
bool TryFetchTokenFromServer();
};
#endif // DEVICE_MANAGER_H