mirror of
https://github.com/pvrzz/atmosphere.git
synced 2026-11-29 05:22:26 +00:00
Mini player, direct file links, backups and polish
- Mini player with optional cover art, blurred backdrop, reorderable queue and always-on-top - Direct .mp3/.wav/.flac/.mp4 links are verified and read for real bitrate, tags and cover - Lyrics soften with distance from the sung line; hovering brings a line into focus - Browser sign-in check with clear guidance, plus cookies.txt file support - Backup and restore of settings, stats, liked songs and artist photos - Uninstaller keeps data by default and offers a backup before deleting it - Stalled partial downloads clear automatically when downloads finish - Window border follows the app theme; images can no longer be dragged out - Fix search results rendering as [object Object]
This commit is contained in:
@@ -30,6 +30,7 @@ const SOURCE = { title: "Detected from the title", metadata: "Detected from trac
|
||||
const FINAL = new Set(["done", "skipped", "error", "cancelled"]);
|
||||
const ACTIVE = new Set(["queued", "preparing", "downloading", "processing", "tagging"]);
|
||||
const PLATFORM_ICON = [
|
||||
[/^\S+\.(mp3|wav|flac|m4a|aac|ogg|oga|opus|aiff?|wma|alac|mp4|m4v|mov|webm|mkv)(?:[?#]\S*)?$/i, "file-music", "File link"],
|
||||
[/soundcloud\.com|snd\.sc/i, "brand-soundcloud", "SoundCloud"],
|
||||
[/youtube\.com|youtu\.be|music\.youtube/i, "brand-youtube", "YouTube"],
|
||||
[/bandcamp\.com/i, "brand-bandcamp", "Bandcamp"],
|
||||
@@ -105,6 +106,12 @@ function applyTheme() {
|
||||
const t = state.settings.theme;
|
||||
if (t === "light" || t === "dark") document.documentElement.dataset.theme = t;
|
||||
else delete document.documentElement.dataset.theme;
|
||||
syncFrame();
|
||||
}
|
||||
|
||||
function syncFrame() {
|
||||
const color = getComputedStyle(document.documentElement).getPropertyValue("--border").trim();
|
||||
if (/^#[0-9a-f]{6}$/i.test(color)) invoke("frame_color", { color }).catch(() => {});
|
||||
}
|
||||
|
||||
/* window chrome */
|
||||
@@ -127,6 +134,7 @@ function bindWindow() {
|
||||
$("#winMax").addEventListener("click", () => win.toggleMaximize());
|
||||
$("#winClose").addEventListener("click", () => win.close());
|
||||
win.onResized?.(() => syncMax());
|
||||
matchMedia("(prefers-color-scheme: dark)").addEventListener("change", syncFrame);
|
||||
window.addEventListener("focus", () => bar.classList.remove("blur"));
|
||||
window.addEventListener("blur", () => bar.classList.add("blur"));
|
||||
syncMax();
|
||||
@@ -146,6 +154,8 @@ async function init() {
|
||||
bindPlayer();
|
||||
bindLibrary();
|
||||
bindLyrics();
|
||||
bindBackup();
|
||||
bindMini();
|
||||
bindStats();
|
||||
await listen("atmosphere://job", (e) => onJob(e.payload));
|
||||
await listen("atmosphere://probe", (e) => onProbe(e.payload));
|
||||
@@ -305,6 +315,10 @@ function bindShell() {
|
||||
fetchText(text);
|
||||
}
|
||||
});
|
||||
document.addEventListener("dragstart", (e) => {
|
||||
const t = e.target;
|
||||
if (t.nodeType !== 1 || (t.getAttribute("draggable") !== "true" && !t.closest?.('[draggable="true"]'))) e.preventDefault();
|
||||
});
|
||||
document.addEventListener("dragover", (e) => e.preventDefault());
|
||||
document.addEventListener("drop", (e) => {
|
||||
e.preventDefault();
|
||||
@@ -763,7 +777,7 @@ function sheetBody(c) {
|
||||
)
|
||||
);
|
||||
const list = h("ul", { class: "tracklist", role: "listbox", "aria-label": "Tracks", "aria-multiselectable": "true" });
|
||||
d.entries.forEach((e, i) => list.append(trackRow(c, e, i)));
|
||||
d.entries.forEach((e, i) => list.append(sheetRow(c, e, i)));
|
||||
body.append(list);
|
||||
if (c.inspected != null) {
|
||||
const e = entryOf(c, c.inspected);
|
||||
@@ -779,7 +793,7 @@ function unavailableNote(entries) {
|
||||
return h("span", { class: "warn-note", title: drm ? "If these are your own tracks, enable downloads on them in the platform's track settings, then choose Original file." : "The platform only offers a short preview of these." }, `${parts}, can't be downloaded`);
|
||||
}
|
||||
|
||||
function trackRow(c, e, i) {
|
||||
function sheetRow(c, e, i) {
|
||||
const ok = selectable(e);
|
||||
const m = finalMeta(c, e);
|
||||
const box = h("input", { type: "checkbox", class: "tl-check", disabled: !ok, "aria-label": `Include ${m.title}` });
|
||||
@@ -1314,6 +1328,7 @@ function bindSettings() {
|
||||
const key = el.dataset.key;
|
||||
el.addEventListener("change", () => patch({ [key]: el.type === "checkbox" ? el.checked : el.value.trim() }));
|
||||
});
|
||||
bindSignin();
|
||||
$("#templateInput").addEventListener("input", renderTemplatePreview);
|
||||
$("#tokens").replaceChildren(
|
||||
...TOKENS.map((t) =>
|
||||
@@ -1371,12 +1386,71 @@ function renderSettings() {
|
||||
const at = s.rightsAcceptedAt ? new Intl.DateTimeFormat(undefined, { dateStyle: "long" }).format(new Date(s.rightsAcceptedAt * 1000)) : "";
|
||||
$("#rightsInfo").textContent = at ? `You confirmed it on ${at}. Withdrawing it cancels downloads and asks again.` : "Not confirmed yet.";
|
||||
renderTemplatePreview();
|
||||
renderSignin();
|
||||
renderToolSettings();
|
||||
renderLibrarySettings();
|
||||
renderLyricsSettings();
|
||||
renderStorage();
|
||||
}
|
||||
|
||||
const OS = isMac ? "mac" : /Linux|X11/.test(navigator.userAgent) ? "linux" : "windows";
|
||||
|
||||
function signinStatus(text, kind) {
|
||||
const el = $("#signinStatus");
|
||||
if (!el) return;
|
||||
el.hidden = !text;
|
||||
el.textContent = text || "";
|
||||
el.dataset.kind = kind || "";
|
||||
}
|
||||
|
||||
function renderSignin() {
|
||||
const s = state.settings;
|
||||
const sel = $("#signinSelect");
|
||||
if (!s || !sel) return;
|
||||
$$("option[data-os]", sel).forEach((o) => (o.hidden = o.dataset.os !== OS && o.value !== s.cookiesBrowser));
|
||||
const isFile = s.cookiesBrowser === "file";
|
||||
$("#cookiesFileRow").hidden = !isFile;
|
||||
$("#signinCheck").hidden = !s.cookiesBrowser;
|
||||
$("#cookiesFilePath").textContent = s.cookiesFile || "Export one in Netscape format from a browser you're signed in to, using a cookies.txt extension.";
|
||||
$("#cookiesFilePath").title = s.cookiesFile || "";
|
||||
}
|
||||
|
||||
async function checkSignin() {
|
||||
const b = $("#signinCheck");
|
||||
b.classList.add("loading");
|
||||
b.disabled = true;
|
||||
signinStatus("Checking…", "");
|
||||
try {
|
||||
signinStatus(await invoke("signin_check", { browser: state.settings.cookiesBrowser, file: state.settings.cookiesFile || "" }), "ok");
|
||||
} catch (e) {
|
||||
signinStatus(errText(e), "err");
|
||||
} finally {
|
||||
b.disabled = false;
|
||||
b.classList.remove("loading");
|
||||
}
|
||||
}
|
||||
|
||||
function bindSignin() {
|
||||
$("#signinSelect")?.addEventListener("change", async (e) => {
|
||||
const v = e.target.value;
|
||||
signinStatus("");
|
||||
await patch({ cookiesBrowser: v });
|
||||
renderSignin();
|
||||
if (v === "file" && !state.settings.cookiesFile) pickCookies();
|
||||
else if (v) checkSignin();
|
||||
});
|
||||
$("#signinCheck")?.addEventListener("click", checkSignin);
|
||||
$("#cookiesFilePick")?.addEventListener("click", pickCookies);
|
||||
}
|
||||
|
||||
async function pickCookies() {
|
||||
const path = await invoke("pick_cookies_file").catch((e) => (toast(errText(e), "err"), null));
|
||||
if (!path) return;
|
||||
await patch({ cookiesFile: path });
|
||||
renderSignin();
|
||||
checkSignin();
|
||||
}
|
||||
|
||||
function renderToolSettings() {
|
||||
const t = state.tools;
|
||||
if (!t || !$("#toolYtdlp")) return;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+30
-5
@@ -97,6 +97,7 @@
|
||||
<li><span class="i" data-icon="music"></span><div><strong>A track or video</strong><span>Saved as one file, with its cover and details.</span></div></li>
|
||||
<li><span class="i" data-icon="disc"></span><div><strong>An album, EP or playlist</strong><span>Detected, numbered in order, kept in one folder.</span></div></li>
|
||||
<li><span class="i" data-icon="user-circle"></span><div><strong>A profile or channel</strong><span>Every upload, listed so you can pick.</span></div></li>
|
||||
<li><span class="i" data-icon="file-music"></span><div><strong>A direct file link</strong><span>Links ending in .mp3, .wav, .flac, .mp4 and more, checked and read for their real quality and tags.</span></div></li>
|
||||
</ul>
|
||||
<p class="hint">Tip: drag a link onto this window, or press <kbd>Ctrl V</kbd> anywhere.</p>
|
||||
</div>
|
||||
@@ -195,6 +196,7 @@
|
||||
<div class="group" id="lyricsProviders"></div>
|
||||
<div class="group gap-top">
|
||||
<div class="setting"><div><strong>Musixmatch API key</strong><span>A developer API key from developer.musixmatch.com (free tier available). Stays on this device.</span></div><input class="text" type="password" data-key="musixmatchKey" placeholder="Not set" spellcheck="false" autocomplete="off" /></div>
|
||||
<label class="setting"><div><strong>Soft focus around the current line</strong><span>Blurs synced lyrics more the further they are from what's being sung. Hover any line to read it clearly.</span></div><input type="checkbox" class="switch" id="lyricsBlurToggle" /></label>
|
||||
<label class="setting"><div><strong>Save lyrics with downloads</strong><span>Writes a synced .lrc file next to each song you download, when lyrics are found.</span></div><input type="checkbox" class="switch" data-key="lyricsOnDownload" /></label>
|
||||
</div>
|
||||
<h2 class="sub">Custom sources</h2>
|
||||
@@ -228,11 +230,27 @@
|
||||
|
||||
<h2 id="set-network">Network & sign-in</h2>
|
||||
<div class="group">
|
||||
<div class="setting">
|
||||
<div><strong>Use my browser sign-in</strong><span>Lets Atmosphere reach content your account can already see, like your own private uploads. Your sign-in stays in your browser.</span></div>
|
||||
<select data-key="cookiesBrowser">
|
||||
<option value="">Off</option><option value="chrome">Chrome</option><option value="edge">Edge</option><option value="firefox">Firefox</option><option value="brave">Brave</option><option value="opera">Opera</option><option value="vivaldi">Vivaldi</option>
|
||||
</select>
|
||||
<div class="setting signin">
|
||||
<div><strong>Use my browser sign-in</strong><span>Lets Atmosphere reach content your account can already see, like your own private uploads. Your sign-in stays on this computer.</span><p class="signin-status" id="signinStatus" role="status" hidden></p></div>
|
||||
<div class="signin-ctl">
|
||||
<select data-key="cookiesBrowser" id="signinSelect">
|
||||
<option value="">Off</option>
|
||||
<option value="firefox">Firefox</option>
|
||||
<option value="chrome">Chrome</option>
|
||||
<option value="edge">Edge</option>
|
||||
<option value="brave">Brave</option>
|
||||
<option value="opera">Opera</option>
|
||||
<option value="vivaldi">Vivaldi</option>
|
||||
<option value="chromium" data-os="linux">Chromium</option>
|
||||
<option value="safari" data-os="mac">Safari</option>
|
||||
<option value="file">A cookies.txt file</option>
|
||||
</select>
|
||||
<button class="btn" id="signinCheck" type="button"><span class="label">Check</span><span class="spin" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting" id="cookiesFileRow" hidden>
|
||||
<div><strong>Cookies file</strong><span id="cookiesFilePath">Export one in Netscape format from a browser you're signed in to, using a cookies.txt extension.</span></div>
|
||||
<button class="btn" id="cookiesFilePick" type="button">Choose file</button>
|
||||
</div>
|
||||
<div class="setting"><div><strong>Speed limit</strong><span>Blank for no limit. For example <code>2M</code> is 2 MB/s.</span></div><input class="text short" data-key="rateLimit" placeholder="No limit" spellcheck="false" /></div>
|
||||
<div class="setting"><div><strong>Proxy</strong><span>For example <code>socks5://127.0.0.1:1080</code></span></div><input class="text" data-key="proxy" placeholder="None" spellcheck="false" /></div>
|
||||
@@ -250,6 +268,10 @@
|
||||
<h2 id="set-storage">Storage</h2>
|
||||
<p class="set-note">Temporary files are removed automatically on every launch and exit. Here's everything else Atmosphere keeps.</p>
|
||||
<div class="group" id="storageList"></div>
|
||||
<div class="group">
|
||||
<div class="setting"><div><strong>Back up your data</strong><span>Settings, stats and play counts, liked songs, artist photos and download history in one .zip. Your music isn't included and is never touched.</span></div><button class="btn" id="backupBtn" type="button"><span class="label">Back up</span><span class="spin" aria-hidden="true"></span></button></div>
|
||||
<div class="setting"><div><strong>Restore from a backup</strong><span>Replaces your current settings and stats with the backup's, then restarts Atmosphere.</span></div><button class="btn" id="restoreBtn" type="button">Restore</button></div>
|
||||
</div>
|
||||
|
||||
<h2 id="set-rights">Your responsibility</h2>
|
||||
<div class="group">
|
||||
@@ -284,6 +306,7 @@
|
||||
<button class="icon-btn" id="fxBtn" aria-label="Sound and effects" aria-pressed="false" aria-expanded="false" title="Sound, presets, pitch and tempo"><span class="i" data-icon="adjustments-horizontal"></span></button>
|
||||
<button class="icon-btn" id="lyricsBtn" aria-label="Lyrics" aria-pressed="false" title="Lyrics (L)"><span class="i" data-icon="microphone"></span></button>
|
||||
<button class="icon-btn" id="queueBtn" aria-label="Queue" aria-pressed="false" title="Queue (Q)"><span class="i" data-icon="list"></span></button>
|
||||
<button class="icon-btn" id="miniBtn" aria-label="Mini player" title="Mini player (P)"><span class="i" data-icon="picture-in-picture"></span></button>
|
||||
<button class="icon-btn" id="tvBtn" aria-label="TV mode" title="TV mode (F)"><span class="i" data-icon="device-tv"></span></button>
|
||||
<button class="icon-btn" id="muteBtn" aria-label="Mute"></button>
|
||||
<input type="range" id="volume" class="range vol" min="0" max="100" value="85" aria-label="Volume" />
|
||||
@@ -294,6 +317,7 @@
|
||||
<aside class="drawer-panel" id="queuePanel" aria-label="Queue" hidden></aside>
|
||||
<div class="fx" id="fxPanel" role="dialog" aria-label="Sound and effects" hidden></div>
|
||||
<div class="tv" id="tv" hidden></div>
|
||||
<div class="mini" id="mini" hidden></div>
|
||||
|
||||
<div class="save-menu" id="saveMenu" role="dialog" aria-label="Save as" hidden></div>
|
||||
<div class="menu" id="typeMenu" role="menu" hidden></div>
|
||||
@@ -334,5 +358,6 @@
|
||||
<script src="nowplaying.js"></script>
|
||||
<script src="lyrics.js"></script>
|
||||
<script src="stats.js"></script>
|
||||
<script src="miniplayer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -696,6 +696,41 @@ function renderLibrarySettings() {
|
||||
h("button", { class: "btn", disabled: !hidden, onclick: async () => { const n = await invoke("tracks_unhide_all"); toast(`Restoring ${songs(n)}…`, "ok"); } }, "Restore all"));
|
||||
}
|
||||
|
||||
async function backupNow() {
|
||||
const b = $("#backupBtn");
|
||||
const d = new Date();
|
||||
const name = `Atmosphere backup ${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}.zip`;
|
||||
b.classList.add("loading");
|
||||
b.disabled = true;
|
||||
try {
|
||||
const r = await invoke("backup_save", { name });
|
||||
if (r) toast(`Backed up ${r[1]} items to ${r[0].split(/[\\/]/).pop()}`, "ok");
|
||||
} catch (e) {
|
||||
toast(errText(e), "err");
|
||||
} finally {
|
||||
b.disabled = false;
|
||||
b.classList.remove("loading");
|
||||
}
|
||||
}
|
||||
|
||||
async function restoreNow() {
|
||||
const path = await invoke("backup_pick").catch(() => null);
|
||||
if (!path) return;
|
||||
const body = h("p", {}, "Your current settings, stats, liked songs and artist photos will be replaced by the ones in ", h("strong", {}, path.split(/[\\/]/).pop()), ". Your music files stay as they are. Atmosphere restarts afterwards.");
|
||||
const ok = await modal("Restore this backup?", body, [{ label: "Cancel", value: false }, { label: "Restore and restart", value: true, primary: true }]);
|
||||
if (!ok) return;
|
||||
try {
|
||||
await invoke("backup_restore", { path });
|
||||
} catch (e) {
|
||||
toast(errText(e), "err");
|
||||
}
|
||||
}
|
||||
|
||||
function bindBackup() {
|
||||
$("#backupBtn")?.addEventListener("click", backupNow);
|
||||
$("#restoreBtn")?.addEventListener("click", restoreNow);
|
||||
}
|
||||
|
||||
async function renderStorage() {
|
||||
const box = $("#storageList");
|
||||
if (!box) return;
|
||||
|
||||
+28
-1
@@ -43,13 +43,26 @@ async function loadLyrics(refresh = false) {
|
||||
}
|
||||
}
|
||||
|
||||
const blurOn = () => {
|
||||
try {
|
||||
return localStorage.getItem("atmo.lyricsBlur") !== "off";
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
function setDepth(box, idx) {
|
||||
$$(".lyr-line", box).forEach((el, i) => el.style.setProperty("--dist", String(Math.min(Math.abs(i - Math.max(idx, -1)) || 0, 4))));
|
||||
}
|
||||
|
||||
function lyricLines(l, big) {
|
||||
const box = h("div", { class: `lyr ${big ? "big" : ""} ${l.synced ? "synced" : "plain"}` });
|
||||
const box = h("div", { class: `lyr ${big ? "big" : ""} ${l.synced ? "synced" : "plain"} ${l.synced && blurOn() ? "depth" : ""}` });
|
||||
l.lines.forEach((line, i) => {
|
||||
const el = h("div", { class: "lyr-line", "data-i": i, role: l.synced ? "button" : null, tabindex: l.synced ? "0" : null, onclick: () => line.t != null && Player.seek((line.t - Lyr.offset) / 1000) });
|
||||
if (line.words?.length > 1) line.words.forEach((w, j) => el.append(h("span", { class: "w", "data-j": j }, w.text)));
|
||||
else el.append(line.text || "· · ·");
|
||||
if (line.translation) el.append(h("span", { class: "lyr-tr" }, line.translation));
|
||||
if (l.synced) el.style.setProperty("--dist", String(Math.min(i + 1, 4)));
|
||||
box.append(el);
|
||||
});
|
||||
return box;
|
||||
@@ -161,6 +174,7 @@ function tick() {
|
||||
el.classList.toggle("on", i === idx);
|
||||
el.classList.toggle("past", i < idx);
|
||||
});
|
||||
if (box.classList.contains("depth")) setDepth(box, idx);
|
||||
const cur = box.querySelector(".lyr-line.on");
|
||||
if (cur) cur.scrollIntoView({ block: "center", behavior: reduced.matches ? "auto" : "smooth" });
|
||||
}
|
||||
@@ -367,7 +381,20 @@ function renderLyricsSettings() {
|
||||
);
|
||||
}
|
||||
|
||||
function renderBlurSetting() {
|
||||
const sw = $("#lyricsBlurToggle");
|
||||
if (!sw) return;
|
||||
sw.checked = blurOn();
|
||||
}
|
||||
|
||||
function bindLyrics() {
|
||||
$("#lyricsBlurToggle")?.addEventListener("change", (e) => {
|
||||
try {
|
||||
localStorage.setItem("atmo.lyricsBlur", e.target.checked ? "on" : "off");
|
||||
} catch {}
|
||||
$$(".lyr.synced").forEach((b) => b.classList.toggle("depth", e.target.checked));
|
||||
});
|
||||
renderBlurSetting();
|
||||
window.addEventListener("player", (e) => {
|
||||
if (e.detail.type === "track") {
|
||||
Lyr.offset = 0;
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
// atmosphere · miniplayer.js · Compact always-on-top player with optional cover, blurred backdrop and an editable queue
|
||||
const Mini = {
|
||||
on: false,
|
||||
restore: null,
|
||||
prefs: { cover: true, blur: true, queue: false, pin: true },
|
||||
dragFrom: null,
|
||||
};
|
||||
|
||||
const MINI_W = 340;
|
||||
const MINI_BASE = 168;
|
||||
const MINI_COVER = 300;
|
||||
const MINI_QUEUE = 232;
|
||||
|
||||
function miniLoad() {
|
||||
try {
|
||||
Object.assign(Mini.prefs, JSON.parse(localStorage.getItem("atmo.mini") || "{}"));
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function miniSave() {
|
||||
try {
|
||||
localStorage.setItem("atmo.mini", JSON.stringify(Mini.prefs));
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const miniWin = () => window.__TAURI__?.window?.getCurrentWindow?.();
|
||||
|
||||
function miniHeight() {
|
||||
return MINI_BASE + (Mini.prefs.cover ? MINI_COVER : 0) + (Mini.prefs.queue ? MINI_QUEUE : 0);
|
||||
}
|
||||
|
||||
async function miniResize() {
|
||||
const win = miniWin();
|
||||
const dpi = window.__TAURI__?.dpi;
|
||||
if (!win || !dpi) return;
|
||||
const min = MINI_BASE + (Mini.prefs.queue ? 120 : 0);
|
||||
await win.setMinSize(new dpi.LogicalSize(300, min)).catch(() => {});
|
||||
await win.setSize(new dpi.LogicalSize(MINI_W, miniHeight())).catch(() => {});
|
||||
}
|
||||
|
||||
async function openMini() {
|
||||
if (Mini.on) return;
|
||||
if (typeof closeTv === "function" && Lyr?.tv) await closeTv();
|
||||
closeDrawers();
|
||||
closeFx();
|
||||
Mini.on = true;
|
||||
document.body.classList.add("mini-mode");
|
||||
$("#mini").hidden = false;
|
||||
$("#mini").classList.toggle("mac", isMac);
|
||||
const win = miniWin();
|
||||
if (win) {
|
||||
Mini.restore = { pos: await win.outerPosition().catch(() => null), size: await win.outerSize().catch(() => null), max: await win.isMaximized().catch(() => false) };
|
||||
if (Mini.restore.max) await win.unmaximize().catch(() => {});
|
||||
await miniResize();
|
||||
await win.setAlwaysOnTop(!!Mini.prefs.pin).catch(() => {});
|
||||
}
|
||||
renderMini();
|
||||
}
|
||||
|
||||
async function closeMini() {
|
||||
if (!Mini.on) return;
|
||||
Mini.on = false;
|
||||
document.body.classList.remove("mini-mode");
|
||||
$("#mini").hidden = true;
|
||||
const win = miniWin();
|
||||
const dpi = window.__TAURI__?.dpi;
|
||||
const r = Mini.restore;
|
||||
Mini.restore = null;
|
||||
if (!win || !dpi) return;
|
||||
await win.setAlwaysOnTop(false).catch(() => {});
|
||||
await win.setMinSize(new dpi.LogicalSize(900, 620)).catch(() => {});
|
||||
if (r?.size) await win.setSize(new dpi.PhysicalSize(r.size.width, r.size.height)).catch(() => {});
|
||||
if (r?.pos) await win.setPosition(new dpi.PhysicalPosition(r.pos.x, r.pos.y)).catch(() => {});
|
||||
if (r?.max) await win.maximize().catch(() => {});
|
||||
}
|
||||
|
||||
async function miniToggle(key) {
|
||||
Mini.prefs[key] = !Mini.prefs[key];
|
||||
miniSave();
|
||||
if (key === "pin") await miniWin()?.setAlwaysOnTop(Mini.prefs.pin).catch(() => {});
|
||||
if (key === "cover" || key === "queue") await miniResize();
|
||||
renderMini();
|
||||
}
|
||||
|
||||
function miniButton(key, iconName, label) {
|
||||
const on = !!Mini.prefs[key];
|
||||
return h("button", { class: "icon-btn mini-opt", "aria-pressed": String(on), "aria-label": label, title: label, onclick: () => miniToggle(key) }, icon(iconName));
|
||||
}
|
||||
|
||||
function miniQueueRow(t, i) {
|
||||
const row = h("div", { class: "mq-row", draggable: "true", "data-qi": i, ondblclick: () => Player.load(i) },
|
||||
h("span", { class: "mq-grip", "aria-hidden": "true" }, icon("grip-vertical")),
|
||||
h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, t.title), h("span", { class: "lt-sub" }, t.artist)),
|
||||
h("button", { class: "icon-btn", "aria-label": `Remove ${t.title}`, title: "Remove", onclick: (e) => { e.stopPropagation(); Player.removeAt(i); } }, icon("x")));
|
||||
row.addEventListener("dragstart", (e) => {
|
||||
Mini.dragFrom = i;
|
||||
e.dataTransfer.effectAllowed = "move";
|
||||
e.dataTransfer.setData("text/plain", "");
|
||||
row.classList.add("dragging");
|
||||
});
|
||||
row.addEventListener("dragend", () => row.classList.remove("dragging"));
|
||||
row.addEventListener("dragover", (e) => {
|
||||
if (Mini.dragFrom == null) return;
|
||||
e.preventDefault();
|
||||
const r = row.getBoundingClientRect();
|
||||
row.classList.toggle("drop-above", e.clientY < r.top + r.height / 2);
|
||||
row.classList.toggle("drop-below", e.clientY >= r.top + r.height / 2);
|
||||
});
|
||||
row.addEventListener("dragleave", () => row.classList.remove("drop-above", "drop-below"));
|
||||
row.addEventListener("drop", (e) => {
|
||||
e.preventDefault();
|
||||
const below = row.classList.contains("drop-below");
|
||||
row.classList.remove("drop-above", "drop-below");
|
||||
const from = Mini.dragFrom;
|
||||
Mini.dragFrom = null;
|
||||
if (from == null) return;
|
||||
moveInQueue(from, below ? i + 1 : i);
|
||||
});
|
||||
return row;
|
||||
}
|
||||
|
||||
function moveInQueue(from, to) {
|
||||
const q = Player.queue;
|
||||
if (from <= Player.index || from >= q.length) return;
|
||||
const [t] = q.splice(from, 1);
|
||||
const dest = Math.max(Player.index + 1, Math.min(q.length, to > from ? to - 1 : to));
|
||||
q.splice(dest, 0, t);
|
||||
Player.emit("queue");
|
||||
Player.persist();
|
||||
}
|
||||
|
||||
function renderMini() {
|
||||
const box = $("#mini");
|
||||
if (!box || !Mini.on) return;
|
||||
const t = Player.current;
|
||||
const art = t?.art ? artUrl(t.art) : null;
|
||||
box.classList.toggle("with-cover", !!Mini.prefs.cover);
|
||||
box.classList.toggle("with-blur", !!Mini.prefs.blur && !!art);
|
||||
box.classList.toggle("with-queue", !!Mini.prefs.queue);
|
||||
box.style.setProperty("--mini-art", art ? `url("${art}")` : "none");
|
||||
const playing = !Player.audio.paused;
|
||||
const next = Player.queue.slice(Player.index + 1);
|
||||
const parts = [
|
||||
h("div", { class: "mini-bg", "aria-hidden": "true" }),
|
||||
h("div", { class: "mini-top", "data-tauri-drag-region": "" },
|
||||
h("span", { class: "mini-brand", "data-tauri-drag-region": "" }, "Atmosphere"),
|
||||
h("div", { class: "mini-opts" },
|
||||
miniButton("cover", "photo", Mini.prefs.cover ? "Hide cover art" : "Show cover art"),
|
||||
miniButton("blur", "droplet", Mini.prefs.blur ? "Turn off blurred backdrop" : "Blurred cover backdrop"),
|
||||
miniButton("queue", "list", Mini.prefs.queue ? "Hide queue" : "Show queue"),
|
||||
miniButton("pin", Mini.prefs.pin ? "pinned" : "pin", Mini.prefs.pin ? "Always on top: on" : "Always on top: off"),
|
||||
h("button", { class: "icon-btn", "aria-label": "Back to full window", title: "Back to full window (P)", onclick: closeMini }, icon("arrows-maximize")))),
|
||||
Mini.prefs.cover ? h("div", { class: "mini-art", "data-tauri-drag-region": "" }, art ? h("img", { src: art, alt: "", draggable: "false", "data-tauri-drag-region": "" }) : h("div", { class: "mini-art-empty" }, icon("music"))) : null,
|
||||
h("div", { class: "mini-meta" },
|
||||
h("span", { class: "mini-title", title: t?.title || "" }, t?.title || "Nothing playing"),
|
||||
h("span", { class: "mini-artist" }, t?.artist || "Pick something from your library")),
|
||||
h("div", { class: "mini-seek" },
|
||||
h("span", { class: "mini-t", id: "miniCur" }, "0:00"),
|
||||
h("input", { type: "range", class: "range", id: "miniSeek", min: "0", max: "1000", value: "0", "aria-label": "Seek" }),
|
||||
h("span", { class: "mini-t", id: "miniDur" }, "0:00")),
|
||||
h("div", { class: "mini-ctl" },
|
||||
h("button", { class: "icon-btn", "aria-label": "Previous", onclick: () => Player.prev() }, icon("player-skip-back-filled")),
|
||||
h("button", { class: "mini-play", "aria-label": playing ? "Pause" : "Play", onclick: () => Player.toggle() }, icon(playing ? "player-pause-filled" : "player-play-filled")),
|
||||
h("button", { class: "icon-btn", "aria-label": "Next", onclick: () => Player.next() }, icon("player-skip-forward-filled"))),
|
||||
Mini.prefs.queue
|
||||
? h("div", { class: "mini-queue" },
|
||||
h("div", { class: "mq-head" }, h("span", {}, next.length ? `Up next · ${next.length}` : "Up next"), next.length ? h("button", { class: "btn small ghost", onclick: () => Player.clearUpNext() }, "Clear") : null),
|
||||
next.length ? h("div", { class: "mq-list" }, ...next.slice(0, 200).map((q, k) => miniQueueRow(q, Player.index + 1 + k))) : h("p", { class: "mq-empty" }, "Nothing queued. Add songs from your library."))
|
||||
: null,
|
||||
];
|
||||
box.replaceChildren(...parts.filter(Boolean));
|
||||
const seek = $("#miniSeek");
|
||||
seek.addEventListener("input", () => {
|
||||
rangeFill(seek);
|
||||
const d = Player.audio.duration;
|
||||
if (isFinite(d)) $("#miniCur").textContent = fmtDur((seek.value / 1000) * d * 1000);
|
||||
});
|
||||
seek.addEventListener("change", () => Player.seek((seek.value / 1000) * Player.audio.duration));
|
||||
miniTime();
|
||||
}
|
||||
|
||||
function miniTime() {
|
||||
if (!Mini.on) return;
|
||||
const seek = $("#miniSeek");
|
||||
if (!seek || document.activeElement === seek) return;
|
||||
const a = Player.audio;
|
||||
const d = isFinite(a.duration) ? a.duration : 0;
|
||||
seek.value = d ? String(Math.round((a.currentTime / d) * 1000)) : "0";
|
||||
rangeFill(seek);
|
||||
$("#miniCur").textContent = fmtDur(a.currentTime * 1000);
|
||||
$("#miniDur").textContent = d ? fmtDur(d * 1000) : "0:00";
|
||||
}
|
||||
|
||||
function bindMini() {
|
||||
miniLoad();
|
||||
$("#miniBtn")?.addEventListener("click", () => (Mini.on ? closeMini() : openMini()));
|
||||
window.addEventListener("player", (e) => {
|
||||
if (!Mini.on) return;
|
||||
const type = e.detail.type;
|
||||
if (type === "time") return miniTime();
|
||||
if (type === "volume" || type === "fx") return;
|
||||
renderMini();
|
||||
});
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.target.closest("input, textarea, select, [contenteditable]") || e.altKey || e.ctrlKey || e.metaKey) return;
|
||||
if (e.key.toLowerCase() === "p") {
|
||||
e.preventDefault();
|
||||
Mini.on ? closeMini() : openMini();
|
||||
} else if (e.key === "Escape" && Mini.on) closeMini();
|
||||
});
|
||||
}
|
||||
@@ -315,6 +315,7 @@ function bindPlayer() {
|
||||
if (e.target.closest("input, textarea, select, [contenteditable]") || e.altKey) return;
|
||||
const mod = e.ctrlKey || e.metaKey;
|
||||
const k = e.key;
|
||||
if (document.body.classList.contains("mini-mode") && /^[lqf]$/i.test(k)) return;
|
||||
if (k === " " && !mod) { e.preventDefault(); Player.toggle(); }
|
||||
else if (k === "ArrowRight" && mod) { e.preventDefault(); Player.next(); }
|
||||
else if (k === "ArrowLeft" && mod) { e.preventDefault(); Player.prev(); }
|
||||
|
||||
@@ -882,3 +882,70 @@ input[type="checkbox"].box:checked::after { content: ""; width: 8px; height: 4px
|
||||
.share-side h3 { font-size: 12px; color: var(--text-2); margin-top: var(--s2); }
|
||||
.share-side .row { margin-top: var(--s3); flex-wrap: wrap; }
|
||||
@media (max-width: 1100px) { .stat-cards { grid-template-columns: 1fr 1fr; } .stat-split { grid-template-columns: 1fr; } .share { grid-template-columns: 1fr; } }
|
||||
|
||||
/* lyric depth of field */
|
||||
.lyr.depth .lyr-line { filter: blur(calc(var(--dist, 2) * 0.7px)); transition: color 180ms var(--ease), opacity 180ms var(--ease), filter 320ms var(--ease); }
|
||||
.lyr.depth .lyr-line.on { filter: none; }
|
||||
.lyr.depth .lyr-line:hover, .lyr.depth .lyr-line:focus-visible { filter: none; opacity: 0.95; transition-duration: 120ms; }
|
||||
.lyr.big.depth .lyr-line { filter: blur(calc(var(--dist, 2) * 1.4px)); }
|
||||
.lyr.big.depth .lyr-line.on, .lyr.big.depth .lyr-line:hover, .lyr.big.depth .lyr-line:focus-visible { filter: none; }
|
||||
@media (prefers-reduced-motion: reduce) { .lyr.depth .lyr-line { transition: none !important; } }
|
||||
|
||||
/* nothing visual drags out of the app */
|
||||
img, svg, canvas, picture, a { -webkit-user-drag: none; user-drag: none; }
|
||||
img { user-select: none; }
|
||||
[draggable="true"] { -webkit-user-drag: element; }
|
||||
|
||||
/* browser sign-in */
|
||||
.signin-ctl { display: flex; gap: var(--s2); align-items: center; flex-shrink: 0; }
|
||||
.signin-status { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--text-2); max-width: 60ch; }
|
||||
.signin-status[data-kind="ok"] { color: var(--ok); }
|
||||
.signin-status[data-kind="err"] { color: var(--err); }
|
||||
#cookiesFilePath { overflow-wrap: anywhere; }
|
||||
|
||||
/* mini player */
|
||||
body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { display: none !important; }
|
||||
.mini { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--text); overflow: hidden; }
|
||||
.mini[hidden] { display: none; }
|
||||
.mini-bg { position: absolute; inset: -60px; background: var(--mini-art) center / cover no-repeat; filter: blur(46px) saturate(1.35) brightness(0.5); opacity: 0; transition: opacity 320ms var(--ease); pointer-events: none; z-index: 0; }
|
||||
.mini.with-blur .mini-bg { opacity: 1; }
|
||||
.mini > :not(.mini-bg) { position: relative; z-index: 1; }
|
||||
.mini.with-blur { color: #f4f5f8; --text-2: rgba(244, 245, 248, 0.74); --text-3: rgba(244, 245, 248, 0.52); --hover: rgba(255, 255, 255, 0.09); --hairline: rgba(255, 255, 255, 0.1); }
|
||||
.mini-top { flex: none; display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 6px 0 14px; }
|
||||
.mini-brand { font-size: 11px; font-weight: 650; letter-spacing: 0.04em; text-transform: lowercase; color: var(--text-3); }
|
||||
.mini-opts { display: flex; gap: 2px; }
|
||||
.mini-opt[aria-pressed="true"] { color: var(--accent); }
|
||||
.mini.with-blur .mini-opt[aria-pressed="true"] { color: #fff; background: rgba(255, 255, 255, 0.12); }
|
||||
.mini-art { flex: none; display: grid; place-items: center; padding: 2px 20px 14px; }
|
||||
.mini-art img, .mini-art-empty { width: 100%; max-width: 268px; aspect-ratio: 1; border-radius: 12px; object-fit: cover; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.6); }
|
||||
.mini-art-empty { display: grid; place-items: center; background: var(--surface); color: var(--text-3); }
|
||||
.mini-art-empty .i svg { width: 48px; height: 48px; }
|
||||
.mini-meta { flex: none; display: grid; gap: 2px; padding: 0 20px; text-align: center; min-width: 0; }
|
||||
.mini-title { font: 650 15px/1.3 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.mini-artist { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.mini-seek { flex: none; display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 8px; align-items: center; padding: 10px 14px 0; }
|
||||
.mini-t { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; text-align: center; }
|
||||
.mini-ctl { flex: none; display: flex; justify-content: center; align-items: center; gap: 22px; padding: 6px 0 12px; }
|
||||
.mini-ctl .icon-btn { width: 36px; height: 36px; color: var(--text-2); }
|
||||
.mini-ctl .icon-btn:hover { color: var(--text); }
|
||||
.mini-play { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); transition: transform 120ms var(--ease); }
|
||||
.mini.with-blur .mini-play { background: #fff; color: #111318; }
|
||||
.mini-play:hover { transform: scale(1.05); }
|
||||
.mini-play:active { transform: scale(0.96); }
|
||||
.mini-play .i svg { width: 20px; height: 20px; }
|
||||
.mini-queue { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--hairline); }
|
||||
.mq-head { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 4px 16px; font-size: 12px; font-weight: 600; color: var(--text-2); min-height: 34px; }
|
||||
.mq-list { flex: 1; overflow-y: auto; padding: 0 6px 8px; }
|
||||
.mq-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) 28px; gap: 6px; align-items: center; padding: 4px 4px 4px 4px; border-radius: 8px; cursor: grab; }
|
||||
.mq-row:hover { background: var(--hover); }
|
||||
.mq-row .icon-btn { opacity: 0; }
|
||||
.mq-row:hover .icon-btn, .mq-row:focus-within .icon-btn { opacity: 1; }
|
||||
.mq-grip { color: var(--text-3); display: grid; place-items: center; }
|
||||
.mq-grip .i svg { width: 14px; height: 14px; }
|
||||
.mq-row.dragging { opacity: 0.4; }
|
||||
.mq-row.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
|
||||
.mq-row.drop-below { box-shadow: inset 0 -2px 0 var(--accent); }
|
||||
.mq-empty { margin: 0; padding: 6px 16px 12px; color: var(--text-3); font-size: 12.5px; }
|
||||
@media (prefers-reduced-motion: reduce) { .mini-bg, .mini-play { transition: none; } }
|
||||
.mini.mac .mini-top { padding-left: 78px; }
|
||||
.mini.mac .mini-brand { display: none; }
|
||||
|
||||
Reference in New Issue
Block a user