Initial commit

This commit is contained in:
mxdyeah committed 2026-07-08 01:15:18 +08:00
commit acadc92e68
780 files changed
+468285

No files matched your search

+216
View File
@@ -0,0 +1,216 @@
<script setup>
import { ref, computed, onMounted, onUnmounted } from "vue";
const props = defineProps({
modelValue: [String, Number],
options: {
type: Array,
required: true,
// Each option: { label: string, value: any }
},
label: String,
id: String, // This ID will be placed on a hidden input/select for legacy JS compatibility
placeholder: String,
class: String,
dropdownClass: String,
});
const emit = defineEmits(["update:modelValue", "change"]);
const isOpen = ref(false);
const container = ref(null);
const triggerRef = ref(null);
const dropdownRef = ref(null);
const dropdownStyle = ref({ top: "0px", left: "0px", width: "auto" });
const updateDropdownPosition = () => {
if (triggerRef.value) {
const rect = triggerRef.value.getBoundingClientRect();
const scrollY = window.scrollY || window.pageYOffset;
const scrollX = window.scrollX || window.pageXOffset;
dropdownStyle.value = {
top: `${rect.bottom + scrollY + 6}px`,
left: `${rect.left + scrollX}px`,
minWidth: `${rect.width}px`,
};
}
};
const handleScroll = (event) => {
if (!isOpen.value) return;
// If the scroll target is the dropdown itself or inside it, do nothing
if (
dropdownRef.value &&
(dropdownRef.value === event.target ||
dropdownRef.value.contains(event.target))
) {
return;
}
// Otherwise close the dropdown on external scroll to prevent misplacement
isOpen.value = false;
};
const toggleDropdown = () => {
isOpen.value = !isOpen.value;
if (isOpen.value) {
updateDropdownPosition();
}
};
const selectOption = (option) => {
emit("update:modelValue", option.value);
emit("change", option.value);
isOpen.value = false;
// For legacy JS interop: trigger event on hidden element if ID is provided
if (props.id) {
const hiddenEl = document.getElementById(props.id);
if (hiddenEl) {
hiddenEl.value = option.value;
hiddenEl.dispatchEvent(new Event("change", { bubbles: true }));
}
}
};
const handleClickOutside = (event) => {
if (container.value && !container.value.contains(event.target)) {
isOpen.value = false;
}
};
onMounted(() => {
document.addEventListener("click", handleClickOutside);
window.addEventListener("scroll", handleScroll, true);
window.addEventListener("resize", () => {
if (isOpen.value) isOpen.value = false;
});
});
onUnmounted(() => {
document.removeEventListener("click", handleClickOutside);
window.removeEventListener("scroll", handleScroll, true);
window.removeEventListener("resize", () => {
if (isOpen.value) isOpen.value = false;
});
});
const selectedLabel = computed(() => {
const option = props.options.find((opt) => opt.value == props.modelValue);
return option ? option.label : props.placeholder || "";
});
</script>
<template>
<div class="relative inline-block" :class="props.class" ref="container">
<!-- Hidden element for legacy JS interop -->
<select v-if="id" :id="id" class="hidden" :value="modelValue">
<option v-for="opt in options" :key="opt.value" :value="opt.value">
{{ opt.label }}
</option>
</select>
<div ref="triggerRef" class="h-full">
<slot name="trigger" :toggle="toggleDropdown" :isOpen="isOpen">
<button
type="button"
@click="toggleDropdown"
class="flex items-center gap-1.5 px-3 h-10 rounded-lg border border-border bg-surface text-text text-sm font-semibold transition-all hover:border-border-strong hover:bg-surface-hover hover:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 group whitespace-nowrap"
>
<span class="truncate">{{ selectedLabel }}</span>
<svg
class="w-3.5 h-3.5 text-text-soft transition-transform duration-200"
:class="{ 'rotate-180': isOpen }"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 9 6 6 6-6" />
</svg>
</button>
</slot>
</div>
<Teleport to="body">
<transition
enter-active-class="transition duration-240 ease-[cubic-bezier(0.23,1,0.32,1)]"
enter-from-class="transform scale-[0.96] opacity-0 -translate-y-1"
enter-to-class="transform scale-100 opacity-100 translate-y-0"
leave-active-class="transition duration-150 ease-[cubic-bezier(0.4,0,1,1)]"
leave-from-class="transform scale-100 opacity-100 translate-y-0"
leave-to-class="transform scale-[0.96] opacity-0 -translate-y-1"
>
<div
v-if="isOpen"
ref="dropdownRef"
class="absolute rounded-xl border border-border/60 bg-surface/85 backdrop-blur-md shadow-[0_20px_50px_rgba(0,0,0,0.3),0_0_1px_rgba(255,255,255,0.1)] py-2 z-[9999] overflow-y-auto max-h-[400px] custom-scrollbar will-change-[transform,opacity]"
:style="dropdownStyle"
:class="dropdownClass"
>
<div
v-if="label"
class="px-3 py-1.5 text-[0.62rem] font-bold text-text-muted uppercase tracking-[0.15em] border-b border-border/40 mb-1"
>
{{ label }}
</div>
<button
v-for="option in options"
:key="option.value"
@click="selectOption(option)"
class="w-full flex items-center justify-between px-4 py-2 text-sm transition-colors hover:bg-accent/10 text-left group"
:class="
modelValue == option.value
? 'text-accent font-semibold bg-accent/5'
: 'text-text-soft hover:text-text'
"
>
<span>{{ option.label }}</span>
<svg
v-if="modelValue == option.value"
class="w-4 h-4 text-accent"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="3"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M5 13l4 4L19 7"
/>
</svg>
</button>
</div>
</transition>
</Teleport>
</div>
</template>
<style scoped>
.custom-scrollbar::-webkit-scrollbar {
width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background: var(--scrollbar-thumb);
border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background: var(--accent);
}
/* Firefox */
.custom-scrollbar {
scrollbar-width: thin;
scrollbar-color: var(--scrollbar-thumb) transparent;
}
</style>
+928
View File
@@ -0,0 +1,928 @@
<script setup>
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
import { ChannelScopesWebGLRenderer, showWebGLErrorBanner } from "../utils/webgl-visualizer";
const channels = ref([]);
const canvasRefs = ref([]);
const containerRef = ref(null);
const totalCanvasRef = ref(null);
// 示波器可见性设置
const showTotal = ref(true);
const showChannels = ref(true);
const isPlaying = ref(false);
const getInitialPlayingState = () => {
if (typeof window !== "undefined" && window.__playerUiState) {
return !!window.__playerUiState.isPlaying;
}
return false;
};
let lastTickTime = 0;
let lastDomUpdateTime = 0;
function readScopeSettings() {
try {
const s = JSON.parse(localStorage.getItem("player_settings") || "{}");
showTotal.value = s.setTotalScope !== false;
showChannels.value = s.setChannelScope !== false;
} catch {}
}
const handleScopeSettings = (e) => {
if (!e || !e.detail) return;
if ("showTotal" in e.detail) showTotal.value = !!e.detail.showTotal;
if ("showChannels" in e.detail) showChannels.value = !!e.detail.showChannels;
};
// 两者都关闭时隐藏整个容器
const showContainer = computed(() => showTotal.value || showChannels.value);
// 通道网格列数:自动计算最优列数,使每行尽可能填满、行间均衡
// ≤24 通道最多 8 列(12→6×2,16→8×2);>24 通道允许收窄至 12 列(48→12×4)
const gridColumns = computed(() => {
const count = channels.value.length;
if (count === 0) return 1;
if (count <= 4) return count;
// 24 通道及以下保持宽松(最多 8 列),超过 24 允许收窄(最多 12 列)
const maxCols = count <= 24 ? 8 : 12;
let best = 4;
let bestScore = Infinity;
for (let cols = maxCols; cols >= 4; cols--) {
const rows = Math.ceil(count / cols);
const lastRowFill = count % cols;
const waste = lastRowFill === 0 ? 0 : cols - lastRowFill;
const score = waste * waste + rows * 4;
if (score < bestScore) {
bestScore = score;
best = cols;
}
}
return best;
});
let rafHandle = null;
let analyserSlots = [];
let canvasCtxs = [];
let canvasSizes = [];
let peakHistory = [];
let waveformSamples = []; // per-channel: Float32Array[COLS] of raw sample values
let cachedGradients = [];
let resizeObserver = null;
let themeColors = null;
let themeReadAt = 0;
let mqlReducedMotion = null;
let prefersReducedMotion = false;
// Total (sum) waveform state
let totalCtx = null;
let totalSize = null;
let totalSamples = null; // Float32Array[COLS] summed waveform
let totalGradient = null;
let totalPeak = 0;
const WAVEFORM_SAMPLES = 512; // matches C-side WAVEFORM_SAMPLES
const COLS = 512; // one texel per waveform sample for full fidelity
let lastFrame = 0;
// ── WebGL state ──────────────────────────────────────────────────────────────
const webglCanvasRef = ref(null);
let webglRenderer = null;
let webglFailed = false;
// Cached Rects for WebGL viewport/scissor to avoid Layout Thrashing (getBoundingClientRect)
let cachedGlRect = null;
let cachedTotalRect = null;
const cachedChannelRects = [];
let needUpdateRects = true;
function updateRectsCache() {
if (!webglRenderer) return;
const glCanvas = webglRenderer.canvas;
if (!glCanvas) return;
cachedGlRect = glCanvas.getBoundingClientRect();
if (totalCanvasRef.value) {
cachedTotalRect = totalCanvasRef.value.getBoundingClientRect();
} else {
cachedTotalRect = null;
}
cachedChannelRects.length = analyserSlots.length;
for (let i = 0; i < analyserSlots.length; i++) {
const placeholder = canvasRefs.value[i];
if (placeholder) {
cachedChannelRects[i] = placeholder.getBoundingClientRect();
} else {
cachedChannelRects[i] = null;
}
}
needUpdateRects = false;
}
function tryInitWebGL() {
if (webglFailed || webglRenderer) return;
const canvas = webglCanvasRef.value;
if (!canvas) return;
try {
webglRenderer = ChannelScopesWebGLRenderer.create(canvas, COLS);
} catch (e) {
console.error("[webgl-vis] ChannelScopes WebGL init failed, falling back to 2D canvas. Error:", e);
showWebGLErrorBanner("多通道示波器 WebGL 初始化错误 (ChannelScopes Init)", e);
webglFailed = true;
webglRenderer = null;
}
}
function destroyWebGL() {
if (webglRenderer) {
try { webglRenderer.destroy(); } catch {}
webglRenderer = null;
}
}
// ─────────────────────────────────────────────────────────────────────────────
const setCanvasRef = (el, idx) => {
if (el) {
canvasRefs.value[idx] = el;
// Only get 2D context if WebGL is not available
if (webglFailed) {
canvasCtxs[idx] = el.getContext("2d", { alpha: true, desynchronized: true });
}
}
};
const setTotalCanvasRef = (el) => {
totalCanvasRef.value = el;
if (el) {
// Only get 2D context if WebGL is not available
if (webglFailed) {
totalCtx = el.getContext("2d", { alpha: true, desynchronized: true });
}
} else {
totalCtx = null;
totalSize = null;
totalGradient = null;
}
};
function readAnalysers() {
const list = (typeof window !== "undefined" && window.__channelAnalysers) || [];
analyserSlots = list.filter((slot) => slot && slot.analyser);
for (const slot of analyserSlots) {
// Keep analyser in case other components use it, but we don't need FFT size
slot.analyser.smoothingTimeConstant = 0.25;
}
const n = analyserSlots.length;
canvasRefs.value.length = n;
canvasCtxs.length = n;
canvasSizes.length = n;
cachedGradients.length = n;
peakHistory.length = n;
waveformSamples.length = n;
channels.value = analyserSlots.map((_, i) => i);
for (let i = 0; i < n; i++) {
if (!waveformSamples[i] || waveformSamples[i].length !== COLS) {
waveformSamples[i] = new Float32Array(COLS);
}
if (peakHistory[i] == null) peakHistory[i] = 0;
}
requestAnimationFrame(resizeAllCanvases);
needUpdateRects = true;
}
function resizeAllCanvases() {
const dpr = Math.min(window.devicePixelRatio || 1, 2);
// Resize WebGL canvas
if (webglRenderer && webglCanvasRef.value) {
webglRenderer.resize(dpr);
}
// Resize 2D canvases (fallback mode only)
if (webglFailed) {
for (let i = 0; i < canvasRefs.value.length; i++) {
const canvas = canvasRefs.value[i];
if (!canvas) continue;
const rect = canvas.getBoundingClientRect();
const w = Math.max(1, Math.floor(rect.width * dpr));
const h = Math.max(1, Math.floor(rect.height * dpr));
if (canvas.width !== w) canvas.width = w;
if (canvas.height !== h) canvas.height = h;
canvasSizes[i] = { w, h, dpr };
cachedGradients[i] = null;
}
const tCanvas = totalCanvasRef.value;
if (tCanvas) {
const rect = tCanvas.getBoundingClientRect();
const w = Math.max(1, Math.floor(rect.width * dpr));
const h = Math.max(1, Math.floor(rect.height * dpr));
if (tCanvas.width !== w) tCanvas.width = w;
if (tCanvas.height !== h) tCanvas.height = h;
totalSize = { w, h, dpr };
totalGradient = null;
}
}
needUpdateRects = true;
}
function readThemeColors(force) {
const now = performance.now();
if (!force && themeColors && now - themeReadAt < 1000) return themeColors;
themeReadAt = now;
if (!containerRef.value) {
themeColors = {
stroke: "#34d399",
fillTop: "rgba(52,211,153,0.55)",
fillBottom: "rgba(52,211,153,0.05)",
idle: "rgba(148,163,184,0.18)",
grid: "rgba(255,255,255,0.05)",
label: "#94a3b8",
};
return themeColors;
}
const cs = window.getComputedStyle(containerRef.value);
const stroke = cs.getPropertyValue("--scope-waveform").trim() || "#34d399";
const accent = cs.getPropertyValue("--accent").trim() || stroke;
const muted = cs.getPropertyValue("--text-soft").trim() || "#94a3b8";
const border = cs.getPropertyValue("--border").trim() || "rgba(255,255,255,0.08)";
themeColors = {
stroke,
accent,
fillTop: hexToRgba(stroke, 0.45),
fillBottom: hexToRgba(stroke, 0.04),
idle: hexToRgba(muted, 0.15),
grid: border,
label: muted,
};
return themeColors;
}
function hexToRgba(color, alpha) {
if (!color) return `rgba(148,163,184,${alpha})`;
color = color.trim();
if (color.startsWith("rgb")) {
const inner = color.replace(/^rgba?\(|\)$/g, "");
const parts = inner.split(/[\s,/]+/).filter(Boolean).slice(0, 3);
if (parts.length === 3) return `rgba(${parts.join(",")},${alpha})`;
}
if (color.startsWith("#")) {
let h = color.slice(1);
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
if (h.length >= 6) {
const r = parseInt(h.slice(0, 2), 16);
const g = parseInt(h.slice(2, 4), 16);
const b = parseInt(h.slice(4, 6), 16);
if ([r, g, b].every((v) => Number.isFinite(v))) {
return `rgba(${r},${g},${b},${alpha})`;
}
}
}
return color;
}
// ── Raw waveform computation (replaces envelope) ───────────────────────
// Takes realWaveData (512 samples from C side), interpolates to COLS samples.
// The C side already handles trigger centering, period-adaptive view width,
// and amplitude normalization — so JS side just interpolates and renders.
function computeWaveform(waveData, samples) {
if (!waveData || waveData.length === 0) {
samples.fill(0);
return 0;
}
const dataLen = waveData.length; // 512 from C
// Compute intensity from peak
let peakAbs = 0;
for (let i = 0; i < dataLen; i++) {
const a = waveData[i] < 0 ? -waveData[i] : waveData[i];
if (a > peakAbs) peakAbs = a;
}
const intensity = Math.min(1, peakAbs / 0.85);
// Interpolate 512 → COLS samples (linear interpolation) with soft clip
for (let c = 0; c < COLS; c++) {
const srcPos = (c / (COLS - 1)) * (dataLen - 1);
const srcIdx = Math.floor(srcPos);
const frac = srcPos - srcIdx;
const v0 = waveData[srcIdx];
const v1 = srcIdx + 1 < dataLen ? waveData[srcIdx + 1] : v0;
let v = v0 + (v1 - v0) * frac;
// Hard clip to ±1.0 — essential for correct uint8 texture storage
// Values outside [-1,1] overflow the Uint8 range and wrap to opposite side
if (v > 1.0) v = 1.0;
if (v < -1.0) v = -1.0;
samples[c] = v;
}
return intensity;
}
// ── Raw waveform renderer (SidWiz-style polyline) ──────────────────────
function renderWaveform(ctx, size, samples, colors, intensity) {
const { w, h } = size;
ctx.clearRect(0, 0, w, h);
// Center axis
ctx.fillStyle = colors.grid;
ctx.fillRect(0, (h - 1) >> 1, w, 1);
const halfH = h * 0.5;
const amp = halfH - 2;
// Idle: flat center line with uniform stroke color
if (intensity < 0.02) {
ctx.strokeStyle = colors.stroke;
ctx.lineWidth = Math.max(1, size.dpr);
ctx.beginPath();
ctx.moveTo(0, halfH);
ctx.lineTo(w, halfH);
ctx.stroke();
return intensity;
}
// Draw polyline through all sample points (SidWiz style)
ctx.lineJoin = "round";
ctx.lineCap = "round";
ctx.beginPath();
const step = w / (COLS - 1);
ctx.moveTo(0, halfH - samples[0] * amp);
for (let c = 1; c < COLS; c++) {
const x = c * step;
const y = halfH - samples[c] * amp;
ctx.lineTo(x, y);
}
// Halo pass (wide, translucent)
ctx.strokeStyle = hexToRgba(colors.stroke, 0.22);
ctx.lineWidth = Math.max(2, size.dpr * 2.5);
ctx.stroke();
// Sharp core pass
ctx.strokeStyle = colors.stroke;
ctx.lineWidth = Math.max(1.0, size.dpr * 1.1);
ctx.stroke();
return intensity;
}
function drawChannel(idx, colors) {
const slot = analyserSlots[idx];
if (!slot) return 0;
// Read realWaveData directly from DummyAnalyser (512 samples from C side)
const waveData = slot.analyser.realWaveData;
const samples = waveformSamples[idx];
if (!samples) return 0;
// Interpolate waveform samples for rendering but use C-side
// dB-scaled RMS intensity for LED/glow (continuous, not binary)
computeWaveform(waveData, samples);
const intensity = slot.analyser.waveformIntensity ?? 0;
// 2D fallback only
if (webglFailed) {
const ctx = canvasCtxs[idx];
const size = canvasSizes[idx];
if (!ctx || !size) return intensity;
return renderWaveform(ctx, size, samples, colors, intensity);
}
return intensity;
}
function drawTotal(colors) {
if (analyserSlots.length === 0) return 0;
// Sum all channel waveform samples
if (!totalSamples || totalSamples.length !== COLS) {
totalSamples = new Float32Array(COLS);
}
totalSamples.fill(0);
let maxIntensity = 0;
for (let i = 0; i < analyserSlots.length; i++) {
const chSamples = waveformSamples[i];
if (!chSamples) continue;
for (let c = 0; c < COLS; c++) {
totalSamples[c] += chSamples[c];
}
// Approximate intensity from per-channel peak history
const p = peakHistory[i] || 0;
if (p > maxIntensity) maxIntensity = p;
}
// Per-frame min-max normalize: map [min, max] → [-1, 1] so peaks always touch edges
let totalMin = Infinity;
let totalMax = -Infinity;
for (let c = 0; c < COLS; c++) {
const v = totalSamples[c];
if (v < totalMin) totalMin = v;
if (v > totalMax) totalMax = v;
}
const range = totalMax - totalMin;
// Noise gate: don't amplify near-silence (range < ~2 LSB of 8-bit)
if (range > 0.008) {
const scale = 2.0 / range;
const offset = (totalMax + totalMin) / 2.0;
for (let c = 0; c < COLS; c++) {
totalSamples[c] = (totalSamples[c] - offset) * scale;
}
} else {
totalSamples.fill(0);
}
const intensity = Math.min(1, maxIntensity * 1.2);
// 2D fallback only
if (webglFailed) {
if (!totalCtx || !totalSize) return intensity;
return renderWaveform(totalCtx, totalSize, totalSamples, colors, intensity);
}
return intensity;
}
function tick(ts) {
let allIdle = false;
if (!isPlaying.value) {
let checkIdle = true;
for (let i = 0; i < analyserSlots.length; i++) {
if ((peakHistory[i] || 0) > 0.01) {
checkIdle = false;
break;
}
}
if (totalPeak > 0.01) checkIdle = false;
if (checkIdle) {
allIdle = true;
}
}
if (allIdle) {
stopLoop();
for (let i = 0; i < analyserSlots.length; i++) {
peakHistory[i] = 0;
const cell = canvasRefs.value[i] && canvasRefs.value[i].parentElement;
if (cell) {
cell.__activity = 0;
cell.style.setProperty("--cell-activity", "0.00");
}
}
totalPeak = 0;
const tCell = totalCanvasRef.value && totalCanvasRef.value.parentElement;
if (tCell) {
tCell.__activity = 0;
tCell.style.setProperty("--cell-activity", "0.00");
}
} else {
rafHandle = requestAnimationFrame(tick);
}
// ── Delta Time ──
const now = performance.now();
let dt = 22.22;
if (lastTickTime > 0) {
dt = Math.max(1, now - lastTickTime);
if (dt > 100) dt = 22.22; // 挂起或卡顿唤醒防过度衰减
}
lastTickTime = now;
const decayRate = dt / 22.22;
const decayFactor = Math.pow(0.88, decayRate);
const shouldUpdateDom = now - lastDomUpdateTime >= 40;
if (shouldUpdateDom) {
lastDomUpdateTime = now;
}
if (prefersReducedMotion) {
if (ts - lastFrame < 200) return;
}
lastFrame = ts;
if (analyserSlots.length === 0) return;
if (document.hidden) return;
const colors = readThemeColors(false);
const dpr = Math.min(window.devicePixelRatio || 1, 2);
// Lazy-init WebGL
if (!webglFailed && !webglRenderer) {
tryInitWebGL();
}
// Draw all channels (populates waveformSamples)
for (let i = 0; i < analyserSlots.length; i++) {
const intensity = drawChannel(i, colors);
const prev = peakHistory[i] || 0;
const next = intensity > prev ? intensity : prev * decayFactor;
peakHistory[i] = next;
const cell = canvasRefs.value[i] && canvasRefs.value[i].parentElement;
if (cell && shouldUpdateDom) {
const quantized = Math.round(next * 20) / 20;
if (cell.__activity !== quantized) {
cell.__activity = quantized;
cell.style.setProperty("--cell-activity", quantized.toFixed(2));
}
}
}
// Total (sum) waveform — uses the waveformSamples populated above.
const totalIntensity = drawTotal(colors);
const totalNext = totalIntensity > totalPeak ? totalIntensity : totalPeak * decayFactor;
totalPeak = totalNext;
const tCell = totalCanvasRef.value && totalCanvasRef.value.parentElement;
if (tCell && shouldUpdateDom) {
const quantized = Math.round(totalNext * 20) / 20;
if (tCell.__activity !== quantized) {
tCell.__activity = quantized;
tCell.style.setProperty("--cell-activity", quantized.toFixed(2));
}
}
// ── WebGL batch rendering via viewport/scissor ────────────────────────
if (webglRenderer) {
if (needUpdateRects) {
updateRectsCache();
}
if (cachedGlRect) {
try {
webglRenderer.clear();
const glRect = cachedGlRect;
// Render Total waveform
if (showTotal.value && totalSamples && cachedTotalRect) {
const elRect = cachedTotalRect;
const vpX = Math.floor((elRect.left - glRect.left) * dpr);
const vpY = Math.floor((glRect.bottom - elRect.bottom) * dpr); // WebGL y=0 at bottom
const vpW = Math.floor(elRect.width * dpr);
const vpH = Math.floor(elRect.height * dpr);
if (vpW > 0 && vpH > 0) {
webglRenderer.renderChannel(
totalSamples,
COLS,
{ x: vpX, y: vpY, w: vpW, h: vpH },
totalPeak,
colors,
dpr,
true,
);
}
}
// Render each channel
if (showChannels.value) {
for (let i = 0; i < analyserSlots.length; i++) {
const elRect = cachedChannelRects[i];
if (!elRect || !waveformSamples[i]) continue;
const vpX = Math.floor((elRect.left - glRect.left) * dpr);
const vpY = Math.floor((glRect.bottom - elRect.bottom) * dpr);
const vpW = Math.floor(elRect.width * dpr);
const vpH = Math.floor(elRect.height * dpr);
if (vpW > 0 && vpH > 0) {
webglRenderer.renderChannel(
waveformSamples[i],
COLS,
{ x: vpX, y: vpY, w: vpW, h: vpH },
peakHistory[i] || 0,
colors,
dpr,
);
}
}
}
} catch (e) {
console.error("[webgl-vis] ChannelScopes WebGL runtime error, falling back to 2D:", e);
showWebGLErrorBanner("多通道示波器 WebGL 运行时错误 (ChannelScopes Render)", e);
destroyWebGL();
webglFailed = true;
// Re-initialize 2D contexts
for (let i = 0; i < canvasRefs.value.length; i++) {
const el = canvasRefs.value[i];
if (el) canvasCtxs[i] = el.getContext("2d", { alpha: true, desynchronized: true });
}
if (totalCanvasRef.value) {
totalCtx = totalCanvasRef.value.getContext("2d", { alpha: true, desynchronized: true });
}
resizeAllCanvases();
}
}
}
}
function startLoop() {
if (rafHandle != null) return;
rafHandle = requestAnimationFrame(tick);
}
function stopLoop() {
if (rafHandle != null) cancelAnimationFrame(rafHandle);
rafHandle = null;
lastTickTime = 0;
}
const handleChannelsReady = () => {
readAnalysers();
};
const handleVisibility = () => {
if (document.hidden) stopLoop();
else startLoop();
};
const handleThemeChange = () => {
readThemeColors(true);
};
const handlePlayState = (e) => {
if (e && e.detail && typeof e.detail.isPlaying === "boolean") {
isPlaying.value = e.detail.isPlaying;
if (isPlaying.value) {
startLoop();
}
}
};
onMounted(() => {
readScopeSettings();
if (typeof window !== "undefined") {
isPlaying.value = getInitialPlayingState();
}
if (typeof window.matchMedia === "function") {
mqlReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
prefersReducedMotion = mqlReducedMotion.matches;
mqlReducedMotion.addEventListener?.("change", (e) => {
prefersReducedMotion = e.matches;
});
}
readAnalysers();
window.addEventListener("player:channels-ready", handleChannelsReady);
window.addEventListener("player:track-change", handleChannelsReady);
window.addEventListener("app:locale-changed", handleThemeChange);
window.addEventListener("player:scope-settings", handleScopeSettings);
window.addEventListener("player:play-state", handlePlayState);
document.addEventListener("visibilitychange", handleVisibility);
if (typeof ResizeObserver !== "undefined" && containerRef.value) {
resizeObserver = new ResizeObserver(() => resizeAllCanvases());
resizeObserver.observe(containerRef.value);
}
window.addEventListener("resize", resizeAllCanvases);
startLoop();
});
onBeforeUnmount(() => {
stopLoop();
destroyWebGL();
window.removeEventListener("player:channels-ready", handleChannelsReady);
window.removeEventListener("player:track-change", handleChannelsReady);
window.removeEventListener("app:locale-changed", handleThemeChange);
window.removeEventListener("player:scope-settings", handleScopeSettings);
window.removeEventListener("player:play-state", handlePlayState);
document.removeEventListener("visibilitychange", handleVisibility);
window.removeEventListener("resize", resizeAllCanvases);
if (resizeObserver) {
resizeObserver.disconnect();
resizeObserver = null;
}
});
</script>
<template>
<div
ref="containerRef"
v-show="showContainer"
class="card channel-scopes p-2.5 opacity-0 translate-y-4 animate-fadeUp [animation-delay:0.07s] hover:shadow-card-hover"
aria-label="Per-channel oscilloscopes"
>
<!-- WebGL Canvas — shared single canvas for all channels -->
<canvas
ref="webglCanvasRef"
class="webgl-channel-canvas"
></canvas>
<div
v-if="channels.length === 0"
class="text-xs text-text-muted opacity-70 text-center py-2"
>
Channels initializing...
</div>
<template v-else>
<div
id="scopeTotalCell"
class="total-cell"
:style="showTotal ? '' : 'display:none'"
>
<span class="channel-label">SUM · ALL CH</span>
<span class="channel-led" aria-hidden="true"></span>
<canvas
:ref="setTotalCanvasRef"
class="total-canvas"
></canvas>
</div>
<div
id="scopeChannelGrid"
class="channel-grid"
:data-channels="channels.length"
:style="showChannels ? { '--grid-cols': gridColumns } : { display: 'none' }"
>
<div
v-for="(_, idx) in channels"
:key="idx"
class="channel-cell"
>
<span class="channel-label">CH {{ (idx + 1).toString().padStart(2, "0") }}</span>
<span class="channel-led" aria-hidden="true"></span>
<canvas
:ref="(el) => setCanvasRef(el, idx)"
class="channel-canvas"
></canvas>
</div>
</div>
</template>
</div>
</template>
<style scoped>
.channel-scopes {
--cell-bg-a: color-mix(in srgb, var(--surface-2, #0b0f17) 92%, transparent);
--cell-bg-b: color-mix(in srgb, var(--surface-3, #111827) 78%, transparent);
display: grid;
gap: 6px;
position: relative;
}
/* WebGL canvas overlays the entire container */
.webgl-channel-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
z-index: 1;
pointer-events: none;
}
.total-cell {
--cell-activity: 0;
position: relative;
border-radius: 7px;
overflow: hidden;
background:
radial-gradient(
120% 80% at 50% 100%,
color-mix(in srgb, var(--scope-waveform, #34d399) calc(var(--cell-activity) * 22%), transparent) 0%,
transparent 60%
),
linear-gradient(180deg, var(--cell-bg-a), var(--cell-bg-b));
border: 1px solid
color-mix(in srgb, var(--scope-waveform, #34d399) calc(35% + var(--cell-activity) * 25%), var(--border));
box-shadow:
inset 0 1px 0 color-mix(in srgb, white calc(var(--cell-activity) * 14%), transparent),
0 6px 14px -10px color-mix(in srgb, var(--scope-waveform, #34d399) calc(var(--cell-activity) * 70%), transparent);
transition: box-shadow 120ms linear, border-color 120ms linear;
}
.total-cell::before {
content: "";
position: absolute;
inset: 0;
pointer-events: none;
background-image: linear-gradient(
to right,
var(--border, rgba(255, 255, 255, 0.06)) 1px,
transparent 1px
);
background-size: 12.5% 100%;
opacity: 0.16;
}
.total-canvas {
width: 100%;
height: 56px;
display: block;
position: relative;
}
.total-cell .channel-label {
font-size: 9px;
letter-spacing: 0.16em;
opacity: 0.9;
color: color-mix(in srgb, var(--scope-waveform, #34d399) 60%, var(--text));
}
.channel-grid {
display: grid;
gap: 3px;
/* Mobile: max 6 cols */
grid-template-columns: repeat(min(var(--grid-cols, 4), 6), 1fr);
}
@media (min-width: 720px) {
.channel-grid {
gap: 4px;
/* Tablet: max 8 cols */
grid-template-columns: repeat(min(var(--grid-cols, 6), 8), 1fr);
}
}
@media (min-width: 1024px) {
.channel-grid {
/* Desktop: max 12 cols */
grid-template-columns: repeat(min(var(--grid-cols, 8), 12), 1fr);
}
}
.channel-cell {
--cell-activity: 0;
position: relative;
border-radius: 5px;
overflow: hidden;
background:
radial-gradient(
120% 80% at 50% 100%,
color-mix(in srgb, var(--scope-waveform, #34d399) calc(var(--cell-activity) * 18%), transparent) 0%,
transparent 60%
),
linear-gradient(180deg, var(--cell-bg-a), var(--cell-bg-b));
border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
box-shadow:
inset 0 1px 0 color-mix(in srgb, white calc(var(--cell-activity) * 10%), transparent),
0 0 0 1px transparent,
0 4px 10px -8px color-mix(in srgb, var(--scope-waveform, #34d399) calc(var(--cell-activity) * 65%), transparent);
transition: box-shadow 120ms linear, border-color 120ms linear;
will-change: box-shadow;
}
.channel-cell::before {
content: "";
position: absolute;
inset: 0;
pointer-events: none;
background-image: linear-gradient(
to right,
var(--border, rgba(255, 255, 255, 0.06)) 1px,
transparent 1px
);
background-size: 25% 100%;
opacity: 0.14;
}
.channel-canvas {
width: 100%;
height: 32px;
display: block;
position: relative;
}
.channel-label {
position: absolute;
top: 2px;
left: 4px;
font-size: 7px;
font-family: ui-monospace, "Fira Code", SFMono-Regular, Menlo, monospace;
letter-spacing: 0.05em;
font-weight: 700;
color: var(--text-soft, #94a3b8);
opacity: 0.75;
pointer-events: none;
z-index: 2;
text-shadow: 0 1px 0 color-mix(in srgb, var(--surface-2, #000) 70%, transparent);
}
.channel-led {
position: absolute;
top: 3px;
right: 3px;
width: 3px;
height: 3px;
border-radius: 999px;
background: color-mix(
in srgb,
var(--scope-waveform, #34d399) calc(var(--cell-activity) * 100%),
color-mix(in srgb, var(--text-soft, #94a3b8) 30%, transparent)
);
box-shadow: 0 0 calc(var(--cell-activity) * 6px) color-mix(in srgb, var(--scope-waveform, #34d399) 80%, transparent);
z-index: 2;
pointer-events: none;
transition: background-color 120ms linear, box-shadow 120ms linear;
}
@media (prefers-reduced-motion: reduce) {
.channel-cell {
transition: none;
}
.channel-led {
transition: none;
}
}
</style>
+376
View File
@@ -0,0 +1,376 @@
<script setup>
import { ref, computed } from "vue";
const props = defineProps({
isOpen: Boolean,
closeModal: Function,
fileName: { type: String, default: "" },
fileUrl: { type: String, default: "" },
downloadUrl: { type: String, default: "" },
});
const { t } = useI18n();
const isConverting = ref(false);
const convertError = ref("");
const sourceUrl = computed(() => props.downloadUrl || props.fileUrl);
const fileExt = computed(() => {
const name = props.fileName || "";
const dot = name.lastIndexOf(".");
return dot >= 0 ? name.slice(dot + 1).toLowerCase() : "";
});
const canConvertToMp3 = computed(() =>
["xm", "mod", "it", "s3m", "umx", "mptm", "stm", "mtm", "ptm", "far", "ult", "669", "amf", "dsm", "mdl", "med", "okt", "psm", "dbm", "imf", "j2b", "mo3", "gdm", "stp", "sfx", "sfx2", "itp", "dtm", "mt2", "symmod", "c67", "ams", "stx", "667", "cba", "digi", "dmf", "dsym", "etx", "fc", "fc13", "fc14", "fmt", "ftm", "gmc", "gt2", "gtk", "ice", "ims", "m15", "mms", "mus", "oxm", "plm", "pt36", "puma", "rtm", "smod", "st26", "stk", "wow", "xmf", "mdz", "s3z", "xmz", "itz", "mptmz", "mdr"].includes(fileExt.value)
);
const sourceLabel = computed(() => {
const ext = fileExt.value.toUpperCase();
return ext ? t("download.sourceFile", { ext }) : t("download.sourceFileGeneric");
});
// Build the server-relative path from the music API URL
const musicApiPath = computed(() => {
if (!sourceUrl.value) return "";
try {
const url = new URL(sourceUrl.value, window.location.origin);
// e.g. /api/music/somedir/file.xm -> extract path after /api/music/
const prefix = "/api/music/";
if (url.pathname.startsWith(prefix)) {
return url.pathname.slice(prefix.length);
}
} catch {}
return "";
});
const mp3ConvertUrl = computed(() => {
if (!musicApiPath.value) return "";
return `/api/music/convert-mp3?path=${encodeURIComponent(musicApiPath.value)}`;
});
const handleDownloadSource = () => {
if (!sourceUrl.value) return;
const a = document.createElement("a");
a.href = sourceUrl.value;
a.download = props.fileName || "track";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
props.closeModal?.();
};
const handleDownloadMp3 = async () => {
if (!mp3ConvertUrl.value) return;
convertError.value = "";
isConverting.value = true;
try {
const res = await fetch(mp3ConvertUrl.value);
if (!res.ok) {
const text = await res.text().catch(() => "");
throw new Error(text || `HTTP ${res.status}`);
}
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
const baseName = props.fileName.replace(/\.[^.]+$/, "");
a.href = url;
a.download = `${baseName}.mp3`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
props.closeModal?.();
} catch (err) {
convertError.value = t("download.convertError");
} finally {
isConverting.value = false;
}
};
const handleBackdropClick = (e) => {
if (e.target === e.currentTarget) props.closeModal?.();
};
const handleKeydown = (e) => {
if (e.key === "Escape") props.closeModal?.();
};
</script>
<template>
<Teleport to="body">
<Transition name="dl-modal">
<div
v-if="isOpen"
class="dl-overlay"
role="dialog"
aria-modal="true"
:aria-label="t('download.modalTitle')"
@click="handleBackdropClick"
@keydown="handleKeydown"
>
<div class="dl-panel card">
<header class="dl-header">
<h2 class="dl-title">{{ t("download.modalTitle") }}</h2>
<button
class="dl-close btn-base"
type="button"
:aria-label="t('download.close')"
@click="closeModal?.()"
>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</header>
<p class="dl-filename">{{ fileName }}</p>
<div class="dl-options">
<!-- Source file -->
<button
class="dl-option btn-base"
type="button"
:disabled="!sourceUrl"
@click="handleDownloadSource"
>
<span class="dl-option-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
<path d="M14 2v6h6" />
<path d="M12 12v6" />
<path d="m9 15 3 3 3-3" />
</svg>
</span>
<span class="dl-option-body">
<span class="dl-option-label">{{ sourceLabel }}</span>
<span class="dl-option-desc">{{ t("download.sourceDesc") }}</span>
</span>
</button>
<!-- MP3 (only for convertible formats) -->
<button
v-if="canConvertToMp3"
class="dl-option dl-option-mp3 btn-base"
type="button"
:disabled="isConverting || !mp3ConvertUrl"
@click="handleDownloadMp3"
>
<span class="dl-option-icon">
<span v-if="isConverting" class="dl-spinner" aria-hidden="true"></span>
<svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="9" />
<path d="M10 8l6 4-6 4V8z" />
</svg>
</span>
<span class="dl-option-body">
<span class="dl-option-label">{{ isConverting ? t("download.converting") : t("download.mp3Label") }}</span>
<span class="dl-option-desc">{{ t("download.mp3Desc") }}</span>
</span>
</button>
</div>
<p v-if="convertError" class="dl-error" role="alert">{{ convertError }}</p>
</div>
</div>
</Transition>
</Teleport>
</template>
<style scoped>
.dl-overlay {
position: fixed;
inset: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
background: rgba(0, 0, 0, 0.55);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
}
.dl-panel {
width: 100%;
max-width: 380px;
padding: 1.25rem;
display: grid;
gap: 1rem;
position: relative;
}
.dl-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
}
.dl-title {
margin: 0;
font-size: 1rem;
font-weight: 800;
letter-spacing: -0.01em;
color: var(--text);
}
.dl-close {
width: 30px;
height: 30px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
border-radius: 8px;
}
.dl-close svg {
width: 16px;
height: 16px;
}
.dl-filename {
margin: 0;
font-size: 0.78rem;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
color: var(--text-soft);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0.35rem 0.6rem;
background: color-mix(in srgb, var(--surface-2) 70%, transparent);
border-radius: 8px;
border: 1px solid var(--border);
}
.dl-options {
display: grid;
gap: 0.55rem;
}
.dl-option {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 0.85rem;
padding: 0.75rem 0.9rem;
border-radius: 12px;
border: 1px solid var(--border);
background: color-mix(in srgb, var(--surface) 70%, transparent);
text-align: left;
cursor: pointer;
transition: all 0.18s ease;
width: 100%;
}
.dl-option:hover:not(:disabled) {
border-color: var(--border-strong);
background: var(--surface-hover);
transform: translateY(-1px);
box-shadow: 0 8px 20px -12px rgba(15, 23, 42, 0.25);
}
.dl-option:disabled {
opacity: 0.45;
cursor: not-allowed;
}
.dl-option-mp3 {
border-color: rgba(37, 99, 235, 0.3);
background: rgba(37, 99, 235, 0.04);
}
.dl-option-mp3:hover:not(:disabled) {
border-color: rgba(37, 99, 235, 0.55);
background: rgba(37, 99, 235, 0.09);
}
.dl-option-icon {
width: 36px;
height: 36px;
border-radius: 9px;
display: flex;
align-items: center;
justify-content: center;
background: color-mix(in srgb, var(--surface-2) 80%, transparent);
flex-shrink: 0;
}
.dl-option-icon svg {
width: 18px;
height: 18px;
color: var(--text-soft);
}
.dl-option-mp3 .dl-option-icon {
background: rgba(37, 99, 235, 0.1);
}
.dl-option-mp3 .dl-option-icon svg {
color: var(--accent-strong, #2563eb);
}
.dl-option-body {
display: flex;
flex-direction: column;
gap: 0.15rem;
min-width: 0;
}
.dl-option-label {
font-size: 0.88rem;
font-weight: 700;
color: var(--text);
}
.dl-option-desc {
font-size: 0.72rem;
color: var(--text-soft);
}
.dl-spinner {
width: 18px;
height: 18px;
border-radius: 999px;
border: 2px solid var(--accent);
border-top-color: transparent;
animation: dlSpin 0.7s linear infinite;
}
.dl-error {
margin: 0;
font-size: 0.78rem;
color: var(--danger, #dc2626);
padding: 0.45rem 0.7rem;
border-radius: 8px;
background: rgba(220, 38, 38, 0.08);
border: 1px solid rgba(220, 38, 38, 0.25);
}
/* Transition */
.dl-modal-enter-active,
.dl-modal-leave-active {
transition: opacity 0.2s ease;
}
.dl-modal-enter-from,
.dl-modal-leave-to {
opacity: 0;
}
.dl-modal-enter-active .dl-panel,
.dl-modal-leave-active .dl-panel {
transition: transform 0.2s ease, opacity 0.2s ease;
}
.dl-modal-enter-from .dl-panel,
.dl-modal-leave-to .dl-panel {
transform: translateY(10px) scale(0.97);
opacity: 0;
}
@keyframes dlSpin {
to { transform: rotate(360deg); }
}
</style>
+383
View File
@@ -0,0 +1,383 @@
<script setup>
import { ref, computed, onMounted } from "vue";
const { t } = useI18n();
// ─── 预设定义 ───
const CHIPTUNE3_ALL_EXTS = [
"xm", "mod", "it", "s3m", "umx", "mptm", "stm", "mtm", "ptm", "far", "ult",
"669", "amf", "dsm", "mdl", "med", "okt", "psm", "dbm", "imf", "j2b", "mo3",
"gdm", "stp", "sfx", "sfx2", "itp", "dtm", "mt2", "symmod", "c67", "ams", "stx",
"667", "cba", "digi", "dmf", "dsym", "etx", "fc", "fc13", "fc14", "fmt", "ftm",
"gmc", "gt2", "gtk", "ice", "ims", "m15", "mms", "mus", "oxm", "plm", "pt36",
"puma", "rtm", "smod", "st26", "stk", "wow", "xmf",
"mdz", "s3z", "xmz", "itz", "mptmz", "mdr",
];
// 引擎标签: bc=Bassoon+Chiptune3, c=Chiptune3, n=Native, f=FFmpeg
const ENGINE_TAG_MAP = {
xm: "bc", mod: "bc",
it: "c", s3m: "c", umx: "c", mptm: "c", stm: "c", mtm: "c", ptm: "c",
far: "c", ult: "c", "669": "c", amf: "c", dsm: "c", mdl: "c", med: "c",
okt: "c", psm: "c", dbm: "c", imf: "c", j2b: "c", mo3: "c", gdm: "c",
stp: "c", sfx: "c", sfx2: "c", itp: "c", dtm: "c", mt2: "c", symmod: "c",
c67: "c", ams: "c", stx: "c", "667": "c", cba: "c", digi: "c", dmf: "c",
dsym: "c", etx: "c", fc: "c", fc13: "c", fc14: "c", fmt: "c", ftm: "c",
gmc: "c", gt2: "c", gtk: "c", ice: "c", ims: "c", m15: "c", mms: "c",
mus: "c", oxm: "c", plm: "c", pt36: "c", puma: "c", rtm: "c", smod: "c",
st26: "c", stk: "c", wow: "c", xmf: "c", mdz: "c", s3z: "c", xmz: "c",
itz: "c", mptmz: "c", mdr: "c",
mp3: "n", ogg: "n", wav: "n", flac: "n",
};
const ENGINE_LABELS = { bc: "B,C", c: "C", n: "N", f: "F" };
// ─── 预设 ───
const PRESETS = {
bassoon: { label: () => t("playlist.formatPresetBassoon"), exts: ["xm", "mod"] },
major: { label: () => t("playlist.formatPresetMajor"), exts: ["xm", "mod", "it", "s3m", "mptm"] },
chiptune3: { label: () => t("playlist.formatPresetChiptune3"), exts: CHIPTUNE3_ALL_EXTS },
all: { label: () => t("playlist.formatPresetAll"), exts: null },
};
// ─── 状态 ───
const isOpen = ref(false);
const selected = ref(new Set(CHIPTUNE3_ALL_EXTS));
const activePreset = ref("chiptune3");
const rawCounts = ref([]);
const container = ref(null);
const panelRef = ref(null);
// API 结果 + 硬编码 C3 列表合并(补零),确保网格稳定完整
const mergedFormats = computed(() => {
const map = new Map();
// 先放 API 数据
for (const f of rawCounts.value) {
const engine = f.engine || ENGINE_TAG_MAP[f.extension];
if (engine) map.set(f.extension, { ...f, engine });
}
// 补充 C3 列表中 API 没有的(count=0)
for (const ext of CHIPTUNE3_ALL_EXTS) {
if (!map.has(ext)) {
map.set(ext, { extension: ext, count: 0, engine: ENGINE_TAG_MAP[ext] || "c" });
}
}
return [...map.values()];
});
// 按引擎支持顺序排列:B,C → C → N → F,同组按数量降序
const ENGINE_ORDER = { bc: 0, c: 1, n: 2, f: 3 };
const sortedFormats = computed(() => {
return [...mergedFormats.value].sort((a, b) => {
const oa = ENGINE_ORDER[a.engine] ?? 4;
const ob = ENGINE_ORDER[b.engine] ?? 4;
if (oa !== ob) return oa - ob;
return b.count - a.count;
});
});
async function fetchCounts() {
try {
rawCounts.value = await $fetch("/api/songs/formats");
} catch (e) {
console.error("format counts fetch failed", e);
}
}
onMounted(async () => {
await fetchCounts();
// 确保初始化时 68 种 C3 格式已写入隐藏 input,player-app.ts 读取前生效
await nextTick();
emitChange();
});
// ─── 操作 ───
function applyPreset(key) {
const preset = PRESETS[key];
if (!preset) return;
activePreset.value = key;
if (preset.exts === null) {
selected.value = new Set(mergedFormats.value.map(f => f.extension));
} else {
selected.value = new Set(preset.exts);
}
emitChange();
}
function toggleFormat(ext) {
const next = new Set(selected.value);
next.has(ext) ? next.delete(ext) : next.add(ext);
selected.value = next;
// 匹配预设
const selArr = [...next].sort().join(",");
let matched = null;
for (const [key, p] of Object.entries(PRESETS)) {
if (p.exts !== null) {
if ([...p.exts].sort().join(",") === selArr) { matched = key; break; }
}
}
activePreset.value = matched;
emitChange();
}
function selectAll() {
selected.value = new Set(mergedFormats.value.map(f => f.extension));
activePreset.value = null;
emitChange();
}
function clearAll() {
selected.value = new Set();
activePreset.value = null;
emitChange();
}
function emitChange() {
const input = document.getElementById("extensionsInput");
if (input) {
input.value = [...selected.value].join(",");
input.dispatchEvent(new Event("change", { bubbles: true }));
}
}
// ─── 面板定位 ───
const panelStyle = ref({ top: "0px", left: "0px" });
function updatePosition() {
if (container.value) {
const r = container.value.getBoundingClientRect();
panelStyle.value = {
top: `${r.bottom + 6}px`,
left: `${Math.min(r.left, window.innerWidth - 400)}px`,
};
}
}
// ─── 打开/关闭 ───
function onToggle() {
if (isOpen.value) {
closePanel();
} else {
openPanel();
}
}
function openPanel() {
updatePosition();
if (!rawCounts.value.length) fetchCounts();
isOpen.value = true;
// 延迟绑定 document click,避免触发按钮的 click 立即关闭
setTimeout(() => document.addEventListener("click", onDocClick), 0);
}
function closePanel() {
isOpen.value = false;
document.removeEventListener("click", onDocClick);
}
function onDocClick(e) {
// 点击容器内(触发按钮)或面板内 → 不关闭
const inContainer = container.value?.contains(e.target);
const inPanel = panelRef.value?.contains(e.target);
if (!inContainer && !inPanel) {
closePanel();
}
}
defineExpose({
resetToDefault() {
activePreset.value = 'chiptune3';
selected.value = new Set(CHIPTUNE3_ALL_EXTS);
// Don't call emitChange() here — parent will batch and dispatch once
},
});
const selectedCount = computed(() => selected.value.size);
const hasActiveFilter = computed(() => {
const def = [...CHIPTUNE3_ALL_EXTS].sort().join(",");
return [...selected.value].sort().join(",") !== def;
});
// 触发按钮标签:匹配预设则显示预设名,否则显示"筛选 + N"
const triggerLabel = computed(() => {
if (activePreset.value && PRESETS[activePreset.value]) {
return PRESETS[activePreset.value].label();
}
return `${t("playlist.formatFilterLabel")} · ${selectedCount.value}`;
});
</script>
<template>
<div ref="container" class="relative">
<button
type="button"
class="ff-trigger"
:class="{ 'ff-trigger--active': hasActiveFilter }"
@click.stop="onToggle"
>
<span class="ff-trigger-label">{{ triggerLabel }}</span>
<svg class="ff-trigger-chev" :class="{ 'rotate-180': isOpen }" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
</button>
<input id="extensionsInput" type="hidden" :value="[...selected].join(',')" />
<Teleport to="body">
<Transition name="ffpanel">
<div
v-if="isOpen"
ref="panelRef"
class="ff-panel"
:style="{ top: panelStyle.top, left: panelStyle.left, minWidth: '380px' }"
>
<div class="ff-presets">
<button
v-for="(p, k) in PRESETS" :key="k"
class="ff-preset"
:class="{ 'ff-preset--on': activePreset === k }"
@click="applyPreset(k)"
>{{ p.label() }}</button>
</div>
<div class="ff-actions">
<span class="ff-actions-label">{{ t("playlist.formatFilterSelected", { n: selectedCount }) }}</span>
<button class="ff-act" @click="selectAll">{{ t("playlist.formatFilterSelectAll") }}</button>
<button class="ff-act" @click="clearAll">{{ t("playlist.formatFilterClear") }}</button>
</div>
<div class="ff-grid">
<button
v-for="fmt in sortedFormats" :key="fmt.extension"
class="ff-chip"
:class="{ 'ff-chip--on': selected.has(fmt.extension) }"
@click="toggleFormat(fmt.extension)"
>
<span class="ff-chip-dot" :data-engine="fmt.engine" />
<span class="ff-chip-ext">{{ fmt.extension.toUpperCase() }}</span>
<span class="ff-chip-tag" :data-engine="fmt.engine">{{ ENGINE_LABELS[fmt.engine] || "F" }}</span>
<span class="ff-chip-n">{{ fmt.count.toLocaleString() }}</span>
</button>
</div>
</div>
</Transition>
</Teleport>
</div>
</template>
<style scoped>
/* ── Trigger ── */
.ff-trigger {
display: inline-flex;
align-items: center;
justify-content: space-between;
gap: 6px;
width: 100%;
height: 2.5rem; /* h-10 */
padding: 0 0.75rem; /* px-3 */
border-radius: 0.5rem; /* rounded-lg */
border: 1px solid var(--color-border);
background: var(--color-surface);
color: var(--color-text);
font-size: 0.875rem; /* text-sm */
font-weight: 600;
line-height: 1.25rem;
cursor: pointer;
transition: all 0.2s;
white-space: nowrap;
user-select: none;
}
.ff-trigger:hover { border-color: var(--color-border-strong, var(--color-border)); background: var(--color-surface-hover, var(--color-surface)); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.ff-trigger--active {
border-color: var(--color-accent);
color: var(--color-accent);
}
.ff-trigger-label { font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; }
.ff-trigger-chev { width: 0.875rem; height: 0.875rem; color: var(--color-text-soft, var(--color-text-muted)); transition: transform 0.2s; flex-shrink: 0; }
/* ── Panel ── */
.ff-panel {
position: fixed; z-index: 10000; padding: 12px; border-radius: 14px;
border: 1px solid var(--color-border);
background: var(--color-surface-glass, var(--color-surface));
backdrop-filter: blur(20px);
box-shadow: 0 16px 48px rgba(0,0,0,.45);
max-height: 480px; display: flex; flex-direction: column; gap: 10px;
}
/* ── Presets ── */
.ff-presets { display: flex; flex-wrap: wrap; gap: 5px; }
.ff-preset {
padding: 4px 10px; border-radius: 999px;
border: 1px solid var(--color-border);
background: transparent; color: var(--color-text-muted);
font-size: 0.7rem; font-weight: 600; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.ff-preset:hover { border-color: var(--color-text-muted); color: var(--color-text); }
.ff-preset--on {
border-color: var(--color-accent);
background: color-mix(in srgb, var(--color-accent) 12%, transparent);
color: var(--color-accent);
}
/* ── Actions ── */
.ff-actions {
display: flex; align-items: center; gap: 6px;
padding-bottom: 4px; border-bottom: 1px solid var(--color-border);
}
.ff-actions-label {
flex: 1; font-size: 0.68rem; font-weight: 700;
text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted);
}
.ff-act {
padding: 2px 8px; border-radius: 6px; border: 1px solid var(--color-border);
background: transparent; color: var(--color-text-muted); font-size: 0.65rem;
font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.ff-act:hover { border-color: var(--color-text-muted); color: var(--color-text); }
/* ── Grid ── */
.ff-grid {
display: flex; flex-wrap: wrap; gap: 4px; overflow-y: auto;
align-content: flex-start; max-height: 320px; padding-right: 2px;
}
.ff-grid::-webkit-scrollbar { width: 5px; }
.ff-grid::-webkit-scrollbar-track { background: transparent; }
.ff-grid::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 999px; }
/* ── Chip ── */
.ff-chip {
display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px;
border-radius: 7px; border: 1px solid transparent;
background: transparent; cursor: pointer; transition: all 0.12s;
font-size: 0.67rem; white-space: nowrap; color: var(--color-text-muted);
opacity: 0.45;
}
.ff-chip:hover {
border-color: var(--color-border);
opacity: 0.7;
}
.ff-chip--on {
border-color: color-mix(in srgb, var(--color-accent) 40%, transparent);
background: color-mix(in srgb, var(--color-accent) 10%, transparent);
color: var(--color-text);
opacity: 1;
box-shadow: 0 0 6px color-mix(in srgb, var(--color-accent) 15%, transparent);
}
/* engine dot */
.ff-chip-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; transition: transform 0.12s; }
.ff-chip--on .ff-chip-dot { transform: scale(1.2); }
.ff-chip-dot[data-engine="bc"] { background: #f59e0b; }
.ff-chip-dot[data-engine="c"] { background: #60a5fa; }
.ff-chip-dot[data-engine="n"] { background: #34d399; }
.ff-chip-dot[data-engine="f"] { background: #a78bfa; }
.ff-chip-ext { font-weight: 700; letter-spacing: 0.02em; }
/* engine tag badge */
.ff-chip-tag { font-size: 0.55rem; font-weight: 700; padding: 0 3px; border-radius: 3px; }
.ff-chip-tag[data-engine="bc"] { background: rgba(245,158,11,.18); color: #f59e0b; }
.ff-chip-tag[data-engine="c"] { background: rgba(96,165,250,.18); color: #60a5fa; }
.ff-chip-tag[data-engine="n"] { background: rgba(52,211,153,.18); color: #34d399; }
.ff-chip-tag[data-engine="f"] { background: rgba(167,139,250,.18); color: #a78bfa; }
.ff-chip-n { color: var(--color-text-muted); font-size: 0.6rem; min-width: 28px; text-align: right; opacity: 0.6; }
/* ── Transition ── */
.ffpanel-enter-active { transition: all 0.15s ease-out; }
.ffpanel-leave-active { transition: all 0.1s ease-in; }
.ffpanel-enter-from, .ffpanel-leave-to { opacity: 0; transform: translateY(-4px) scale(0.98); }
</style>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+116
View File
@@ -0,0 +1,116 @@
<script setup>
import { onMounted, ref } from "vue";
import SettingsModal from "~/components/SettingsModal.vue";
import PlayerControls from "~/components/PlayerControls.vue";
import PlaylistView from "~/components/PlaylistView.vue";
import ChannelScopes from "~/components/ChannelScopes.vue";
import InfoDrawer from "~/components/InfoDrawer.vue";
const isSettingsModalOpen = ref(false);
const isPlayerBooting = ref(true);
const isLoggingOut = ref(false);
const { t } = useI18n();
const { authState, refresh: refreshAuth, logout } = useAuthStore();
const nuxtApp = useNuxtApp();
const openSettingsModal = () => {
isSettingsModalOpen.value = true;
};
const closeSettingsModal = () => {
isSettingsModalOpen.value = false;
};
const handleLogout = async () => {
if (isLoggingOut.value) return;
isLoggingOut.value = true;
try {
await logout();
} finally {
isLoggingOut.value = false;
}
};
const playerScripts = [
"/script/jsonh.js",
"/script/bassoonplayer-min.js",
"/script/enum.js",
];
const loadScript = (src) =>
new Promise((resolve, reject) => {
if (document.querySelector(`script[data-player-src="${src}"]`)) {
resolve();
return;
}
const script = document.createElement("script");
script.src = src;
script.defer = true;
script.dataset.playerSrc = src;
script.onload = resolve;
script.onerror = () => reject(new Error(`Failed to load ${src}`));
document.body.appendChild(script);
});
await refreshAuth();
onMounted(async () => {
// Expose legacy interop helpers used by the player app logic
window.openSettingsModal = openSettingsModal;
window.closeSettingsModal = closeSettingsModal;
try {
for (const src of playerScripts) {
await loadScript(src);
}
const { setupPlayerApp } = await import("~/utils/player-app");
setupPlayerApp(nuxtApp);
} catch (error) {
console.error(error);
} finally {
isPlayerBooting.value = false;
}
});
</script>
<template>
<div class="flex flex-col gap-1 pb-20 pt-4">
<SettingsModal
:isOpen="isSettingsModalOpen"
:closeModal="closeSettingsModal"
/>
<InfoDrawer />
<main
class="max-w-[1200px] mt-4 mx-auto w-[calc(100%-3rem)] max-[720px]:w-[calc(100%-2rem)] grid gap-5 max-[720px]:mt-5"
>
<div
v-if="isPlayerBooting"
class="inline-flex items-center gap-2.5 rounded-md border border-border bg-surface-2/60 px-3 py-2 text-sm text-text-soft"
role="status"
aria-live="polite"
>
<span
class="inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"
aria-hidden="true"
></span>
<span>{{ t("common.loading", null, "正在初始化播放器...") }}</span>
</div>
<ChannelScopes />
<div
class="grid gap-5 md:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)] md:items-stretch"
style="min-width: 0"
>
<PlayerControls />
<PlaylistView @open-settings="openSettingsModal" />
</div>
</main>
</div>
</template>
+727
View File
@@ -0,0 +1,727 @@
<script setup>
import { ref, computed, onMounted, onBeforeUnmount, nextTick } from "vue";
import BaseSelect from "./BaseSelect.vue";
import FormatFilterPanel from "./FormatFilterPanel.vue";
defineEmits(["open-settings"]);
const { t } = useI18n();
const itemsPerPage = 50;
const source = ref("0");
const sort = ref("0");
const channels = ref("all");
const size = ref("all");
const isPlaylistLoading = ref(false);
const playlistMode = ref(0);
const playlistRef = ref(null);
let leftObserver;
let mediaQuery;
const syncHeight = () => {
if (!playlistRef.value) return;
if (!mediaQuery || !mediaQuery.matches) {
// 在移动端,设置最大高度为视口高度的 80%,确保有滚动
const vh = window.innerHeight;
playlistRef.value.style.maxHeight = `${Math.round(vh * 0.8)}px`;
playlistRef.value.style.height = "";
return;
}
const leftColumn = document.getElementById("cleftPart");
if (!leftColumn) {
playlistRef.value.style.height = "";
return;
}
// 确保元素已渲染且可见
const rect = leftColumn.getBoundingClientRect();
if (rect.height === 0) {
// 如果高度为0,说明元素可能还在动画中,延迟重试
setTimeout(() => syncHeight(), 100);
return;
}
playlistRef.value.style.height = `${Math.round(rect.height)}px`;
playlistRef.value.style.maxHeight = "";
};
const updateFromState = (state) => {
if (!state || typeof state !== "object") return;
if (typeof state.isPlaylistLoading === "boolean") {
isPlaylistLoading.value = state.isPlaylistLoading;
}
if (typeof state.playlistMode === "number") {
playlistMode.value = state.playlistMode;
}
};
const handlePlaylistLoading = (event) => updateFromState(event?.detail);
const syncFromWindowState = () => {
if (typeof window === "undefined") return;
updateFromState(window.__playerUiState);
};
onMounted(() => {
if (typeof window === "undefined") return;
syncFromWindowState();
window.addEventListener("player:playlist-loading", handlePlaylistLoading);
mediaQuery = window.matchMedia("(min-width: 768px)");
if (mediaQuery.addEventListener) {
mediaQuery.addEventListener("change", syncHeight);
} else {
mediaQuery.addListener(syncHeight);
}
const leftColumn = document.getElementById("cleftPart");
if (leftColumn && typeof ResizeObserver !== "undefined") {
leftObserver = new ResizeObserver(() => syncHeight());
leftObserver.observe(leftColumn);
} else {
window.addEventListener("resize", syncHeight);
}
// 等待 DOM 渲染和动画完成后再同步高度
// fadeUp 动画: 0.5s duration, PlaylistView delay: 0.1s, PlayerControls: 0s delay
// 使用 requestAnimationFrame 确保在下一帧执行
requestAnimationFrame(() => {
requestAnimationFrame(() => {
syncHeight();
// 动画完成后再次同步(0.5s + 0.1s + 缓冲)
setTimeout(() => {
syncHeight();
}, 700);
});
});
});
onBeforeUnmount(() => {
if (leftObserver) {
leftObserver.disconnect();
}
if (typeof window === "undefined") return;
window.removeEventListener("player:playlist-loading", handlePlaylistLoading);
if (mediaQuery) {
if (mediaQuery.removeEventListener) {
mediaQuery.removeEventListener("change", syncHeight);
} else {
mediaQuery.removeListener(syncHeight);
}
}
window.removeEventListener("resize", syncHeight);
});
const sourceOptions = computed(() => [
{ label: t("playlist.sourceAll"), value: "0" },
{ label: t("playlist.sourceFavorites"), value: "1" },
{ label: t("playlist.sourceHistory"), value: "2" },
]);
const isFilterMenuOpen = ref(false);
const trackerName = ref("");
const formatFilterRef = ref(null);
const searchText = ref("");
const sortOptions = computed(() => [
{ label: t("playlist.sortIdAsc", null, "ID 正序 (升序)"), value: "0" },
{ label: t("playlist.sortIdDesc", null, "ID 倒序 (降序)"), value: "1" },
{ label: t("playlist.sortTitleAsc", null, "标题 正序 (A-Z)"), value: "2" },
{ label: t("playlist.sortTitleDesc", null, "标题 倒序 (Z-A)"), value: "3" },
{ label: t("playlist.sortFilenameAsc", null, "文件名 正序 (A-Z)"), value: "4" },
{ label: t("playlist.sortFilenameDesc", null, "文件名 倒序 (Z-A)"), value: "5" },
{ label: t("playlist.sortSizeAsc", null, "文件大小 正序 (小到大)"), value: "6" },
{ label: t("playlist.sortSizeDesc", null, "文件大小 倒序 (大到小)"), value: "7" },
{ label: t("playlist.sortMtimeAsc", null, "修改时间 正序 (旧到新)"), value: "8" },
{ label: t("playlist.sortMtimeDesc", null, "修改时间 倒序 (新到旧)"), value: "9" },
]);
const hasActiveFilters = computed(() => {
return sort.value !== "0" ||
channels.value !== "all" ||
size.value !== "all" ||
(trackerName.value && trackerName.value.trim() !== "");
});
const onTrackerNameChange = () => {
const hiddenEl = document.getElementById("trackerNameInput");
if (hiddenEl) {
hiddenEl.dispatchEvent(new Event("change", { bubbles: true }));
}
};
const clearSearch = () => {
searchText.value = "";
nextTick(() => {
const input = document.getElementById("searchInput");
if (input) input.dispatchEvent(new Event("input", { bubbles: true }));
});
};
const clearTrackerName = () => {
trackerName.value = "";
onTrackerNameChange();
};
const clearAllFilters = () => {
sort.value = "0";
channels.value = "all";
size.value = "all";
trackerName.value = "";
if (formatFilterRef.value) {
formatFilterRef.value.resetToDefault();
}
nextTick(() => {
// Dispatch a single change event to trigger one server reload.
// All filter values are read from the DOM by loadSongsFromServer,
// and Vue has already updated all bound elements by this tick.
const sortSelect = document.getElementById("sortSelect");
if (sortSelect) sortSelect.dispatchEvent(new Event("change", { bubbles: true }));
});
};
const channelsOptions = computed(() => [
{ label: t("playlist.channelsAll", null, "全部通道"), value: "all" },
{ label: t("playlist.channels4", null, "4 通道"), value: "4" },
{ label: t("playlist.channels8", null, "8 通道"), value: "8" },
{ label: t("playlist.channelsMulti", null, "多通道 (>8)"), value: "multi" },
]);
const sizeOptions = computed(() => [
{ label: t("playlist.sizeAll", null, "全部大小"), value: "all" },
{ label: t("playlist.sizeSmall", null, "极小 (< 100KB)"), value: "small" },
{ label: t("playlist.sizeMedium", null, "中等 (100KB - 1MB)"), value: "medium" },
{ label: t("playlist.sizeLarge", null, "超大 (> 1MB)"), value: "large" },
]);
const playlistModeLabel = computed(() => {
switch (playlistMode.value) {
case 1:
return t("playlist.sourceFavorites");
case 2:
return t("playlist.sourceHistory");
default:
return t("playlist.sourceAll");
}
});
</script>
<template>
<section
ref="playlistRef"
class="card flex flex-col gap-4 min-h-0 overflow-hidden opacity-0 translate-y-4 animate-fadeUp [animation-delay:0.1s]"
style="min-width: 0;"
>
<div class="shrink-0 border-b border-border/30 pb-3.5">
<div class="flex flex-wrap items-center justify-between gap-3 min-w-0">
<!-- Left: List Source & Search input -->
<div class="flex flex-1 items-center gap-2 sm:gap-3 min-w-[200px]">
<div class="flex items-center gap-2 whitespace-nowrap shrink-0">
<BaseSelect
id="likeBoxBtn"
v-model="source"
:options="sourceOptions"
/>
<span
id="likeBoxSpinner"
class="hidden h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent text-text-soft"
aria-hidden="true"
></span>
</div>
<div class="flex-1 min-w-[120px] relative group">
<input
id="searchInput"
v-model="searchText"
type="text"
class="input-base w-full pl-10 pr-8 h-10 bg-surface-2/40 border-border/40 focus:bg-surface-2/60 transition-all text-sm"
:placeholder="t('playlist.searchPlaceholder')"
:aria-label="t('playlist.searchLabel')"
/>
<svg
class="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted group-focus-within:text-accent transition-colors"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<circle cx="11" cy="11" r="8" />
<line x1="21" y1="21" x2="16.65" y2="16.65" />
</svg>
<button
v-if="searchText"
@click="clearSearch"
type="button"
class="absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text cursor-pointer transition-colors"
>
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
</div>
</div>
<!-- Right: Toggle filters panel button -->
<button
type="button"
@click="isFilterMenuOpen = !isFilterMenuOpen"
class="flex items-center gap-2 px-3.5 h-10 rounded-lg border text-sm font-semibold transition-all cursor-pointer select-none active:scale-[0.98]"
:class="isFilterMenuOpen
? 'border-accent/40 bg-accent/[0.08] text-accent'
: 'border-border/80 bg-surface text-text-soft hover:text-text hover:border-border-strong hover:bg-surface-hover'"
>
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon>
</svg>
<span class="max-sm:hidden">{{ t('playlist.filterAndSort', null, '筛选与排序') }}</span>
<span
v-if="hasActiveFilters"
class="w-1.5 h-1.5 rounded-full bg-accent animate-pulse"
:title="t('playlist.filterActive')"
></span>
<svg
class="w-3.5 h-3.5 text-text-muted transition-transform duration-200"
:class="{ 'rotate-180': isFilterMenuOpen }"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 9 6 6 6-6" />
</svg>
</button>
</div>
<!-- Collapsible filters panel -->
<transition
enter-active-class="transition duration-200 ease-out"
enter-from-class="transform scale-y-95 opacity-0 max-h-0"
enter-to-class="transform scale-y-100 opacity-100 max-h-[500px]"
leave-active-class="transition duration-150 ease-in"
leave-from-class="transform scale-y-100 opacity-100 max-h-[500px]"
leave-to-class="transform scale-y-95 opacity-0 max-h-0"
>
<div
v-show="isFilterMenuOpen"
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mt-3.5 p-4 rounded-xl border border-border/40 bg-surface-2/20 backdrop-blur-xs overflow-hidden origin-top"
>
<!-- Sort -->
<div class="flex flex-col gap-1.5">
<label class="text-[0.68rem] font-bold uppercase tracking-[0.15em] text-text-muted/80">
{{ t("playlist.sortLabel") }}
</label>
<BaseSelect id="sortSelect" v-model="sort" :options="sortOptions" class="w-full" />
</div>
<!-- Format (multi-select panel) -->
<div class="flex flex-col gap-1.5">
<label class="text-[0.68rem] font-bold uppercase tracking-[0.15em] text-text-muted/80">
{{ t("playlist.formatLabel", null, "格式") }}
</label>
<FormatFilterPanel ref="formatFilterRef" />
</div>
<!-- Channels -->
<div class="flex flex-col gap-1.5">
<label class="text-[0.68rem] font-bold uppercase tracking-[0.15em] text-text-muted/80">
{{ t("playlist.channelsLabel", null, "声道") }}
</label>
<BaseSelect id="channelsSelect" v-model="channels" :options="channelsOptions" class="w-full" />
</div>
<!-- Size -->
<div class="flex flex-col gap-1.5">
<label class="text-[0.68rem] font-bold uppercase tracking-[0.15em] text-text-muted/80">
{{ t("playlist.sizeLabel", null, "大小") }}
</label>
<BaseSelect id="sizeSelect" v-model="size" :options="sizeOptions" class="w-full" />
</div>
<!-- Tracker Name Filter -->
<div class="flex flex-col gap-1.5 sm:col-span-2">
<label class="text-[0.68rem] font-bold uppercase tracking-[0.15em] text-text-muted/80 flex items-center justify-between">
<span>{{ t("playlist.trackerNameLabel", null, "Tracker 名称") }}</span>
<button
v-if="trackerName"
@click="clearTrackerName"
type="button"
class="text-[0.62rem] text-accent hover:underline lowercase font-bold transition-all"
>
{{ t('playlist.clearFilter') }}
</button>
</label>
<div class="relative w-full">
<input
id="trackerNameInput"
v-model="trackerName"
@keyup.enter="onTrackerNameChange"
type="text"
class="input-base w-full h-10 bg-surface pl-3 pr-8 border border-border/40 focus:border-accent/40 focus:bg-surface-2/40 transition-all text-sm rounded-lg"
:placeholder="t('playlist.trackerNamePlaceholder')"
list="trackerNameList"
/>
<datalist id="trackerNameList">
<option value="FastTracker II" />
<option value="MilkyTracker" />
<option value="OpenMPT" />
<option value="Scream Tracker 3" />
<option value="Protracker" />
<option value="MadTracker 2.0" />
<option value="Impulse Tracker" />
</datalist>
<button
v-if="trackerName"
@click="clearTrackerName"
type="button"
class="absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text cursor-pointer transition-colors"
>
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
</div>
</div>
<!-- Clear all filters -->
<div
v-if="hasActiveFilters"
class="col-span-full flex justify-end border-t border-border/30 pt-3 mt-1"
>
<button
type="button"
@click="clearAllFilters"
class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-text-soft hover:text-accent hover:bg-accent/[0.08] transition-all cursor-pointer select-none active:scale-[0.97]"
>
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
<path d="M3 3v5h5" />
</svg>
<span>{{ t('playlist.clearAllFilters', null, '清除筛选') }}</span>
</button>
</div>
</div>
</transition>
</div>
<div class="flex flex-col flex-1 min-h-0 gap-2.5">
<div
class="hidden sm:flex items-center justify-between gap-3 rounded-md border border-border/70 bg-surface-2/60 px-3 py-2 text-[0.78rem] font-semibold text-text-soft shrink-0"
role="status"
aria-live="polite"
>
<div class="flex items-center gap-2">
<span
class="text-[0.68rem] uppercase tracking-[0.12em] text-text-soft"
>
{{ t("playlist.playlistLabel") }}
</span>
<span class="h-1 w-1 rounded-full bg-border-strong/80"></span>
<span id="pageRangeSummary" class="text-text-muted">
{{ t("playlist.pageRangeEmpty") }}
</span>
<span class="h-1 w-1 rounded-full bg-border-strong/80"></span>
<span class="text-text-muted">{{ playlistModeLabel }}</span>
<span
v-if="isPlaylistLoading"
class="playlist-loading-chip"
role="status"
aria-live="polite"
>
<span class="playlist-spinner" aria-hidden="true"></span>
<span>{{ t("player.loadingSongShort") }}</span>
</span>
</div>
<div class="flex items-center gap-2">
<span
class="text-[0.66rem] uppercase tracking-[0.12em] text-text-soft"
>
{{ t("playlist.rowsLabel") }}
</span>
<span class="font-bold text-text">
{{ t("playlist.rowsPerPage", { count: itemsPerPage }) }}
</span>
</div>
</div>
<div
class="flex-1 min-h-0 overflow-y-auto overflow-x-hidden rounded-md border border-border bg-surface-2/40 webkit-overflow-scrolling-touch"
:aria-busy="isPlaylistLoading ? 'true' : 'false'"
style="max-width: 100%;"
>
<table
id="playlist"
class="w-full table-fixed border-collapse text-[0.9rem] [&_th]:text-left [&_th]:text-[0.7rem] [&_th]:uppercase [&_th]:tracking-[0.12em] [&_th]:text-text-soft [&_th]:py-2.5 [&_th]:px-4 [&_th]:border-b [&_th]:border-border [&_th]:font-semibold [&_th]:sticky [&_th]:top-0 [&_th]:bg-surface-2 [&_th]:z-10 [&_th:first-child]:w-[70px] [&_th:first-child]:sm:w-[80px] [&_td:first-child]:w-[70px] [&_td:first-child]:sm:w-[80px] [&_td]:py-2 [&_td]:px-4 [&_td]:border-b [&_td]:border-border-light/50 [&_td:nth-child(2)]:overflow-hidden [&_tr]:transition-all [&_tr]:duration-150 [&_tbody_tr]:cursor-pointer [&_tbody_tr:hover]:bg-accent/[0.12] [&_tbody_tr:hover]:shadow-sm [&_tbody_tr:hover]:scale-[1.002] [&_tbody_tr:hover]:-translate-y-px [&_tbody_tr:active]:bg-accent/[0.18] [&_tbody_tr:active]:scale-[0.998]"
style="max-width: 100%;"
>
<colgroup>
<col class="w-[70px] sm:w-[80px]" />
<col />
</colgroup>
<thead>
<tr>
<th>{{ t("playlist.tableNo") }}</th>
<th>{{ t("playlist.tableSongInfo", null, "歌曲信息") }}</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<nav
id="playlistPager"
class="pagination flex items-center justify-center gap-1 sm:gap-1.5 shrink-0 border-t border-border/70 pt-3"
:aria-label="t('playlist.pager.aria')"
>
<!-- Left button group: jump back 10, previous -->
<button
id="pageMinus10"
data-page-step="-10"
type="button"
class="pager-btn"
:aria-label="t('playlist.pager.back10')"
>
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="m11 17-5-5 5-5" />
<path d="m18 17-5-5 5-5" />
</svg>
</button>
<button
id="pagePrev"
data-page-step="-1"
type="button"
class="pager-btn"
:aria-label="t('playlist.pager.prev')"
>
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="m15 18-6-6 6-6" />
</svg>
</button>
<!-- Center: compact page indicator -->
<div class="flex items-center gap-1 rounded-md bg-surface-2/60 px-2.5 py-1.5">
<input
type="number"
inputmode="numeric"
min="1"
step="1"
class="h-7 w-11 sm:w-14 rounded border-0 bg-transparent text-center text-sm font-bold text-text [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none focus:outline-none focus:ring-1 focus:ring-accent/40 focus:ring-offset-0"
id="pageInput"
:aria-label="t('playlist.pager.currentPage')"
/>
<span class="text-sm font-bold text-text-soft whitespace-nowrap min-w-[2ch] text-center" id="totalPages">
<span
id="loading001"
class="hidden h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"
role="status"
aria-hidden="true"
></span>
</span>
</div>
<!-- Right button group: next, jump forward 10 -->
<button
id="pageNext"
data-page-step="1"
type="button"
class="pager-btn"
:aria-label="t('playlist.pager.next')"
>
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="m9 18 6-6-6-6" />
</svg>
</button>
<button
id="pagePlus10"
data-page-step="10"
type="button"
class="pager-btn"
:aria-label="t('playlist.pager.forward10')"
>
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="m13 7 5 5-5 5" />
<path d="m6 7 5 5-5 5" />
</svg>
</button>
</nav>
</section>
</template>
<style scoped>
.pager-btn {
display: inline-flex;
align-items: center;
justify-content: center;
height: 2rem;
width: 2rem;
border-radius: 0.375rem;
border: 1px solid var(--border);
background: var(--surface);
color: var(--text);
cursor: pointer;
transition: all 0.15s;
flex-shrink: 0;
}
.pager-btn:hover:not(:disabled) {
border-color: var(--border-strong);
background: var(--surface-hover);
box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.pager-btn:active:not(:disabled) {
transform: scale(0.96);
}
.pager-btn:focus-visible {
outline: none;
box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent), 0 0 0 1px var(--surface);
}
.pager-btn:disabled {
opacity: 0.4;
cursor: not-allowed;
}
.playlist-loading-chip {
display: inline-flex;
align-items: center;
gap: 0.35rem;
padding: 0.18rem 0.55rem;
border-radius: 999px;
border: 1px solid var(--border);
background: var(--surface);
color: var(--text-soft);
font-size: 0.62rem;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.playlist-spinner {
width: 10px;
height: 10px;
border-radius: 999px;
border: 2px solid currentColor;
border-top-color: transparent;
animation: spin 0.8s linear infinite;
/* 使用 GPU 加速 */
will-change: transform;
transform: translateZ(0);
}
@keyframes spin {
to {
transform: rotate(360deg) translateZ(0);
}
}
/* 性能优化:使用 contain 限制布局和绘制范围 */
.card {
contain: layout style;
}
/* 优化表格渲染性能 */
#playlist {
contain: layout style paint;
/* 启用硬件加速 */
transform: translateZ(0);
will-change: contents;
}
/* 优化滚动性能 */
#playlist tbody {
contain: layout style;
}
/* 为表格行添加优化 */
#playlist tbody tr {
contain: layout style;
/* 使用 GPU 加速过渡效果 */
will-change: background-color, transform;
position: relative;
transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
/* 为表格行添加边框高亮效果 */
#playlist tbody tr::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
background: var(--accent);
opacity: 0;
transition: opacity 0.15s ease;
}
/* 增强的 hover 效果 */
#playlist tbody tr:hover {
background: linear-gradient(
90deg,
rgb(var(--accent-rgb) / 0.08),
rgb(var(--accent-rgb) / 0.12),
rgb(var(--accent-rgb) / 0.08)
);
box-shadow:
0 2px 8px -2px rgb(var(--accent-rgb) / 0.15),
inset 0 0 0 1px rgb(var(--accent-rgb) / 0.1);
}
#playlist tbody tr:hover::before {
opacity: 1;
}
#playlist tbody tr:hover td {
color: var(--text);
}
#playlist tbody tr:hover td:first-child {
font-weight: 600;
color: var(--accent);
}
#playlist tbody tr:hover td:nth-child(2) {
color: var(--text);
font-weight: 500;
}
/* 激活状态 */
#playlist tbody tr:active {
transform: scale(0.998) translateY(1px);
background: rgb(var(--accent-rgb) / 0.16);
box-shadow:
0 1px 4px -1px rgb(var(--accent-rgb) / 0.2),
inset 0 0 0 1px rgb(var(--accent-rgb) / 0.15);
}
/* 平滑的文本过渡 */
#playlist tbody tr td {
transition: all 0.15s ease;
}
/* 移动端滚动优化 */
@media (max-width: 767px) {
.webkit-overflow-scrolling-touch {
-webkit-overflow-scrolling: touch;
scroll-behavior: smooth;
}
/* 确保在移动端显示滚动条 */
.webkit-overflow-scrolling-touch::-webkit-scrollbar {
width: 8px;
}
.webkit-overflow-scrolling-touch::-webkit-scrollbar-track {
background: var(--scrollbar-track);
}
.webkit-overflow-scrolling-touch::-webkit-scrollbar-thumb {
background: var(--scrollbar-thumb);
border-radius: 4px;
}
.webkit-overflow-scrolling-touch::-webkit-scrollbar-thumb:hover {
background: var(--border-strong);
}
}
</style>
+212
View File
@@ -0,0 +1,212 @@
<script setup>
defineProps({
mode: {
type: String,
default: "card",
validator: (value) => ["card", "background"].includes(value),
},
});
</script>
<template>
<div
id="scope"
:class="[
'relative overflow-hidden',
mode === 'card'
? 'scope-card card p-3.5 opacity-0 translate-y-4 animate-fadeUp [animation-delay:0.05s] hover:shadow-card-hover'
: 'scope-bg',
]"
:data-mode="mode"
>
<span class="scope-corner scope-corner--tl" aria-hidden="true"></span>
<span class="scope-corner scope-corner--tr" aria-hidden="true"></span>
<span class="scope-corner scope-corner--bl" aria-hidden="true"></span>
<span class="scope-corner scope-corner--br" aria-hidden="true"></span>
<canvas
id="scopeCanvas"
:class="
mode === 'card'
? 'w-full h-[110px] block rounded-sm relative z-[1]'
: 'scope-bg-canvas'
"
:data-fill="mode === 'background' ? 'true' : 'false'"
></canvas>
<!-- Inactive label overlay (used by WebGL mode since WebGL can't draw text) -->
<span
id="scopeInactiveLabel"
class="scope-inactive-label"
style="display: none"
></span>
</div>
</template>
<style scoped>
.scope-card {
background:
radial-gradient(
120% 90% at 50% 110%,
color-mix(in srgb, var(--scope-waveform, #34d399) 14%, transparent) 0%,
transparent 55%
),
radial-gradient(
90% 60% at 0% 0%,
color-mix(in srgb, var(--scope-spectrum-start, #3b82f6) 10%, transparent)
0%,
transparent 60%
),
linear-gradient(
180deg,
color-mix(in srgb, var(--surface-2, #0b0f17) 92%, transparent),
color-mix(in srgb, var(--surface-3, #111827) 78%, transparent)
);
}
.scope-card::before {
content: "";
position: absolute;
inset: 12px;
border-radius: 4px;
pointer-events: none;
background-image: repeating-linear-gradient(
to right,
color-mix(
in srgb,
var(--border, rgba(255, 255, 255, 0.06)) 60%,
transparent
)
0 1px,
transparent 1px calc(100% / 8)
);
opacity: 0.18;
z-index: 0;
}
/* Background mode: scope occupies a top strip (less than half the card) */
.scope-bg {
position: absolute;
inset: 0 0 auto 0;
height: 48%;
min-height: 70px;
max-height: 220px;
z-index: 0;
pointer-events: none;
border-top-left-radius: inherit;
border-top-right-radius: inherit;
border-bottom: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
background: radial-gradient(
130% 100% at 50% -10%,
color-mix(in srgb, var(--scope-spectrum-start, #3b82f6) 8%, transparent) 0%,
transparent 70%
);
}
.scope-bg::before {
content: "";
position: absolute;
inset: 10px;
border-radius: 6px;
pointer-events: none;
background-image: repeating-linear-gradient(
to right,
color-mix(
in srgb,
var(--border, rgba(255, 255, 255, 0.06)) 30%,
transparent
)
0 1px,
transparent 1px calc(100% / 8)
);
opacity: 0.06;
z-index: 0;
}
.scope-bg-canvas {
position: absolute !important;
inset: 0;
width: 100% !important;
height: 100% !important;
display: block;
z-index: 1;
opacity: 0.5;
mix-blend-mode: screen;
}
@media (prefers-color-scheme: light) {
.scope-bg-canvas {
mix-blend-mode: multiply;
opacity: 0.4;
}
}
.scope-bg::after {
content: "";
position: absolute;
inset: 0;
pointer-events: none;
background: linear-gradient(
180deg,
color-mix(in srgb, var(--surface) 0%, transparent) 0%,
color-mix(in srgb, var(--surface) 0%, transparent) 100%
);
z-index: 2;
}
.scope-corner {
position: absolute;
width: 10px;
height: 10px;
pointer-events: none;
z-index: 3;
border-color: color-mix(
in srgb,
var(--scope-waveform, #34d399) 70%,
transparent
);
}
.scope-bg .scope-corner {
width: 12px;
height: 12px;
border-color: color-mix(
in srgb,
var(--scope-waveform, #34d399) 25%,
transparent
);
}
.scope-corner--tl {
top: 8px;
left: 8px;
border-top: 1px solid;
border-left: 1px solid;
}
.scope-corner--tr {
top: 8px;
right: 8px;
border-top: 1px solid;
border-right: 1px solid;
}
.scope-corner--bl {
bottom: 8px;
left: 8px;
border-bottom: 1px solid;
border-left: 1px solid;
}
.scope-corner--br {
bottom: 8px;
right: 8px;
border-bottom: 1px solid;
border-right: 1px solid;
}
/* Inactive label overlay (WebGL mode — WebGL can't draw text) */
.scope-inactive-label {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
color: var(--text-soft, #94a3b8);
opacity: 0.55;
pointer-events: none;
z-index: 3;
text-transform: lowercase;
letter-spacing: 0.1em;
}
</style>
+245
View File
@@ -0,0 +1,245 @@
<script setup>
/**
* SettingsBody — reusable settings form.
* Used by SettingsModal and InfoDrawer.
*/
import { nextTick, ref, onMounted, onUnmounted } from "vue";
const props = defineProps({
active: { type: Boolean, default: true },
});
const { t } = useI18n();
function readSetting(key, fallback = true) {
try {
const s = JSON.parse(localStorage.getItem("player_settings") || "{}");
return key in s ? !!s[key] : fallback;
} catch { return fallback; }
}
function readSettingNum(key, fallback = 0) {
try {
const s = JSON.parse(localStorage.getItem("player_settings") || "{}");
return key in s ? Number(s[key]) : fallback;
} catch { return fallback; }
}
function applyGeneral(key, value) {
if (typeof window !== "undefined" && window.applyGeneralSettings) {
window.applyGeneralSettings({ [key]: value });
} else {
try {
const s = JSON.parse(localStorage.getItem("player_settings") || "{}");
s[key] = value;
localStorage.setItem("player_settings", JSON.stringify(s));
} catch {}
}
}
// ── Oscilloscope ────────────────────────────────────────────────────
const scopeHistogram = ref(readSetting("setScope", true));
const scopeTotal = ref(readSetting("setTotalScope", false));
const scopeChannels = ref(readSetting("setChannelScope", true));
function applyScopeToggles() {
if (typeof window !== "undefined" && window.applyScopeSettings) {
window.applyScopeSettings(scopeHistogram.value, scopeTotal.value, scopeChannels.value);
} else {
try {
const s = JSON.parse(localStorage.getItem("player_settings") || "{}");
s.setScope = scopeHistogram.value;
s.setTotalScope = scopeTotal.value;
s.setChannelScope = scopeChannels.value;
localStorage.setItem("player_settings", JSON.stringify(s));
} catch {}
window.dispatchEvent(new CustomEvent("player:scope-settings", {
detail: { showTotal: scopeTotal.value, showChannels: scopeChannels.value },
}));
const scopeEl = document.getElementById("scope");
if (scopeEl) scopeEl.style.display = scopeHistogram.value ? "" : "none";
}
}
function toggleScope(w) {
if (w === "histogram") scopeHistogram.value = !scopeHistogram.value;
if (w === "total") scopeTotal.value = !scopeTotal.value;
if (w === "channels") scopeChannels.value = !scopeChannels.value;
applyScopeToggles();
}
// ── Display ─────────────────────────────────────────────────────────
const showPattern = ref(readSetting("setPattern", true));
const showIntro = ref(readSetting("setIntroduce", true));
function toggleShowPattern() { showPattern.value = !showPattern.value; applyGeneral("setPattern", showPattern.value); }
function toggleShowIntro() { showIntro.value = !showIntro.value; applyGeneral("setIntroduce", showIntro.value); }
// ── Playback ────────────────────────────────────────────────────────
const forceVolume = ref(readSetting("forcedVolume", false));
const defaultVolume = ref(readSettingNum("setVolume", 40));
const maxLoop = ref(readSettingNum("setLooptimes", 2));
const loudnessEq = ref(readSetting("loudnessEq", false));
function toggleForceVolume() { forceVolume.value = !forceVolume.value; applyGeneral("forcedVolume", forceVolume.value); }
function toggleLoudnessEq() { loudnessEq.value = !loudnessEq.value; applyGeneral("loudnessEq", loudnessEq.value); }
function onVolumeChange() { const v = Math.max(0, Math.min(100, Number(defaultVolume.value) || 0)); defaultVolume.value = v; applyGeneral("setVolume", v); }
function onLoopChange() { const v = Math.max(0, Math.min(100, Number(maxLoop.value) || 0)); maxLoop.value = v; applyGeneral("setLooptimes", v); }
// ── Engine ──────────────────────────────────────────────────────────
const selectedEngine = ref(readSettingNum("setEngine", 2));
function onEngineChange() { const v = Math.max(1, Math.min(3, Number(selectedEngine.value) || 2)); selectedEngine.value = v; applyGeneral("setEngine", v); }
// ── Actions ─────────────────────────────────────────────────────────
function onResetSettings() { if (window.resetSettings) window.resetSettings(); nextTick(() => syncFromStorage()); }
// ── Sync ────────────────────────────────────────────────────────────
function syncFromStorage() {
scopeHistogram.value = readSetting("setScope", true);
scopeTotal.value = readSetting("setTotalScope", false);
scopeChannels.value = readSetting("setChannelScope", true);
showPattern.value = readSetting("setPattern", true);
showIntro.value = readSetting("setIntroduce", true);
forceVolume.value = readSetting("forcedVolume", false);
defaultVolume.value = readSettingNum("setVolume", 10);
maxLoop.value = readSettingNum("setLooptimes", 2);
loudnessEq.value = readSetting("loudnessEq", false);
selectedEngine.value = readSettingNum("setEngine", 2);
}
const handleScopeSettingsEvent = (e) => {
if (!e?.detail) return;
if ("showHistogram" in e.detail) scopeHistogram.value = !!e.detail.showHistogram;
if ("showTotal" in e.detail) scopeTotal.value = !!e.detail.showTotal;
if ("showChannels" in e.detail) scopeChannels.value = !!e.detail.showChannels;
};
onMounted(() => {
window.addEventListener("player:scope-settings", handleScopeSettingsEvent);
if (props.active) syncFromStorage();
});
onUnmounted(() => {
window.removeEventListener("player:scope-settings", handleScopeSettingsEvent);
});
</script>
<template>
<div class="sb-root">
<!-- Oscilloscope -->
<section class="sb-section">
<div class="sb-label">
<svg width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M1 8 Q3 3 5 8 Q7 13 9 8 Q11 3 13 8 Q14.5 11 15 8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" fill="none"/></svg>
Oscilloscope
</div>
<div class="scope-cards">
<button type="button" class="scope-card" :class="{ 'scope-card--on': scopeHistogram }" @click="toggleScope('histogram')" :aria-pressed="scopeHistogram">
<div class="scope-card-preview"><svg viewBox="0 0 80 40" preserveAspectRatio="none" aria-hidden="true"><defs><linearGradient id="hg1" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="var(--scope-spectrum-start,#3b82f6)" stop-opacity="0.85"/><stop offset="100%" stop-color="var(--scope-spectrum-end,#8b5cf6)" stop-opacity="0.3"/></linearGradient></defs><rect x="1" y="14" width="5" height="26" rx="1.5" fill="url(#hg1)"/><rect x="8" y="6" width="5" height="34" rx="1.5" fill="url(#hg1)"/><rect x="15" y="10" width="5" height="30" rx="1.5" fill="url(#hg1)"/><rect x="22" y="2" width="5" height="38" rx="1.5" fill="url(#hg1)"/><rect x="29" y="8" width="5" height="32" rx="1.5" fill="url(#hg1)"/><rect x="36" y="18" width="5" height="22" rx="1.5" fill="url(#hg1)"/><rect x="43" y="12" width="5" height="28" rx="1.5" fill="url(#hg1)"/><rect x="50" y="22" width="5" height="18" rx="1.5" fill="url(#hg1)"/><rect x="57" y="26" width="5" height="14" rx="1.5" fill="url(#hg1)"/><rect x="64" y="30" width="5" height="10" rx="1.5" fill="url(#hg1)"/><rect x="71" y="33" width="5" height="7" rx="1.5" fill="url(#hg1)"/></svg></div>
<div class="scope-card-meta"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" aria-hidden="true"><rect x="0.5" y="6" width="3" height="7" rx="0.75" fill="currentColor" opacity="0.7"/><rect x="5" y="3" width="3" height="10" rx="0.75" fill="currentColor"/><rect x="9.5" y="8" width="3" height="5" rx="0.75" fill="currentColor" opacity="0.6"/></svg><span class="scope-card-name">Spectrum</span><span class="scope-card-dot" :class="scopeHistogram ? 'on' : 'off'"/></div>
</button>
<button type="button" class="scope-card" :class="{ 'scope-card--on': scopeTotal }" @click="toggleScope('total')" :aria-pressed="scopeTotal">
<div class="scope-card-preview"><svg viewBox="0 0 80 40" preserveAspectRatio="none" aria-hidden="true"><defs><linearGradient id="wg1" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="var(--scope-waveform,#34d399)" stop-opacity="0.55"/><stop offset="50%" stop-color="var(--scope-waveform,#34d399)" stop-opacity="0.06"/><stop offset="100%" stop-color="var(--scope-waveform,#34d399)" stop-opacity="0.55"/></linearGradient></defs><line x1="0" y1="20" x2="80" y2="20" stroke="rgba(255,255,255,0.08)" stroke-width="1"/><path d="M0,20 Q5,9 10,15 Q15,21 20,11 Q25,1 30,12 Q35,23 40,10 Q45,0 50,13 Q55,26 60,16 Q65,6 70,18 Q75,28 80,20 L80,20 Q75,32 70,22 Q65,14 60,24 Q55,34 50,27 Q45,20 40,30 Q35,37 30,28 Q25,19 20,29 Q15,39 10,25 Q5,31 0,20Z" fill="url(#wg1)"/><path d="M0,20 Q5,9 10,15 Q15,21 20,11 Q25,1 30,12 Q35,23 40,10 Q45,0 50,13 Q55,26 60,16 Q65,6 70,18 Q75,28 80,20" stroke="var(--scope-waveform,#34d399)" stroke-width="1.5" fill="none" stroke-linecap="round"/></svg></div>
<div class="scope-card-meta"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" aria-hidden="true"><path d="M0,6.5 Q2,2 4,6.5 Q6,11 8,6.5 Q10,2 13,6.5" stroke="currentColor" stroke-width="1.4" fill="none" stroke-linecap="round"/></svg><span class="scope-card-name">CH SUM</span><span class="scope-card-dot" :class="scopeTotal ? 'on' : 'off'"/></div>
</button>
<button type="button" class="scope-card" :class="{ 'scope-card--on': scopeChannels }" @click="toggleScope('channels')" :aria-pressed="scopeChannels">
<div class="scope-card-preview"><svg viewBox="0 0 80 40" preserveAspectRatio="none" aria-hidden="true"><rect x="0" y="0" width="24" height="18" rx="2" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="0.5"/><path d="M2,9 Q5,4 8,9 Q11,14 14,9 Q18,4 22,9" stroke="var(--scope-waveform,#34d399)" stroke-width="1" fill="none" opacity="0.8"/><rect x="28" y="0" width="24" height="18" rx="2" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="0.5"/><path d="M30,9 Q33,6 36,9 Q39,12 42,9 Q45,6 50,9" stroke="var(--scope-waveform,#34d399)" stroke-width="1" fill="none" opacity="0.6"/><rect x="56" y="0" width="24" height="18" rx="2" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="0.5"/><path d="M58,9 Q61,5 64,9 Q67,13 70,9 Q73,5 78,8" stroke="var(--scope-waveform,#34d399)" stroke-width="1" fill="none" opacity="0.9"/><rect x="0" y="22" width="24" height="18" rx="2" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="0.5"/><path d="M2,31 Q6,27 10,31 Q14,35 18,31 Q21,28 22,31" stroke="var(--scope-waveform,#34d399)" stroke-width="1" fill="none" opacity="0.5"/><rect x="28" y="22" width="24" height="18" rx="2" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="0.5"/><path d="M30,31 Q34,28 38,31 Q42,34 46,31 Q49,29 50,31" stroke="var(--scope-waveform,#34d399)" stroke-width="1" fill="none" opacity="0.75"/><rect x="56" y="22" width="24" height="18" rx="2" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="0.5"/><path d="M58,31 Q62,26 66,31 Q70,36 74,31 Q77,28 78,30" stroke="var(--scope-waveform,#34d399)" stroke-width="1" fill="none" opacity="0.65"/></svg></div>
<div class="scope-card-meta"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" aria-hidden="true"><rect x="0" y="0" width="5.5" height="5.5" rx="1" fill="currentColor" opacity="0.7"/><rect x="7.5" y="0" width="5.5" height="5.5" rx="1" fill="currentColor"/><rect x="0" y="7.5" width="5.5" height="5.5" rx="1" fill="currentColor" opacity="0.5"/><rect x="7.5" y="7.5" width="5.5" height="5.5" rx="1" fill="currentColor" opacity="0.85"/></svg><span class="scope-card-name">Channels</span><span class="scope-card-dot" :class="scopeChannels ? 'on' : 'off'"/></div>
</button>
</div>
</section>
<!-- Display -->
<section class="sb-section">
<div class="sb-label"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" aria-hidden="true"><rect x="2" y="3" width="20" height="14" rx="2" stroke="currentColor" stroke-width="2"/><path d="M8 21h8M12 17v4" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg> Display</div>
<div class="sb-rows">
<div class="sb-row"><span class="sb-row-label">{{ t("settings.table.showPattern") }}</span><button type="button" class="sb-toggle" :class="{ 'sb-toggle--on': showPattern }" @click="toggleShowPattern" :aria-checked="showPattern" role="switch"><span class="sb-toggle-thumb"/></button></div>
<div class="sb-row"><span class="sb-row-label">{{ t("settings.table.showIntro") }}</span><button type="button" class="sb-toggle" :class="{ 'sb-toggle--on': showIntro }" @click="toggleShowIntro" :aria-checked="showIntro" role="switch"><span class="sb-toggle-thumb"/></button></div>
</div>
</section>
<!-- Playback -->
<section class="sb-section">
<div class="sb-label"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" aria-hidden="true"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M10 8l6 4-6 4V8z" fill="currentColor"/></svg> Playback</div>
<div class="sb-rows">
<div class="sb-row"><span class="sb-row-label">{{ t("settings.table.forceVolume") }}</span><button type="button" class="sb-toggle" :class="{ 'sb-toggle--on': forceVolume }" @click="toggleForceVolume" :aria-checked="forceVolume" role="switch"><span class="sb-toggle-thumb"/></button></div>
<div class="sb-row"><span class="sb-row-label">{{ t("settings.table.defaultVolume") }}</span><input type="number" class="sb-num" v-model.number="defaultVolume" min="0" max="100" @change="onVolumeChange"/></div>
<div class="sb-row"><span class="sb-row-label">{{ t("settings.table.maxLoop") }}</span><input type="number" class="sb-num" v-model.number="maxLoop" min="0" max="100" @change="onLoopChange"/></div>
<div class="sb-row"><span class="sb-row-label">{{ t("settings.table.loudnessEq") }}</span><button type="button" class="sb-toggle" :class="{ 'sb-toggle--on': loudnessEq }" @click="toggleLoudnessEq" :aria-checked="loudnessEq" role="switch"><span class="sb-toggle-thumb"/></button></div>
</div>
</section>
<!-- Engine -->
<section class="sb-section">
<div class="sb-label"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> {{ t("settings.engine") }}</div>
<p class="sb-hint">{{ t("settings.engineDesc") }}</p>
<div class="engine-cards">
<button type="button" class="engine-card" :class="{ 'engine-card--on': selectedEngine === 1 }" @click="selectedEngine = 1; onEngineChange()" :aria-pressed="selectedEngine === 1"><div class="engine-card-meta"><span class="engine-card-name">{{ t("settings.engines.bassoon") }}</span><span class="engine-card-badge">1</span></div><span class="engine-card-desc">{{ t("settings.engines.bassoonDesc") }}</span><span class="engine-card-dot" :class="selectedEngine === 1 ? 'on' : 'off'"/></button>
<button type="button" class="engine-card" :class="{ 'engine-card--on': selectedEngine === 2 }" @click="selectedEngine = 2; onEngineChange()" :aria-pressed="selectedEngine === 2"><div class="engine-card-meta"><span class="engine-card-name">{{ t("settings.engines.chiptune3") }}</span><span class="engine-card-badge engine-card-badge--rec">★ {{ t("settings.engines.chiptune3Badge") }}</span></div><span class="engine-card-desc">{{ t("settings.engines.chiptune3Desc") }}</span><span class="engine-card-dot" :class="selectedEngine === 2 ? 'on' : 'off'"/></button>
<button type="button" class="engine-card" :class="{ 'engine-card--on': selectedEngine === 3 }" @click="selectedEngine = 3; onEngineChange()" :aria-pressed="selectedEngine === 3"><div class="engine-card-meta"><span class="engine-card-name">{{ t("settings.engines.ffmpeg") }}</span><span class="engine-card-badge">3</span></div><span class="engine-card-desc">{{ t("settings.engines.ffmpegDesc") }}</span><span class="engine-card-dot" :class="selectedEngine === 3 ? 'on' : 'off'"/></button>
</div>
</section>
<!-- Actions -->
<section class="sb-section">
<div class="sb-label"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg> Actions</div>
<div class="flex flex-col gap-2">
<button class="btn-base btn-ghost justify-start" type="button" @click="onResetSettings"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="flex-shrink-0"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M3 3v5h5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> {{ t("settings.actions.restoreDefaults") }}</button>
<button class="btn-base btn-ghost justify-start" type="button" onclick="clearHistory()"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="flex-shrink-0"><path d="M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> {{ t("settings.actions.clearHistory") }}</button>
<button class="btn-base btn-ghost justify-start" type="button" onclick="clearCachedPlaylist()"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="flex-shrink-0"><path d="M4 7h16M4 12h16M4 17h16" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="20" cy="17" r="3" fill="currentColor" opacity="0.3"/><path d="M19 16l2 2M21 16l-2 2" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg> {{ t("settings.actions.clearCache") }}</button>
</div>
</section>
</div>
</template>
<style scoped>
.sb-root { display: flex; flex-direction: column; gap: 22px; }
.sb-section { display: flex; flex-direction: column; gap: 10px; }
.sb-label { display: flex; align-items: center; gap: 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-soft); }
.sb-hint { margin: 0; font-size: 0.72rem; color: var(--text-soft); line-height: 1.5; }
.sb-rows { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.sb-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.sb-row:last-child { border-bottom: none; }
.sb-row-label { font-size: 0.82rem; font-weight: 500; color: var(--text); }
.sb-toggle { position: relative; width: 38px; height: 22px; border-radius: 11px; background: color-mix(in srgb, var(--text-soft) 30%, var(--border)); border: none; cursor: pointer; flex-shrink: 0; transition: background 160ms; padding: 0; }
.sb-toggle--on { background: var(--accent, #3b82f6); }
.sb-toggle-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 160ms cubic-bezier(0.34,1.56,0.64,1); }
.sb-toggle--on .sb-toggle-thumb { transform: translateX(16px); }
.sb-num { width: 68px; padding: 5px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-3, var(--surface-2)); color: var(--text); font-size: 0.82rem; text-align: right; outline: none; transition: border-color 150ms; font-family: ui-monospace,"Fira Code",SFMono-Regular,monospace; }
.sb-num:focus { border-color: var(--accent, #3b82f6); }
.sb-num::-webkit-inner-spin-button, .sb-num::-webkit-outer-spin-button { opacity: 0.4; }
/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
.sb-root { gap: 18px; }
.scope-cards { grid-template-columns: 1fr; gap: 6px; }
.scope-card-meta { font-size: 0.72rem; padding: 7px 10px; }
.sb-row { padding: 10px 12px; gap: 8px; }
.sb-row-label { font-size: 0.78rem; }
.engine-card { padding: 8px 12px; }
.engine-card-name { font-size: 0.78rem; }
.engine-card-desc { font-size: 0.65rem; }
}
/* Scope cards */
.scope-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scope-card { position: relative; display: flex; flex-direction: column; gap: 0; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; background: color-mix(in srgb, var(--surface-2) 80%, transparent); cursor: pointer; transition: border-color 160ms, box-shadow 160ms, transform 100ms; text-align: left; }
.scope-card:hover { border-color: color-mix(in srgb, var(--scope-waveform, #34d399) 55%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--scope-waveform, #34d399) 20%, transparent), 0 6px 18px -6px color-mix(in srgb, var(--scope-waveform, #34d399) 25%, transparent); transform: translateY(-1px); }
.scope-card--on { border-color: color-mix(in srgb, var(--scope-waveform, #34d399) 65%, transparent); background: color-mix(in srgb, var(--scope-waveform, #34d399) 6%, var(--surface-2)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--scope-waveform, #34d399) 18%, transparent), inset 0 1px 0 color-mix(in srgb, white 8%, transparent); }
.scope-card-preview { width: 100%; padding: 8px 8px 5px; line-height: 0; background: color-mix(in srgb, var(--surface-3, #111827) 60%, transparent); border-bottom: 1px solid var(--border); }
.scope-card-preview svg { width: 100%; height: 34px; display: block; }
.scope-card-meta { display: flex; align-items: center; gap: 5px; padding: 6px 8px; color: var(--text-soft); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; }
.scope-card-name { flex: 1; font-family: ui-monospace,"Fira Code",SFMono-Regular,monospace; }
.scope-card-dot { width: 6px; height: 6px; border-radius: 999px; flex-shrink: 0; transition: background 160ms, box-shadow 160ms; }
.scope-card-dot.on { background: var(--scope-waveform, #34d399); box-shadow: 0 0 5px var(--scope-waveform, #34d399); }
.scope-card-dot.off { background: color-mix(in srgb, var(--text-soft) 30%, transparent); }
/* Engine cards */
.engine-cards { display: flex; flex-direction: column; gap: 6px; }
.engine-card { position: relative; display: flex; flex-direction: column; gap: 2px; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; background: color-mix(in srgb, var(--surface-2) 60%, transparent); cursor: pointer; transition: border-color 160ms, box-shadow 160ms, transform 100ms; text-align: left; padding: 10px 14px; }
.engine-card:hover { border-color: color-mix(in srgb, var(--accent, #3b82f6) 55%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #3b82f6) 20%, transparent), 0 4px 12px -4px color-mix(in srgb, var(--accent, #3b82f6) 18%, transparent); transform: translateY(-1px); }
.engine-card--on { border-color: color-mix(in srgb, var(--accent, #3b82f6) 65%, transparent); background: color-mix(in srgb, var(--accent, #3b82f6) 6%, var(--surface-2)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #3b82f6) 18%, transparent), inset 0 1px 0 color-mix(in srgb, white 8%, transparent); }
.engine-card-meta { display: flex; align-items: center; gap: 6px; }
.engine-card-name { font-size: 0.82rem; font-weight: 600; color: var(--text); font-family: ui-monospace,"Fira Code",SFMono-Regular,monospace; }
.engine-card-badge { font-size: 0.62rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-soft); letter-spacing: 0.04em; }
.engine-card-badge--rec { background: color-mix(in srgb, var(--accent, #3b82f6) 18%, transparent); color: var(--accent, #3b82f6); }
.engine-card-desc { font-size: 0.68rem; color: var(--text-soft); padding-right: 12px; }
.engine-card-dot { position: absolute; top: 12px; right: 12px; width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; transition: background 160ms, box-shadow 160ms; }
.engine-card-dot.on { background: var(--accent, #3b82f6); box-shadow: 0 0 6px var(--accent, #3b82f6); }
.engine-card-dot.off { background: color-mix(in srgb, var(--text-soft) 25%, transparent); }
</style>
+45
View File
@@ -0,0 +1,45 @@
<script setup>
import SettingsBody from "./SettingsBody.vue";
const props = defineProps({
isOpen: Boolean,
closeModal: Function,
});
const { t } = useI18n();
</script>
<template>
<Transition name="sidebar">
<div v-if="isOpen" class="fixed inset-0 z-[200] flex justify-end" role="dialog" aria-modal="true">
<div class="backdrop absolute inset-0 bg-slate-900/60 backdrop-blur-sm" aria-hidden="true" @click="closeModal" />
<div class="drawer-panel relative h-full w-[380px] max-w-[90vw] flex flex-col shadow-2xl">
<div class="flex items-center justify-between px-5 py-4 border-b border-border flex-shrink-0 bg-surface">
<div class="flex items-center gap-2.5">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="text-text-soft"><circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.93 4.93l2.12 2.12M16.95 16.95l2.12 2.12M4.93 19.07l2.12-2.12M16.95 7.05l2.12-2.12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
<h4 class="m-0 text-[0.95rem] font-bold tracking-tight text-text">{{ t("settings.title") }}</h4>
</div>
<button type="button" class="btn-icon w-8 h-8" @click="closeModal">
<span class="sr-only">{{ t("common.close") }}</span>
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 18L18 6M6 6l12 12" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/></svg>
</button>
</div>
<div class="flex-1 overflow-y-auto bg-surface">
<div class="p-5">
<SettingsBody :active="isOpen" />
</div>
</div>
</div>
</div>
</Transition>
</template>
<style scoped>
.drawer-panel { background: var(--surface); border-left: 1px solid var(--border); will-change: transform; }
.sidebar-enter-active, .sidebar-leave-active { transition: all 400ms; }
.sidebar-enter-active .backdrop, .sidebar-leave-active .backdrop { transition: opacity 350ms ease; }
.sidebar-enter-from .backdrop, .sidebar-leave-to .backdrop { opacity: 0; }
.sidebar-enter-active .drawer-panel { transition: transform 400ms cubic-bezier(0.22, 1, 0.36, 1); }
.sidebar-leave-active .drawer-panel { transition: transform 300ms cubic-bezier(0.32, 0, 0.67, 0); }
.sidebar-enter-from .drawer-panel, .sidebar-leave-to .drawer-panel { transform: translate3d(100%, 0, 0); }
</style>
+412
View File
@@ -0,0 +1,412 @@
<script setup>
import { computed, ref, onMounted, onUnmounted } from "vue";
import BaseSelect from "./BaseSelect.vue";
const props = defineProps({
openAuthModal: {
type: Function,
required: true,
},
openSettingsModal: {
type: Function,
required: true,
},
isLoggedIn: {
type: Boolean,
default: false,
},
onLogout: {
type: Function,
default: null,
},
isLoggingOut: {
type: Boolean,
default: false,
},
});
const { t, locales, locale, setLocale } = useI18n();
const colorMode = useColorMode();
const langOptions = computed(() =>
(locales.value || locales).map((l) => ({ label: l.label, value: l.code }))
);
const themeOptions = computed(() => [
{ label: t("settings.themes.light"), value: "light" },
{ label: t("settings.themes.dark"), value: "dark" },
{ label: t("settings.themes.midnight"), value: "midnight" },
{ label: t("settings.themes.retro"), value: "retro" },
{ label: t("settings.themes.ocean"), value: "ocean" },
{ label: t("settings.themes.forest"), value: "forest" },
{ label: t("settings.themes.strawberry"), value: "strawberry" },
{ label: t("settings.themes.golden"), value: "golden" },
{ label: t("settings.themes.purple"), value: "purple" },
{ label: t("settings.themes.blue"), value: "blue" },
{ label: t("settings.themes.pink"), value: "pink" },
{ label: t("settings.themes.cyan"), value: "cyan" },
{ label: t("settings.themes.orange"), value: "orange" },
{ label: t("settings.themes.red"), value: "red" },
{ label: t("settings.themes.green"), value: "green" },
{ label: t("settings.themes.gray"), value: "gray" },
]);
const handleLocaleChange = (newLocale) => {
setLocale(newLocale);
};
const handleLogout = () => {
if (props.isLoggingOut) return;
if (props.onLogout) {
props.onLogout();
}
};
const isMobile = ref(false);
const isMobileMenuOpen = ref(false);
onMounted(() => {
const checkMobile = () => {
isMobile.value = window.innerWidth <= 640;
if (!isMobile.value) {
isMobileMenuOpen.value = false;
}
};
checkMobile();
window.addEventListener("resize", checkMobile);
onUnmounted(() => window.removeEventListener("resize", checkMobile));
});
const mobileExpandedSection = ref("");
const toggleMobileSection = (section) => {
mobileExpandedSection.value = mobileExpandedSection.value === section ? "" : section;
};
const handleMobileSettings = () => {
isMobileMenuOpen.value = false;
props.openSettingsModal();
};
const handleMobileAuth = (type) => {
isMobileMenuOpen.value = false;
props.openAuthModal(type);
};
const handleMobileLogout = () => {
isMobileMenuOpen.value = false;
handleLogout();
};
</script>
<template>
<header
id="dsetNav"
class="fixed top-3 left-1/2 -translate-x-1/2 z-[100] max-w-[1200px] w-[calc(100%-3rem)] max-[720px]:w-[calc(100%-2rem)] rounded-full bg-bg/65 backdrop-blur-2xl border border-border/30 shadow-[0_8px_32px_rgba(0,0,0,0.12)] transition-all duration-300"
>
<div
class="w-full py-1 px-4 grid grid-cols-2 sm:grid-cols-[1fr_auto_1fr] items-center gap-3 min-h-[44px]"
>
<!-- Brand -->
<div class="flex items-center gap-2.5 min-w-0 justify-self-start">
<span
class="font-bold tracking-[0.06em] uppercase text-[0.85rem] text-text whitespace-nowrap"
>
{{ isMobile ? "Tracker" : t("nav.brand") }}
</span>
</div>
<!-- Actions (Middle on Desktop) -->
<div v-if="!isMobile" class="flex items-center justify-center gap-1 bg-surface-2/40 rounded-full p-0.5 border border-border/20 shadow-sm">
<!-- Language Switcher -->
<BaseSelect
:model-value="locale"
:options="langOptions"
:label="t('settings.table.language')"
@update:model-value="handleLocaleChange"
class="!min-w-0"
dropdown-class="w-48"
>
<template #trigger="{ toggle, isOpen }">
<button
@click="toggle"
class="flex items-center justify-center p-1.5 rounded-full hover:bg-surface-2/60 hover:scale-105 active:scale-95 transition-all duration-200 text-text-muted hover:text-text"
:class="{
'bg-surface-2/60 text-text ring-2 ring-accent/20': isOpen,
}"
:title="t('settings.table.language')"
type="button"
>
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="10" />
<line x1="2" y1="12" x2="22" y2="12" />
<path
d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
/>
</svg>
</button>
</template>
</BaseSelect>
<!-- Theme Switcher -->
<BaseSelect
v-model="colorMode.preference"
:options="themeOptions"
:label="t('settings.table.theme')"
class="!min-w-0"
dropdown-class="w-48"
>
<template #trigger="{ toggle, isOpen }">
<button
@click="toggle"
class="flex items-center justify-center p-1.5 rounded-full hover:bg-surface-2/60 hover:scale-105 active:scale-95 transition-all duration-200 text-text-muted hover:text-text"
:class="{
'bg-surface-2/60 text-text ring-2 ring-accent/20': isOpen,
}"
:title="t('settings.table.theme')"
type="button"
>
<ClientOnly>
<svg
v-if="
['light', 'retro', 'ocean', 'forest', 'strawberry'].includes(
colorMode.preference,
)
"
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="5" />
<line x1="12" y1="1" x2="12" y2="3" />
<line x1="12" y1="21" x2="12" y2="23" />
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64" />
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78" />
<line x1="1" y1="12" x2="3" y2="12" />
<line x1="21" y1="12" x2="23" y2="12" />
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36" />
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22" />
</svg>
<svg
v-else
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
</svg>
<template #fallback>
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="5" />
</svg>
</template>
</ClientOnly>
</button>
</template>
</BaseSelect>
<!-- Settings Button -->
<button
@click="openSettingsModal"
class="flex items-center justify-center p-1.5 rounded-full hover:bg-surface-2/60 hover:scale-105 active:scale-95 transition-all duration-200 text-text-muted hover:text-text"
:title="t('settings.title')"
type="button"
>
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="3" />
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"
/>
</svg>
</button>
</div>
<!-- Auth & Mobile Menu Toggle (Right) -->
<div class="flex items-center justify-self-end gap-2 flex-shrink-0">
<template v-if="!isMobile">
<button
class="btn-base btn-ghost px-3 py-1.5 text-xs rounded-full"
:class="{ hidden: isLoggedIn }"
@click="openAuthModal('login')"
type="button"
>
{{ t("auth.login") }}
</button>
<button
class="btn-base btn-primary px-3 py-1.5 text-xs shadow-sm shadow-primary/20 rounded-full"
:class="{ hidden: isLoggedIn }"
@click="openAuthModal('register')"
type="button"
>
{{ t("auth.signup") }}
</button>
<button
class="btn-base btn-danger px-3 py-1.5 text-xs rounded-full inline-flex items-center gap-1.5 disabled:opacity-70 disabled:cursor-not-allowed"
:class="{ hidden: !isLoggedIn }"
:disabled="isLoggingOut"
:aria-busy="isLoggingOut ? 'true' : 'false'"
@click="handleLogout"
type="button"
>
<span
v-if="isLoggingOut"
class="inline-block w-3.5 h-3.5 border-2 rounded-full border-current border-t-transparent animate-spin"
aria-hidden="true"
></span>
{{ isLoggingOut ? t("common.loading", null, "处理中...") : t("auth.logout") }}
</button>
</template>
<template v-else>
<button
@click="openSettingsModal"
class="p-2 rounded-full text-text hover:bg-surface-2/50 active:scale-95 transition-all"
:title="t('settings.title')"
>
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="3" />
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />
</svg>
</button>
<button
@click="isMobileMenuOpen = true"
class="p-2 -mr-2 rounded-full text-text hover:bg-surface-2/50 active:scale-95 transition-all"
>
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</button>
</template>
</div>
</div>
</header>
<!-- Mobile Menu Drawer -->
<Teleport to="body">
<Transition name="drawer">
<div v-show="isMobileMenuOpen && isMobile" class="fixed inset-0 z-[200] flex flex-col justify-end">
<div class="absolute inset-0 bg-black/60 transition-opacity" @click="isMobileMenuOpen = false"></div>
<div class="relative bg-bg rounded-t-3xl p-6 border-t border-border/60 shadow-[0_-10px_40px_rgba(0,0,0,0.3)] flex flex-col gap-5 max-h-[85vh] overflow-y-auto">
<div class="w-12 h-1.5 bg-border/80 rounded-full mx-auto -mt-2 mb-2"></div>
<!-- Tools -->
<div class="flex flex-col bg-surface-2/30 rounded-2xl border border-border/40">
<!-- Language Accordion -->
<div class="flex flex-col border-b border-border/40">
<button @click="toggleMobileSection('language')" class="flex items-center justify-between w-full py-3.5 px-4 hover:bg-surface-2/60 transition-colors rounded-t-2xl">
<span class="text-sm font-medium">{{ t('settings.table.language') }}</span>
<div class="flex items-center gap-2 text-text-muted">
<span class="text-sm">{{ langOptions.find(l => l.value === locale)?.label || locale }}</span>
<svg class="w-4 h-4 transition-transform duration-200" :class="{ 'rotate-180': mobileExpandedSection === 'language' }" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>
</div>
</button>
<div class="grid transition-all duration-300 ease-[cubic-bezier(0.4,0,0.2,1)]" :style="{ gridTemplateRows: mobileExpandedSection === 'language' ? '1fr' : '0fr' }">
<div class="overflow-hidden min-h-0 transition-opacity duration-300" :class="mobileExpandedSection === 'language' ? 'opacity-100' : 'opacity-0 invisible'">
<div class="px-3 pb-3 grid grid-cols-2 gap-2 pt-1">
<button v-for="opt in langOptions" :key="opt.value" @click="handleLocaleChange(opt.value); toggleMobileSection('')" class="py-2.5 px-3 rounded-xl text-sm text-center border transition-all" :class="locale === opt.value ? 'bg-accent/10 border-accent/40 text-accent font-medium shadow-sm' : 'border-border/30 hover:bg-surface-2/80 text-text-muted hover:text-text'">
{{ opt.label }}
</button>
</div>
</div>
</div>
</div>
<!-- Theme Accordion -->
<div class="flex flex-col border-b border-border/40">
<button @click="toggleMobileSection('theme')" class="flex items-center justify-between w-full py-3.5 px-4 hover:bg-surface-2/60 transition-colors">
<span class="text-sm font-medium">{{ t('settings.table.theme') }}</span>
<div class="flex items-center gap-2 text-text-muted">
<ClientOnly>
<span class="text-sm">{{ themeOptions.find(t => t.value === colorMode.preference)?.label || colorMode.preference }}</span>
<template #fallback>
<span class="text-sm opacity-0">...</span>
</template>
</ClientOnly>
<svg class="w-4 h-4 transition-transform duration-200" :class="{ 'rotate-180': mobileExpandedSection === 'theme' }" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>
</div>
</button>
<div class="grid transition-all duration-300 ease-[cubic-bezier(0.4,0,0.2,1)]" :style="{ gridTemplateRows: mobileExpandedSection === 'theme' ? '1fr' : '0fr' }">
<div class="overflow-hidden min-h-0 transition-opacity duration-300" :class="mobileExpandedSection === 'theme' ? 'opacity-100' : 'opacity-0 invisible'">
<div class="px-3 pb-3 grid grid-cols-3 sm:grid-cols-4 gap-2 max-h-[35vh] overflow-y-auto custom-scrollbar pt-1">
<ClientOnly>
<button v-for="opt in themeOptions" :key="opt.value" @click="colorMode.preference = opt.value" class="py-2 px-1 rounded-xl text-xs text-center border transition-all truncate" :class="colorMode.preference === opt.value ? 'bg-accent/10 border-accent/40 text-accent font-medium shadow-sm' : 'border-border/30 hover:bg-surface-2/80 text-text-muted hover:text-text'">
{{ opt.label }}
</button>
<template #fallback>
<button v-for="opt in themeOptions" :key="'fallback-' + opt.value" class="py-2 px-1 rounded-xl text-xs text-center border transition-all truncate border-border/30 text-text-muted">
{{ opt.label }}
</button>
</template>
</ClientOnly>
</div>
</div>
</div>
</div>
</div>
<!-- Auth -->
<div class="flex gap-3 mt-2">
<template v-if="!isLoggedIn">
<button class="btn-base btn-ghost flex-1 py-3 rounded-xl border border-border/50" @click="handleMobileAuth('login')">
{{ t("auth.login") }}
</button>
<button class="btn-base btn-primary flex-1 py-3 rounded-xl shadow-sm shadow-primary/20" @click="handleMobileAuth('register')">
{{ t("auth.signup") }}
</button>
</template>
<button v-else class="btn-base btn-danger flex-1 py-3 rounded-xl flex items-center justify-center gap-2" @click="handleMobileLogout" :disabled="isLoggingOut">
<span v-if="isLoggingOut" class="inline-block w-4 h-4 border-2 rounded-full border-current border-t-transparent animate-spin"></span>
{{ isLoggingOut ? t("common.loading", null, "处理中...") : t("auth.logout") }}
</button>
</div>
</div>
</div>
</Transition>
</Teleport>
</template>
<style scoped>
.drawer-enter-active,
.drawer-leave-active {
transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.4s ease;
}
.drawer-enter-from,
.drawer-leave-to {
opacity: 0;
}
.drawer-enter-from .relative,
.drawer-leave-to .relative {
transform: translateY(100%);
}
</style>
+362
View File
@@ -0,0 +1,362 @@
<script setup>
import { computed } from "vue";
const { t } = useI18n();
const props = defineProps({
isOpen: Boolean,
closeModal: Function,
meta: { type: Object, default: () => ({}) },
fileName: { type: String, default: "" },
});
function close() {
props.closeModal?.();
}
const hasMeta = computed(() => {
const m = props.meta;
return m && (m.title || m.type || m.tracker || (m.channels && m.channels.length) || (m.instruments && m.instruments.length));
});
const formatDuration = (sec) => {
if (!sec || sec <= 0) return "--:--";
const m = Math.floor(sec / 60);
const s = Math.floor(sec % 60);
return `${m}:${s.toString().padStart(2, "0")}`;
};
const metaRows = computed(() => {
const m = props.meta;
const rows = [];
if (m.title) rows.push({ label: t("trackInfo.title"), value: m.title });
if (m.artist) rows.push({ label: t("trackInfo.artist"), value: m.artist });
if (m.type) rows.push({ label: t("trackInfo.type"), value: m.type });
if (m.tracker) rows.push({ label: t("trackInfo.tracker"), value: m.tracker });
if (m.date) rows.push({ label: t("trackInfo.date"), value: m.date });
if (m.dur) rows.push({ label: t("trackInfo.duration"), value: formatDuration(m.dur) });
if (m.container) rows.push({ label: t("trackInfo.container"), value: m.container });
if (m.numSubsongs > 1) rows.push({ label: t("trackInfo.subsongs"), value: String(m.numSubsongs) });
return rows;
});
const hasChannels = computed(() => props.meta?.channels?.length > 0);
const hasInstruments = computed(() => props.meta?.instruments?.length > 0);
const hasSamples = computed(() => props.meta?.samples?.length > 0);
const hasOrders = computed(() => props.meta?.orders?.length > 0);
const hasSongs = computed(() => props.meta?.songs?.length > 1);
function handleBackdropClick(e) {
if (e.target?.classList?.contains("ti-overlay")) {
close();
}
}
function handleKeydown(e) {
if (e.key === "Escape") close();
}
</script>
<template>
<Teleport to="body">
<Transition name="ti-modal">
<div
v-if="isOpen"
class="ti-overlay"
role="dialog"
aria-modal="true"
:aria-label="t('trackInfo.modalTitle')"
@click="handleBackdropClick"
@keydown="handleKeydown"
>
<div class="ti-panel card">
<header class="ti-header">
<h2 class="ti-title">{{ t("trackInfo.modalTitle") }}</h2>
<button
class="ti-close btn-base"
type="button"
:aria-label="t('trackInfo.close')"
@click="close"
>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</header>
<p class="ti-filename">{{ fileName }}</p>
<div v-if="!hasMeta" class="ti-empty">
{{ t("trackInfo.noMeta") }}
</div>
<template v-else>
<table v-if="metaRows.length" class="ti-table">
<tbody>
<tr v-for="row in metaRows" :key="row.label">
<th>{{ row.label }}</th>
<td>{{ row.value }}</td>
</tr>
</tbody>
</table>
<div v-if="meta.message" class="ti-section">
<h3 class="ti-section-title">{{ t("trackInfo.message") }}</h3>
<pre class="ti-message">{{ meta.message }}</pre>
</div>
<div v-if="hasChannels" class="ti-section">
<h3 class="ti-section-title">{{ t("trackInfo.channels") }} ({{ meta.channels.length }})</h3>
<div class="ti-tags">
<span v-for="(ch, i) in meta.channels" :key="'ch'+i" class="ti-tag ti-tag-ch">{{ ch || `CH${i + 1}` }}</span>
</div>
</div>
<div v-if="hasInstruments" class="ti-section">
<h3 class="ti-section-title">{{ t("trackInfo.instruments") }} ({{ meta.instruments.length }})</h3>
<div class="ti-tags">
<span v-for="(ins, i) in meta.instruments" :key="'ins'+i" class="ti-tag ti-tag-ins">{{ ins || `INS${i + 1}` }}</span>
</div>
</div>
<div v-if="hasSamples" class="ti-section">
<h3 class="ti-section-title">{{ t("trackInfo.samples") }} ({{ meta.samples.length }})</h3>
<div class="ti-tags">
<span v-for="(smp, i) in meta.samples" :key="'smp'+i" class="ti-tag ti-tag-smp">{{ smp || `SMP${i + 1}` }}</span>
</div>
</div>
<div v-if="hasOrders" class="ti-section">
<h3 class="ti-section-title">{{ t("trackInfo.orders") }} ({{ meta.orders.length }})</h3>
<div class="ti-orders">
<div v-for="(ord, i) in meta.orders" :key="'ord'+i" class="ti-order-item">
<span class="ti-order-idx">{{ i }}</span>
<span class="ti-order-name">{{ ord.name || `Order ${i}` }}</span>
<span class="ti-order-pat">{{ t("trackInfo.pattern") }} {{ ord.pat }}</span>
</div>
</div>
</div>
<div v-if="hasSongs" class="ti-section">
<h3 class="ti-section-title">{{ t("trackInfo.subsongs") }}</h3>
<ul class="ti-list">
<li v-for="(s, i) in meta.songs" :key="'song'+i">{{ s }}</li>
</ul>
</div>
</template>
</div>
</div>
</Transition>
</Teleport>
</template>
<style scoped>
.ti-overlay {
position: fixed;
inset: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
background: rgba(0, 0, 0, 0.55);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
}
.ti-panel {
width: 100%;
max-width: 420px;
max-height: 80vh;
overflow-y: auto;
padding: 1.25rem;
display: grid;
gap: 0.85rem;
position: relative;
}
.ti-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
}
.ti-title {
margin: 0;
font-size: 1rem;
font-weight: 800;
letter-spacing: -0.01em;
color: var(--text);
}
.ti-close {
width: 30px;
height: 30px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
border-radius: 8px;
}
.ti-close svg {
width: 16px;
height: 16px;
}
.ti-filename {
margin: 0;
font-size: 0.78rem;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
color: var(--text-soft);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0.35rem 0.6rem;
background: color-mix(in srgb, var(--surface-2) 70%, transparent);
border-radius: 8px;
border: 1px solid var(--border);
}
.ti-empty {
color: var(--text-soft);
font-size: 0.85rem;
text-align: center;
padding: 1.5rem 0;
}
.ti-table {
width: 100%;
border-collapse: collapse;
}
.ti-table th {
text-align: left;
font-size: 0.78rem;
font-weight: 600;
color: var(--text-soft);
padding: 0.3rem 0.6rem 0.3rem 0;
white-space: nowrap;
vertical-align: top;
width: 1%;
}
.ti-table td {
font-size: 0.85rem;
padding: 0.3rem 0;
color: var(--text);
word-break: break-all;
}
.ti-section {
display: grid;
gap: 0.4rem;
}
.ti-section-title {
margin: 0;
font-size: 0.72rem;
font-weight: 800;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.06em;
}
.ti-message {
margin: 0;
font-size: 0.78rem;
color: var(--text-soft);
white-space: pre-wrap;
word-break: break-word;
background: color-mix(in srgb, var(--surface-2) 70%, transparent);
padding: 0.6rem 0.75rem;
border-radius: 8px;
border: 1px solid var(--border);
max-height: 180px;
overflow-y: auto;
font-family: inherit;
}
.ti-tags {
display: flex;
flex-wrap: wrap;
gap: 0.3rem;
}
.ti-tag {
font-size: 0.7rem;
font-weight: 600;
padding: 0.15rem 0.5rem;
border-radius: 9999px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
line-height: 1.6;
}
.ti-tag-ch {
background: color-mix(in srgb, var(--accent, #3b82f6) 12%, transparent);
color: var(--accent, #3b82f6);
border: 1px solid color-mix(in srgb, var(--accent, #3b82f6) 20%, transparent);
}
.ti-tag-ins {
background: color-mix(in srgb, var(--accent-green, #10b981) 12%, transparent);
color: var(--accent-green, #10b981);
border: 1px solid color-mix(in srgb, var(--accent-green, #10b981) 20%, transparent);
}
.ti-tag-smp {
background: color-mix(in srgb, var(--accent-amber, #f59e0b) 12%, transparent);
color: var(--accent-amber, #f59e0b);
border: 1px solid color-mix(in srgb, var(--accent-amber, #f59e0b) 20%, transparent);
}
.ti-orders {
display: flex;
flex-wrap: wrap;
gap: 0.2rem;
max-height: 160px;
overflow-y: auto;
}
.ti-order-item {
font-size: 0.68rem;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
background: color-mix(in srgb, var(--surface-2) 70%, transparent);
padding: 0.1rem 0.4rem;
border-radius: 6px;
border: 1px solid var(--border);
color: var(--text-soft);
display: flex;
gap: 0.2rem;
}
.ti-order-idx {
color: var(--text-muted);
min-width: 1.4em;
}
.ti-order-pat {
color: var(--text-muted);
}
.ti-list {
list-style: none;
padding: 0;
margin: 0;
}
.ti-list li {
font-size: 0.82rem;
color: var(--text);
padding: 0.1rem 0;
}
/* transitions – match DownloadModal */
.ti-modal-enter-active,
.ti-modal-leave-active {
transition: opacity 0.2s ease;
}
.ti-modal-enter-from,
.ti-modal-leave-to {
opacity: 0;
}
.ti-modal-enter-active .ti-panel,
.ti-modal-leave-active .ti-panel {
transition: transform 0.2s ease;
}
.ti-modal-enter-from .ti-panel {
transform: scale(0.96) translateY(6px);
}
.ti-modal-leave-to .ti-panel {
transform: scale(0.96) translateY(6px);
}
</style>