简体   繁体   English

具有 Angular 应用程序文件结构的 Electron

[英]Electron with Angular app file structure

What's the best practice of creating an Electron app with Angular as UI framework?使用 Angular 作为 UI 框架创建 Electron 应用程序的最佳实践是什么?
My current proposal (which i think is not the best):我目前的建议(我认为这不是最好的):

  • (root) (根)
  • ---- node_modules/ ---- node_modules/
  • ---- package.json ---- 包.json
  • ---- index.js ---- index.js
  • ---- app/ - - 应用程序/
  • ---- ---- node_modules ---- ---- node_modules
  • ---- ---- package.json ---- ---- 包.json
  • ---- ---- bower.json ---- ---- bower.json
  • ---- ---- bower_components/ ---- ---- bower_components/
  • ---- ---- backend/ # contains all core logic as node modules ---- ---- backend/ # 包含所有核心逻辑作为节点模块
  • ---- ---- ui/ # angular application code ---- ---- ui/ # angular 应用代码
  • ---- ---- ---- controllers ---- ---- ---- 控制器
  • ---- ---- ---- services - - - - - - 服务
  • ---- ---- ---- templates ---- ---- ---- 模板

Now, i have the backend encapsulates the core logic and exposes some APIs, which i include (require) from ui/services and wrap it as Angular service and then inject/use in controllers normally.现在,我让后端封装了核心逻辑并公开了一些 API,我从 ui/services 中包含(需要)并将其包装为 Angular 服务,然后在控制器中正常注入/使用。

I can't say it's the best, but here's what I normally use:我不能说它是最好的,但这是我通常使用的:

┌ .
├ app/
├── dist/
├──── css/
├──── fonts/
├──── js/
├── src/
├──── css/
├──── js/
├── index.html
├ bower.json
├ bower_components/
├ index.js
├ gulpfile.js
├ node_modules/
└ package.json

So, ./index.js is the entry point.所以,./ ./index.js是入口点。 It basically loads ./app/index.html and inside that file, I refer the files under ./app/dist folder.它基本上加载./app/index.html并在该文件中,我指的是./app/dist文件夹下的文件。 ./app/src is where I do my code changes. ./app/src是我更改代码的地方。 And ./gulpfile.js is simply a tasklist such as converting SASS files to css (from ./app/src/css to ./app/dist/css ), bundling, minification, linting, etc../gulpfile.js只是一个任务列表,例如将 SASS 文件转换为 css(从./app/src/css./app/dist/css )、捆绑、缩小、linting 等。

I know, that's not the best structure but by this way I can only type npm install and I can get a working environment within the seconds (thanks to postinstall script).我知道,这不是最好的结构,但通过这种方式我只能输入npm install并且我可以在几秒钟内获得一个工作环境(感谢 postinstall 脚本)。 It also make easier to manage dependencies on both end.它还可以更轻松地管理两端的依赖关系。 It's up to you how you continue to write your JavaScript and CSS after ./app/src/ , but in the end, they'll be in one file and moved to ./app/dist/ ../app/src/之后如何继续编写 JavaScript 和 CSS ./app/src/ ,但最终,它们将在一个文件中并移至./app/dist/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM