Compare commits

..

3 Commits

Author SHA1 Message Date
95f9fc86fe 优化UI 2025-05-29 08:36:15 +08:00
1405cb714d 增加在标签页打开-优化 2025-05-29 08:08:41 +08:00
a339130105 增加在标签页打开 2025-05-28 17:40:45 +08:00
4 changed files with 144 additions and 1 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

@ -53,6 +53,8 @@
</div>
</div>
</div>
<script src="popup.js"></script>
</body>
</html>

View File

@ -1,4 +1,59 @@
document.addEventListener("DOMContentLoaded", async () => {
// 标签页/弹窗自适应:宽大则自动全屏自适应
if (window.innerWidth > 900 && window.innerHeight > 700) {
document.body.classList.add('fullscreen');
// 禁用拖拽
const panel = document.getElementById('draggablePanel');
if (panel) {
panel.style.left = '';
panel.style.top = '';
panel.style.position = 'fixed';
}
} else {
// 弹窗环境支持拖拽
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 = '';
});
}
}
// 标签页打开按钮
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");
}
};
}
const input = document.getElementById("searchInput");
const searchBtn = document.getElementById("searchBtn");
const clearHistoryBtn = document.getElementById("clearHistoryBtn");
@ -515,3 +570,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

@ -5,6 +5,23 @@ body {
background-color: #fefefe;
}
/* 新增:标签页下自动全屏自适应,内容居中不可拖拽 */
body.fullscreen .draggable-panel {
position: fixed !important;
left: 50% !important;
top: 50% !important;
transform: translate(-50%, -50%) !important;
width: 90vw !important;
max-width: 1200px !important;
height: 94vh !important;
max-height: 98vh !important;
min-width: 360px !important;
min-height: 320px !important;
box-shadow: 0 10px 40px #3070ed22;
resize: none !important;
}
.header {
display: flex;
align-items: center;
@ -403,6 +420,22 @@ 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;
}
.tab-bar {
display: flex;
margin-bottom: 8px;
@ -438,3 +471,10 @@ h1 {
margin-bottom: 0;
}
body.fullscreen #tabContentAi .llm-result-container {
resize: vertical;
overflow: auto;
min-height: 160px;
max-height: 80vh;
}