topfans/frontend/utils/handlers/guideKeys.js
2026-07-29 16:03:33 +08:00

31 lines
825 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// frontend/utils/handlers/guideKeys.js
// guide 分类工具函数(供 guideHandler 和 othersHandler 共用)
const GUIDE_PREFIX = 'guide_'
/**
* 列出所有 guide_* key
*/
export function listGuideKeys() {
try {
const info = uni.getStorageInfoSync()
return (info.keys || []).filter((k) => k.startsWith(GUIDE_PREFIX))
} catch (e) { return [] }
}
/**
* 解析 key 中包含的 uid如果有
* 支持两种 owner 段:
* - 数字 uid如 'guide_done_10001_intro'
* - 'default'(如 'guide_done_default_intro'guideConfig.js 在未登录时使用)
*/
export function extractUidFromGuideKey(key) {
// 先试数字
const m = key.match(/_(\d+)(?:_|$)/)
if (m) return m[1]
// 再试 default
const d = key.match(/_(default)(?:_|$)/)
if (d) return 'default'
return null
}