@OptIn(BetaOpenAI::class) @GetMapping("generate", produces = [MediaType.TEXT_EVENT_STREAM_VALUE]) fun chat(): Flow<String> { return chatService.chat().map { chat -> var content = "" chat.choices.forEach { chatChunk -> chatChunk.delta?.content?.apply { content += this } } // print("content == $content") Base64.getEncoder().encodeToString(content.toByteArray(Charsets.UTF_8)) } } 前端使用base64界面后就可以了 const arrayBuffer = buffer.data; const uint8Array = new Uint8Array(arrayBuffer); let oText = String.fromCharCode.apply(null, uint8Array) let text = oText.replaceAll("data:", "") let res = "" if (text.length > 0) { res = Base64.decode(text) } all += res this.setData({ info: all })
request 中的onChunkReceived 乱码网页,postman ,接口都表现正常,开启 enableChunked: true, 后就乱码,求解 let task = wx.request({ url: 'https://xxx/api/chat/generate', enableChunked: true, method: "GET", }) task.onChunkReceived((buffer) => { // const decoder = new TextDecoder("utf-8"); // const str = decoder.decode(new Uint8Array(buffer.data)) const arrayBuffer = buffer.data; const uint8Array = new Uint8Array(arrayBuffer); let text = String.fromCharCode.apply(null, uint8Array); console.log('onChunkReceived',text) }) chrome表现 [图片] postman [图片] 后台接口 [图片] 乱码 [图片]
2023-05-19代码片段:https://developers.weixin.qq.com/s/Xo6aTHmj7Xjt [图片][图片] 设备为hc09 allowDuplicatesKey: false, 还是多次上报了
onBluetoothDeviceFound 回调只有一个设备?周围有两个设备但是只返回了一个设备,两个设备不能同时搜索到,只能搜索到一个 非常着急!!!!
2020-08-18荣耀10
qrcode.js canvas画二维码qrcode.js canvas画二维码 画的时候是空白 隐藏小程序 再次打开就能显示二维码 机型:华为荣耀v20 qrcode({ width: width, height: width, canvasId: 'qrcodeCanvas', text: qrCode, foreground: item.hasUsed ? '#C8C5C4' : '#000000' })
2019-05-14