Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lsj315820
dr_py
提交
0c612051
dr_py
项目概览
lsj315820
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
dr_py
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0c612051
编写于
11月 17, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
实时日志界面优化完毕
上级
b36a0165
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
114 addition
and
3 deletion
+114
-3
base/rules.db
base/rules.db
+0
-0
templates/logtail.html
templates/logtail.html
+114
-3
未找到文件。
base/rules.db
浏览文件 @
0c612051
无法预览此类型文件
templates/logtail.html
浏览文件 @
0c612051
...
...
@@ -23,6 +23,7 @@
#title
{
background
:
#000000
;
color
:
#5dc2f1
;
padding
:
3px
1px
3px
1px
;
}
#height
{
margin-left
:
10px
;
...
...
@@ -40,9 +41,24 @@
/*上右下左*/
padding
:
1px
2px
10px
2px
;
}
#clearLog
{
.btn
{
background
:
#f06e57
;
color
:
#FFFFFF
;
margin
:
0
5px
0
0
;
border
:
2px
solid
#aaaaaa
;
border-radius
:
2px
;
}
.input
{
width
:
70%
;
height
:
20px
;
}
#inputMsg
{
background
:
#333
;
padding
:
5px
1px
5px
1px
;
}
#inputMsg
span
{
color
:
#5dc2f1
;
}
</style>
</head>
...
...
@@ -51,7 +67,15 @@
<div
id=
"title"
>
<strong>
tvbox实时日志 by道长
</strong>
<span
id=
"height"
></span>
<button
id=
"clearLog"
>
清空日志
</button>
<button
id=
"clearLog"
class=
"btn"
>
清空日志
</button>
<button
id=
"showInput"
class=
"btn"
>
显示输入框
</button>
<button
id=
"clearInput"
class=
"btn"
>
清空输入框
</button>
<button
id=
"autoClearInput"
class=
"btn"
>
自动清空
</button>
</div>
<div
id=
"inputMsg"
>
<span>
输入
</span>
<input
type=
"text"
class=
"input"
>
<button
id=
"sendMsg"
class=
"btn"
>
发送
</button>
</div>
<div
id=
"log-container"
>
<div
id=
"msg"
>
...
...
@@ -93,10 +117,38 @@
const
reconnect_time
=
5000
;
var
lockReconnect
=
false
;
//避免重复连接
var
ws
=
null
;
//WebSocket的引用
var
showInput
;
var
autoClearInput
;
showInput
=
!!
(
localStorage
.
showInput
&&
localStorage
.
showInput
===
'
1
'
);
autoClearInput
=
!!
(
localStorage
.
autoClearInput
&&
localStorage
.
autoClearInput
===
'
1
'
);
var
btn_showInput
=
$
(
'
#showInput
'
);
var
btn_autoClearInput
=
$
(
'
#autoClearInput
'
);
if
(
!
showInput
){
$
(
'
#inputMsg
'
).
hide
();
$
(
'
#clearInput
'
).
hide
();
$
(
'
#autoClearInput
'
).
hide
();
btn_showInput
.
text
(
'
显示输入框
'
);
btn_showInput
[
0
].
style
.
borderStyle
=
'
outset
'
;
}
else
{
$
(
'
#inputMsg
'
).
show
();
$
(
'
#clearInput
'
).
show
();
$
(
'
#autoClearInput
'
).
show
();
btn_showInput
.
text
(
'
隐藏输入框
'
);
btn_showInput
[
0
].
style
.
borderStyle
=
'
inset
'
;
}
if
(
autoClearInput
){
btn_autoClearInput
.
text
(
'
自动清空
'
);
btn_autoClearInput
[
0
].
style
.
borderStyle
=
'
inset
'
;
}
else
{
btn_autoClearInput
.
text
(
'
手动清空
'
);
btn_autoClearInput
[
0
].
style
.
borderStyle
=
'
outset
'
;
}
function
initHeight
(){
//动态刷新日志框高度自适应设备
var
div_height
=
window
.
screen
.
availHeight
;
var
height
=
Math
.
ceil
(
div_height
*
0.75
);
if
(
showInput
){
height
-=
35
;
}
$
(
'
#height
'
).
text
(
'
日志窗口高度:
'
+
height
);
$
(
"
#log-container
"
).
height
(
height
);
}
...
...
@@ -149,6 +201,7 @@
ws
=
new
WebSocket
(
websocketUrl
);
initEventHandle
();
}
catch
(
e
)
{
ws
=
null
;
reconnect
();
}
}
...
...
@@ -179,6 +232,7 @@
};
ws
.
onclose
=
function
(
event
)
{
addMsg
(
'
websocket连接关闭
'
);
ws
=
null
;
reconnect
();
};
ws
.
onerror
=
function
(
event
){
...
...
@@ -188,6 +242,7 @@
// console.log(event);
console
.
log
(
msg
);
addMsg
(
msg
);
ws
=
null
;
reconnect
();
}
}
...
...
@@ -232,6 +287,62 @@
}
});
});
$
(
'
#clearInput
'
).
click
(
function
(){
$
(
'
.input
'
).
val
(
''
);
});
$
(
'
#showInput
'
).
click
(
function
(){
// console.log(localStorage.showInput);
if
(
!
showInput
){
showInput
=
true
;
localStorage
.
showInput
=
'
1
'
;
$
(
'
#inputMsg
'
).
show
();
$
(
'
#clearInput
'
).
show
();
$
(
'
#autoClearInput
'
).
show
();
btn_showInput
.
text
(
'
隐藏输入框
'
);
btn_showInput
[
0
].
style
.
borderStyle
=
'
inset
'
;
}
else
{
showInput
=
false
;
localStorage
.
showInput
=
'
0
'
;
$
(
'
#inputMsg
'
).
hide
();
$
(
'
#clearInput
'
).
hide
();
$
(
'
#autoClearInput
'
).
hide
();
btn_showInput
.
text
(
'
显示输入框
'
);
btn_showInput
[
0
].
style
.
borderStyle
=
'
outset
'
;
}
initHeight
();
});
$
(
'
#autoClearInput
'
).
click
(
function
(){
if
(
!
autoClearInput
){
autoClearInput
=
true
;
localStorage
.
autoClearInput
=
'
1
'
;
btn_autoClearInput
.
text
(
'
自动清空
'
);
btn_autoClearInput
[
0
].
style
.
borderStyle
=
'
inset
'
;
}
else
{
autoClearInput
=
false
;
localStorage
.
autoClearInput
=
'
0
'
;
btn_autoClearInput
.
text
(
'
手动清空
'
);
btn_autoClearInput
[
0
].
style
.
borderStyle
=
'
outset
'
;
}
});
$
(
'
#sendMsg
'
).
click
(
function
(){
let
text_input
=
$
(
'
.input
'
);
let
msg
=
text_input
.
val
();
if
(
msg
){
if
(
ws
){
addMsg
(
'
主动发送文本消息:
'
+
msg
);
ws
.
send
(
msg
);
if
(
autoClearInput
){
text_input
.
val
(
''
);
}
}
else
{
addMsg
(
'
ws未正常连接,待发送消息无效:
'
+
msg
);
}
}
});
});
</script>
</body>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录