feat(chrome-qwen-bridge): 🔥 init chrome qwen code bridge

This commit is contained in:
yiliang114
2025-12-20 00:58:41 +08:00
parent a92be72e88
commit a60c5c6697
57 changed files with 9489 additions and 0 deletions

View File

@@ -0,0 +1,217 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Qwen CLI Bridge - Options</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 40px 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.2);
padding: 40px;
}
h1 {
color: #333;
font-size: 2em;
margin-bottom: 10px;
}
.subtitle {
color: #666;
margin-bottom: 30px;
}
.section {
margin: 30px 0;
padding: 25px;
background: #f8f9fa;
border-radius: 10px;
}
.section h2 {
color: #667eea;
margin-bottom: 15px;
font-size: 1.3em;
}
.option-group {
margin: 20px 0;
}
label {
display: block;
margin-bottom: 8px;
color: #444;
font-weight: 500;
}
input[type="text"],
input[type="number"],
textarea {
width: 100%;
padding: 10px 15px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 14px;
transition: border-color 0.3s;
}
input:focus,
textarea:focus {
outline: none;
border-color: #667eea;
}
input[type="checkbox"] {
margin-right: 8px;
}
.checkbox-label {
display: flex;
align-items: center;
cursor: pointer;
}
button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: transform 0.2s;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.save-status {
display: inline-block;
margin-left: 15px;
color: #4caf50;
opacity: 0;
transition: opacity 0.3s;
}
.save-status.show {
opacity: 1;
}
.help-text {
font-size: 12px;
color: #999;
margin-top: 5px;
}
.info-box {
background: #e3f2fd;
border-left: 4px solid #2196f3;
padding: 15px;
margin: 20px 0;
border-radius: 4px;
}
.info-box h3 {
color: #1976d2;
margin-bottom: 8px;
}
.info-box p {
color: #555;
}
</style>
</head>
<body>
<div class="container">
<h1>⚙️ Qwen CLI Bridge Settings</h1>
<p class="subtitle">Configure your Chrome extension and Qwen CLI integration</p>
<div class="section">
<h2>🔌 Connection Settings</h2>
<div class="option-group">
<label for="httpPort">HTTP Server Port</label>
<input type="number" id="httpPort" min="1024" max="65535" value="8080">
<p class="help-text">Port for Qwen CLI HTTP server (default: 8080)</p>
</div>
<div class="option-group">
<label for="mcpServers">MCP Servers</label>
<input type="text" id="mcpServers" placeholder="chrome-devtools,playwright">
<p class="help-text">Comma-separated list of MCP servers to load</p>
</div>
<div class="option-group">
<label class="checkbox-label">
<input type="checkbox" id="autoConnect">
<span>Auto-connect on startup</span>
</label>
<p class="help-text">Automatically connect to Qwen CLI when opening the popup</p>
</div>
</div>
<div class="section">
<h2>🎨 Display Settings</h2>
<div class="option-group">
<label class="checkbox-label">
<input type="checkbox" id="showNotifications">
<span>Show notifications</span>
</label>
<p class="help-text">Display desktop notifications for important events</p>
</div>
<div class="option-group">
<label class="checkbox-label">
<input type="checkbox" id="debugMode">
<span>Debug mode</span>
</label>
<p class="help-text">Show detailed debug information in console</p>
</div>
</div>
<div class="info-box">
<h3> Native Host Status</h3>
<p id="nativeHostStatus">Checking...</p>
</div>
<div class="info-box">
<h3>📍 Extension ID</h3>
<p id="extensionId">Loading...</p>
</div>
<button id="saveBtn">Save Settings</button>
<span class="save-status" id="saveStatus">✓ Settings saved</span>
<div style="margin-top: 40px; padding-top: 20px; border-top: 1px solid #e0e0e0;">
<p style="text-align: center; color: #999; font-size: 14px;">
Qwen CLI Bridge v1.0.0 |
<a href="https://github.com/QwenLM/qwen-code" style="color: #667eea;">GitHub</a> |
<a href="#" id="helpLink" style="color: #667eea;">Help</a>
</p>
</div>
</div>
<script src="options.js"></script>
</body>
</html>

View File

@@ -0,0 +1,80 @@
/**
* Options page script for Qwen CLI Bridge
*/
// Load saved settings
async function loadSettings() {
const settings = await chrome.storage.local.get([
'httpPort',
'mcpServers',
'autoConnect',
'showNotifications',
'debugMode'
]);
// Set values in form
document.getElementById('httpPort').value = settings.httpPort || 8080;
document.getElementById('mcpServers').value = settings.mcpServers || '';
document.getElementById('autoConnect').checked = settings.autoConnect || false;
document.getElementById('showNotifications').checked = settings.showNotifications || false;
document.getElementById('debugMode').checked = settings.debugMode || false;
}
// Save settings
document.getElementById('saveBtn').addEventListener('click', async () => {
const settings = {
httpPort: parseInt(document.getElementById('httpPort').value) || 8080,
mcpServers: document.getElementById('mcpServers').value,
autoConnect: document.getElementById('autoConnect').checked,
showNotifications: document.getElementById('showNotifications').checked,
debugMode: document.getElementById('debugMode').checked
};
await chrome.storage.local.set(settings);
// Show saved status
const saveStatus = document.getElementById('saveStatus');
saveStatus.classList.add('show');
setTimeout(() => {
saveStatus.classList.remove('show');
}, 2000);
});
// Check Native Host status
async function checkNativeHostStatus() {
try {
// Try to send a message to check if Native Host is installed
chrome.runtime.sendMessage({ type: 'GET_STATUS' }, (response) => {
if (chrome.runtime.lastError) {
document.getElementById('nativeHostStatus').textContent =
'❌ Not installed - Please run install script';
} else if (response && response.connected) {
document.getElementById('nativeHostStatus').textContent =
'✅ Connected and running';
} else {
document.getElementById('nativeHostStatus').textContent =
'⚠️ Installed but not connected';
}
});
} catch (error) {
document.getElementById('nativeHostStatus').textContent =
'❌ Error checking status';
}
}
// Show extension ID
document.getElementById('extensionId').textContent = chrome.runtime.id;
// Help link
document.getElementById('helpLink').addEventListener('click', (e) => {
e.preventDefault();
chrome.tabs.create({
url: 'https://github.com/QwenLM/qwen-code/tree/main/packages/chrome-qwen-bridge'
});
});
// Initialize
document.addEventListener('DOMContentLoaded', () => {
loadSettings();
checkNativeHostStatus();
});