Skip to content

Commit

Permalink
Fix current list ui
Browse files Browse the repository at this point in the history
  • Loading branch information
HeHang0 committed Jan 28, 2024
1 parent 3156339 commit de93634
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 24 deletions.
1 change: 1 addition & 0 deletions web/public/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async function cacheThenNetwork(request) {
routerPattern.test(requestUrl);
if (
requestUrl.startsWith('http') &&
response.status == 200 &&
(cacheRouter || (willCache && response.ok))
) {
try {
Expand Down
3 changes: 3 additions & 0 deletions web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,8 @@ onMounted(() => {
position: relative;
min-height: 100%;
}
:deep(.el-overlay) {
z-index: 2001;
}
}
</style>
3 changes: 3 additions & 0 deletions web/src/assets/images/apple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 36 additions & 3 deletions web/src/components/CurrentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
import { ElMessageBox } from 'element-plus';
import MusicList from './MusicList.vue';
import { usePlayStore } from '../stores/play';
import { scrollToElement } from '../utils/utils';
import { ref } from 'vue';
const play = usePlayStore();
const portrait = window.matchMedia('(orientation: portrait)');
const drawerDirection = ref(portrait.matches ? 'btt' : 'rtl');
portrait.addEventListener('change', () => {
drawerDirection.value = portrait.matches ? 'btt' : 'rtl';
});
function clear() {
ElMessageBox.confirm('', '确定要清空播放列表吗?', {
closeOnClickModal: false,
Expand All @@ -14,13 +21,25 @@ function clear() {
})
.catch(() => {});
}
function onOpen() {
const index = play.musicList.findIndex(
item => item.id === play.music?.id && item.type == play.music?.type
);
if (index < 0) return;
const elements = document.querySelectorAll(
'.music-current-list-content .music-list-item'
);
scrollToElement(elements.item(index) as HTMLElement, false, true);
}
</script>

<template>
<el-drawer
class="music-current-list"
v-model="play.currentListShow"
:with-header="false">
:with-header="false"
@opened="onOpen"
:direction="drawerDirection">
<div class="music-current-list-header">
<span class="music-current-list-header-title">
播放列表
Expand Down Expand Up @@ -93,8 +112,22 @@ function clear() {
height: calc(100% - 192px) !important;
min-height: 80% !important;
border-radius: var(--music-border-radius);
top: 50% !important;
transform: translateY(-50%);
margin-top: min(10%, 96px);
// top: 50% !important;
// transform: translateY(-50%);
@media (orientation: portrait) {
width: 100% !important;
height: calc(100% - 80px - calc(var(--sab) / 1.5)) !important;
margin-top: 0;
top: 0;
border-radius: 0 0 var(--music-border-radius) var(--music-border-radius);
}
@media (max-height: 600px) and (orientation: landscape) {
height: calc(100% - 80px - calc(var(--sab) / 1.5)) !important;
margin-top: 0;
border-radius: var(--music-border-radius) 0 var(--music-border-radius)
var(--music-border-radius);
}
.el-drawer__body {
padding: 0;
}
Expand Down
9 changes: 5 additions & 4 deletions web/src/components/PlayDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function setMouseStillness() {
}
let isTouching = false;
function checkMouseStillness() {
if (isMobile) return;
if (isTouching) {
isTouching = false;
return;
Expand All @@ -98,6 +99,7 @@ function checkMouseStillness() {
mouseStillnessTimeout = setTimeout(setMouseStillness, 5000);
}
function setMouseMotion() {
if (isMobile) return;
mouseStillness.value = false;
clearTimeout(mouseStillnessTimeout);
}
Expand Down Expand Up @@ -139,7 +141,6 @@ beforeResolve(() => {
}
if (play.playDetailShow) play.playDetailShow = false;
});
watch(() => play.playDetailShow, setTheme);
</script>

Expand All @@ -152,11 +153,11 @@ watch(() => play.playDetailShow, setTheme);
<div
class="music-play-detail-layout"
ref="pageElement"
@mouseleave="!isMobile ? checkMouseStillness : void 0"
@mouseleave="checkMouseStillness"
:style="imageThemeStyle">
<div
class="music-play-detail-header"
@mouseenter="!isMobile ? setMouseMotion : void 0"
@mouseenter="setMouseMotion"
:style="mouseStillness ? 'opacity:0' : ''">
<span>
<el-button class="music-button-pure music-icon" @click="close"
Expand Down Expand Up @@ -199,7 +200,7 @@ watch(() => play.playDetailShow, setTheme);
<div
class="music-play-detail-body"
:class="mouseStillness ? '' : 'music-play-detail-body-short'"
@mousemove="!isMobile ? onMouseMove : void 0"
@mousemove="onMouseMove"
@touchstart.stop="onTouchStart">
<LyricMode v-if="play.playerMode == 'lyric'" />
<PolarBearMode
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/player/PolarBearMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ onMounted(async () => {
});
function calcSeat() {
if (!snowContainer.value) return;
const screenRatio =
snowContainer.value.offsetWidth / snowContainer.value.offsetHeight;
const screenRatio = window.innerWidth / window.innerHeight;
const imageRatio = 1924 / 1080;
let screenHeight = 0;
let screenWidth = 0;
Expand Down Expand Up @@ -191,6 +190,7 @@ onUnmounted(() => {
text-align: center;
transform: translateX(-50%);
opacity: 0;
margin-top: var(--sat, 0);
transition: opacity 0.3s, width 0.3s;
& > span {
font-size: 18px;
Expand Down
4 changes: 4 additions & 0 deletions web/src/style/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
--music-affix-background: var(--music-background);
}

.dark.pure {
--music-background: black;
}

.red {
--music-side-background: rgb(255, 58, 58);
--music-side-text-color: white;
Expand Down
2 changes: 1 addition & 1 deletion web/src/utils/lyric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type LyricLineChange = (
duration?: number
) => void;

const devicePixelRatio = Math.max(window.devicePixelRatio || 1, 1.5) * 2;
const devicePixelRatio = (window.devicePixelRatio || 1) * 2;
let defaultFont = '';
export class LyricManager {
private static lyricOption = {} as Record<LyricOptionsKey, any>;
Expand Down
15 changes: 14 additions & 1 deletion web/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ export const isMobile =
export const isSafari =
!isWindows && !isAndroid && /Safari|AppleWebKit/i.test(navigator.userAgent);

export function scrollToElement(
ele: HTMLElement,
center?: boolean,
smooth?: boolean
) {
if (!ele) return;
const scrollParams: ScrollIntoViewOptions = {
behavior: smooth ? 'smooth' : 'instant',
block: center ? 'center' : 'start'
};
ele.scrollIntoView(scrollParams);
}

export function scrollToElementId(
id: string,
center?: boolean,
Expand All @@ -137,7 +150,7 @@ export function scrollToElementId(
behavior: smooth ? 'smooth' : 'instant',
block: center ? 'center' : 'start'
};
ele && ele.scrollIntoView(scrollParams);
ele.scrollIntoView(scrollParams);
}

// export function scrollToElementId(
Expand Down
59 changes: 54 additions & 5 deletions web/src/views/setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
import { LogoCircleImage } from '../utils/logo';
import { ThemeColorManager } from '../utils/color';
import DroidImage from '../assets/images/droid.svg';
import AppleImage from '../assets/images/apple.svg';
import { getServiceWorkerRegistration } from '../sw/register';
const { currentRoute, replace, options } = useRouter();
Expand Down Expand Up @@ -200,15 +201,20 @@ const delayShutdown = ref(false);
const themes = ref([
{
id: '',
name: '默认',
name: '亮色',
color: 'white'
},
{
id: 'dark',
name: '深色',
color: 'black'
color: '#13131a'
},
setting.customTheme,
{
id: 'dark pure',
name: '暗色',
color: 'black'
},
{
id: 'red',
name: '',
Expand Down Expand Up @@ -804,7 +810,7 @@ onUnmounted(unWatch);
v-model="setting.pageValue.lyric.fontSize"
@change="setting.setLyricOptions">
<el-option
v-for="(_item, index) in new Array(50)"
v-for="(_item, index) in new Array(53)"
:key="index"
:label="index + 20"
:value="index + 20">
Expand All @@ -828,7 +834,8 @@ onUnmounted(unWatch);
size="large">
</el-checkbox>
</div>
<div class="music-setting-lyric-item">
<div
class="music-setting-lyric-item music-setting-lyric-item-portrait-top">
<span class="music-setting-lyric-item-title">配色方案</span>
<div class="music-setting-lyric-item-color">
<el-select
Expand Down Expand Up @@ -860,6 +867,27 @@ onUnmounted(unWatch);
</span>
</div>
</div>
<div
class="music-setting-lyric-item music-setting-lyric-item-portrait-top">
<span class="music-setting-lyric-item-title"
>预<span style="opacity: 0">占位</span>览</span
>
<div
class="music-setting-lyric-item-preview"
:style="{
fontSize: setting.pageValue.lyric.fontSize + 'px',
fontFamily: setting.pageValue.lyric.fontFamily,
color: setting.pageValue.lyric.fontColor,
textShadow: setting.pageValue.lyric.effect
? '0 0 1px ' + setting.pageValue.lyric.effectColor
: 'none',
fontWeight: setting.pageValue.lyric.fontBold
? 'bold'
: 'normal'
}">
音乐和
</div>
</div>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -910,6 +938,17 @@ onUnmounted(unWatch);
</div>
<p>Android版</p>
</a>
<a
class="music-setting-about-card"
href="https://hehang0.github.io/musiche/Musiche.ipa"
target="_blank">
<div
class="logo-app"
style="--logo-app-color: var(--music-footer-background)">
<img :src="AppleImage" />
</div>
<p>IOS版</p>
</a>
<a
v-if="
!isInStandaloneMode &&
Expand Down Expand Up @@ -1196,6 +1235,16 @@ onUnmounted(unWatch);
background-color: var(--fix-color);
}
}
&-preview {
border-radius: var(--music-border-radius);
border: 1px solid var(--music-button-info-border-color);
flex: 1;
height: 100px;
text-align: center;
line-height: 100px;
background-color: var(--music-side-background);
letter-spacing: 6px;
}
.el-select {
width: 140px;
&.short {
Expand Down Expand Up @@ -1374,7 +1423,7 @@ onUnmounted(unWatch);
}
&-lyric {
&-item {
&:last-child {
&-portrait-top {
align-items: baseline;
}
&-fix-color {
Expand Down
5 changes: 4 additions & 1 deletion windows/LyricWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ namespace Musiche
/// <summary>
/// LyricWindow.xaml 的交互逻辑
/// </summary>
public delegate void LyricLockedChangedEventHandler(object sender, bool locked);
public partial class LyricWindow : Window
{
public event LyricLockedChangedEventHandler LyricLockedChanged;
private bool closeFlag = false;
private bool locked = false;
private readonly DropShadowEffect lyricEffect;
Expand Down Expand Up @@ -261,7 +263,7 @@ private void LockWindow(object sender, MouseButtonEventArgs e)
SetLocked(label.Content?.ToString() == "锁");
}

private void SetLocked(bool isLock, bool isInitial=false)
public void SetLocked(bool isLock, bool isInitial=false)
{
locked = isLock;
LockLabel.Content = locked ? "解" : "锁";
Expand All @@ -277,6 +279,7 @@ private void SetLocked(bool isLock, bool isInitial=false)
LyricBorder.Background = locked ? Brushes.Transparent : hoverBackground;
ResizeGrid.Visibility = locked ? Visibility.Collapsed : Visibility.Visible;
}
LyricLockedChanged?.Invoke(this, isLock);
}

private void CloseWindow(object sender, MouseButtonEventArgs e)
Expand Down
Loading

0 comments on commit de93634

Please sign in to comment.