最后
整理面试题,不是让大家去只刷面试题,而是熟悉目前实际面试中常见的考察方式和知识点,做到心中有数,也可以用来自查及完善知识体系。
《前端基础面试题》,《前端校招面试题精编解析大全》,《前端面试题宝典》,《前端面试题:常用算法》
这里我选择最新的版本^11.0.0
3. 安装完插件后, 项目中的一些变化
① package.json 新增了几个scripts
electron开发模式
npm run electron:serve
electron打包复制代码
npm run electron:build
postinstall 和 postuninstall 是为了确保安装或者移除依赖时, 始终跟electron匹配
② 新增了background.js文件
主进程相关操作, 写在这个文件中
三、开发总结
1. 配置项目图标
使用electron-icon-builder, 生成符合Electron的图标
① 安装
npm install --save-dev electron-icon-builder
② package.json 中配置生成命令
"electron:generate-icons": "electron-icon-builder --input=./public/icon.png --output=build --flatten"
③ 生成图标
npm run electron:generate-icons
④ 使用
import path from 'path'const win = new BrowserWindow({
icon: path.join(__static, 'icon.png')
})
2. 在Mac系统下的几个问题
在mac系统下修改electron默认图标
在根目录下放置一张名为icon的图片,即icon.png即可。
在Mac系统下,复制粘贴无效的问题:
可以在创建窗口的时候自定义快捷键:
具体代码:
async function createWindow() {
createMenu();
// Create the browser window.
win = new BrowserWindow({
width: 1300,
height: 660,
minWidth: 1300,
useContentSize: true,
resizable: true,
// frame: false,
// backgroundColor: '#DC143C',
// titleBarStyle: 'hidden',
webPreferences: {
webSecurity: false, //Remove cross domain restrictions
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
// eslint-disable-next-line no-undef
preload: ${__static}/preload.js
},
//${__ Static} corresponds to the public directory
// eslint-disable-next-line no-undef
icon: ${__static}/img/icons/logo-64.png
// icon: ${__static}/img/icons/favicon.ico
});
if (process.platform === 'darwin') {
// eslint-disable-next-line no-undef
app.dock.setIcon(${__static}/img/icons/logo-512.png);
}
if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL);
/* if (!process.env.IS_TEST) win.webContents.openDevTools(); */
} else {
createProtocol('app');
// Load the index.html when not in development
win.loadURL('app://./index.html');
//Detect version updates
updateHandle(win, feedUrl);
}
win.on('closed', () => {
win = null;
});
globalShortcut.register('CommandOrControl+Shift+i', function () {
win.webContents.openDevTools();
});
// esc,
globalShortcut.register('ESC', function () {
win.unmaximize();
});
if (process.platform === 'darwin') {
const template = [
{
label: 'Application',
submenu: [
{
label: 'Quit',
accelerator: 'Command+Q',
click: function () {
app.quit();
}
}
]
},
{
label: 'Edit',
submenu: [
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' }
]
}
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}
最后
为了帮助大家更好的了解前端,特别整理了《前端工程师面试手册》电子稿文件。
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】