ow
This commit is contained in:
1 parent
6417562c4f
commit
f1e6e116c3
31 files changed
+2065
-309
No files matched your search
@@ -18,8 +18,15 @@ export interface VinylTrack {
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{ tracks?: VinylTrack[]; controls?: boolean }>(),
|
||||
{ tracks: () => [], controls: true },
|
||||
defineProps<{
|
||||
tracks?: VinylTrack[];
|
||||
/** 打开时从第几首开始(文件页单击音频进音乐厅时指名) */
|
||||
startIndex?: number;
|
||||
/** 挂上源后是否立即播放(仅 App 生效:H5 自动播放受浏览器手势策略限制) */
|
||||
autoPlay?: boolean;
|
||||
controls?: boolean;
|
||||
}>(),
|
||||
{ tracks: () => [], startIndex: 0, autoPlay: false, controls: true },
|
||||
);
|
||||
const emit = defineEmits<{
|
||||
(e: "close"): void;
|
||||
@@ -27,7 +34,12 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const tracks = computed(() => props.tracks || []);
|
||||
const index = ref(0);
|
||||
/** 起始下标:未指名或越界(列表长度对不上)一律从第一首开始 */
|
||||
function initialIndex(): number {
|
||||
const start = props.startIndex || 0;
|
||||
return start > 0 && start < (props.tracks?.length ?? 0) ? start : 0;
|
||||
}
|
||||
const index = ref(initialIndex());
|
||||
const isPlaying = ref(false);
|
||||
const currentTime = ref(0);
|
||||
const duration = ref(0);
|
||||
@@ -585,6 +597,12 @@ onMounted(() => {
|
||||
if (current.value) {
|
||||
loadLrc(current.value.lrc);
|
||||
}
|
||||
// 文件页单击音频进音乐厅:App 内挂载即开播(H5 受浏览器自动播放策略限制,留给用户点播放)
|
||||
// #ifndef H5
|
||||
if (props.autoPlay && current.value) {
|
||||
engPlay();
|
||||
}
|
||||
// #endif
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
if (sleepTimer) {
|
||||
@@ -787,7 +805,13 @@ watch(() => tracks.value.length, (n) => {
|
||||
/* 左上角返回(非沉浸态) */
|
||||
.vap-back {
|
||||
position: absolute;
|
||||
/* App 端状态栏透明且不占位,用 uni 注入的 --status-bar-height 避让;H5 用 safe-area(App 下该值为 0 不可靠) */
|
||||
/* #ifdef APP-PLUS */
|
||||
top: calc(24rpx + var(--status-bar-height, 0px));
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
top: calc(24rpx + env(safe-area-inset-top));
|
||||
/* #endif */
|
||||
left: 24rpx;
|
||||
z-index: 9;
|
||||
width: 72rpx;
|
||||
|
||||
Reference in new issue
Block a user