iTEMX-bloxerBETA / main.js
SamuelGalaxys's picture
Upload 1921 files
e4a10af
raw
history blame contribute delete
No virus
3.17 kB
const electron = require('electron');
const { app, dialog, ipcMain, BrowserWindow } = require('electron');
const fs = require('fs');
const path = require('path');
const os = require('os');
function createWindow() {
const win = new BrowserWindow({
width: 900,
height: 600,
// ์œˆ๋„์šฐ ์ตœ์†Œ ๋„ˆ๋น„
minWidth: 700,
// ์œˆ๋„์šฐ ์ตœ์†Œ ๋†’์ด
minHeight: 600,
autoHideMenuBar: true,
center: true,
//resizable: false,
//npm run start frame: false,
webPreferences: {
nodeIntegration: true,
contextIsolation : false
}
});
win.loadFile("index.html");
}
let isQuitting = false;
app.on('before-quit', (event) => {
if (!isQuitting) {
event.preventDefault();
console.log("DDD")
showDialog();
}
});
function showDialog() {
const options = {
type: 'question',
buttons: ['๋‹ซ๊ธฐ', '์ทจ์†Œ'],
defaultId: 1,
message: 'itemX๋ฅผ ๋‹ซ์œผ์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? ์ €์žฅ๋˜์ง€ ์•Š์€ ๋‚ด์šฉ์€ ์‚ฌ๋ผ์ง‘๋‹ˆ๋‹ค.',
title: 'itemX'
};
dialog.showMessageBox(null, options).then((response) => {
const choice = response.response;
if (choice === 0) {
isQuitting = true;
app.exit(); // Quit the application
}
});
}
//npm run deploy:win
app.whenReady().then(() => {
createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
//npm install -g electron-builder
//npm run build:win
// ๋ฐ์ดํ„ฐ ์ €์žฅ ๊ฒฝ๋กœ
const homedir = os.homedir();
const filePathX = path.join(homedir, 'Documents', 'helloooooooooooo.txt');
// 30์ดˆ๋งˆ๋‹ค ๋ฐ์ดํ„ฐ ์ €์žฅ
setInterval(() => {
// ๋ฐ์ดํ„ฐ๋ฅผ ๋กœ์ปฌ ํŒŒ์ผ์— ์ €์žฅ
fs.writeFile(filePathX, 'Kim Samuel Kihoon the Great and Happy, with wife, and His family. long live, happy and leaderful, and strong from Great lots of money and business.', (err) => {
if (err) {
console.error('๋ฐ์ดํ„ฐ ์ €์žฅ ์‹คํŒจ:', err);
} else {
console.log('๋ฐ์ดํ„ฐ ์ €์žฅ ์„ฑ๊ณต');
}
});
function readAndLogFileContent() {
const filePath = '/User/samuelgalaxy/documents/helloooooooooooo.txt';
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading the file: ${err}`);
return;
}
console.log(data);
});
}
app.whenReady().then(() => {
setInterval(readAndLogFileContent, 8000);
});
}, 5000);
// 30์ดˆ๋งˆ๋‹ค ๋ฐ์ดํ„ฐ ์ €์žฅ
setInterval(() => {
// ๋ฐ์ดํ„ฐ๋ฅผ ๋กœ์ปฌ ํŒŒ์ผ์— ์ €์žฅ
// ์ €์žฅ ์š”์ฒญ์„ ๋ฐ›์•„ ํŒŒ์ผ์— ๋‚ด์šฉ ์ €์žฅ
ipcMain.on('saveContentToFile', (event, content) => {
const filePath = path.join(app.getPath('documents'), 'xxxxxxxx.txt');
console.log('XXXXX');
fs.writeFile(filePath, content, (err) => {
if (err) {
console.error('ํŒŒ์ผ ์ €์žฅ ์‹คํŒจ:', err);
} else {
console.log('ํŒŒ์ผ์ด ์„ฑ๊ณต์ ์œผ๋กœ ์ €์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.');
}
});
});
}, 5000);
// Renderer process์—์„œ ๊ฐ’์„ ๋ฐ›์•„์™€์„œ console.log๋กœ ์ถœ๋ ฅ
ipcMain.on('submitData', (event, data) => {
console.log(data);
});