refactor: 更新 eslint 和 prettier 配置 格式化代码

This commit is contained in:
alger
2025-07-23 23:54:35 +08:00
parent d1f5c8af84
commit c08c2cbf19
134 changed files with 3887 additions and 3301 deletions
+22 -15
View File
@@ -103,7 +103,13 @@
:class="setAnimationClass('animate__bounceInUp')"
:style="setAnimationDelay(index, 25)"
>
<song-item class="song-item" :index="index" :item="item" compact @play="handlePlay" />
<song-item
class="song-item"
:index="index"
:item="item"
compact
@play="handlePlay"
/>
</div>
</div>
</n-tab-pane>
@@ -128,8 +134,8 @@ import { useRoute, useRouter } from 'vue-router';
import { getListDetail } from '@/api/list';
import { getUserDetail, getUserPlaylist, getUserRecord } from '@/api/user';
import SongItem from '@/components/common/SongItem.vue';
import { navigateToMusicList } from '@/components/common/MusicListNavigator';
import SongItem from '@/components/common/SongItem.vue';
import { usePlayerStore } from '@/store/modules/player';
import type { Playlist } from '@/type/listDetail';
import type { IUserDetail } from '@/type/user';
@@ -190,7 +196,7 @@ const loadUserData = async () => {
// 2. 单独处理听歌记录请求,这个请求可能会无权限
try {
const recordRes = await getUserRecord(userId.value);
if (recordRes.data && recordRes.data.allData) {
recordList.value = recordRes.data.allData.map((item: any) => ({
...item,
@@ -233,11 +239,11 @@ watch(
// 替换显示歌单的方法
const openPlaylist = (item: any) => {
listLoading.value = true;
getListDetail(item.id).then(res => {
getListDetail(item.id).then((res) => {
currentList.value = res.data.playlist;
listLoading.value = false;
navigateToMusicList(router, {
id: item.id,
type: 'playlist',
@@ -260,12 +266,12 @@ const handlePlay = () => {
// 显示关注列表
const showFollowList = () => {
if (!userDetail.value) return;
router.push({
path: `/user/follows`,
query: {
query: {
uid: userId.value.toString(),
name: userDetail.value.profile.nickname
name: userDetail.value.profile.nickname
}
});
};
@@ -273,12 +279,12 @@ const showFollowList = () => {
// 显示粉丝列表
const showFollowerList = () => {
if (!userDetail.value) return;
router.push({
path: `/user/followers`,
query: {
query: {
uid: userId.value.toString(),
name: userDetail.value.profile.nickname
name: userDetail.value.profile.nickname
}
});
};
@@ -340,8 +346,9 @@ const isArtist = (profile: any) => {
.label {
@apply text-lg font-bold;
}
&:nth-child(1), &:nth-child(2) {
&:nth-child(1),
&:nth-child(2) {
@apply cursor-pointer transition-all duration-200;
@apply hover:bg-black hover:bg-opacity-20 rounded-lg px-2;
}
@@ -426,7 +433,7 @@ const isArtist = (profile: any) => {
.no-permission {
@apply flex flex-col items-center justify-center text-gray-500 dark:text-gray-400;
@apply p-4 rounded-lg;
i {
@apply text-3xl mb-2;
}
+17 -18
View File
@@ -7,7 +7,7 @@
<div class="page-title" v-else>
{{ t('user.follower.myFollowersTitle') }}
</div>
<n-spin v-if="followerListLoading && followerList.length === 0" size="large" />
<n-scrollbar v-else class="scrollbar-container">
<div v-if="followerList.length === 0" class="empty-follower">
@@ -69,7 +69,7 @@
import { useMessage } from 'naive-ui';
import { computed, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter, useRoute } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { getUserFollowers } from '@/api/user';
import { useUserStore } from '@/store/modules/user';
@@ -101,13 +101,13 @@ const user = computed(() => userStore.user);
const checkTargetUser = () => {
const uid = route.query.uid;
const name = route.query.name;
if (uid && typeof uid === 'string') {
targetUserId.value = parseInt(uid);
targetUserName.value = typeof name === 'string' ? name : '';
return true;
}
// 如果没有指定用户ID,则显示当前登录用户的粉丝列表
return checkLoginStatus();
};
@@ -133,17 +133,13 @@ const checkLoginStatus = () => {
// 加载粉丝列表
const loadFollowerList = async () => {
// 确定要加载哪个用户的粉丝列表
const userId = targetUserId.value || (user.value?.userId);
const userId = targetUserId.value || user.value?.userId;
if (!userId) return;
try {
followerListLoading.value = true;
const { data } = await getUserFollowers(
userId,
followerLimit.value,
followerOffset.value
);
const { data } = await getUserFollowers(userId, followerLimit.value, followerOffset.value);
if (!data || !data.followeds) {
hasMoreFollowers.value = false;
@@ -191,14 +187,17 @@ onMounted(() => {
});
// 监听路由变化重新加载数据
watch(() => route.query, (newQuery) => {
if (newQuery.uid && newQuery.uid !== targetUserId.value?.toString()) {
followerList.value = []; // 清空列表
followerOffset.value = 0; // 重置偏移量
checkTargetUser();
loadFollowerList();
watch(
() => route.query,
(newQuery) => {
if (newQuery.uid && newQuery.uid !== targetUserId.value?.toString()) {
followerList.value = []; // 清空列表
followerOffset.value = 0; // 重置偏移量
checkTargetUser();
loadFollowerList();
}
}
});
);
</script>
<style lang="scss" scoped>
+16 -13
View File
@@ -7,7 +7,7 @@
<div class="page-title" v-else>
{{ t('user.follow.myFollowsTitle') }}
</div>
<n-spin v-if="followListLoading && followList.length === 0" size="large" />
<n-scrollbar v-else class="scrollbar-container">
<div v-if="followList.length === 0" class="empty-follow">
@@ -69,7 +69,7 @@
import { useMessage } from 'naive-ui';
import { computed, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter, useRoute } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { getUserFollows } from '@/api/user';
import { useUserStore } from '@/store/modules/user';
@@ -101,13 +101,13 @@ const user = computed(() => userStore.user);
const checkTargetUser = () => {
const uid = route.query.uid;
const name = route.query.name;
if (uid && typeof uid === 'string') {
targetUserId.value = parseInt(uid);
targetUserName.value = typeof name === 'string' ? name : '';
return true;
}
// 如果没有指定用户ID,则显示当前登录用户的关注列表
return checkLoginStatus();
};
@@ -133,8 +133,8 @@ const checkLoginStatus = () => {
// 加载关注列表
const loadFollowList = async () => {
// 确定要加载哪个用户的关注列表
const userId = targetUserId.value || (user.value?.userId);
const userId = targetUserId.value || user.value?.userId;
if (!userId) return;
try {
@@ -187,14 +187,17 @@ onMounted(() => {
});
// 监听路由变化重新加载数据
watch(() => route.query, (newQuery) => {
if (newQuery.uid && newQuery.uid !== targetUserId.value?.toString()) {
followList.value = []; // 清空列表
followOffset.value = 0; // 重置偏移量
checkTargetUser();
loadFollowList();
watch(
() => route.query,
(newQuery) => {
if (newQuery.uid && newQuery.uid !== targetUserId.value?.toString()) {
followList.value = []; // 清空列表
followOffset.value = 0; // 重置偏移量
checkTargetUser();
loadFollowList();
}
}
});
);
</script>
<style lang="scss" scoped>
+18 -12
View File
@@ -30,7 +30,9 @@
<div class="play-list" :class="setAnimationClass('animate__fadeInLeft')">
<div class="title">
<div>{{ t('user.playlist.created') }}</div>
<div class="import-btn" @click="goToImportPlaylist" v-if="isElectron">{{ t('comp.playlist.import.button') }}</div>
<div class="import-btn" @click="goToImportPlaylist" v-if="isElectron">
{{ t('comp.playlist.import.button') }}
</div>
</div>
<n-scrollbar>
<div
@@ -91,7 +93,11 @@
</div>
</div>
<!-- 未登录时显示登录组件 -->
<div v-if="!isLoggedIn && isMobile" class="login-container" :class="setAnimationClass('animate__fadeIn')">
<div
v-if="!isLoggedIn && isMobile"
class="login-container"
:class="setAnimationClass('animate__fadeIn')"
>
<login-component @login-success="handleLoginSuccess" />
</div>
</div>
@@ -105,9 +111,9 @@ import { useRouter } from 'vue-router';
import { getListDetail } from '@/api/list';
import { getUserDetail, getUserPlaylist, getUserRecord } from '@/api/user';
import { navigateToMusicList } from '@/components/common/MusicListNavigator';
import PlayBottom from '@/components/common/PlayBottom.vue';
import SongItem from '@/components/common/SongItem.vue';
import { navigateToMusicList } from '@/components/common/MusicListNavigator';
import { usePlayerStore } from '@/store/modules/player';
import { useUserStore } from '@/store/modules/user';
import type { Playlist } from '@/type/listDetail';
@@ -243,11 +249,11 @@ onMounted(() => {
// 替换显示歌单的方法
const openPlaylist = (item: any) => {
listLoading.value = true;
getListDetail(item.id).then(res => {
getListDetail(item.id).then((res) => {
list.value = res.data.playlist;
listLoading.value = false;
navigateToMusicList(router, {
id: item.id,
type: 'playlist',
@@ -300,11 +306,11 @@ const isLoggedIn = computed(() => userStore.user);
.title {
@apply text-lg font-bold flex items-center justify-between;
@apply text-gray-900 dark:text-white;
.import-btn {
@apply bg-light-100 font-normal rounded-lg px-2 py-1 text-opacity-70 text-sm hover:bg-light-200 hover:text-green-500 dark:bg-dark-200 dark:hover:bg-dark-300 dark:hover:text-green-400;
@apply cursor-pointer;
@apply transition-all duration-200;
}
.import-btn {
@apply bg-light-100 font-normal rounded-lg px-2 py-1 text-opacity-70 text-sm hover:bg-light-200 hover:text-green-500 dark:bg-dark-200 dark:hover:bg-dark-300 dark:hover:text-green-400;
@apply cursor-pointer;
@apply transition-all duration-200;
}
}
.user-name {
@@ -388,7 +394,7 @@ const isLoggedIn = computed(() => userStore.user);
&-name {
@apply text-gray-900 dark:text-white text-base flex items-center gap-2;
.playlist-creator-tag {
@apply inline-flex items-center justify-center px-2 rounded-full text-xs;
@apply bg-light-300 text-primary dark:bg-dark-300 dark:text-white;