const { app, screen, BrowserWindow } = require("electron");
const path = require("path");
// 主窗口
let mainWindow = null;
const createMainWindow = () => {
// 获取当前桌面的宽度和高度
const size = screen.getPrimaryDisplay().workAreaSize;
const { width, height } = size;
mainWindow = new BrowserWindow({
width: 390,
height: 390,
// 起始位置是屏幕宽度减去窗口宽度,再减去10个像素
x: width - 390 - 10,
y: height - 390 - 10,
// Preload 脚本
webPreferences: {
preload: path.resolve(__dirname, "../_preload/preload.js"),
},
});
// 开启调试工具
// mainWindow.webContents.openDevTools();
mainWindow.loadFile(path.resolve(__dirname, "../index.html"));
mainWindow.on("ready-to-show", () => {
mainWindow.show();
});
};
app.whenReady().then(() => {
createMainWindow();
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaroPet</title>
<style>
.taro-pet {
width: 100px;
height: 100px;
background-color: red;
}
</style>
</head>
<body>
<div id="taro-pet" class="taro-pet"></div>
</body>
</html>
mainWindow = new BrowserWindow({
width: 390,
height: 390,
// 起始位置是屏幕宽度减去窗口宽度,再减去10个像素
x: width - 390 - 10,
y: height - 390 - 10,
// 隐藏菜单栏
autoHideMenuBar: true,
// 设置为透明窗口
transparent: true,
// 隐藏窗口边框
frame: false,
// 窗口置顶
alwaysOnTop: true,
// 隐藏任务栏图标
skipTaskbar: true,
// 禁止改变窗口大小
resizable: false,
// 先隐藏窗口
show: false,
// Preload 脚本
webPreferences: {
preload: path.resolve(__dirname, "../_preload/preload.js"),
},
});
const { app, screen, BrowserWindow } = require("electron");
const path = require("path");
// 主窗口
let mainWindow = null;
const createMainWindow = () => {
// 获取当前桌面的宽度和高度
const size = screen.getPrimaryDisplay().workAreaSize;
const { width, height } = size;
mainWindow = new BrowserWindow({
width: 390,
height: 390,
// 起始位置是屏幕宽度减去窗口宽度,再减去10个像素
x: width - 390 - 10,
y: height - 390 - 10,
// 隐藏菜单栏
autoHideMenuBar: true,
// 设置为透明窗口
transparent: true,
// 隐藏窗口边框
frame: false,
// 窗口置顶
alwaysOnTop: true,
// 隐藏任务栏图标
skipTaskbar: true,
// 禁止改变窗口大小
resizable: false,
// 先隐藏窗口
show: false,
// Preload 脚本
webPreferences: {
preload: path.resolve(__dirname, "../_preload/preload.js"),
},
});
// 开启调试工具
// mainWindow.webContents.openDevTools();
mainWindow.loadFile(path.resolve(__dirname, "../index.html"));
mainWindow.on("ready-to-show", () => {
mainWindow.show();
});
};
app.whenReady().then(() => {
createMainWindow();
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaroPet</title>
<style>
.taro-pet {
width: 100px;
height: 100px;
background-color: red;
}
</style>
</head>
<body>
<div id="taro-pet" class="taro-pet"></div>
</body>
</html>
此页面不支持夜间模式!
已进入夜间模式!
已进入普通模式!
搜索框不允许为空
签到成功!经验+5!芋圆币+2!
签到失败!今日已签到!
需要登录社区账号才可以进入!