企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
本部分内容为慕课网课程[《Electron + React + 七牛云...》](https://coding.imooc.com/learn/list/384.html)学习笔记,相关参考文献地址如下: - [Electron 官网](https://www.electronjs.org/) - [concurrently ](https://www.npmjs.com/package/concurrently) - [wait-on](https://www.npmjs.com/package/wait-on) - [react-fontawesome](https://github.com/FortAwesome/react-fontawesome) - [Bootstrap](https://www.bootcss.com/) - [classNames](https://github.com/JedWatson/classnames) - [uuid](https://github.com/uuidjs/uuid) - [easy-markdown](https://github.com/RIP21/react-simplemde-editor) ## 要点记录 1、调试 Windows 快捷键:ctrl+shift+i Mac 快捷键:command+option+i <br/> 2、使用 node.js 原生模块(create-react-app),将 require 改成 window.require [https://github.com/electron/electron/issues/7300](https://github.com/electron/electron/issues/7300) <br/> 3、node.js 10+ 支持 API 的 Promise 化, ```js const fs = require('fs').promises // node10+ const path = require('path') const fileHelper = { readFile: (path) => { return fs.readFile(path, { encoding: 'utf8' }) }, writeFile: (path, content) => { return fs.writeFile(path, content, { encoding: 'utf8' }) } } fileHelper.readFile(testPath).then(data => { console.log(data) }) fileHelper.writeFile(testWritePath, '## hello world').then(() => { console.log('写入成功') }) ``` <br/> 4、持久化解决方案 - electron-store [https://github.com/sindresorhus/electron-store](https://github.com/sindresorhus/electron-store)