2025-08-06 07:44:19 +08:00
|
|
|
const { contextBridge, ipcRenderer } = require('electron')
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
2025-08-07 01:15:18 +08:00
|
|
|
playSound: (soundFile) => {
|
|
|
|
try {
|
|
|
|
ipcRenderer.send('play-sound', soundFile)
|
|
|
|
} catch (err) {
|
|
|
|
console.error('播放音效失败:', err)
|
|
|
|
}
|
|
|
|
},
|
2025-08-08 20:06:52 +08:00
|
|
|
getSoundPath: (soundFile) => ipcRenderer.invoke('get-sound-path', soundFile),
|
2025-08-06 14:15:15 +08:00
|
|
|
showTooltip: (text) => ipcRenderer.send('show-tooltip', text),
|
|
|
|
onUpdatePosition: (callback) => {
|
|
|
|
ipcRenderer.on('update-position', (_, position) => callback(position))
|
|
|
|
}
|
2025-08-06 07:44:19 +08:00
|
|
|
})
|