safe-file
// 处理图片显示
protocol.handle('safe-file', async (request) => {
const filePath = decodeURIComponent(request.url.slice('safe-file://'.length))
const newFilePath = url.pathToFileURL(filePath).toString()
// const data = await fs.readFile(filePath)
// return new Response(data, {
// status: 200,
// headers: {
// 'Content-Type': lookup(filePath) as string
// }
// })
return net.fetch(newFilePath)
})
这段代码写了在MessageList中的图片还是不显示
<img v-if="message.imagePath" :src="`safe-file://${message.imagePath}`" alt="Message image" class="h-24 w-24 object-cover rounded block">
文心一言/通义千问/Deepseek/ Claude/Cursor与Vue3、Electron
了解课程