From 382bc7a62073e3e617d0f37b5a9990be56c29821 Mon Sep 17 00:00:00 2001 From: "Gao, Ruiyuan" <905370712@qq.com> Date: Wed, 9 Oct 2024 15:12:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E9=BB=98?= =?UTF-8?q?=E8=AE=A4UI=E7=9A=84=E6=90=9C=E7=B4=A2=E6=A1=86#226=20(#227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/static/default/app.js | 63 +++++++++++++++++++---------- xiaomusic/static/default/index.html | 10 ++++- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/xiaomusic/static/default/app.js b/xiaomusic/static/default/app.js index ada9b88..7c81cd7 100644 --- a/xiaomusic/static/default/app.js +++ b/xiaomusic/static/default/app.js @@ -281,34 +281,55 @@ $(function(){ } // 监听输入框的输入事件 - function debounce(func, delay) { + function debounce(func, delay) { let timeout; return function(...args) { clearTimeout(timeout); timeout = setTimeout(() => func.apply(this, args), delay); }; } - $("#music-name").on('input', debounce(function() { - var inputValue = $(this).val(); - // 发送Ajax请求 - $.ajax({ - url: "/searchmusic", // 服务器端处理脚本 - type: "GET", - dataType: "json", - data: { - name: inputValue - }, - success: function(data) { - // 清空datalist - $("#autocomplete-list").empty(); - // 添加新的option元素 - $.each(data, function(i, item) { - $('