17 lines
723 B
Plaintext
17 lines
723 B
Plaintext
|
|
/** 从 app 列表里找 TikTok 的 bundleId */
|
|||
|
|
export function pickTikTokBundleId(apps) {
|
|||
|
|
if (!Array.isArray(apps)) return null
|
|||
|
|
|
|||
|
|
// 1) 首选常见的 TikTok 包名
|
|||
|
|
const preferred = apps.find(a => a?.bundleId === 'com.zhiliaoapp.musically')
|
|||
|
|
if (preferred) return preferred.bundleId
|
|||
|
|
|
|||
|
|
// 2) 其次按名字匹配(大小写不敏感)
|
|||
|
|
const byName = apps.find(a => String(a?.name).toLowerCase() === 'tiktok')
|
|||
|
|
|| apps.find(a => String(a?.name).toLowerCase().includes('tiktok'))
|
|||
|
|
if (byName) return byName.bundleId
|
|||
|
|
|
|||
|
|
// 3) 兜底:bundleId 里包含 musically
|
|||
|
|
const fuzzy = apps.find(a => String(a?.bundleId || '').includes('musically'))
|
|||
|
|
return fuzzy ? fuzzy.bundleId : null
|
|||
|
|
}
|