正在显示
6 个修改的文件
包含
41 行增加
和
7 行删除
| ... | @@ -5,6 +5,7 @@ const electron = require('electron') | ... | @@ -5,6 +5,7 @@ const electron = require('electron') |
| 5 | const path = require('path') | 5 | const path = require('path') |
| 6 | const { say } = require('cfonts') | 6 | const { say } = require('cfonts') |
| 7 | const { spawn } = require('child_process') | 7 | const { spawn } = require('child_process') |
| 8 | +const config = require('../config') | ||
| 8 | const webpack = require('webpack') | 9 | const webpack = require('webpack') |
| 9 | const WebpackDevServer = require('webpack-dev-server') | 10 | const WebpackDevServer = require('webpack-dev-server') |
| 10 | const webpackHotMiddleware = require('webpack-hot-middleware') | 11 | const webpackHotMiddleware = require('webpack-hot-middleware') |
| ... | @@ -36,6 +37,27 @@ function logStats(proc, data) { | ... | @@ -36,6 +37,27 @@ function logStats(proc, data) { |
| 36 | log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n' | 37 | log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n' |
| 37 | console.log(log) | 38 | console.log(log) |
| 38 | } | 39 | } |
| 40 | +function removeJunk(chunk) { | ||
| 41 | + if (config.dev.removeElectronJunk) { | ||
| 42 | + // Example: 2018-08-10 22:48:42.866 Electron[90311:4883863] *** WARNING: Textured window <AtomNSWindow: 0x7fb75f68a770> | ||
| 43 | + if (/\d+-\d+-\d+ \d+:\d+:\d+\.\d+ Electron(?: Helper)?\[\d+:\d+] /.test(chunk)) { | ||
| 44 | + return false; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + // Example: [90789:0810/225804.894349:ERROR:CONSOLE(105)] "Uncaught (in promise) Error: Could not instantiate: ProductRegistryImpl.Registry", source: chrome-devtools://devtools/bundled/inspector.js (105) | ||
| 48 | + if (/\[\d+:\d+\/|\d+\.\d+:ERROR:CONSOLE\(\d+\)\]/.test(chunk)) { | ||
| 49 | + return false; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + // Example: ALSA lib confmisc.c:767:(parse_card) cannot find card '0' | ||
| 53 | + if (/ALSA lib [a-z]+\.c:\d+:\([a-z_]+\)/.test(chunk)) { | ||
| 54 | + return false; | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + | ||
| 59 | + return chunk; | ||
| 60 | +} | ||
| 39 | 61 | ||
| 40 | function startRenderer() { | 62 | function startRenderer() { |
| 41 | return new Promise((resolve) => { | 63 | return new Promise((resolve) => { |
| ... | @@ -126,10 +148,10 @@ function startElectron() { | ... | @@ -126,10 +148,10 @@ function startElectron() { |
| 126 | electronProcess = spawn(electron, args) | 148 | electronProcess = spawn(electron, args) |
| 127 | 149 | ||
| 128 | electronProcess.stdout.on('data', data => { | 150 | electronProcess.stdout.on('data', data => { |
| 129 | - electronLog(data, 'blue') | 151 | + electronLog(removeJunk(data), 'blue') |
| 130 | }) | 152 | }) |
| 131 | electronProcess.stderr.on('data', data => { | 153 | electronProcess.stderr.on('data', data => { |
| 132 | - electronLog(data, 'red') | 154 | + electronLog(removeJunk(data), 'red') |
| 133 | }) | 155 | }) |
| 134 | 156 | ||
| 135 | electronProcess.on('close', () => { | 157 | electronProcess.on('close', () => { |
| ... | @@ -138,6 +160,7 @@ function startElectron() { | ... | @@ -138,6 +160,7 @@ function startElectron() { |
| 138 | } | 160 | } |
| 139 | 161 | ||
| 140 | function electronLog(data, color) { | 162 | function electronLog(data, color) { |
| 163 | + if (data) { | ||
| 141 | let log = '' | 164 | let log = '' |
| 142 | data = data.toString().split(/\r?\n/) | 165 | data = data.toString().split(/\r?\n/) |
| 143 | data.forEach(line => { | 166 | data.forEach(line => { |
| ... | @@ -152,6 +175,8 @@ function electronLog(data, color) { | ... | @@ -152,6 +175,8 @@ function electronLog(data, color) { |
| 152 | '\n' | 175 | '\n' |
| 153 | ) | 176 | ) |
| 154 | } | 177 | } |
| 178 | + } | ||
| 179 | + | ||
| 155 | } | 180 | } |
| 156 | 181 | ||
| 157 | function greeting() { | 182 | function greeting() { | ... | ... |
| ... | @@ -4,7 +4,8 @@ module.exports = { | ... | @@ -4,7 +4,8 @@ module.exports = { |
| 4 | DisableF12: true | 4 | DisableF12: true |
| 5 | }, | 5 | }, |
| 6 | dev: { | 6 | dev: { |
| 7 | - env: require('./dev.env') | 7 | + env: require('./dev.env'), |
| 8 | + removeElectronJunk: true | ||
| 8 | }, | 9 | }, |
| 9 | UseStartupChart: true | 10 | UseStartupChart: true |
| 10 | } | 11 | } | ... | ... |
| ... | @@ -121,8 +121,10 @@ | ... | @@ -121,8 +121,10 @@ |
| 121 | "node-loader": "^0.6.0", | 121 | "node-loader": "^0.6.0", |
| 122 | "node-sass": "^4.12.0", | 122 | "node-sass": "^4.12.0", |
| 123 | "sass-loader": "^7.0.3", | 123 | "sass-loader": "^7.0.3", |
| 124 | + "split2": "^3.1.1", | ||
| 124 | "style-loader": "^1.0.0", | 125 | "style-loader": "^1.0.0", |
| 125 | "svg-sprite-loader": "^4.1.6", | 126 | "svg-sprite-loader": "^4.1.6", |
| 127 | + "through2-filter": "^3.0.0", | ||
| 126 | "url-loader": "^2.1.0", | 128 | "url-loader": "^2.1.0", |
| 127 | "vue-html-loader": "^1.2.4", | 129 | "vue-html-loader": "^1.2.4", |
| 128 | "vue-loader": "^15.7.1", | 130 | "vue-loader": "^15.7.1", | ... | ... |
| 1 | -import { globalShortcut, dialog } from 'electron' | 1 | +import { globalShortcut } from 'electron' |
| 2 | import config from '@config' | 2 | import config from '@config' |
| 3 | 3 | ||
| 4 | -if (process.env.NODE_ENV === 'production' && config.bulid.DisableF12) { | 4 | +function DisableButton () { |
| 5 | + if (process.env.NODE_ENV === 'production' && config.bulid.DisableF12) { | ||
| 5 | globalShortcut.register('f12', () => { | 6 | globalShortcut.register('f12', () => { |
| 6 | - dialog.showErrorBox({}) | 7 | + console.log('用户试图启动控制台') |
| 7 | }) | 8 | }) |
| 9 | + } | ||
| 8 | } | 10 | } |
| 11 | + | ||
| 12 | +export default DisableButton | ... | ... |
| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | import { app } from 'electron' | 3 | import { app } from 'electron' |
| 4 | import initWindow from './services/windowManager' | 4 | import initWindow from './services/windowManager' |
| 5 | import path from 'path' | 5 | import path from 'path' |
| 6 | - | 6 | +import DisableButton from './config/DisableButton' |
| 7 | /** | 7 | /** |
| 8 | * Set `__static` path to static files in production | 8 | * Set `__static` path to static files in production |
| 9 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html | 9 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html |
| ... | @@ -16,6 +16,7 @@ const loadingURL = process.env.NODE_ENV === 'development' ? `http://localhost:90 | ... | @@ -16,6 +16,7 @@ const loadingURL = process.env.NODE_ENV === 'development' ? `http://localhost:90 |
| 16 | 16 | ||
| 17 | function onAppReady () { | 17 | function onAppReady () { |
| 18 | initWindow(loadingURL) | 18 | initWindow(loadingURL) |
| 19 | + DisableButton() | ||
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | app.isReady() ? onAppReady() : app.on('ready', onAppReady) | 22 | app.isReady() ? onAppReady() : app.on('ready', onAppReady) | ... | ... |
| ... | @@ -16,6 +16,7 @@ export default { | ... | @@ -16,6 +16,7 @@ export default { |
| 16 | message: data.message | 16 | message: data.message |
| 17 | }, index => { | 17 | }, index => { |
| 18 | if (index === 0) { | 18 | if (index === 0) { |
| 19 | + // eslint-disable-next-line prefer-const | ||
| 19 | let tempfun = async () => { | 20 | let tempfun = async () => { |
| 20 | try { | 21 | try { |
| 21 | resolve(await fun) | 22 | resolve(await fun) | ... | ... |
-
请 注册 或 登录 后发表评论