前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >electron 安装_electron修改文件描述

electron 安装_electron修改文件描述

作者头像
全栈程序员站长
发布2022-11-16 18:26:08
1.4K0
发布2022-11-16 18:26:08
举报
1、安装node.js 例如:安装在 F://node 下;
2、cmd控制台:
代码语言:javascript
复制
F: 

Jetbrains全家桶1年46,售后保障稳定

回车,进入F盘,
代码语言:javascript
复制
cd node
回车,进入node文件夹,
代码语言:javascript
复制
node -v
回车,查看node版本,
代码语言:javascript
复制
npm -v
回车,查看npm版本,若出现版本号,表示安装成功;
3、在cmd控制台,node文件夹下,把npm仓库切换到国内taobao仓库,速度会快很多,命令如下:
代码语言:javascript
复制
  npm install -g cnpm --registry=https://registry.npm.taobao.org
4、在node文件夹下,安装electron,命令如下:
代码语言:javascript
复制
  cnpm install -g electron
5、输入命令:
代码语言:javascript
复制
  electron -v
查看electron版本,若出现版本号,表示安装成功;
6、输入命令:
代码语言:javascript
复制
cnpm install -g electron-packager
打包输出工具;
7、下载并安装electron客户端;
8、新建一个项目文件夹,自命名,例如:test1;
9、在 test1 中创建:pakage.json、index.html、main.js 三个文件;
10、通过拖拽 test1 文件夹到 electron客户端,或者在cmd控制台中使用命令打开文件,
代码语言:javascript
复制
F:\electron1\electron.exe E:\electronCodes\test1
前段为客户端地址,后段为文件地址

附录:pakage.json、index.html、main.js

pakage.json:

代码语言:javascript
复制
{ 
   
  "name"    : "your-app",
  "version" : "0.1.0",
  "main"    : "main.js"
}

index.html:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node)</script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
</body>
</html>

main.js:

代码语言:javascript
复制
const electron = require('electron');
// Module to control application life.
const { 
app} = electron;
// Module to create native browser window.
const { 
BrowserWindow} = electron;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
function createWindow() { 

// Create the browser window.
win = new BrowserWindow({ 
width: 800, height: 600});
// and load the index.html of the app.
win.loadURL(`file://${ 
__dirname}/index.html`);
// Open the DevTools.
win.webContents.openDevTools();
// Emitted when the window is closed.
win.on('closed', () => { 

// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null;
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => { 

// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') { 

app.quit();
}
});
app.on('activate', () => { 

// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) { 

createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/234522.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022年11月2日 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、安装node.js 例如:安装在 F://node 下;
  • 2、cmd控制台:
  • 回车,进入F盘,
  • 回车,进入node文件夹,
  • 回车,查看node版本,
  • 回车,查看npm版本,若出现版本号,表示安装成功;
  • 3、在cmd控制台,node文件夹下,把npm仓库切换到国内taobao仓库,速度会快很多,命令如下:
  • 4、在node文件夹下,安装electron,命令如下:
  • 5、输入命令:
  • 查看electron版本,若出现版本号,表示安装成功;
  • 6、输入命令:
  • 打包输出工具;
  • 7、下载并安装electron客户端;
  • 8、新建一个项目文件夹,自命名,例如:test1;
  • 9、在 test1 中创建:pakage.json、index.html、main.js 三个文件;
  • 10、通过拖拽 test1 文件夹到 electron客户端,或者在cmd控制台中使用命令打开文件,
  • 前段为客户端地址,后段为文件地址
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档