From 88e5d98c6857982e37d08eff28285ae1eff2179f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Sun, 28 Jan 2024 18:25:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BE=93=E5=85=A5=E6=A1=86?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=AD=8C=E6=9B=B2=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/static/app.js | 21 ++++++++++++++++++++- xiaomusic/static/index.html | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/xiaomusic/static/app.js b/xiaomusic/static/app.js index f5367b1..811927a 100644 --- a/xiaomusic/static/app.js +++ b/xiaomusic/static/app.js @@ -6,7 +6,9 @@ $(function(){ $container=$("#cmds"); // 遍历数据 for (const [key, value] of Object.entries(data)) { - append_op_button(key); + if (key != "分钟后关机" && key != "放歌曲") { + append_op_button(key); + } } append_op_button("5分钟后关机"); @@ -41,4 +43,21 @@ $(function(){ // 添加按钮到容器 $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: () => { + // 请求失败时执行的操作 + } + }); + }); }); diff --git a/xiaomusic/static/index.html b/xiaomusic/static/index.html index 7b47306..f6dc7c4 100644 --- a/xiaomusic/static/index.html +++ b/xiaomusic/static/index.html @@ -11,6 +11,9 @@ width: 100px; height: 50px; } + input { + height: 40px; + } @@ -18,5 +21,10 @@
+
+
+ + +