MCPcopy Create free account
hub / github.com/zxlie/FeHelper / getUserId

Function getUserId

apps/background/statistics.js:65–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63 * @returns {Promise<string>} 用户ID
64 */
65 const getUserId = async () => {
66 if (userId) return userId;
67
68 try {
69 const result = await Awesome.StorageMgr.get(USER_ID_KEY);
70 if (result) {
71 userId = result;
72 } else {
73 userId = generateUserId();
74 await Awesome.StorageMgr.set(USER_ID_KEY, userId);
75 }
76 return userId;
77 } catch (error) {
78 console.error('获取用户ID失败:', error);
79 return generateUserId(); // 失败时生成临时ID
80 }
81 };
82
83 /**
84 * 加载本地存储的使用数据

Callers 1

initFunction · 0.85

Calls 3

generateUserIdFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected