新增输入框输入歌曲名
This commit is contained in:
parent
c7ab57c06a
commit
88e5d98c68
@ -6,7 +6,9 @@ $(function(){
|
|||||||
$container=$("#cmds");
|
$container=$("#cmds");
|
||||||
// 遍历数据
|
// 遍历数据
|
||||||
for (const [key, value] of Object.entries(data)) {
|
for (const [key, value] of Object.entries(data)) {
|
||||||
append_op_button(key);
|
if (key != "分钟后关机" && key != "放歌曲") {
|
||||||
|
append_op_button(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
append_op_button("5分钟后关机");
|
append_op_button("5分钟后关机");
|
||||||
@ -41,4 +43,21 @@ $(function(){
|
|||||||
// 添加按钮到容器
|
// 添加按钮到容器
|
||||||
$container.append($button);
|
$container.append($button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("#play").on("click", () => {
|
||||||
|
name = $("#music-name").val();
|
||||||
|
let cmd = "播放歌曲"+name;
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/cmd",
|
||||||
|
contentType: "application/json",
|
||||||
|
data: JSON.stringify({cmd: cmd}),
|
||||||
|
success: () => {
|
||||||
|
// 请求成功时执行的操作
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
// 请求失败时执行的操作
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
width: 100px;
|
width: 100px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
input {
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -18,5 +21,10 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<div id="cmds">
|
<div id="cmds">
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div>
|
||||||
|
<input id="music-name" type="text" placeholder="请输入歌曲名称"></input>
|
||||||
|
<button id="play">播放</button>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user