Skip to content

Commit 8053e80

Browse files
author
binnng
committed
Merge branch 'dev'
Conflicts: demo/index.html
2 parents 5d3b3d0 + b5948eb commit 8053e80

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

build/debug.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

debug.coffee

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
class Debug
4949

5050
# 种类和颜色
51-
colorMap =
51+
debugMap =
5252
log: "0074cc"
5353
danger: "da4f49"
5454
warn: "faa732"
@@ -57,7 +57,7 @@
5757

5858
# 将不同类型的msg转换为可读的String
5959
render = (msg) ->
60-
text = []
60+
text = ""
6161
arr = []
6262

6363
if isArray msg
@@ -83,13 +83,18 @@
8383
# debug 容器底部预留的高度
8484
parentBottom = 6
8585

86+
publicCss = [
87+
"-webkit-transition: all .3s ease"
88+
"transition: all .3s ease"
89+
]
90+
8691
# 每个debug信息样式
8792
childCss = [
8893
"margin-top:-1px"
8994
"padding:.5em"
9095
"border-top:1px solid rgba(255,255,255,.1)"
9196
"margin:0"
92-
]
97+
].concat publicCss
9398

9499
# debug容器的样式
95100
parentCss = [
@@ -105,12 +110,10 @@
105110
"color:#fff"
106111
"width:100%"
107112
"padding-bottom:#{parentBottom}px"
108-
"-webkit-transition: all .3s ease"
109-
"transition: all .3s ease"
110-
]
113+
].concat publicCss
111114

112115
constructor: ->
113-
# 是否初始化; 是否收起
116+
# 是否初始化是否收起
114117
@isInit = @isHide = no
115118

116119
# 当前消息,当前执行函数,当前颜色
@@ -136,6 +139,7 @@
136139

137140
@
138141

142+
# `debug.print()`
139143
# 核心的输出debug信息方法
140144
print: ->
141145

@@ -149,6 +153,7 @@
149153

150154
@
151155

156+
# `debug.toggle()`
152157
# 隐藏和收起
153158
toggle: (event) ->
154159
(if @isHide then @show else @hide).call @, event
@@ -166,12 +171,19 @@
166171
@
167172

168173
# 添加所有debug方法
169-
for fn of colorMap
174+
# ```
175+
# debug.log()
176+
# debug.danger()
177+
# debug.warn()
178+
# debug.error()
179+
# debug.success()
180+
# ```
181+
for fn of debugMap
170182
@::[fn] = ((fn) ->
171183
(msg) ->
172184
@fn = fn
173185
@msg = render msg
174-
@color = colorMap[fn]
186+
@color = debugMap[fn]
175187
@print()
176188
) fn
177189

@@ -180,7 +192,7 @@
180192

181193
# 绑定window,捕捉js报错信息
182194
bind WIN, ERROR, (error) ->
183-
195+
# 只输出有用的错误信息
184196
msg = [
185197
"Error:"
186198
"filename: #{error.filename}"

debug.js

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)