GithubHelp home page GithubHelp logo

guoyu07 / electron-vue-spring Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wuruoyun/electron-vue-spring

0.0 0.0 0.0 163 KB

An opinionated desktop application with web front-end and Java backend.

License: MIT License

JavaScript 29.20% HTML 3.58% Shell 30.44% Batchfile 23.50% Java 11.03% Vue 2.26%

electron-vue-spring's Introduction

Electron-Vue-Spring

An opionated desktop application with web front-end and Java backend.

In some cases, you may like to use Java backend for an Electron desktop app. The reasons could be you have some legacy Java codes that you want to reuse, or you want to have the same codes run on Cloud as well as on desktop.

This project has two sub projects. Although they are just folders in this project, but they could be in their own Git repository and merged to this project using Git subtree.

  1. vue: a Vue.js application as the front-end, based on Vue's webpack-simple template.
  2. spring: a Spring Boot application as the backend, based on a Maven project created by Spring Initializer with Web dependency.

Both Windows and Mac OS are supported.

NOTE: This project uses your system Java to run the spring web app. If you prefer to bundle JRE into the app, configure the extraFiles of Electron Builder to copy it when making the installer.

Build Setup

Build the final installer, which can be found in folder dist. It is an exe file for Windows and dmg file for Mac.

# install dependencies
npm install

# install dependencies for vue project
cd vue
npm install
cd ..

# build installer for production
npm run build

Development Setup

During development, you may simple work on front-end and backend with independent tools. Note that the front-end vue project has its own package.json so it can be built independently.

  • For front-end, simple run npm run dev in vue folder. The webpack dev server will be running on port 9000 with hot reload. It is configured to proxy health and api URL to port 8080.
  • For backend, import the Maven project into your favorite Java IDE and launch from there. The embedded Tomcat server will be running on port 8080.

How it works

The main idea is to use Electron as a browser, and the front-end and backend of the app work as a web app. It might not be a common design, but is helpful in some cases.

The backend is a typical Spring Boot app, serving API to the front-end. The front-end is a typical Vue app, consuming API from the backend.

Build process

When building the final desktop app installer:

  1. Front-end is built first. The final artifacts, including index.html and JavaScript files, are copied into spring/src/main/resources/public folder.
  2. Backend is built second. It creates a web app with the front-end artifacts created above and an executable jar.
  3. Electron installer is built last. It includes the web app created above in the bundle and creates an executable installer.

However, both vue sub project and spring sub project are free of Electron and can be built independently without building the Electron part. This allows them to be deployed online, instead of packaged into Electron app.

Launch process

When launching the Electron app:

  1. Electron app detects an available port and starts the backend server with Node child_process at the specified port.
  2. Electron app then displays a splash page, at the same time pings the health URL of the backend server.
  3. Once the health ping returns OK (the web app is up),Electron app switches the page to the home page of the web app.

License

MIT

electron-vue-spring's People

Contributors

wuruoyun avatar ruoyun-wu-tfs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.