15158846557 在线咨询 在线咨询
15158846557 在线咨询
所在位置: 首页 > 营销资讯 > 网站运营 > Electron+React+七牛云开发跨平台云文档

Electron+React+七牛云开发跨平台云文档

时间:2023-05-31 19:18:02 | 来源:网站运营

时间:2023-05-31 19:18:02 来源:网站运营

Electron+React+七牛云开发跨平台云文档:

前言

采用了Electron+React+七牛云搭建的在线Markdown云文档。

git clone git@github.com:FrontDream/cloud-doc.git

cd cloud-doc

npm install (切记在可以科学上网的情况下安装,国内即使用淘宝镜像,虽然能运行起来,打包也会失败)

npm run dev (运行)

npm run dist (打包)

npm run release (发布)
注意

以下是从0到1的搭建过程,当然,其中省略了中间的业务

搭建electron+React开发环境

"main": "main.js",const { app ,BrowserWindow } = require('electron')const isDev = require('electron-is-dev')let mainWindow;app.on('ready',()=>{ mainWindow = new BrowserWindow({ width: 1024, height: 680, webPreferences: { nodeIntegration: true } }) const urlLocation = isDev?'http://localhost:3000': 'ddd' mainWindow.loadURL(urlLocation)})"scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "ele": "electron .", "dev": "concurrently /"npm start/" /"npm run ele/"" }"scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "ele": "electron .", "dev": "concurrently /"npm start/" /"wait-on http://localhost:3000 && electron ./"" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "ele": "electron .", "dev": "concurrently /"cross-env BROWSER=none npm start/" /"wait-on http://localhost:3000 && electron ./"" },

打包过程

"author": { "name": "qiandingwei", "email": "1370336125@qq.com"},"build": { "appId": "cloudDoc", "productName": "七牛云文档", "copyright": "Copyright © 2020 ${author}" },"pack": "electron-builder --dir","prepack": "npm run build","dist": "electron-builder"

配置安装包

"directories": { "buildResources": "assets" },"mac": { "category": "public.app-category.productivity", "artifactName": "${productName}-${version}-${arch}.${ext}" }, "dmg": { "background": "assets/appdmg.png", "icon": "assets/icon.icns", "iconSize": 100, "contents": [ { "x": 380, "y": 280, "type": "link", "path": "/Applications" }, { "x": 110, "y": 280, "type": "file" } ], "window": { "width": 500, "height": 500 } }, "win": { "target": [ "msi", "nsis" ], "icon": "assets/icon.ico", "artifactName": "${productName}-Web-Setup-${version}.${ext}", "publisherName": "Viking Zhang" }, "nsis": { "allowToChangeInstallationDirectory": true, "oneClick": false, "perMachine": false }

压缩优化体积

如何release

"publish": ["github"]"release": "cross-env GH_TOKEN=you_access_key electron-builder", "prerelease": "npm run build && npm run buildMain"

版本自动更新

const { autoUpdater} = require('electron-updater')autoUpdater.autoDownload = false autoUpdater.checkForUpdatesAndNotify() autoUpdater.on('error',(error)=>{ dialog.showErrorBox('Error',error===null?"un-known":error) }) autoUpdater.on('update-available',()=>{ dialog.showMessageBox({ type: 'info', title: '应用有新的版本', message: '发现新应用,是否现在更新?', buttons: ['是','否'], },(buttonIndex)=>{ if(buttonIndex===0){ autoUpdater.downloadUpdate() } }) }) autoUpdater.on('update-not-available',()=>{ dialog.showMessageBox({ type: 'info', title: '没有新的版本', message: '当前已经是最新版本', }) })❤️ 爱心三连击
1.看到这里了就点个在看支持下吧,你的「在看」是我创作的动力。
2.关注公众号前端梦想家,「一起学前端」!
3.添加微信【qdw1370336125】,拉你进技术交流群一起学习。

关键词:平台

74
73
25
news

版权所有© 亿企邦 1997-2025 保留一切法律许可权利。

为了最佳展示效果,本站不支持IE9及以下版本的浏览器,建议您使用谷歌Chrome浏览器。 点击下载Chrome浏览器
关闭