mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-28 10:57:23 +08:00
refactor: 移除未使用的导入和格式问题
This commit is contained in:
@@ -132,13 +132,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { cloneDeep } from 'lodash';
|
|
||||||
import type { MenuOption } from 'naive-ui';
|
import type { MenuOption } from 'naive-ui';
|
||||||
import { NEllipsis, NImage, useMessage, useDialog } from 'naive-ui';
|
import { NEllipsis, NImage, useMessage, useDialog } from 'naive-ui';
|
||||||
import { computed, h, inject, ref, useTemplateRef } from 'vue';
|
import { computed, h, inject, ref, useTemplateRef } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import { getSongUrl } from '@/store/modules/player';
|
|
||||||
import { useArtist } from '@/hooks/useArtist';
|
import { useArtist } from '@/hooks/useArtist';
|
||||||
import { usePlayerStore } from '@/store';
|
import { usePlayerStore } from '@/store';
|
||||||
import type { SongResult } from '@/type/music';
|
import type { SongResult } from '@/type/music';
|
||||||
@@ -350,7 +348,7 @@ const handleSelect = (key: string | number) => {
|
|||||||
showDropdown.value = false;
|
showDropdown.value = false;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'download':
|
case 'download':
|
||||||
downloadMusic();
|
downloadMusic(props.item);
|
||||||
break;
|
break;
|
||||||
case 'playNext':
|
case 'playNext':
|
||||||
handlePlayNext();
|
handlePlayNext();
|
||||||
@@ -376,7 +374,7 @@ const handleSelect = (key: string | number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 下载音乐
|
// 下载音乐
|
||||||
const { isDownloading, downloadMusic } = useDownload();
|
const { downloadMusic } = useDownload();
|
||||||
|
|
||||||
const emits = defineEmits(['play', 'select', 'remove-song']);
|
const emits = defineEmits(['play', 'select', 'remove-song']);
|
||||||
const songImageRef = useTemplateRef('songImg');
|
const songImageRef = useTemplateRef('songImg');
|
||||||
|
|||||||
@@ -1,110 +1,108 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="isComponent ? favoriteSongs.length : true" class="favorite-page">
|
<div v-if="isComponent ? favoriteSongs.length : true" class="favorite-page">
|
||||||
<div class="favorite-header" :class="setAnimationClass('animate__fadeInLeft')">
|
<div class="favorite-header" :class="setAnimationClass('animate__fadeInLeft')">
|
||||||
<div class="favorite-header-left">
|
<div class="favorite-header-left">
|
||||||
<h2>{{ t('favorite.title') }}</h2>
|
<h2>{{ t('favorite.title') }}</h2>
|
||||||
<div class="favorite-count">{{ t('favorite.count', { count: favoriteList.length }) }}</div>
|
<div class="favorite-count">{{ t('favorite.count', { count: favoriteList.length }) }}</div>
|
||||||
</div>
|
|
||||||
<div v-if="!isComponent && isElectron" class="favorite-header-right">
|
|
||||||
<div class="sort-controls" v-if="!isSelecting">
|
|
||||||
<div class="sort-buttons">
|
|
||||||
<div
|
|
||||||
class="sort-button"
|
|
||||||
:class="{ active: isDescending }"
|
|
||||||
@click="toggleSort(true)"
|
|
||||||
>
|
|
||||||
<i class="iconfont ri-sort-desc"></i>
|
|
||||||
{{ t('favorite.descending') }}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="sort-button"
|
|
||||||
:class="{ active: !isDescending }"
|
|
||||||
@click="toggleSort(false)"
|
|
||||||
>
|
|
||||||
<i class="iconfont ri-sort-asc"></i>
|
|
||||||
{{ t('favorite.ascending') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<n-button
|
|
||||||
v-if="!isSelecting"
|
|
||||||
secondary
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
class="select-btn"
|
|
||||||
@click="startSelect"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<i class="iconfont ri-checkbox-multiple-line"></i>
|
|
||||||
</template>
|
|
||||||
{{ t('favorite.batchDownload') }}
|
|
||||||
</n-button>
|
|
||||||
<div v-else class="select-controls">
|
|
||||||
<n-checkbox
|
|
||||||
class="select-all-checkbox"
|
|
||||||
:checked="isAllSelected"
|
|
||||||
:indeterminate="isIndeterminate"
|
|
||||||
@update:checked="handleSelectAll"
|
|
||||||
>
|
|
||||||
{{ t('common.selectAll') }}
|
|
||||||
</n-checkbox>
|
|
||||||
<n-button-group class="operation-btns">
|
|
||||||
<n-button
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
:loading="isDownloading"
|
|
||||||
:disabled="selectedSongs.length === 0"
|
|
||||||
class="download-btn"
|
|
||||||
@click="handleBatchDownload"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<i class="iconfont ri-download-line"></i>
|
|
||||||
</template>
|
|
||||||
{{ t('favorite.download', { count: selectedSongs.length }) }}
|
|
||||||
</n-button>
|
|
||||||
<n-button size="small" class="cancel-btn" @click="cancelSelect">
|
|
||||||
{{ t('common.cancel') }}
|
|
||||||
</n-button>
|
|
||||||
</n-button-group>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="favorite-main" :class="setAnimationClass('animate__bounceInRight')">
|
<div v-if="!isComponent && isElectron" class="favorite-header-right">
|
||||||
<n-scrollbar ref="scrollbarRef" class="favorite-content" @scroll="handleScroll">
|
<div class="sort-controls" v-if="!isSelecting">
|
||||||
<div v-if="favoriteList.length === 0" class="empty-tip">
|
<div class="sort-buttons">
|
||||||
<n-empty :description="t('favorite.emptyTip')" />
|
<div
|
||||||
</div>
|
class="sort-button"
|
||||||
<div v-else class="favorite-list" :class="{ 'max-w-[400px]': isComponent }">
|
:class="{ active: isDescending }"
|
||||||
<song-item
|
@click="toggleSort(true)"
|
||||||
v-for="(song, index) in favoriteSongs"
|
>
|
||||||
:key="song.id"
|
<i class="iconfont ri-sort-desc"></i>
|
||||||
:item="song"
|
{{ t('favorite.descending') }}
|
||||||
:favorite="false"
|
|
||||||
:class="setAnimationClass('animate__bounceInLeft')"
|
|
||||||
:style="getItemAnimationDelay(index)"
|
|
||||||
:selectable="isSelecting"
|
|
||||||
:selected="selectedSongs.includes(song.id as number)"
|
|
||||||
@play="handlePlay"
|
|
||||||
@select="handleSelect"
|
|
||||||
/>
|
|
||||||
<div v-if="isComponent" class="favorite-list-more text-center">
|
|
||||||
<n-button text type="primary" @click="handleMore">{{ t('common.viewMore') }}</n-button>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
<div v-if="loading" class="loading-wrapper">
|
class="sort-button"
|
||||||
<n-spin size="large" />
|
:class="{ active: !isDescending }"
|
||||||
|
@click="toggleSort(false)"
|
||||||
|
>
|
||||||
|
<i class="iconfont ri-sort-asc"></i>
|
||||||
|
{{ t('favorite.ascending') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="noMore" class="no-more-tip">{{ t('common.noMore') }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</n-scrollbar>
|
</div>
|
||||||
|
<n-button
|
||||||
|
v-if="!isSelecting"
|
||||||
|
secondary
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
class="select-btn"
|
||||||
|
@click="startSelect"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<i class="iconfont ri-checkbox-multiple-line"></i>
|
||||||
|
</template>
|
||||||
|
{{ t('favorite.batchDownload') }}
|
||||||
|
</n-button>
|
||||||
|
<div v-else class="select-controls">
|
||||||
|
<n-checkbox
|
||||||
|
class="select-all-checkbox"
|
||||||
|
:checked="isAllSelected"
|
||||||
|
:indeterminate="isIndeterminate"
|
||||||
|
@update:checked="handleSelectAll"
|
||||||
|
>
|
||||||
|
{{ t('common.selectAll') }}
|
||||||
|
</n-checkbox>
|
||||||
|
<n-button-group class="operation-btns">
|
||||||
|
<n-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
:loading="isDownloading"
|
||||||
|
:disabled="selectedSongs.length === 0"
|
||||||
|
class="download-btn"
|
||||||
|
@click="handleBatchDownload"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<i class="iconfont ri-download-line"></i>
|
||||||
|
</template>
|
||||||
|
{{ t('favorite.download', { count: selectedSongs.length }) }}
|
||||||
|
</n-button>
|
||||||
|
<n-button size="small" class="cancel-btn" @click="cancelSelect">
|
||||||
|
{{ t('common.cancel') }}
|
||||||
|
</n-button>
|
||||||
|
</n-button-group>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
<div class="favorite-main" :class="setAnimationClass('animate__bounceInRight')">
|
||||||
|
<n-scrollbar ref="scrollbarRef" class="favorite-content" @scroll="handleScroll">
|
||||||
|
<div v-if="favoriteList.length === 0" class="empty-tip">
|
||||||
|
<n-empty :description="t('favorite.emptyTip')" />
|
||||||
|
</div>
|
||||||
|
<div v-else class="favorite-list" :class="{ 'max-w-[400px]': isComponent }">
|
||||||
|
<song-item
|
||||||
|
v-for="(song, index) in favoriteSongs"
|
||||||
|
:key="song.id"
|
||||||
|
:item="song"
|
||||||
|
:favorite="false"
|
||||||
|
:class="setAnimationClass('animate__bounceInLeft')"
|
||||||
|
:style="getItemAnimationDelay(index)"
|
||||||
|
:selectable="isSelecting"
|
||||||
|
:selected="selectedSongs.includes(song.id as number)"
|
||||||
|
@play="handlePlay"
|
||||||
|
@select="handleSelect"
|
||||||
|
/>
|
||||||
|
<div v-if="isComponent" class="favorite-list-more text-center">
|
||||||
|
<n-button text type="primary" @click="handleMore">{{ t('common.viewMore') }}</n-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<div v-if="loading" class="loading-wrapper">
|
||||||
import { cloneDeep } from 'lodash';
|
<n-spin size="large" />
|
||||||
import { useMessage } from 'naive-ui';
|
</div>
|
||||||
|
|
||||||
|
<div v-if="noMore" class="no-more-tip">{{ t('common.noMore') }}</div>
|
||||||
|
</div>
|
||||||
|
</n-scrollbar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
@@ -119,7 +117,6 @@ import { isElectron, setAnimationClass, setAnimationDelay } from '@/utils';
|
|||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const playerStore = usePlayerStore();
|
const playerStore = usePlayerStore();
|
||||||
const message = useMessage();
|
|
||||||
const favoriteList = computed(() => playerStore.favoriteList);
|
const favoriteList = computed(() => playerStore.favoriteList);
|
||||||
const favoriteSongs = ref<SongResult[]>([]);
|
const favoriteSongs = ref<SongResult[]>([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user