UI调整优化
This commit is contained in:
+19
-2
@@ -1,5 +1,6 @@
|
||||
// All of the Node.js APIs are available in the preload process.
|
||||
// It has the same sandbox as a Chrome extension.
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
// 1. 显示版本号逻辑 (保持不变)
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const replaceText = (selector, text) => {
|
||||
const element = document.getElementById(selector)
|
||||
@@ -10,3 +11,19 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
replaceText(`${type}-version`, process.versions[type])
|
||||
}
|
||||
})
|
||||
|
||||
// 2. 修正:直接挂载到 window 对象
|
||||
// 因为你的 main.js 中 contextIsolation: false,所以直接赋值即可
|
||||
window.sysAPI = {
|
||||
// 读取历史记录
|
||||
readHistory: () => ipcRenderer.invoke('history:read'),
|
||||
|
||||
// 写入历史记录
|
||||
writeHistory: (data) => ipcRenderer.invoke('history:write', data),
|
||||
|
||||
// 读取任意 JSON 文件
|
||||
readJsonFile: (filePath) => ipcRenderer.invoke('file:read-json', filePath),
|
||||
//获取软件版本
|
||||
getAppVersion: () => ipcRenderer.invoke('app:get-version')
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user