优化代码逻辑,修复潜在播放问题

This commit is contained in:
lyswhut
2023-01-14 16:03:56 +08:00
parent d3c8f16aed
commit 850a429243
35 changed files with 85 additions and 342 deletions
@@ -21,7 +21,7 @@ export default (name: string) => {
}
const handle_key_up = () => {
if (keyDown.value) keyDown.value = false
keyDown.value &&= false
}
onMounted(() => {
+3 -3
View File
@@ -128,7 +128,7 @@ export default ({ isPlay, lyric, playProgress, isShowLyricProgressSetting, offse
}
const handleMove = (y) => {
if (isMsDown.value) {
if (!isStopScroll.value) isStopScroll.value = true
isStopScroll.value ||= true
if (cancelScrollFn) {
cancelScrollFn()
cancelScrollFn = null
@@ -150,7 +150,7 @@ export default ({ isPlay, lyric, playProgress, isShowLyricProgressSetting, offse
const handleWheel = (event) => {
console.log(event.deltaY)
if (!isStopScroll.value) isStopScroll.value = true
isStopScroll.value ||= true
if (cancelScrollFn) {
cancelScrollFn()
cancelScrollFn = null
@@ -197,7 +197,7 @@ export default ({ isPlay, lyric, playProgress, isShowLyricProgressSetting, offse
const scrollLine = (line, oldLine) => {
if (line < 0) return
if (line == 0 && isSetedLines) return isSetedLines = false
if (isSetedLines) isSetedLines = false
isSetedLines &&= false
if (oldLine == null || line - oldLine != 1) return handleScrollLrc()
delayScrollTimeout = setTimeout(() => {
+5 -5
View File
@@ -44,7 +44,7 @@ const saveViewPrevStateThrottle = throttle((state) => {
}, 1000)
const initPosition = async() => {
if (listPosition == null) listPosition = await getListPositionInfoFromData() ?? {}
listPosition ??= await getListPositionInfoFromData() ?? {}
}
export const getListPosition = async(id: string): Promise<number> => {
await initPosition()
@@ -74,7 +74,7 @@ const saveListPrevSelectIdThrottle = throttle(() => {
saveListPrevSelectIdFromData(listPrevSelectId)
}, 200)
export const getListPrevSelectId = async() => {
if (listPrevSelectId == null) listPrevSelectId = await getListPrevSelectIdFromData() ?? LIST_IDS.DEFAULT
listPrevSelectId ??= await getListPrevSelectIdFromData() ?? LIST_IDS.DEFAULT
return listPrevSelectId ?? LIST_IDS.DEFAULT
}
export const saveListPrevSelectId = (id: string) => {
@@ -138,7 +138,7 @@ export const overwriteListUpdateInfo = async(ids: string[]) => {
export const getSearchSetting = async() => {
if (!searchSetting) searchSetting = await getSearchSettingFromData()
searchSetting ??= await getSearchSettingFromData()
return { ...searchSetting }
}
export const setSearchSetting = async(setting: Partial<typeof DEFAULT_SETTING['search']>) => {
@@ -154,7 +154,7 @@ export const setSearchSetting = async(setting: Partial<typeof DEFAULT_SETTING['s
}
export const getSongListSetting = async() => {
if (!songListSetting) songListSetting = await getSongListSettingFromData()
songListSetting ??= await getSongListSettingFromData()
return { ...songListSetting }
}
export const setSongListSetting = async(setting: Partial<typeof DEFAULT_SETTING['songList']>) => {
@@ -164,7 +164,7 @@ export const setSongListSetting = async(setting: Partial<typeof DEFAULT_SETTING[
}
export const getLeaderboardSetting = async() => {
if (!leaderboardSetting) leaderboardSetting = await getLeaderboardSettingFromData()
leaderboardSetting ??= await getLeaderboardSettingFromData()
return { ...leaderboardSetting }
}
export const setLeaderboardSetting = async(setting: Partial<typeof DEFAULT_SETTING['leaderboard']>) => {
+1 -1
View File
@@ -27,7 +27,7 @@ export const dateFormat2 = (time: number): string => {
*/
let dom_title = document.getElementsByTagName('title')[0]
export const setTitle = (title: string | null) => {
if (!title) title = '洛雪音乐助手'
title ||= '洛雪音乐助手'
dom_title.innerText = title
}