mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-24 08:07:23 +08:00
✨ feat: 修复布局问题
This commit is contained in:
@@ -90,7 +90,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right-controls">
|
<div class="right-controls">
|
||||||
<div class="volume-control custom-slider">
|
<div v-if="!isMobile" class="volume-control custom-slider">
|
||||||
<n-tooltip placement="top">
|
<n-tooltip placement="top">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<n-button quaternary circle @click="toggleMute">
|
<n-button quaternary circle @click="toggleMute">
|
||||||
@@ -172,7 +172,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NButton, NIcon, NSlider, NTooltip } from 'naive-ui';
|
import { NButton, NIcon, NSlider, NTooltip } from 'naive-ui';
|
||||||
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
import { useStore } from 'vuex';
|
import { useStore } from 'vuex';
|
||||||
|
|
||||||
import { getMvUrl } from '@/api/mv';
|
import { getMvUrl } from '@/api/mv';
|
||||||
@@ -300,6 +300,7 @@ onUnmounted(() => {
|
|||||||
if (cursorTimer) {
|
if (cursorTimer) {
|
||||||
clearTimeout(cursorTimer);
|
clearTimeout(cursorTimer);
|
||||||
}
|
}
|
||||||
|
unlockScreenOrientation();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听 currentMv 的变化
|
// 监听 currentMv 的变化
|
||||||
@@ -390,7 +391,28 @@ const checkFullscreenAPI = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// 切换全屏状态
|
// 添加横屏锁定功能
|
||||||
|
const lockScreenOrientation = async () => {
|
||||||
|
try {
|
||||||
|
if ('orientation' in screen) {
|
||||||
|
await (screen as any).orientation.lock('landscape');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('无法锁定屏幕方向:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const unlockScreenOrientation = () => {
|
||||||
|
try {
|
||||||
|
if ('orientation' in screen) {
|
||||||
|
(screen as any).orientation.unlock();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('无法解锁屏幕方向:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 修改切换全屏状态的方法
|
||||||
const toggleFullscreen = async () => {
|
const toggleFullscreen = async () => {
|
||||||
const api = checkFullscreenAPI();
|
const api = checkFullscreenAPI();
|
||||||
|
|
||||||
@@ -403,9 +425,17 @@ const toggleFullscreen = async () => {
|
|||||||
if (!api.fullscreenElement) {
|
if (!api.fullscreenElement) {
|
||||||
await videoContainerRef.value?.requestFullscreen();
|
await videoContainerRef.value?.requestFullscreen();
|
||||||
isFullscreen.value = true;
|
isFullscreen.value = true;
|
||||||
|
// 在移动端进入全屏时锁定横屏
|
||||||
|
if (window.innerWidth <= 768) {
|
||||||
|
await lockScreenOrientation();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await document.exitFullscreen();
|
await document.exitFullscreen();
|
||||||
isFullscreen.value = false;
|
isFullscreen.value = false;
|
||||||
|
// 退出全屏时解锁屏幕方向
|
||||||
|
if (window.innerWidth <= 768) {
|
||||||
|
unlockScreenOrientation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('切换全屏失败:', error);
|
console.error('切换全屏失败:', error);
|
||||||
@@ -513,16 +543,54 @@ watch(showControls, (newValue) => {
|
|||||||
resetCursorTimer();
|
resetCursorTimer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isMobile = computed(() => store.state.isMobile);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.mv-detail {
|
.mv-detail {
|
||||||
@apply w-full h-full bg-black relative;
|
@apply w-full h-full bg-black relative;
|
||||||
|
|
||||||
|
// 添加横屏模式支持
|
||||||
|
@media screen and (orientation: landscape) {
|
||||||
|
height: 100vh !important;
|
||||||
|
width: 100vw !important;
|
||||||
|
}
|
||||||
|
|
||||||
.video-container {
|
.video-container {
|
||||||
@apply w-full h-full relative;
|
@apply w-full h-full relative;
|
||||||
transition: cursor 0.3s ease;
|
transition: cursor 0.3s ease;
|
||||||
|
|
||||||
|
// 移动端适配
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.custom-controls {
|
||||||
|
.controls-main {
|
||||||
|
@apply flex-wrap gap-2 justify-center;
|
||||||
|
|
||||||
|
.left-controls,
|
||||||
|
.right-controls {
|
||||||
|
@apply w-full justify-center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-display {
|
||||||
|
@apply order-first w-full text-center mb-2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调整标题样式
|
||||||
|
.mv-detail-title {
|
||||||
|
.title {
|
||||||
|
@apply text-base max-w-full;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调整进度条
|
||||||
|
.progress-bar {
|
||||||
|
@apply mb-2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.cursor-hidden {
|
&.cursor-hidden {
|
||||||
* {
|
* {
|
||||||
cursor: none !important;
|
cursor: none !important;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ defineOptions({
|
|||||||
name: 'List',
|
name: 'List',
|
||||||
});
|
});
|
||||||
|
|
||||||
const TOTAL_ITEMS = 40; // 每页数量
|
const TOTAL_ITEMS = 42; // 每页数量
|
||||||
|
|
||||||
const recommendList = ref<any[]>([]);
|
const recommendList = ref<any[]>([]);
|
||||||
const showMusic = ref(false);
|
const showMusic = ref(false);
|
||||||
@@ -162,12 +162,12 @@ watch(
|
|||||||
.recommend {
|
.recommend {
|
||||||
@apply w-full h-full bg-none;
|
@apply w-full h-full bg-none;
|
||||||
&-title {
|
&-title {
|
||||||
@apply text-lg font-bold text-white pb-4;
|
@apply text-lg font-bold text-white pb-2;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-list {
|
&-list {
|
||||||
@apply grid gap-x-8 gap-y-6 pb-28 pr-4;
|
@apply grid gap-x-8 gap-y-6 pb-28 pr-4;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||||
}
|
}
|
||||||
&-item {
|
&-item {
|
||||||
@apply flex flex-col;
|
@apply flex flex-col;
|
||||||
@@ -218,10 +218,12 @@ watch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mobile {
|
.mobile {
|
||||||
|
.recommend-title {
|
||||||
|
@apply text-xl font-bold px-4;
|
||||||
|
}
|
||||||
|
|
||||||
.recommend-list {
|
.recommend-list {
|
||||||
@apply px-4;
|
@apply px-4 gap-4;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ const initLoading = ref(false);
|
|||||||
const loadingMore = ref(false);
|
const loadingMore = ref(false);
|
||||||
const currentIndex = ref(0);
|
const currentIndex = ref(0);
|
||||||
const offset = ref(0);
|
const offset = ref(0);
|
||||||
const limit = ref(30);
|
const limit = ref(28);
|
||||||
const hasMore = ref(true);
|
const hasMore = ref(true);
|
||||||
|
|
||||||
const getItemAnimationDelay = (index: number) => {
|
const getItemAnimationDelay = (index: number) => {
|
||||||
@@ -158,12 +158,12 @@ const isPrevDisabled = computed(() => currentIndex.value === 0);
|
|||||||
@apply relative h-full w-full;
|
@apply relative h-full w-full;
|
||||||
|
|
||||||
&-title {
|
&-title {
|
||||||
@apply text-xl font-bold;
|
@apply text-xl font-bold pb-2;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-content {
|
&-content {
|
||||||
@apply grid gap-4 pb-28 mt-2 pr-4;
|
@apply grid gap-4 pb-28 mt-2 pr-4;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
.mv-item {
|
.mv-item {
|
||||||
@@ -217,10 +217,12 @@ const isPrevDisabled = computed(() => currentIndex.value === 0);
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mobile {
|
.mobile {
|
||||||
|
.mv-list-title {
|
||||||
|
@apply text-xl font-bold px-4;
|
||||||
|
}
|
||||||
|
|
||||||
.mv-list-content {
|
.mv-list-content {
|
||||||
@apply px-4;
|
@apply px-4;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user