添加文件下载目录
This commit is contained in:
parent
150cd2655c
commit
5454d5ceba
12
main.js
12
main.js
|
|
@ -11,6 +11,7 @@ const {
|
|||
desktopCapturer,
|
||||
} = require('electron');
|
||||
const path = require('node:path')
|
||||
const fs = require('fs');
|
||||
const {autoUpdater, CancellationToken} = require('electron-updater');
|
||||
const cancellationToken = new CancellationToken()
|
||||
app.allowRendererProcessReuse = false;
|
||||
|
|
@ -64,9 +65,11 @@ function showWindow() {
|
|||
createWindow();
|
||||
}
|
||||
}
|
||||
|
||||
function quit() {
|
||||
app.quit()
|
||||
}
|
||||
|
||||
function createTray() {
|
||||
const iconPath = `${__dirname}/src/assets/icon.png`;
|
||||
const trayIcon = nativeImage.createFromPath(iconPath);
|
||||
|
|
@ -132,6 +135,15 @@ app.on('ready', () => {
|
|||
createWindow()
|
||||
updateHandle() // 检查更新
|
||||
createTray()
|
||||
// 获取当前脚本所在目录的绝对路径
|
||||
const currentDirectory = __dirname;
|
||||
// 获取安装父目录
|
||||
const parentDirectory = path.resolve(currentDirectory, '../..');
|
||||
const customFolderPath = path.join(parentDirectory, 'Downloads');
|
||||
if (!fs.existsSync(customFolderPath)) {
|
||||
// 如果不存在,则创建文件夹
|
||||
fs.mkdirSync(customFolderPath);
|
||||
}
|
||||
// 监听f12打开控制台
|
||||
mainWindow.webContents.on('before-input-event', (event, input) => {
|
||||
if (input.key === 'F12') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue