增加在标签页打开

This commit is contained in:
luke 2025-05-28 17:40:45 +08:00
parent df177dff58
commit a339130105
4 changed files with 98 additions and 41 deletions

View File

@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "渠道应用开发部知识库",
"version": "1.3.2",
"version": "1.3.3",
"description": "通过关键词快速搜索内部文档",
"permissions": ["storage"],
"host_permissions": [

View File

@ -6,11 +6,12 @@
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="header">
<div class="draggable-panel" id="draggablePanel">
<div class="header">
<img src="../assets/icon.png" alt="logo" class="logo" />
<h1>渠道应用开发部知识库</h1>
<a href="https://oa.ahrcu.com/sys/portal/page.jsp" target="_blank" class="oa-link">跳转OA</a>
<button class="open-tab-btn" id="openTabBtn" title="以标签页方式打开"></button>
<div class="user-menu">
<div class="user-avatar" id="userAvatar">👤</div>
<div class="user-dropdown hidden" id="userDropdown">
@ -18,14 +19,12 @@
<div id="logoutBtn" class="logout-option">退出登录</div>
</div>
</div>
</div>
<div class="container">
</div>
<div class="container">
<div class="search-bar">
<input id="searchInput" type="text" autocomplete="off" placeholder="请输入关键词(空格分隔)..." />
<button id="searchBtn">搜索</button>
</div>
<div class="history-wrapper hidden" id="historyWrapper">
<div class="history-header">
<span>历史搜索:</span>
@ -33,7 +32,6 @@
</div>
<div id="historyTags" class="tag-history"></div>
</div>
<!-- AnythingLLM结果区域 -->
<div id="llmResultContainer" class="llm-result-container hidden">
<div class="llm-title">智能助手答案</div>
@ -43,12 +41,9 @@
<button id="llmSendBtn">发送</button>
</div>
</div>
<ul id="results"></ul>
</div>
</div>
<script src="popup.js"></script>
</body>
</html>

View File

@ -483,3 +483,49 @@ document.addEventListener("DOMContentLoaded", async () => {
document.body.style.userSelect = '';
});
})();
document.addEventListener('DOMContentLoaded', function () {
// 标签页打开按钮事件
const openTabBtn = document.getElementById('openTabBtn');
if (openTabBtn) {
openTabBtn.onclick = function () {
if (window.chrome && chrome.runtime && chrome.runtime.id && chrome.tabs && chrome.runtime.getURL) {
try {
chrome.tabs.create({ url: chrome.runtime.getURL("pages/popup.html") });
} catch (e) {
window.open("popup.html", "_blank");
}
} else {
window.open("popup.html", "_blank");
}
};
}
// 拖拽功能(如你的页面有 .draggable-panel
const panel = document.getElementById('draggablePanel');
const header = document.querySelector('.header');
let dragging = false, offsetX = 0, offsetY = 0;
if (panel && header) {
header.addEventListener('mousedown', function(e) {
dragging = true;
offsetX = e.clientX - panel.offsetLeft;
offsetY = e.clientY - panel.offsetTop;
document.body.style.userSelect = 'none';
});
document.addEventListener('mousemove', function(e) {
if (dragging) {
let left = Math.max(0, e.clientX - offsetX);
let top = Math.max(0, e.clientY - offsetY);
panel.style.left = left + 'px';
panel.style.top = top + 'px';
}
});
document.addEventListener('mouseup', function() {
dragging = false;
document.body.style.userSelect = '';
});
}
});

View File

@ -403,4 +403,20 @@ h1 {
white-space: pre-wrap;
}
.open-tab-btn {
margin-left: 8px;
padding: 2px 10px;
background: #f8f8f8;
border: 1px solid #c9dafc;
color: #2560de;
border-radius: 4px;
font-size: 15px;
cursor: pointer;
vertical-align: middle;
transition: background 0.2s;
}
.open-tab-btn:hover {
background: #eaf1fb;
color: #1e40af;
}