26 lines
873 B
JavaScript
26 lines
873 B
JavaScript
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
// 暴露API给渲染进程
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
|
// 数据库相关
|
|
checkDatabaseInitialized: () => ipcRenderer.invoke('check-database-initialized'),
|
|
initializeDatabase: () => ipcRenderer.invoke('initialize-database'),
|
|
|
|
// 认证相关
|
|
adminLogin: (credentials) => ipcRenderer.invoke('admin-login', credentials),
|
|
|
|
// 系统相关
|
|
getSystemConfig: () => ipcRenderer.invoke('system-get-config')
|
|
});
|
|
|
|
// 这里可以添加预加载脚本
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
const replaceText = (selector, text) => {
|
|
const element = document.getElementById(selector)
|
|
if (element) element.innerText = text
|
|
}
|
|
|
|
for (const dependency of ['chrome', 'node', 'electron']) {
|
|
replaceText(`${dependency}-version`, process.versions[dependency])
|
|
}
|
|
}) |