diff --git a/2000s/js/xinhan-index.js b/2000s/js/xinhan-index.js
index a929d39..9221cf8 100644
--- a/2000s/js/xinhan-index.js
+++ b/2000s/js/xinhan-index.js
@@ -2,7 +2,19 @@ const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
const sb = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
+ function escapeHtml(value) {
+ return String(value ?? '').replace(/[&<>"']/g, char => ({
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": '''
+ }[char]));
+ }
+
async function handleSearch() {
+ const selfNumberTerm = document.getElementById('selfNumberTerm').value.trim();
+ const trackingNumberTerm = document.getElementById('trackingNumberTerm').value.trim();
const recipientTerm = document.getElementById('recipientTerm').value.trim();
const contentTerm = document.getElementById('searchTerm').value.trim();
const from = document.getElementById('dateFrom').value;
@@ -12,6 +24,8 @@ const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
out.innerHTML = '
正在连接信函数据库并执行检索...
';
let q = sb.from('xinhan').select('*');
+ if (selfNumberTerm) q = q.ilike('self_number', `%${selfNumberTerm}%`);
+ if (trackingNumberTerm) q = q.ilike('tracking_number', `%${trackingNumberTerm}%`);
if (recipientTerm) q = q.ilike('recipient', `%${recipientTerm}%`);
if (contentTerm) q = q.ilike('content', `%${contentTerm}%`);
if (from) q = q.gte('sent_date', from);
@@ -19,7 +33,7 @@ const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
const { data, error } = await q.order('sent_date', { ascending: false });
if (error) {
- out.innerHTML = `查询失败:${error.message}
`;
+ out.innerHTML = `查询失败:${escapeHtml(error.message)}
`;
return;
}
renderResults(data || []);
@@ -38,6 +52,8 @@ const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
| ID |
+ 自编号 |
+ 快递号 |
收件人 |
目的地 |
寄出日期 |
@@ -51,16 +67,18 @@ const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
rows.forEach(row => {
const content = row.content || '';
const summary = content.length > 60
- ? `${content}`
- : content;
+ ? `${escapeHtml(content)}`
+ : escapeHtml(content);
html += `
- | ${row.id} |
- ${row.recipient || ''} |
- ${row.destination || ''} |
- ${row.sent_date || ''} |
- ${row.arrival_date || ''} |
+ ${escapeHtml(row.id)} |
+ ${escapeHtml(row.self_number || '')} |
+ ${escapeHtml(row.tracking_number || '')} |
+ ${escapeHtml(row.recipient || '')} |
+ ${escapeHtml(row.destination || '')} |
+ ${escapeHtml(row.sent_date || '')} |
+ ${escapeHtml(row.arrival_date || '')} |
${summary} |
`;
@@ -71,3 +89,18 @@ const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
}
document.getElementById('searchBtn').addEventListener('click', handleSearch);
+
+ function applyQueryParams() {
+ const params = new URLSearchParams(window.location.search);
+ const selfNumber =
+ params.get('q') ||
+ params.get('self_number') ||
+ params.get('selfNumber');
+
+ if (!selfNumber) return;
+
+ document.getElementById('selfNumberTerm').value = selfNumber.trim();
+ handleSearch();
+ }
+
+ applyQueryParams();
diff --git a/2000s/xinhan/index.html b/2000s/xinhan/index.html
index a332c2a..df4ca33 100644
--- a/2000s/xinhan/index.html
+++ b/2000s/xinhan/index.html
@@ -19,8 +19,8 @@
信函流转查询台
可按收件人、关键字与寄送时间进行检索,统一展示寄达信息与内容摘要,方便快速确认记录。
- 检索字段:收件人 / 内容关键字
- 输出内容:目的地 / 时间 / 摘要
+ 检索字段:自编号 / 快递号 / 收件人 / 内容关键字
+ 输出内容:自编号 / 快递号 / 目的地 / 时间 / 摘要