切换导航条
切换导航条
当前项目
正在载入...
登录
术习电报
/
electron-vue-template
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
作者
张恒
2019-08-20 15:39:17 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
提交
f58a9f67b52673cb76d5184dc89ed91182b52430
f58a9f67
1 个父辈
9df9cb64
去除开发环境中,electron发出的无用控制台信息,加入禁用f12方法
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
56 行增加
和
22 行删除
.electron-vue/dev-runner.js
config/index.js
package.json
src/main/config/DisableButton.js
src/main/index.js
src/renderer/tools/dialog.js
.electron-vue/dev-runner.js
查看文件 @
f58a9f6
...
...
@@ -5,6 +5,7 @@ const electron = require('electron')
const
path
=
require
(
'path'
)
const
{
say
}
=
require
(
'cfonts'
)
const
{
spawn
}
=
require
(
'child_process'
)
const
config
=
require
(
'../config'
)
const
webpack
=
require
(
'webpack'
)
const
WebpackDevServer
=
require
(
'webpack-dev-server'
)
const
webpackHotMiddleware
=
require
(
'webpack-hot-middleware'
)
...
...
@@ -36,6 +37,27 @@ function logStats(proc, data) {
log
+=
'\n'
+
chalk
.
yellow
.
bold
(
`┗
${
new
Array
(
28
+
1
).
join
(
'-'
)}
`
)
+
'\n'
console
.
log
(
log
)
}
function
removeJunk
(
chunk
)
{
if
(
config
.
dev
.
removeElectronJunk
)
{
// Example: 2018-08-10 22:48:42.866 Electron[90311:4883863] *** WARNING: Textured window <AtomNSWindow: 0x7fb75f68a770>
if
(
/
\d
+-
\d
+-
\d
+
\d
+:
\d
+:
\d
+
\.\d
+ Electron
(?:
Helper
)?\[\d
+:
\d
+] /
.
test
(
chunk
))
{
return
false
;
}
// 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)
if
(
/
\[\d
+:
\d
+
\/
|
\d
+
\.\d
+:ERROR:CONSOLE
\(\d
+
\)\]
/
.
test
(
chunk
))
{
return
false
;
}
// Example: ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
if
(
/ALSA lib
[
a-z
]
+
\.
c:
\d
+:
\([
a-z_
]
+
\)
/
.
test
(
chunk
))
{
return
false
;
}
}
return
chunk
;
}
function
startRenderer
()
{
return
new
Promise
((
resolve
)
=>
{
...
...
@@ -126,10 +148,10 @@ function startElectron() {
electronProcess
=
spawn
(
electron
,
args
)
electronProcess
.
stdout
.
on
(
'data'
,
data
=>
{
electronLog
(
data
,
'blue'
)
electronLog
(
removeJunk
(
data
)
,
'blue'
)
})
electronProcess
.
stderr
.
on
(
'data'
,
data
=>
{
electronLog
(
data
,
'red'
)
electronLog
(
removeJunk
(
data
)
,
'red'
)
})
electronProcess
.
on
(
'close'
,
()
=>
{
...
...
@@ -138,20 +160,23 @@ function startElectron() {
}
function
electronLog
(
data
,
color
)
{
let
log
=
''
data
=
data
.
toString
().
split
(
/
\r?\n
/
)
data
.
forEach
(
line
=>
{
log
+=
`
${
line
}
\n`
})
if
(
/
[
0-9A-z
]
+/
.
test
(
log
))
{
console
.
log
(
chalk
[
color
].
bold
(
'┏ Electron -------------------'
)
+
'\n\n'
+
log
+
chalk
[
color
].
bold
(
'┗ ----------------------------'
)
+
'\n'
)
if
(
data
)
{
let
log
=
''
data
=
data
.
toString
().
split
(
/
\r?\n
/
)
data
.
forEach
(
line
=>
{
log
+=
`
${
line
}
\n`
})
if
(
/
[
0-9A-z
]
+/
.
test
(
log
))
{
console
.
log
(
chalk
[
color
].
bold
(
'┏ Electron -------------------'
)
+
'\n\n'
+
log
+
chalk
[
color
].
bold
(
'┗ ----------------------------'
)
+
'\n'
)
}
}
}
function
greeting
()
{
...
...
config/index.js
查看文件 @
f58a9f6
...
...
@@ -4,7 +4,8 @@ module.exports = {
DisableF12
:
true
},
dev
:
{
env
:
require
(
'./dev.env'
)
env
:
require
(
'./dev.env'
),
removeElectronJunk
:
true
},
UseStartupChart
:
true
}
...
...
package.json
查看文件 @
f58a9f6
...
...
@@ -121,8 +121,10 @@
"node-loader"
:
"^0.6.0"
,
"node-sass"
:
"^4.12.0"
,
"sass-loader"
:
"^7.0.3"
,
"split2"
:
"^3.1.1"
,
"style-loader"
:
"^1.0.0"
,
"svg-sprite-loader"
:
"^4.1.6"
,
"through2-filter"
:
"^3.0.0"
,
"url-loader"
:
"^2.1.0"
,
"vue-html-loader"
:
"^1.2.4"
,
"vue-loader"
:
"^15.7.1"
,
...
...
src/main/config/DisableButton.js
查看文件 @
f58a9f6
import
{
globalShortcut
,
dialog
}
from
'electron'
import
{
globalShortcut
}
from
'electron'
import
config
from
'@config'
if
(
process
.
env
.
NODE_ENV
===
'production'
&&
config
.
bulid
.
DisableF12
)
{
globalShortcut
.
register
(
'f12'
,
()
=>
{
dialog
.
showErrorBox
({})
})
function
DisableButton
()
{
if
(
process
.
env
.
NODE_ENV
===
'production'
&&
config
.
bulid
.
DisableF12
)
{
globalShortcut
.
register
(
'f12'
,
()
=>
{
console
.
log
(
'用户试图启动控制台'
)
})
}
}
export
default
DisableButton
...
...
src/main/index.js
查看文件 @
f58a9f6
...
...
@@ -3,7 +3,7 @@
import
{
app
}
from
'electron'
import
initWindow
from
'./services/windowManager'
import
path
from
'path'
import
DisableButton
from
'./config/DisableButton'
/**
* Set `__static` path to static files in production
* 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
function
onAppReady
()
{
initWindow
(
loadingURL
)
DisableButton
()
}
app
.
isReady
()
?
onAppReady
()
:
app
.
on
(
'ready'
,
onAppReady
)
...
...
src/renderer/tools/dialog.js
查看文件 @
f58a9f6
...
...
@@ -16,6 +16,7 @@ export default {
message
:
data
.
message
},
index
=>
{
if
(
index
===
0
)
{
// eslint-disable-next-line prefer-const
let
tempfun
=
async
()
=>
{
try
{
resolve
(
await
fun
)
...
...
请
注册
或
登录
后发表评论