mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
8dd9d578d4
* feat(browser): support multiple chrome profiles * fix(browser): tighten profile popup context id * fix(browser): harden profile routing edge cases * refactor(browser): remove unnecessary profile id guard
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
// Query connection status from background service worker
|
|
chrome.runtime.sendMessage({ type: 'getStatus' }, (resp) => {
|
|
const dot = document.getElementById('dot');
|
|
const status = document.getElementById('status');
|
|
const hint = document.getElementById('hint');
|
|
const profile = document.getElementById('profile');
|
|
const contextId = document.getElementById('contextId');
|
|
if (chrome.runtime.lastError || !resp) {
|
|
dot.className = 'dot disconnected';
|
|
status.innerHTML = '<strong>No daemon connected</strong>';
|
|
profile.style.display = 'none';
|
|
hint.style.display = 'block';
|
|
return;
|
|
}
|
|
if (typeof resp.contextId === 'string' && resp.contextId.length > 0) {
|
|
contextId.textContent = resp.contextId;
|
|
profile.style.display = 'block';
|
|
} else {
|
|
profile.style.display = 'none';
|
|
}
|
|
if (resp.connected) {
|
|
dot.className = 'dot connected';
|
|
status.innerHTML = '<strong>Connected to daemon</strong>';
|
|
hint.style.display = 'none';
|
|
} else if (resp.reconnecting) {
|
|
dot.className = 'dot connecting';
|
|
status.innerHTML = '<strong>Reconnecting...</strong>';
|
|
hint.style.display = 'none';
|
|
} else {
|
|
dot.className = 'dot disconnected';
|
|
status.innerHTML = '<strong>No daemon connected</strong>';
|
|
hint.style.display = 'block';
|
|
}
|
|
});
|