From 90255f9db0d0d329c9e6adb940fc1dd64c8eea99 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 9 Jun 2025 14:30:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 2 +- readme.md | 1 + scripts/popup.js | 10 ++++++++++ scripts/utils.js | 12 ++++++++++++ styles/styles-es.css | 24 +++++++++++++++++++++++- 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index baa64df..372691e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "渠道应用开发部知识库", - "version": "2.0.3", + "version": "2.0.4", "description": "通过关键词快速搜索内部文档", "permissions": ["storage"], "host_permissions": [ diff --git a/readme.md b/readme.md index 2e1dfc1..450f097 100644 --- a/readme.md +++ b/readme.md @@ -7,4 +7,5 @@ | 2025.06.03 | V2.0.1 | Luke.Ye | 完成llm token过期时间的配置化 | | 2025.06.03 | V2.0.2 | Luke.Ye | 支持LLM工作区配置化 | | 2025.06.06 | V2.0.3 | Luke.Ye | 添加跳转页面权限校验 | +| 2025.06.09 | V2.0.4 | Luke.Ye | 优化es搜索展示页面 | diff --git a/scripts/popup.js b/scripts/popup.js index 5c60d13..6d16834 100644 --- a/scripts/popup.js +++ b/scripts/popup.js @@ -179,6 +179,7 @@ document.addEventListener("DOMContentLoaded", async () => { const li = document.createElement("li"); const filename = doc.filename || doc.title || "未知文件"; const filepath = doc.filepath?.replace(/^import-data\//, "").replace(/\.md$/, ".html") || ""; + const mtime = doc.mtime ? formatLocalTime(doc.mtime) : ""; // 格式化时间 const link = document.createElement("a"); link.href = `${fileBaseUrl}/${filepath || filename}`; link.target = "_blank"; @@ -188,8 +189,17 @@ document.addEventListener("DOMContentLoaded", async () => { snippet.className = "summary"; snippet.innerHTML = doc.summary?.slice(0, 300) + "..."; + // 元信息行 + const metaRow = document.createElement("div"); + metaRow.className = "es-meta-row"; + metaRow.innerHTML = ` + ${filepath} + ${mtime ? "更新时间:" + mtime : ""} + `; + li.appendChild(link); li.appendChild(snippet); + li.appendChild(metaRow); resultBox.appendChild(li); }); diff --git a/scripts/utils.js b/scripts/utils.js index d06412b..1198bb7 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -7,3 +7,15 @@ function log(...args) { function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } + +function formatLocalTime(ts) { + if (!ts) return ""; + const date = new Date(Number(ts)); + if (isNaN(date.getTime())) return ""; + // 格式:2024-06-01 13:47 + return date.getFullYear() + "-" + + String(date.getMonth() + 1).padStart(2, "0") + "-" + + String(date.getDate()).padStart(2, "0") + " " + + String(date.getHours()).padStart(2, "0") + ":" + + String(date.getMinutes()).padStart(2, "0"); +} diff --git a/styles/styles-es.css b/styles/styles-es.css index 41bb91d..e224011 100644 --- a/styles/styles-es.css +++ b/styles/styles-es.css @@ -28,7 +28,7 @@ #results .summary { font-size: 13px; color: #444; - margin-top: 4px; + margin-top: 5px; } .pagination { @@ -97,3 +97,25 @@ .tag-history .tag:hover { background-color: #dcdcdc; } + +/* 搜索结果项小号元信息行 */ +.es-meta-row { + color: #9198ad; + font-size: 12px; + margin: 5px 0 0 0; + display: flex; + gap: 24px; + align-items: center; + white-space: nowrap; +} +.es-filepath { + max-width: 320px; + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; + vertical-align: middle; +} +.es-updatetime { + margin-left: 10px; +} +