We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Electron是通过Chromium和Node.js集成来达到这一开发体验的, 我们可以用React / Vue 很轻松的搭建一个桌面应用程序。应用启动时就避免不了短暂的白屏或者需要启动时加载基础数据。
那么怎样解决这一问题呢?
有APP开发经验的同学肯定立马就想到了 启动动画(开屏广告)。
准备开屏动画
配置主进程main.js文件
const createWindow = async () => { mainWindow = new BrowserWindow({ minHeight: 600, minWidth: 1024, width: 1280, height: 720, titleBarStyle: 'hidden', frame: false, show: false }); …… };
// loading const createLoadingWindow = async () => { loadingWindow = new BrowserWindow({ height: 260, width: 650, show: true, transparent: true, // 透明窗口 maximizable: false, //禁止双击放大 frame: false // 去掉顶部操作栏 }) loadingWindow.loadURL(url.format({ // loading.html 加载动画 pathname: path.join(__dirname, './lib/loading/loading.html'), protocol: 'file:', slashes: true })) …… }
import { ipcRenderer } from "electron"; const ipcMain = require('electron').ipcMain; // 页面加载完毕时调用 通知关闭loading ipcRenderer.send("close-loading-window"); app.on('ready', () => { // 创建加载动画 createLoadingWindow(); // 创建主窗口 createWindow(); // 监听页面加载完毕事件 ipcMain.on('close-loading-window', () => { if(loadingWindow) { loadingWindow.close(); } mainWindow.show(); }) });
transparent: true, // 透明窗口
在win7下不起作用
解决方案: 禁用硬件加速(未尝试)
app.disableHardwareAcceleration(); app.on('ready', () => { setTimeout(() => { createWindow(); autoUpdater.checkForUpdatesAndNotify(); createMenu(); }, 50); });
The text was updated successfully, but these errors were encountered:
创建透明窗口忘记写这个属性了,show: true。然后创建的窗口必须点击几下才会变透明,加上就OK了
Sorry, something went wrong.
No branches or pull requests
背景
Electron是通过Chromium和Node.js集成来达到这一开发体验的, 我们可以用React / Vue 很轻松的搭建一个桌面应用程序。应用启动时就避免不了短暂的白屏或者需要启动时加载基础数据。
那么怎样解决这一问题呢?
有APP开发经验的同学肯定立马就想到了 启动动画(开屏广告)。
思路
实现
准备开屏动画
配置主进程main.js文件
完成
不足
transparent: true, // 透明窗口
在win7下不起作用
解决方案: 禁用硬件加速(未尝试)
The text was updated successfully, but these errors were encountered: