├── .babelrc ├── .electron-vue ├── build.js ├── dev-client.js ├── dev-runner.js ├── webpack.main.config.js ├── webpack.renderer.config.js └── webpack.web.config.js ├── .gitignore ├── .travis.yml ├── README.md ├── appveyor.yml ├── build └── icons │ ├── 256x256.png │ ├── favicon (1).ico │ └── icon.ico ├── dist ├── electron │ └── .gitkeep └── web │ └── .gitkeep ├── mind.png ├── package-lock.json ├── package.json ├── screenshort1.png ├── screenshort2.png ├── screenshort3.png ├── src ├── db │ └── datastore.js ├── index.ejs ├── main │ ├── deploy │ │ └── deploy.js │ ├── index.dev.js │ └── index.js └── renderer │ ├── App.vue │ ├── assets │ ├── .gitkeep │ ├── logo.png │ └── null.png │ ├── components │ ├── About.vue │ ├── AddPro.vue │ ├── Log.vue │ ├── Null.vue │ └── ProList.vue │ ├── main.js │ ├── router │ └── index.js │ └── store │ ├── index.js │ └── modules │ ├── Counter.js │ └── index.js └── static └── .gitkeep /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "comments": false, 3 | "env": { 4 | "main": { 5 | "presets": [ 6 | ["env", { 7 | "targets": { "node": 7 } 8 | }], 9 | "stage-0" 10 | ] 11 | }, 12 | "renderer": { 13 | "presets": [ 14 | ["env", { 15 | "modules": false 16 | }], 17 | "stage-0" 18 | ] 19 | }, 20 | "web": { 21 | "presets": [ 22 | ["env", { 23 | "modules": false 24 | }], 25 | "stage-0" 26 | ] 27 | } 28 | }, 29 | "plugins": ["transform-runtime"] 30 | } 31 | -------------------------------------------------------------------------------- /.electron-vue/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | const { say } = require('cfonts') 6 | const chalk = require('chalk') 7 | const del = require('del') 8 | const { spawn } = require('child_process') 9 | const webpack = require('webpack') 10 | const Multispinner = require('multispinner') 11 | 12 | 13 | const mainConfig = require('./webpack.main.config') 14 | const rendererConfig = require('./webpack.renderer.config') 15 | const webConfig = require('./webpack.web.config') 16 | 17 | const doneLog = chalk.bgGreen.white(' DONE ') + ' ' 18 | const errorLog = chalk.bgRed.white(' ERROR ') + ' ' 19 | const okayLog = chalk.bgBlue.white(' OKAY ') + ' ' 20 | const isCI = process.env.CI || false 21 | 22 | if (process.env.BUILD_TARGET === 'clean') clean() 23 | else if (process.env.BUILD_TARGET === 'web') web() 24 | else build() 25 | 26 | function clean () { 27 | del.sync(['build/*', '!build/icons', '!build/icons/icon.*']) 28 | console.log(`\n${doneLog}\n`) 29 | process.exit() 30 | } 31 | 32 | function build () { 33 | greeting() 34 | 35 | del.sync(['dist/electron/*', '!.gitkeep']) 36 | 37 | const tasks = ['main', 'renderer'] 38 | const m = new Multispinner(tasks, { 39 | preText: 'building', 40 | postText: 'process' 41 | }) 42 | 43 | let results = '' 44 | 45 | m.on('success', () => { 46 | process.stdout.write('\x1B[2J\x1B[0f') 47 | console.log(`\n\n${results}`) 48 | console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`) 49 | process.exit() 50 | }) 51 | 52 | pack(mainConfig).then(result => { 53 | results += result + '\n\n' 54 | m.success('main') 55 | }).catch(err => { 56 | m.error('main') 57 | console.log(`\n ${errorLog}failed to build main process`) 58 | console.error(`\n${err}\n`) 59 | process.exit(1) 60 | }) 61 | 62 | pack(rendererConfig).then(result => { 63 | results += result + '\n\n' 64 | m.success('renderer') 65 | }).catch(err => { 66 | m.error('renderer') 67 | console.log(`\n ${errorLog}failed to build renderer process`) 68 | console.error(`\n${err}\n`) 69 | process.exit(1) 70 | }) 71 | } 72 | 73 | function pack (config) { 74 | return new Promise((resolve, reject) => { 75 | config.mode = 'production' 76 | webpack(config, (err, stats) => { 77 | if (err) reject(err.stack || err) 78 | else if (stats.hasErrors()) { 79 | let err = '' 80 | 81 | stats.toString({ 82 | chunks: false, 83 | colors: true 84 | }) 85 | .split(/\r?\n/) 86 | .forEach(line => { 87 | err += ` ${line}\n` 88 | }) 89 | 90 | reject(err) 91 | } else { 92 | resolve(stats.toString({ 93 | chunks: false, 94 | colors: true 95 | })) 96 | } 97 | }) 98 | }) 99 | } 100 | 101 | function web () { 102 | del.sync(['dist/web/*', '!.gitkeep']) 103 | webConfig.mode = 'production' 104 | webpack(webConfig, (err, stats) => { 105 | if (err || stats.hasErrors()) console.log(err) 106 | 107 | console.log(stats.toString({ 108 | chunks: false, 109 | colors: true 110 | })) 111 | 112 | process.exit() 113 | }) 114 | } 115 | 116 | function greeting () { 117 | const cols = process.stdout.columns 118 | let text = '' 119 | 120 | if (cols > 85) text = 'lets-build' 121 | else if (cols > 60) text = 'lets-|build' 122 | else text = false 123 | 124 | if (text && !isCI) { 125 | say(text, { 126 | colors: ['yellow'], 127 | font: 'simple3d', 128 | space: false 129 | }) 130 | } else console.log(chalk.yellow.bold('\n lets-build')) 131 | console.log() 132 | } -------------------------------------------------------------------------------- /.electron-vue/dev-client.js: -------------------------------------------------------------------------------- 1 | const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 2 | 3 | hotClient.subscribe(event => { 4 | /** 5 | * Reload browser when HTMLWebpackPlugin emits a new index.html 6 | * 7 | * Currently disabled until jantimon/html-webpack-plugin#680 is resolved. 8 | * https://github.com/SimulatedGREG/electron-vue/issues/437 9 | * https://github.com/jantimon/html-webpack-plugin/issues/680 10 | */ 11 | // if (event.action === 'reload') { 12 | // window.location.reload() 13 | // } 14 | 15 | /** 16 | * Notify `mainWindow` when `main` process is compiling, 17 | * giving notice for an expected reload of the `electron` process 18 | */ 19 | if (event.action === 'compiling') { 20 | document.body.innerHTML += ` 21 | 34 | 35 |
36 | Compiling Main Process... 37 |
38 | ` 39 | } 40 | }) 41 | -------------------------------------------------------------------------------- /.electron-vue/dev-runner.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const chalk = require('chalk') 4 | const electron = require('electron') 5 | const path = require('path') 6 | const { say } = require('cfonts') 7 | const { spawn } = require('child_process') 8 | const webpack = require('webpack') 9 | const WebpackDevServer = require('webpack-dev-server') 10 | const webpackHotMiddleware = require('webpack-hot-middleware') 11 | 12 | const mainConfig = require('./webpack.main.config') 13 | const rendererConfig = require('./webpack.renderer.config') 14 | 15 | let electronProcess = null 16 | let manualRestart = false 17 | let hotMiddleware 18 | 19 | function logStats (proc, data) { 20 | let log = '' 21 | 22 | log += chalk.yellow.bold(`┏ ${proc} Process ${new Array((19 - proc.length) + 1).join('-')}`) 23 | log += '\n\n' 24 | 25 | if (typeof data === 'object') { 26 | data.toString({ 27 | colors: true, 28 | chunks: false 29 | }).split(/\r?\n/).forEach(line => { 30 | log += ' ' + line + '\n' 31 | }) 32 | } else { 33 | log += ` ${data}\n` 34 | } 35 | 36 | log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n' 37 | 38 | console.log(log) 39 | } 40 | 41 | function startRenderer () { 42 | return new Promise((resolve, reject) => { 43 | rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer) 44 | rendererConfig.mode = 'development' 45 | const compiler = webpack(rendererConfig) 46 | hotMiddleware = webpackHotMiddleware(compiler, { 47 | log: false, 48 | heartbeat: 2500 49 | }) 50 | 51 | compiler.hooks.compilation.tap('compilation', compilation => { 52 | compilation.hooks.htmlWebpackPluginAfterEmit.tapAsync('html-webpack-plugin-after-emit', (data, cb) => { 53 | hotMiddleware.publish({ action: 'reload' }) 54 | cb() 55 | }) 56 | }) 57 | 58 | compiler.hooks.done.tap('done', stats => { 59 | logStats('Renderer', stats) 60 | }) 61 | 62 | const server = new WebpackDevServer( 63 | compiler, 64 | { 65 | contentBase: path.join(__dirname, '../'), 66 | quiet: true, 67 | before (app, ctx) { 68 | app.use(hotMiddleware) 69 | ctx.middleware.waitUntilValid(() => { 70 | resolve() 71 | }) 72 | } 73 | } 74 | ) 75 | 76 | server.listen(9080) 77 | }) 78 | } 79 | 80 | function startMain () { 81 | return new Promise((resolve, reject) => { 82 | mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main) 83 | mainConfig.mode = 'development' 84 | const compiler = webpack(mainConfig) 85 | 86 | compiler.hooks.watchRun.tapAsync('watch-run', (compilation, done) => { 87 | logStats('Main', chalk.white.bold('compiling...')) 88 | hotMiddleware.publish({ action: 'compiling' }) 89 | done() 90 | }) 91 | 92 | compiler.watch({}, (err, stats) => { 93 | if (err) { 94 | console.log(err) 95 | return 96 | } 97 | 98 | logStats('Main', stats) 99 | 100 | if (electronProcess && electronProcess.kill) { 101 | manualRestart = true 102 | process.kill(electronProcess.pid) 103 | electronProcess = null 104 | startElectron() 105 | 106 | setTimeout(() => { 107 | manualRestart = false 108 | }, 5000) 109 | } 110 | 111 | resolve() 112 | }) 113 | }) 114 | } 115 | 116 | function startElectron () { 117 | var args = [ 118 | '--inspect=5858', 119 | path.join(__dirname, '../dist/electron/main.js') 120 | ] 121 | 122 | // detect yarn or npm and process commandline args accordingly 123 | if (process.env.npm_execpath.endsWith('yarn.js')) { 124 | args = args.concat(process.argv.slice(3)) 125 | } else if (process.env.npm_execpath.endsWith('npm-cli.js')) { 126 | args = args.concat(process.argv.slice(2)) 127 | } 128 | 129 | electronProcess = spawn(electron, args) 130 | 131 | electronProcess.stdout.on('data', data => { 132 | electronLog(data, 'blue') 133 | }) 134 | electronProcess.stderr.on('data', data => { 135 | electronLog(data, 'red') 136 | }) 137 | 138 | electronProcess.on('close', () => { 139 | if (!manualRestart) process.exit() 140 | }) 141 | } 142 | 143 | function electronLog (data, color) { 144 | let log = '' 145 | data = data.toString().split(/\r?\n/) 146 | data.forEach(line => { 147 | log += ` ${line}\n` 148 | }) 149 | if (/[0-9A-z]+/.test(log)) { 150 | console.log( 151 | chalk[color].bold('┏ Electron -------------------') + 152 | '\n\n' + 153 | log + 154 | chalk[color].bold('┗ ----------------------------') + 155 | '\n' 156 | ) 157 | } 158 | } 159 | 160 | function greeting () { 161 | const cols = process.stdout.columns 162 | let text = '' 163 | 164 | if (cols > 104) text = 'electron-vue' 165 | else if (cols > 76) text = 'electron-|vue' 166 | else text = false 167 | 168 | if (text) { 169 | say(text, { 170 | colors: ['yellow'], 171 | font: 'simple3d', 172 | space: false 173 | }) 174 | } else console.log(chalk.yellow.bold('\n electron-vue')) 175 | console.log(chalk.blue(' getting ready...') + '\n') 176 | } 177 | 178 | function init () { 179 | greeting() 180 | 181 | Promise.all([startRenderer(), startMain()]) 182 | .then(() => { 183 | startElectron() 184 | }) 185 | .catch(err => { 186 | console.error(err) 187 | }) 188 | } 189 | 190 | init() 191 | -------------------------------------------------------------------------------- /.electron-vue/webpack.main.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'main' 4 | 5 | const path = require('path') 6 | const { dependencies } = require('../package.json') 7 | const webpack = require('webpack') 8 | 9 | const MinifyPlugin = require("babel-minify-webpack-plugin") 10 | 11 | let mainConfig = { 12 | entry: { 13 | main: path.join(__dirname, '../src/main/index.js') 14 | }, 15 | externals: [ 16 | ...Object.keys(dependencies || {}) 17 | ], 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.js$/, 22 | use: 'babel-loader', 23 | exclude: /node_modules/ 24 | }, 25 | { 26 | test: /\.node$/, 27 | use: 'node-loader' 28 | } 29 | ] 30 | }, 31 | node: { 32 | __dirname: process.env.NODE_ENV !== 'production', 33 | __filename: process.env.NODE_ENV !== 'production' 34 | }, 35 | output: { 36 | filename: '[name].js', 37 | libraryTarget: 'commonjs2', 38 | path: path.join(__dirname, '../dist/electron') 39 | }, 40 | plugins: [ 41 | new webpack.NoEmitOnErrorsPlugin() 42 | ], 43 | resolve: { 44 | extensions: ['.js', '.json', '.node'] 45 | }, 46 | target: 'electron-main' 47 | } 48 | 49 | /** 50 | * Adjust mainConfig for development settings 51 | */ 52 | if (process.env.NODE_ENV !== 'production') { 53 | mainConfig.plugins.push( 54 | new webpack.DefinePlugin({ 55 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"` 56 | }) 57 | ) 58 | } 59 | 60 | /** 61 | * Adjust mainConfig for production settings 62 | */ 63 | if (process.env.NODE_ENV === 'production') { 64 | mainConfig.plugins.push( 65 | new MinifyPlugin(), 66 | new webpack.DefinePlugin({ 67 | 'process.env.NODE_ENV': '"production"' 68 | }) 69 | ) 70 | } 71 | 72 | module.exports = mainConfig 73 | -------------------------------------------------------------------------------- /.electron-vue/webpack.renderer.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'renderer' 4 | 5 | const path = require('path') 6 | const { dependencies } = require('../package.json') 7 | const webpack = require('webpack') 8 | 9 | const MinifyPlugin = require("babel-minify-webpack-plugin") 10 | const CopyWebpackPlugin = require('copy-webpack-plugin') 11 | const MiniCssExtractPlugin = require('mini-css-extract-plugin') 12 | const HtmlWebpackPlugin = require('html-webpack-plugin') 13 | const { VueLoaderPlugin } = require('vue-loader') 14 | 15 | /** 16 | * List of node_modules to include in webpack bundle 17 | * 18 | * Required for specific packages like Vue UI libraries 19 | * that provide pure *.vue files that need compiling 20 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals 21 | */ 22 | let whiteListedModules = ['vue'] 23 | 24 | let rendererConfig = { 25 | devtool: '#cheap-module-eval-source-map', 26 | entry: { 27 | renderer: path.join(__dirname, '../src/renderer/main.js') 28 | }, 29 | externals: [ 30 | ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d)) 31 | ], 32 | module: { 33 | rules: [ 34 | { 35 | test: /\.scss$/, 36 | use: ['vue-style-loader', 'css-loader', 'sass-loader'] 37 | }, 38 | { 39 | test: /\.sass$/, 40 | use: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax'] 41 | }, 42 | { 43 | test: /\.less$/, 44 | use: ['vue-style-loader', 'css-loader', 'less-loader'] 45 | }, 46 | { 47 | test: /\.css$/, 48 | use: ['vue-style-loader', 'css-loader'] 49 | }, 50 | { 51 | test: /\.html$/, 52 | use: 'vue-html-loader' 53 | }, 54 | { 55 | test: /\.js$/, 56 | use: 'babel-loader', 57 | exclude: /node_modules/ 58 | }, 59 | { 60 | test: /\.node$/, 61 | use: 'node-loader' 62 | }, 63 | { 64 | test: /\.vue$/, 65 | use: { 66 | loader: 'vue-loader', 67 | options: { 68 | extractCSS: process.env.NODE_ENV === 'production', 69 | loaders: { 70 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1', 71 | scss: 'vue-style-loader!css-loader!sass-loader', 72 | less: 'vue-style-loader!css-loader!less-loader' 73 | } 74 | } 75 | } 76 | }, 77 | { 78 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 79 | use: { 80 | loader: 'url-loader', 81 | query: { 82 | limit: 10000, 83 | name: 'imgs/[name]--[folder].[ext]' 84 | } 85 | } 86 | }, 87 | { 88 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 89 | loader: 'url-loader', 90 | options: { 91 | limit: 10000, 92 | name: 'media/[name]--[folder].[ext]' 93 | } 94 | }, 95 | { 96 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 97 | use: { 98 | loader: 'url-loader', 99 | query: { 100 | limit: 10000, 101 | name: 'fonts/[name]--[folder].[ext]' 102 | } 103 | } 104 | } 105 | ] 106 | }, 107 | node: { 108 | __dirname: process.env.NODE_ENV !== 'production', 109 | __filename: process.env.NODE_ENV !== 'production' 110 | }, 111 | plugins: [ 112 | new VueLoaderPlugin(), 113 | new MiniCssExtractPlugin({filename: 'styles.css'}), 114 | new HtmlWebpackPlugin({ 115 | filename: 'index.html', 116 | template: path.resolve(__dirname, '../src/index.ejs'), 117 | minify: { 118 | collapseWhitespace: true, 119 | removeAttributeQuotes: true, 120 | removeComments: true 121 | }, 122 | nodeModules: process.env.NODE_ENV !== 'production' 123 | ? path.resolve(__dirname, '../node_modules') 124 | : false 125 | }), 126 | new webpack.HotModuleReplacementPlugin(), 127 | new webpack.NoEmitOnErrorsPlugin() 128 | ], 129 | output: { 130 | filename: '[name].js', 131 | libraryTarget: 'commonjs2', 132 | path: path.join(__dirname, '../dist/electron') 133 | }, 134 | resolve: { 135 | alias: { 136 | '@': path.join(__dirname, '../src/renderer'), 137 | 'vue$': 'vue/dist/vue.esm.js' 138 | }, 139 | extensions: ['.js', '.vue', '.json', '.css', '.node'] 140 | }, 141 | target: 'electron-renderer' 142 | } 143 | 144 | /** 145 | * Adjust rendererConfig for development settings 146 | */ 147 | if (process.env.NODE_ENV !== 'production') { 148 | rendererConfig.plugins.push( 149 | new webpack.DefinePlugin({ 150 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"` 151 | }) 152 | ) 153 | } 154 | 155 | /** 156 | * Adjust rendererConfig for production settings 157 | */ 158 | if (process.env.NODE_ENV === 'production') { 159 | rendererConfig.devtool = '' 160 | 161 | rendererConfig.plugins.push( 162 | new MinifyPlugin(), 163 | new CopyWebpackPlugin([ 164 | { 165 | from: path.join(__dirname, '../static'), 166 | to: path.join(__dirname, '../dist/electron/static'), 167 | ignore: ['.*'] 168 | } 169 | ]), 170 | new webpack.DefinePlugin({ 171 | 'process.env.NODE_ENV': '"production"' 172 | }), 173 | new webpack.LoaderOptionsPlugin({ 174 | minimize: true 175 | }) 176 | ) 177 | } 178 | 179 | module.exports = rendererConfig 180 | -------------------------------------------------------------------------------- /.electron-vue/webpack.web.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'web' 4 | 5 | const path = require('path') 6 | const webpack = require('webpack') 7 | 8 | const MinifyPlugin = require("babel-minify-webpack-plugin") 9 | const CopyWebpackPlugin = require('copy-webpack-plugin') 10 | const MiniCssExtractPlugin = require('mini-css-extract-plugin') 11 | const HtmlWebpackPlugin = require('html-webpack-plugin') 12 | const { VueLoaderPlugin } = require('vue-loader') 13 | 14 | let webConfig = { 15 | devtool: '#cheap-module-eval-source-map', 16 | entry: { 17 | web: path.join(__dirname, '../src/renderer/main.js') 18 | }, 19 | module: { 20 | rules: [ 21 | { 22 | test: /\.scss$/, 23 | use: ['vue-style-loader', 'css-loader', 'sass-loader'] 24 | }, 25 | { 26 | test: /\.sass$/, 27 | use: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax'] 28 | }, 29 | { 30 | test: /\.less$/, 31 | use: ['vue-style-loader', 'css-loader', 'less-loader'] 32 | }, 33 | { 34 | test: /\.css$/, 35 | use: ['vue-style-loader', 'css-loader'] 36 | }, 37 | { 38 | test: /\.html$/, 39 | use: 'vue-html-loader' 40 | }, 41 | { 42 | test: /\.js$/, 43 | use: 'babel-loader', 44 | include: [ path.resolve(__dirname, '../src/renderer') ], 45 | exclude: /node_modules/ 46 | }, 47 | { 48 | test: /\.vue$/, 49 | use: { 50 | loader: 'vue-loader', 51 | options: { 52 | extractCSS: true, 53 | loaders: { 54 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1', 55 | scss: 'vue-style-loader!css-loader!sass-loader', 56 | less: 'vue-style-loader!css-loader!less-loader' 57 | } 58 | } 59 | } 60 | }, 61 | { 62 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 63 | use: { 64 | loader: 'url-loader', 65 | query: { 66 | limit: 10000, 67 | name: 'imgs/[name].[ext]' 68 | } 69 | } 70 | }, 71 | { 72 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 73 | use: { 74 | loader: 'url-loader', 75 | query: { 76 | limit: 10000, 77 | name: 'fonts/[name].[ext]' 78 | } 79 | } 80 | } 81 | ] 82 | }, 83 | plugins: [ 84 | new VueLoaderPlugin(), 85 | new MiniCssExtractPlugin({filename: 'styles.css'}), 86 | new HtmlWebpackPlugin({ 87 | filename: 'index.html', 88 | template: path.resolve(__dirname, '../src/index.ejs'), 89 | minify: { 90 | collapseWhitespace: true, 91 | removeAttributeQuotes: true, 92 | removeComments: true 93 | }, 94 | nodeModules: false 95 | }), 96 | new webpack.DefinePlugin({ 97 | 'process.env.IS_WEB': 'true' 98 | }), 99 | new webpack.HotModuleReplacementPlugin(), 100 | new webpack.NoEmitOnErrorsPlugin() 101 | ], 102 | output: { 103 | filename: '[name].js', 104 | path: path.join(__dirname, '../dist/web') 105 | }, 106 | resolve: { 107 | alias: { 108 | '@': path.join(__dirname, '../src/renderer'), 109 | 'vue$': 'vue/dist/vue.esm.js' 110 | }, 111 | extensions: ['.js', '.vue', '.json', '.css'] 112 | }, 113 | target: 'web' 114 | } 115 | 116 | /** 117 | * Adjust webConfig for production settings 118 | */ 119 | if (process.env.NODE_ENV === 'production') { 120 | webConfig.devtool = '' 121 | 122 | webConfig.plugins.push( 123 | new MinifyPlugin(), 124 | new CopyWebpackPlugin([ 125 | { 126 | from: path.join(__dirname, '../static'), 127 | to: path.join(__dirname, '../dist/web/static'), 128 | ignore: ['.*'] 129 | } 130 | ]), 131 | new webpack.DefinePlugin({ 132 | 'process.env.NODE_ENV': '"production"' 133 | }), 134 | new webpack.LoaderOptionsPlugin({ 135 | minimize: true 136 | }) 137 | ) 138 | } 139 | 140 | module.exports = webConfig 141 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | dist/electron/* 3 | dist/web/* 4 | build/* 5 | !build/icons 6 | node_modules/ 7 | npm-debug.log 8 | npm-debug.log.* 9 | thumbs.db 10 | !.gitkeep 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode8.3 2 | sudo: required 3 | dist: trusty 4 | language: c 5 | matrix: 6 | include: 7 | - os: osx 8 | - os: linux 9 | env: CC=clang CXX=clang++ npm_config_clang=1 10 | compiler: clang 11 | cache: 12 | directories: 13 | - node_modules 14 | - "$HOME/.electron" 15 | - "$HOME/.cache" 16 | addons: 17 | apt: 18 | packages: 19 | - libgnome-keyring-dev 20 | - icnsutils 21 | before_install: 22 | - mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([ 23 | "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz 24 | | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull 25 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi 26 | install: 27 | - nvm install 10 28 | - curl -o- -L https://yarnpkg.com/install.sh | bash 29 | - source ~/.bashrc 30 | - npm install -g xvfb-maybe 31 | - yarn 32 | script: 33 | - yarn run build 34 | branches: 35 | only: 36 | - master 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 部署狗 2 | 3 | - 适用与个人与小团队的轻量级自动部署工具 4 | - 基于electron+vue+element开发 5 | 6 | ## :tada: 技术棧 7 | - electron-vue 8 | 9 | ## :construction_worker: 开发 10 | ``` node 11 | $ npm install 12 | $ npm run dev 13 | ``` 14 | 15 | ## :sparkles: screenshot 16 | 17 | **项目管理** 18 | 19 | ![avatar](./screenshort1.png) 20 | 21 | **添加项目** 22 | 23 | ![avatar](./screenshort2.png) 24 | 25 | **发布进度** 26 | 27 | ![avatar](./screenshort3.png) 28 | 29 | ## 部署流程 30 | ![avatar](./mind.png) 31 | 32 | 33 | ## :package: 安装包 34 | [windows下载](https://github.com/RocWangPeng/deploy-dog/releases/tag/1.0.0) 35 | 36 | 37 | ## 具体代码: 38 | - 部署代码 deploy.js (electron主进程中执行) 39 | ``` javascript 40 | const path = require('path'); 41 | const node_ssh = require('node-ssh'); 42 | const zipFile = require('compressing')// 压缩zip 43 | 44 | let SSH = new node_ssh(); // 生成ssh实例 45 | let mainWindow = null; // 窗口实例,用于向向渲染进程通信 46 | 47 | // 部署流程入口 48 | const deploy = async (config, mainWindows) => { 49 | mainWindow = mainWindows 50 | await startZip(config); 51 | await connectSSH(config); 52 | await uploadZipBySSH(config) 53 | } 54 | 55 | //压缩代码 56 | const startZip = async (config) => { 57 | return new Promise((resolve, reject) => { 58 | let { distPath } = config; 59 | let distZipPath = path.resolve(distPath, `../dist.zip`); 60 | mainWindow.send('deploy', '本地项目开始压缩') 61 | zipFile.zip.compressDir(distPath, distZipPath).then(res => { 62 | mainWindow.send('deploy', `本地项目压缩完成:${distZipPath}`) 63 | resolve() 64 | }).catch(err => { 65 | mainWindow.send('deploy', `压缩失败${err}`) 66 | reject() 67 | }) 68 | }) 69 | } 70 | 71 | //连接服务器 72 | const connectSSH = async (config) => { 73 | return new Promise((resolve, reject) => { 74 | mainWindow.send('deploy', `正在连接服务器:${config.host}`) 75 | SSH.connect({ 76 | host: config.host, 77 | username: config.username, 78 | password: config.password // 密码登录 方式二 79 | }).then(res => { 80 | mainWindow.send('deploy', `连接服务器成功:${config.host}`) 81 | resolve() 82 | }).catch(err => { 83 | mainWindow.send('deploy', `连接服务器失败:${err}`) 84 | reject() 85 | }) 86 | }) 87 | } 88 | 89 | //清空线上目标目录里的旧文件 90 | const clearOldFile = async (config) => { 91 | mainWindow.send('deploy', `准备清空服务器部署目录${config.webDir}内的文件`) 92 | const commands = ['ls', 'rm -rf *']; 93 | await Promise.all(commands.map(async (item) => { 94 | return await SSH.execCommand(item, { cwd: config.webDir }); 95 | })); 96 | mainWindow.send('deploy', `清空服务器目录${config.webDir}内的文件完成`) 97 | } 98 | 99 | //上传zip文件到服务器 100 | const uploadZipBySSH = async (config) => { 101 | let distZipPath = path.resolve(config.distPath, `../dist.zip`); 102 | //线上目标文件清空 103 | await clearOldFile(config); 104 | try { 105 | await SSH.putFiles([{ local: distZipPath, remote: config.webDir + '/dist.zip' }]); //local 本地 ; remote 服务器 ; 106 | mainWindow.send('deploy', `上传文件到服务器成功:${config.webDir}`) 107 | await SSH.execCommand('unzip -o dist.zip && rm -f dist.zip', { cwd: config.webDir }); //解压 108 | mainWindow.send('deploy', `解压上传到服务器的文件成功`) 109 | await SSH.execCommand(`rm -rf ${config.webDir}/dist.zip`, { cwd: config.webDir }); //解压完删除线上压缩包 110 | mainWindow.send('deploy', `删除上传到服务器的文件成功`) 111 | 112 | //将解压后的文件夹内的所有文件移动到目标目录 113 | var dir = path.basename(path.join(config.distPath)) 114 | mainWindow.send('deploy', `将${config.webDir}/${dir}/内解压的文件移动到目录${config.webDir}`) 115 | await SSH.execCommand(`mv - f ${config.webDir}/${dir}/* ${config.webDir}`); 116 | await SSH.execCommand(`rm -rf ${config.webDir}/${dir}`); //移出后删除 dist 文件夹 117 | mainWindow.send('deploy', `全部完成`) 118 | SSH.dispose(); //断开连接 119 | } catch (error) { 120 | mainWindow.send('deploy', `文件上传到服务器失败:${error}`) 121 | // process.exit(); //退出流程 122 | } 123 | } 124 | 125 | export default deploy 126 | 127 | ``` 128 | 129 | - 主进程进行监听与渲染进行发送的命令 130 | ``` javascript 131 | // 监听前台传来的deploy命令 132 | ipcMain.on('deploy', (e, data) => { 133 | deploy(data, mainWindow) 134 | }); 135 | ``` 136 | 137 | - 前台部分代码 138 | ``` javascript 139 | 163 | 164 | 197 | ``` 198 | 199 | --- 200 | 201 | This project was generated with [electron-vue](https://github.com/SimulatedGREG/electron-vue)@[45a3e22](https://github.com/SimulatedGREG/electron-vue/tree/45a3e224e7bb8fc71909021ccfdcfec0f461f634) using [vue-cli](https://github.com/vuejs/vue-cli). Documentation about the original structure can be found [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html). 202 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.1.{build} 2 | 3 | branches: 4 | only: 5 | - master 6 | 7 | image: Visual Studio 2017 8 | platform: 9 | - x64 10 | 11 | cache: 12 | - node_modules 13 | - '%APPDATA%\npm-cache' 14 | - '%USERPROFILE%\.electron' 15 | - '%USERPROFILE%\AppData\Local\Yarn\cache' 16 | 17 | init: 18 | - git config --global core.autocrlf input 19 | 20 | install: 21 | - ps: Install-Product node 8 x64 22 | - git reset --hard HEAD 23 | - yarn 24 | - node --version 25 | 26 | build_script: 27 | - yarn build 28 | 29 | test: off 30 | -------------------------------------------------------------------------------- /build/icons/256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/build/icons/256x256.png -------------------------------------------------------------------------------- /build/icons/favicon (1).ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/build/icons/favicon (1).ico -------------------------------------------------------------------------------- /build/icons/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/build/icons/icon.ico -------------------------------------------------------------------------------- /dist/electron/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/dist/electron/.gitkeep -------------------------------------------------------------------------------- /dist/web/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/dist/web/.gitkeep -------------------------------------------------------------------------------- /mind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/mind.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deploy-dog", 3 | "version": "1.0.0", 4 | "author": "king ", 5 | "description": "An electron-vue project", 6 | "license": null, 7 | "main": "./dist/electron/main.js", 8 | "scripts": { 9 | "build": "node .electron-vue/build.js && electron-builder", 10 | "build:dir": "node .electron-vue/build.js && electron-builder --dir", 11 | "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js", 12 | "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js", 13 | "dev": "node .electron-vue/dev-runner.js", 14 | "pack": "npm run pack:main && npm run pack:renderer", 15 | "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js", 16 | "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js", 17 | "postinstall": "" 18 | }, 19 | "build": { 20 | "productName": "部署狗", 21 | "appId": "com.example.yourapp", 22 | "directories": { 23 | "output": "build" 24 | }, 25 | "files": [ 26 | "dist/electron/**/*" 27 | ], 28 | "dmg": { 29 | "contents": [ 30 | { 31 | "x": 410, 32 | "y": 150, 33 | "type": "link", 34 | "path": "/Applications" 35 | }, 36 | { 37 | "x": 130, 38 | "y": 150, 39 | "type": "file" 40 | } 41 | ] 42 | }, 43 | "mac": { 44 | "icon": "build/icons/icon.icns" 45 | }, 46 | "win": { 47 | "icon": "build/icons/icon.ico" 48 | }, 49 | "linux": { 50 | "icon": "build/icons" 51 | } 52 | }, 53 | "dependencies": { 54 | "axios": "^0.18.0", 55 | "compressing": "^1.5.0", 56 | "element-ui": "^2.13.0", 57 | "fs-extra": "^8.1.0", 58 | "lowdb": "^1.0.0", 59 | "node-ssh": "^7.0.0", 60 | "vue": "^2.5.16", 61 | "vue-electron": "^1.0.6", 62 | "vue-router": "^3.0.1", 63 | "vuex": "^3.0.1", 64 | "vuex-electron": "^1.0.0" 65 | }, 66 | "devDependencies": { 67 | "ajv": "^6.5.0", 68 | "babel-core": "^6.26.3", 69 | "babel-loader": "^7.1.4", 70 | "babel-plugin-transform-runtime": "^6.23.0", 71 | "babel-preset-env": "^1.7.0", 72 | "babel-preset-stage-0": "^6.24.1", 73 | "babel-register": "^6.26.0", 74 | "babel-minify-webpack-plugin": "^0.3.1", 75 | "cfonts": "^2.1.2", 76 | "chalk": "^2.4.1", 77 | "copy-webpack-plugin": "^4.5.1", 78 | "cross-env": "^5.1.6", 79 | "css-loader": "^0.28.11", 80 | "del": "^3.0.0", 81 | "devtron": "^1.4.0", 82 | "electron": "^2.0.4", 83 | "electron-debug": "^1.5.0", 84 | "electron-devtools-installer": "^2.2.4", 85 | "electron-builder": "^20.19.2", 86 | "mini-css-extract-plugin": "0.4.0", 87 | "file-loader": "^1.1.11", 88 | "html-webpack-plugin": "^3.2.0", 89 | "multispinner": "^0.2.1", 90 | "node-loader": "^0.6.0", 91 | "node-sass": "^4.9.2", 92 | "sass-loader": "^7.0.3", 93 | "style-loader": "^0.21.0", 94 | "url-loader": "^1.0.1", 95 | "vue-html-loader": "^1.2.4", 96 | "vue-loader": "^15.2.4", 97 | "vue-style-loader": "^4.1.0", 98 | "vue-template-compiler": "^2.5.16", 99 | "webpack-cli": "^3.0.8", 100 | "webpack": "^4.15.1", 101 | "webpack-dev-server": "^3.1.4", 102 | "webpack-hot-middleware": "^2.22.2", 103 | "webpack-merge": "^4.1.3" 104 | } 105 | } -------------------------------------------------------------------------------- /screenshort1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/screenshort1.png -------------------------------------------------------------------------------- /screenshort2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/screenshort2.png -------------------------------------------------------------------------------- /screenshort3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/screenshort3.png -------------------------------------------------------------------------------- /src/db/datastore.js: -------------------------------------------------------------------------------- 1 | import Datastore from 'lowdb' 2 | import FileSync from 'lowdb/adapters/FileSync' 3 | import path from 'path' 4 | import fs from 'fs-extra' 5 | import { app, remote } from 'electron' // 引入remote模块 6 | const APP = process.type === 'renderer' ? remote.app : app // 根据process.type来分辨在哪种模式使用哪种模块 7 | const STORE_PATH = APP.getPath('userData') // 获取electron应用的用户目录 8 | if (process.type !== 'renderer') { 9 | if (!fs.pathExistsSync(STORE_PATH)) { 10 | fs.mkdirpSync(STORE_PATH) 11 | } 12 | } 13 | 14 | const adapter = new FileSync(path.join(STORE_PATH, '/data.json')) // 初始化lowdb读写的json文件名以及存储路径 15 | const db = Datastore(adapter) // lowdb接管该文件 16 | 17 | if (!db.has('project').value()) { 18 | db.set('project', []).write() 19 | } 20 | 21 | export default db // 暴露出去 -------------------------------------------------------------------------------- /src/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 部署狗 7 | <% if (htmlWebpackPlugin.options.nodeModules) { %> 8 | 9 | 12 | <% } %> 13 | 14 | 15 | 16 |
17 | 18 | <% if (!process.browser) { %> 19 | 22 | <% } %> 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/deploy/deploy.js: -------------------------------------------------------------------------------- 1 | 2 | const path = require('path'); 3 | const node_ssh = require('node-ssh'); 4 | const zipFile = require('compressing')// 压缩zip 5 | 6 | let SSH = new node_ssh(); // 生成ssh实例 7 | let mainWindow = null; // 窗口实例,用于向向渲染进程通信 8 | 9 | // 部署流程入口 10 | const deploy = async (config, mainWindows) => { 11 | mainWindow = mainWindows 12 | await startZip(config); 13 | await connectSSH(config); 14 | await uploadZipBySSH(config) 15 | } 16 | 17 | //压缩代码 18 | const startZip = async (config) => { 19 | return new Promise((resolve, reject) => { 20 | let { distPath } = config; 21 | let distZipPath = path.resolve(distPath, `../dist.zip`); 22 | mainWindow.send('deploy', '本地项目开始压缩') 23 | zipFile.zip.compressDir(distPath, distZipPath).then(res => { 24 | mainWindow.send('deploy', `本地项目压缩完成:${distZipPath}`) 25 | resolve() 26 | }).catch(err => { 27 | mainWindow.send('deploy', `压缩失败${err}`) 28 | reject() 29 | }) 30 | }) 31 | } 32 | 33 | //连接服务器 34 | const connectSSH = async (config) => { 35 | return new Promise((resolve, reject) => { 36 | mainWindow.send('deploy', `正在连接服务器:${config.host}`) 37 | SSH.connect({ 38 | host: config.host, 39 | username: config.username, 40 | password: config.password // 密码登录 方式二 41 | }).then(res => { 42 | mainWindow.send('deploy', `连接服务器成功:${config.host}`) 43 | resolve() 44 | }).catch(err => { 45 | mainWindow.send('deploy', `连接服务器失败:${err}`) 46 | reject() 47 | }) 48 | }) 49 | } 50 | 51 | //清空线上目标目录里的旧文件 52 | const clearOldFile = async (config) => { 53 | mainWindow.send('deploy', `准备清空服务器部署目录${config.webDir}内的文件`) 54 | const commands = ['ls', 'rm -rf *']; 55 | await Promise.all(commands.map(async (item) => { 56 | return await SSH.execCommand(item, { cwd: config.webDir }); 57 | })); 58 | mainWindow.send('deploy', `清空服务器目录${config.webDir}内的文件完成`) 59 | } 60 | 61 | //上传zip文件到服务器 62 | const uploadZipBySSH = async (config) => { 63 | let distZipPath = path.resolve(config.distPath, `../dist.zip`); 64 | //线上目标文件清空 65 | await clearOldFile(config); 66 | try { 67 | await SSH.putFiles([{ local: distZipPath, remote: config.webDir + '/dist.zip' }]); //local 本地 ; remote 服务器 ; 68 | mainWindow.send('deploy', `上传文件到服务器成功:${config.webDir}`) 69 | await SSH.execCommand('unzip -o dist.zip && rm -f dist.zip', { cwd: config.webDir }); //解压 70 | mainWindow.send('deploy', `解压上传到服务器的文件成功`) 71 | await SSH.execCommand(`rm -rf ${config.webDir}/dist.zip`, { cwd: config.webDir }); //解压完删除线上压缩包 72 | mainWindow.send('deploy', `删除上传到服务器的文件成功`) 73 | 74 | //将解压后的文件夹内的所有文件移动到目标目录 75 | var dir = path.basename(path.join(config.distPath)) 76 | mainWindow.send('deploy', `将${config.webDir}/${dir}/内解压的文件移动到目录${config.webDir}`) 77 | await SSH.execCommand(`mv - f ${config.webDir}/${dir}/* ${config.webDir}`); 78 | await SSH.execCommand(`rm -rf ${config.webDir}/${dir}`); //移出后删除 dist 文件夹 79 | mainWindow.send('deploy', `全部完成`) 80 | SSH.dispose(); //断开连接 81 | } catch (error) { 82 | mainWindow.send('deploy', `文件上传到服务器失败:${error}`) 83 | // process.exit(); //退出流程 84 | } 85 | } 86 | 87 | export default deploy -------------------------------------------------------------------------------- /src/main/index.dev.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is used specifically and only for development. It installs 3 | * `electron-debug` & `vue-devtools`. There shouldn't be any need to 4 | * modify this file, but it can be used to extend your development 5 | * environment. 6 | */ 7 | 8 | /* eslint-disable */ 9 | 10 | // Install `electron-debug` with `devtron` 11 | require('electron-debug')({ showDevTools: true }) 12 | 13 | // Install `vue-devtools` 14 | require('electron').app.on('ready', () => { 15 | let installExtension = require('electron-devtools-installer') 16 | installExtension.default(installExtension.VUEJS_DEVTOOLS) 17 | .then(() => {}) 18 | .catch(err => { 19 | console.log('Unable to install `vue-devtools`: \n', err) 20 | }) 21 | }) 22 | 23 | // Require `main` process to boot app 24 | require('./index') -------------------------------------------------------------------------------- /src/main/index.js: -------------------------------------------------------------------------------- 1 | import { app, BrowserWindow, ipcMain } from 'electron' 2 | import deploy from './deploy/deploy' 3 | 4 | /** 5 | * Set `__static` path to static files in production 6 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html 7 | */ 8 | if (process.env.NODE_ENV !== 'development') { 9 | global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') 10 | } 11 | 12 | let mainWindow 13 | const winURL = process.env.NODE_ENV === 'development' 14 | ? `http://localhost:9080` 15 | : `file://${__dirname}/index.html` 16 | 17 | function createWindow() { 18 | /** 19 | * Initial window options 20 | */ 21 | mainWindow = new BrowserWindow({ 22 | height: 760, 23 | useContentSize: true, 24 | width: 1200, 25 | autoHideMenuBar: true, 26 | // frame: false 27 | }) 28 | 29 | mainWindow.loadURL(winURL) 30 | 31 | mainWindow.on('closed', () => { 32 | mainWindow = null 33 | }) 34 | } 35 | 36 | app.on('ready', createWindow) 37 | 38 | app.on('window-all-closed', () => { 39 | if (process.platform !== 'darwin') { 40 | app.quit() 41 | } 42 | }) 43 | 44 | app.on('activate', () => { 45 | if (mainWindow === null) { 46 | createWindow() 47 | } 48 | }) 49 | 50 | ipcMain.on('close', e => mainWindow.close()); 51 | 52 | ipcMain.on('deploy', (e, data) => { 53 | deploy(data, mainWindow) 54 | }); 55 | 56 | 57 | /** 58 | * Auto Updater 59 | * 60 | * Uncomment the following code below and install `electron-updater` to 61 | * support auto updating. Code Signing with a valid certificate is required. 62 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating 63 | */ 64 | 65 | /* 66 | import { autoUpdater } from 'electron-updater' 67 | 68 | autoUpdater.on('update-downloaded', () => { 69 | autoUpdater.quitAndInstall() 70 | }) 71 | 72 | app.on('ready', () => { 73 | if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates() 74 | }) 75 | */ 76 | -------------------------------------------------------------------------------- /src/renderer/App.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 38 | 39 | 88 | -------------------------------------------------------------------------------- /src/renderer/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/src/renderer/assets/.gitkeep -------------------------------------------------------------------------------- /src/renderer/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/src/renderer/assets/logo.png -------------------------------------------------------------------------------- /src/renderer/assets/null.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/src/renderer/assets/null.png -------------------------------------------------------------------------------- /src/renderer/components/About.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 77 | 78 | 119 | -------------------------------------------------------------------------------- /src/renderer/components/AddPro.vue: -------------------------------------------------------------------------------- 1 | 42 | 43 | 122 | 123 | 130 | -------------------------------------------------------------------------------- /src/renderer/components/Log.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 48 | 49 | 88 | -------------------------------------------------------------------------------- /src/renderer/components/Null.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /src/renderer/components/ProList.vue: -------------------------------------------------------------------------------- 1 | 84 | 85 | 160 | 161 | 206 | -------------------------------------------------------------------------------- /src/renderer/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import axios from 'axios' 3 | 4 | import ElementUI from 'element-ui'; 5 | import 'element-ui/lib/theme-chalk/index.css'; 6 | 7 | import App from './App' 8 | import router from './router' 9 | import store from './store' 10 | import db from '../db/datastore' 11 | 12 | Vue.use(ElementUI, { size: 'small', zIndex: 3000 }); 13 | 14 | if (!process.env.IS_WEB) Vue.use(require('vue-electron')) 15 | Vue.http = Vue.prototype.$http = axios 16 | Vue.prototype.$db = db 17 | Vue.config.productionTip = false 18 | 19 | /* eslint-disable no-new */ 20 | new Vue({ 21 | components: { App }, 22 | router, 23 | store, 24 | template: '' 25 | }).$mount('#app') 26 | -------------------------------------------------------------------------------- /src/renderer/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | 4 | import ProList from '../components/ProList' 5 | import AddPro from '../components/AddPro' 6 | import Log from '../components/Log' 7 | import About from '../components/About' 8 | 9 | Vue.use(Router) 10 | 11 | export default new Router({ 12 | routes: [ 13 | { 14 | path: '/', 15 | name: 'proList', 16 | component: ProList 17 | }, 18 | { 19 | path: '/addpro', 20 | name: 'addpro', 21 | component: AddPro 22 | }, 23 | { 24 | path: '/about', 25 | name: 'about', 26 | component: About 27 | }, 28 | { 29 | path: '*', 30 | redirect: '/' 31 | } 32 | ] 33 | }) 34 | -------------------------------------------------------------------------------- /src/renderer/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | import { createPersistedState, createSharedMutations } from 'vuex-electron' 5 | 6 | import modules from './modules' 7 | 8 | Vue.use(Vuex) 9 | 10 | export default new Vuex.Store({ 11 | modules, 12 | plugins: [ 13 | createPersistedState(), 14 | createSharedMutations() 15 | ], 16 | strict: process.env.NODE_ENV !== 'production' 17 | }) 18 | -------------------------------------------------------------------------------- /src/renderer/store/modules/Counter.js: -------------------------------------------------------------------------------- 1 | const state = { 2 | main: 0 3 | } 4 | 5 | const mutations = { 6 | DECREMENT_MAIN_COUNTER (state) { 7 | state.main-- 8 | }, 9 | INCREMENT_MAIN_COUNTER (state) { 10 | state.main++ 11 | } 12 | } 13 | 14 | const actions = { 15 | someAsyncTask ({ commit }) { 16 | // do something async 17 | commit('INCREMENT_MAIN_COUNTER') 18 | } 19 | } 20 | 21 | export default { 22 | state, 23 | mutations, 24 | actions 25 | } 26 | -------------------------------------------------------------------------------- /src/renderer/store/modules/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The file enables `@/store/index.js` to import all vuex modules 3 | * in a one-shot manner. There should not be any reason to edit this file. 4 | */ 5 | 6 | const files = require.context('.', false, /\.js$/) 7 | const modules = {} 8 | 9 | files.keys().forEach(key => { 10 | if (key === './index.js') return 11 | modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default 12 | }) 13 | 14 | export default modules 15 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freekingg/deploy-dog/7302692f989ee03d7d98772c33f4be63f709ae80/static/.gitkeep --------------------------------------------------------------------------------