From 43d6a44decd865e6b51cb961165acb06aa1e5f56 Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Tue, 20 Jan 2026 23:05:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20AI=20=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=A1=B5=E9=9D=A2=E5=9B=BA=E5=AE=9A=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注册 /ai-query 和 /ai-query/{CODE} 路由 - 支持 URL 路径参数传递识别码 - 更新所有识别码链接为固定链接格式 - 与友链、反馈页面保持一致的实现方式 --- ai-summary-query.php | 6 ++++-- functions.php | 18 ++++++++++++++++++ template-parts/ai-summary.php | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ai-summary-query.php b/ai-summary-query.php index 6d3465a..b548782 100644 --- a/ai-summary-query.php +++ b/ai-summary-query.php @@ -8,6 +8,9 @@ if (!file_exists($wp_load_path)) $wp_load_path = $_SERVER['DOCUMENT_ROOT'] . '/w require_once($wp_load_path); $query_code = isset($_GET['code']) ? sanitize_text_field($_GET['code']) : ''; +if (empty($query_code)) { + $query_code = get_query_var('code') ? sanitize_text_field(get_query_var('code')) : ''; +} $result = null; $error = ''; @@ -276,7 +279,7 @@ html.darkmode .ai-verify-subtitle { color: #aaa; } - + @@ -284,7 +287,6 @@ html.darkmode .ai-verify-subtitle { color: #aaa; }

diff --git a/functions.php b/functions.php index e9d163c..a6b2c21 100644 --- a/functions.php +++ b/functions.php @@ -4482,12 +4482,20 @@ function argon_feedback_rewrite() { add_rewrite_rule('^feedback/?$', 'index.php?argon_feedback_view=1', 'top'); } +// AI 查询页面 URL 重写 +add_action('init', 'argon_ai_query_rewrite'); +function argon_ai_query_rewrite() { + add_rewrite_rule('^ai-query/?$', 'index.php?argon_ai_query=1', 'top'); + add_rewrite_rule('^ai-query/([A-Z0-9]{8})/?$', 'index.php?argon_ai_query=1&code=$matches[1]', 'top'); +} + // 主题激活或更新时刷新重写规则 add_action('after_switch_theme', 'argon_flush_rewrite_rules'); add_action('upgrader_process_complete', 'argon_flush_rewrite_rules'); function argon_flush_rewrite_rules() { argon_friend_links_rewrite(); argon_feedback_rewrite(); + argon_ai_query_rewrite(); flush_rewrite_rules(); } @@ -4495,6 +4503,7 @@ add_filter('query_vars', 'argon_friend_links_query_vars'); function argon_friend_links_query_vars($vars) { $vars[] = 'argon_friend_links'; $vars[] = 'argon_feedback_view'; + $vars[] = 'argon_ai_query'; return $vars; } @@ -4515,6 +4524,15 @@ function argon_feedback_template() { } } +// AI 查询页面路由 +add_action('template_redirect', 'argon_ai_query_template'); +function argon_ai_query_template() { + if (get_query_var('argon_ai_query')) { + include(get_template_directory() . '/ai-summary-query.php'); + exit; + } +} + //隐藏 admin 管理条 //show_admin_bar(false); diff --git a/template-parts/ai-summary.php b/template-parts/ai-summary.php index 72be4be..fe68810 100644 --- a/template-parts/ai-summary.php +++ b/template-parts/ai-summary.php @@ -76,7 +76,7 @@ $model_display = !empty($model) ? $model : __('未知模型', 'argon'); : - : + : @@ -121,7 +121,7 @@ $model_display = !empty($model) ? $model : __('未知模型', 'argon'); footerHTML += ': ' + data.data.model + ''; } if (data.data.code) { - footerHTML += ': ' + data.data.code + ''; + footerHTML += ': ' + data.data.code + ''; } footerDiv.innerHTML = footerHTML; }