Bixby 如何在动作脚本中检测设备目标类型?
我希望我的“GetContent”脚本检测设备是否为“watch”,并传递一条指令,从content.json文件中筛选出候选答案,该文件的文本字段长度大于一定数量的字符 content.json格式:Bixby 如何在动作脚本中检测设备目标类型?,bixby,bixbystudio,Bixby,Bixbystudio,我希望我的“GetContent”脚本检测设备是否为“watch”,并传递一条指令,从content.json文件中筛选出候选答案,该文件的文本字段长度大于一定数量的字符 content.json格式: {tags: ["literature"], text: "At once it struck me what quality went to form a man of achievement, especially in literature, and which Shakespeare p
{tags: ["literature"], text: "At once it struck me what quality went to form a man of achievement, especially in literature, and which Shakespeare possessed so enormously -- I mean negative capability, that is, when a man is capable of being in uncertainties, mysteries, doubts, without any irritable reaching after fact and reason. Source: John Keats", image: {url: "images/Shakespeare.jpg"}},
所以逻辑应该是
if (watch) content = short_quotes_only
我建议探索
$vivContext
()
设备
属性将允许您查看用户正在使用的设备类型(bixby mobile、bixby tv等),并提供您希望为正在使用的设备显示的数据。这组代码片段对我很有用:
device = $vivContext.device
console.log('device', device)
if (device == 'bixby-watch' ) { maxlength = 100
console.log('maxlength is now', maxlength)
}
然后在稍后的脚本中
//filters entitled content by length of text field in characters
content = content.filter(function(i) { return i.text.length < maxlength;
//按字符文本字段长度筛选标题内容
content=content.filter(函数(i){返回i.text.length