纯新手
报错: Cannot read properties of undefined (reading 'getCurrentWindow')
目录下只有三个文件: plugin.json, preload.js, logo.png
系统: macos
const path = require('path')
const fs = require('fs')
const { shell } = require('electron')
const cp = require('child_process')
///Users/alex/Desktop/tmp/log.txt
function printToFile(str) {
fs.appendFile('/Users/alex/Desktop/tmp/log.txt', str + '\n', function (err) {
});
}
function printArrayToFile(arr) {
arr.forEach(element => {
fs.appendFile('/Users/alex/Desktop/tmp/log.txt', element + '\n', function (err) {
});
});
}
window.exports = {
'test': {
mode: 'none', // 该模式不需要输入参数或显示列表
args: {
enter: () => {
try {
printToFile("start1")
window.utools.hideMainWindow();
const { remote } = require('electron')
const win = remote.getCurrentWindow()
if(win == null) {
printToFile("win is null")
}
else {
printToFile("win is not null")
}
} catch(err) {
printToFile("err1");
printToFile(err.message);
}
}
}
},
}
{
"version": "1.0.6",
"pluginName": "test",
"description": "测试插件",
"author": "uTools官方",
"homepage": "https://u.tools",
"preload": "preload.js",
"logo": "logo.png",
"features": [
{
"code": "test",
"explain": "测试",
"cmds": [
"test"
]
}
]
}