96 UI optimization (#122)

* fix(home): 🐛 解决多次切换路由后页面卡顿的问题 #96

卸载路由时清除requestAnimationFrame

* feat:  文件存储使用Blob格式

* style: 💄 修改部分类型any为具体类型

* feat:  界面设置中模块使用瀑布流布局 #96

* fix: 🐛 md文档更换文件夹解决控制台警告

* style: 💄 switch按钮改回使用daisyui组件

* refactor: ♻️ 所有人员列表提取tableColumn

* style: 💄 奖项列表中的图片类型修复
This commit is contained in:
LOG1997
2025-12-18 17:32:00 +08:00
committed by GitHub
parent 92254cb750
commit 5b8682bb7c
29 changed files with 351 additions and 146 deletions

View File

@@ -1,3 +1,5 @@
import type { IFileData } from '@/components/FileUpload/type'
import type { IMusic } from '@/types/storeType'
import localforage from 'localforage'
import { storeToRefs } from 'pinia'
import { onMounted, onUnmounted, ref, watch } from 'vue'
@@ -12,7 +14,7 @@ export function usePlayMusic() {
const { getMusicList: localMusicList, getCurrentMusic: currentMusic } = storeToRefs(globalConfig)
const audio = ref(new Audio())
async function play(item: any) {
async function play(item: IMusic) {
if (!item) {
return
}
@@ -26,16 +28,18 @@ export function usePlayMusic() {
return
}
if (item.url === 'Storage') {
audioUrl = await audioDbStore.getItem(item.name) as string
const key = item.id
const audioData = await audioDbStore.getItem<IFileData>(key)
audioUrl = URL.createObjectURL(audioData?.data as Blob)
}
else {
audioUrl = item.url
audioUrl = item.url as string
}
audio.value.pause()
audio.value.src = audioUrl
audio.value.play()
}
function playMusic(item: any, skip = false) {
function playMusic(item: IMusic, skip = false) {
if (!item) {
return
}
@@ -49,7 +53,7 @@ export function usePlayMusic() {
function nextPlay() {
// 播放下一首
if (localMusicList.value.length >= 1) {
let index = localMusicList.value.findIndex((item: any) => item.name === currentMusic.value.item.name)
let index = localMusicList.value.findIndex((item: IMusic) => item.name === currentMusic.value.item.name)
index++
if (index >= localMusicList.value.length) {
index = 0
@@ -69,7 +73,7 @@ export function usePlayMusic() {
onUnmounted(() => {
audio.value.removeEventListener('ended', nextPlay)
})
watch(currentMusic, (val: any) => {
watch(currentMusic, (val: { item: IMusic, paused: boolean }) => {
if (!val.paused && audio.value) {
play(val.item)
}