联想输入
1.请求配置
request: {
autoComplete(data) {
// return { //自动补全接口
// url: '/xiaomi/associate.do',
// data: {
// q: data.text,
// },
// };
// console.log(data,'联想')
return {
list: [
{
title: '联想1',
},
{
title: '联想2',
},
{
title: '联想3',
}
],
keyword: '2'
}
},
}
根据官网的返回消息格式,只有重复title才会有效果,title的值是字符串,不能是数组
2.数据格式转换
官网上的数据格式转换还未尝试
语音输入
交互效果有两种,目前只尝试了ChatUI自带的交互
在config下配置
makeRecorder({ ctx }) {
return {
canRecord,
onStart() {
console.log('开始录音');
nativeInvoke('startVoiceRecognition');
},
onEnd() {
console.log('停止录音');
nativeInvoke('stopVoiceRecognition', (text) => {
ctx.postMessage({
type: 'text',
content: { text },
});
});
},
onCancel() {
console.log('取消录音');
nativeInvoke('cancelVoiceRecognition');
},
};
},
这里官网假设 App 提供了 bridge 对象 `nativeInvoke`,还未实现其语音功能,只能展示出页面效果