From cd41214f0b7b8b690fae0495f247864e77680e12 Mon Sep 17 00:00:00 2001 From: Lunatic Date: Mon, 3 Aug 2026 14:32:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=A1=86=E7=9B=B4=E6=8E=A5=E8=BE=93=E5=85=A5=20username/repo:t?= =?UTF-8?q?ag=20=E5=AE=9A=E4=BD=8D=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Web UI 搜索框现在可识别带斜杠的镜像路径: - 输入 username/repo 时跳过关键词搜索,直接选中仓库并拉取 tag 列表 - 输入 username/repo:tag 时额外预填指定 tag --- app.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index fee4c96..e9b41c0 100644 --- a/app.py +++ b/app.py @@ -562,7 +562,8 @@ def toggle_proxy_visibility(mode): with gr.Column(scale=4): gr.Markdown("### 🔍 步骤 1:全网查镜像") with gr.Row(): - kw_ui = gr.Textbox(label="输入镜像关键词", placeholder="eg: nginx, redis, pytorch", show_label=False) + kw_ui = gr.Textbox(label="输入镜像关键词", placeholder="eg: nginx, redis, pytorch", show_label=False, + info="也可直接输入 username/repo:tag 定位镜像") search_btn = gr.Button("🔍 搜 索", variant="primary") df_results = gr.Dataframe( @@ -614,14 +615,23 @@ def toggle_proxy_visibility(mode): # 🌟 修改:绑定首次搜索事件(重置为第1页),同步更新并保存 State 记录 def on_initial_search(kw, p_mode, p_host, p_user, p_pass, vSSL): - res, actual_page, html_info, can_prev, can_next = execute_search(kw, 1, p_mode, p_host, p_user, p_pass, vSSL) - return kw, res, actual_page, html_info, can_prev, can_next + value = (kw or "").strip() + if "/" in value: + repo, _, direct_tag = value.partition(":") + tag_update = fn_get_tags(repo, p_mode, p_host, p_user, p_pass, vSSL) + if direct_tag: + tag_update = gr.update(choices=[direct_tag], value=direct_tag, interactive=True) + return repo, [], 1, "", False, False, repo, tag_update + res, actual_page, html_info, can_prev, can_next = execute_search( + value, 1, p_mode, p_host, p_user, p_pass, vSSL) + return value, res, actual_page, html_info, can_prev, can_next, "", gr.update() search_btn.click( fn=on_initial_search, inputs=[kw_ui, proxy_mode_ui, proxy_host_ui, proxy_user_ui, proxy_pass_ui, ssl_ui], - outputs=[current_kw_state, df_results, current_page_state, page_info_ui, prev_btn, next_btn] + outputs=[current_kw_state, df_results, current_page_state, page_info_ui, prev_btn, next_btn, + selected_repo_ui, tag_ui] )