visual fix
This commit is contained in:
25
src/main.js
25
src/main.js
@@ -58,6 +58,11 @@ function setupEventListeners() {
|
||||
castBtn.addEventListener('click', openCastOverlay);
|
||||
closeOverlayBtn.addEventListener('click', closeCastOverlay);
|
||||
|
||||
// Close overlay on background click
|
||||
castOverlay.addEventListener('click', (e) => {
|
||||
if (e.target === castOverlay) closeCastOverlay();
|
||||
});
|
||||
|
||||
// Close button
|
||||
document.getElementById('close-btn').addEventListener('click', async () => {
|
||||
const appWindow = getCurrentWindow();
|
||||
@@ -213,37 +218,37 @@ function handleVolumeInput() {
|
||||
// Cast Logic
|
||||
async function openCastOverlay() {
|
||||
castOverlay.classList.remove('hidden');
|
||||
deviceListEl.innerHTML = '<li>Scanning...</li>';
|
||||
castOverlay.setAttribute('aria-hidden', 'false');
|
||||
deviceListEl.innerHTML = '<li class="device"><div class="device-main">Scanning...</div><div class="device-sub">Searching for speakers</div></li>';
|
||||
|
||||
try {
|
||||
const devices = await invoke('list_cast_devices');
|
||||
deviceListEl.innerHTML = '';
|
||||
|
||||
// Add "Stop Casting / Local" option
|
||||
// Add "This Computer" option
|
||||
const localLi = document.createElement('li');
|
||||
localLi.textContent = 'This Computer (Local Playback)';
|
||||
localLi.className = 'device' + (currentMode === 'local' ? ' selected' : '');
|
||||
localLi.innerHTML = '<div class="device-main">This Computer</div><div class="device-sub">Local Playback</div>';
|
||||
localLi.onclick = () => selectCastDevice(null);
|
||||
deviceListEl.appendChild(localLi);
|
||||
|
||||
if (devices.length === 0) {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = 'No speakers found';
|
||||
deviceListEl.appendChild(li);
|
||||
} else {
|
||||
if (devices.length > 0) {
|
||||
devices.forEach(d => {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = d;
|
||||
li.className = 'device' + (currentMode === 'cast' && currentCastDevice === d ? ' selected' : '');
|
||||
li.innerHTML = `<div class="device-main">${d}</div><div class="device-sub">Google Cast Speaker</div>`;
|
||||
li.onclick = () => selectCastDevice(d);
|
||||
deviceListEl.appendChild(li);
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
deviceListEl.innerHTML = `<li>Error: ${e}</li>`;
|
||||
deviceListEl.innerHTML = `<li class="device"><div class="device-main">Error</div><div class="device-sub">${e}</div></li>`;
|
||||
}
|
||||
}
|
||||
|
||||
function closeCastOverlay() {
|
||||
castOverlay.classList.add('hidden');
|
||||
castOverlay.setAttribute('aria-hidden', 'true');
|
||||
}
|
||||
|
||||
async function selectCastDevice(deviceName) {
|
||||
|
||||
Reference in New Issue
Block a user