diff --git a/.eslintrc.json b/.eslintrc.json index 07a37d9..033d068 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,53 +1,58 @@ -{ - "extends": [ - "next/core-web-vitals", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended", - "eslint-config-prettier" - ], - "plugins": ["prettier"], - "rules": { - "@typescript-eslint/no-explicit-any": ["off"], // 允许使用any - "@typescript-eslint/ban-ts-comment": "off", // 允许使用@ts-ignore - "@typescript-eslint/no-non-null-assertion": "off", // 允许使用非空断言 - "@typescript-eslint/no-var-requires": "off", // 允许使用CommonJS的写法 - "no-console": ["warn", { "allow": ["warn", "error"] }], // 提交时不允许有console.log - "no-debugger": "warn", - "import/order": [ - "error", - { - "groups": ["builtin", "external", "parent", "sibling", "index", "internal", "object", "type"], // 按照分组顺序进行排序 - // 通过路径自定义分组 - "pathGroups": [ - { - "pattern": "react*", - "group": "builtin", - "position": "before" - }, - { - "pattern": "@/components/**", - "group": "parent", - "position": "before" - }, - { - "pattern": "@/utils/**", - "group": "parent", - "position": "after" - }, - { - "pattern": "@/apis/**", - "group": "parent", - "position": "after" - } - ], - "pathGroupsExcludedImportTypes": ["react"], - "newlines-between": "always", // 每个分组之间换行 - // 根据字母顺序对每个组内的顺序进行排序 - "alphabetize": { - "order": "asc", - "caseInsensitive": true - } - } - ] - } -} +{ + "extends": [ + "next/core-web-vitals", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", + "eslint-config-prettier" + ], + "plugins": ["prettier"], + "rules": { + "@typescript-eslint/no-explicit-any": ["off"], // 允许使用any + "@typescript-eslint/ban-ts-comment": "off", // 允许使用@ts-ignore + "@typescript-eslint/no-non-null-assertion": "off", // 允许使用非空断言 + "@typescript-eslint/no-var-requires": "off", // 允许使用CommonJS的写法 + "no-console": ["warn", { "allow": ["warn", "error"] }], // 提交时不允许有console.log + "no-debugger": "warn", + "import/order": [ + "error", + { + "groups": ["builtin", "external", "parent", "sibling", "index", "internal", "object", "type"], // 按照分组顺序进行排序 + // 通过路径自定义分组 + "pathGroups": [ + { + "pattern": "@/components/ui/**", // 添加排除规则 + "group": "internal", // 或者其他你认为合适的组 + "position": "after" + }, + { + "pattern": "react*", + "group": "builtin", + "position": "before" + }, + { + "pattern": "@/components/**", + "group": "parent", + "position": "before" + }, + { + "pattern": "@/utils/**", + "group": "parent", + "position": "after" + }, + { + "pattern": "@/apis/**", + "group": "parent", + "position": "after" + } + ], + "pathGroupsExcludedImportTypes": ["react"], + "newlines-between": "always", // 每个分组之间换行 + // 根据字母顺序对每个组内的顺序进行排序 + "alphabetize": { + "order": "asc", + "caseInsensitive": true + } + } + ] + } +} diff --git a/src/components/AudioPlayer/Player.tsx b/src/components/AudioPlayer/Player.tsx index 87237e4..0a7c50c 100644 --- a/src/components/AudioPlayer/Player.tsx +++ b/src/components/AudioPlayer/Player.tsx @@ -18,7 +18,7 @@ export default function AudioPlayer({ className?: string; onSwitchShowCard: () => void; }) { - const { audioId, order, playQueue, showCard, switchSongByDiff, setOrder, setShowCard } = useAudioStore( + const { audioId, order, playQueue, showCard, switchSongByDiff, setOrder } = useAudioStore( useShallow((state) => { return { audioId: state.audioId, @@ -27,7 +27,6 @@ export default function AudioPlayer({ showCard: state.showCard, setOrder: state.setOrder, switchSongByDiff: state.switchSongByDiff, - setShowCard: state.setShowCard, }; }), ); diff --git a/src/components/AudioPlayer/PlayerBar.tsx b/src/components/AudioPlayer/PlayerBar.tsx index 3e010b6..6ef114e 100644 --- a/src/components/AudioPlayer/PlayerBar.tsx +++ b/src/components/AudioPlayer/PlayerBar.tsx @@ -1,5 +1,5 @@ 'use client'; -import { useEffect, useState } from 'react'; +import { useEffect } from 'react'; import dynamic from 'next/dynamic'; import { useShallow } from 'zustand/react/shallow'; @@ -10,17 +10,13 @@ import PlayerCard from './PlayerCard'; import useAudioStore from '@/store/audio'; const PlayerBar = ({ className }: { className?: string }) => { - const { show, audioId, order, playQueue, showCard, setShow, setOrder, setShowCard } = useAudioStore( + const { show, audioId, showCard, setShow, setShowCard } = useAudioStore( useShallow((state) => { return { show: state.show, audioId: state.audioId, - order: state.order, - playQueue: state.playQueue, showCard: state.showCard, setShow: state.setShow, - setOrder: state.setOrder, - switchSongByDiff: state.switchSongByDiff, setShowCard: state.setShowCard, }; }), diff --git a/src/components/Header/HeaderAvatar.tsx b/src/components/Header/HeaderAvatar.tsx index 9a91c15..33f57b8 100644 --- a/src/components/Header/HeaderAvatar.tsx +++ b/src/components/Header/HeaderAvatar.tsx @@ -2,13 +2,13 @@ import { useShallow } from 'zustand/react/shallow'; -import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; -import { HoverCard, HoverCardPortal, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card'; - import UserCard from './UserCard'; import useUserStore from '@/store/user'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { HoverCard, HoverCardPortal, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card'; + export default function HeaderAvatar({ className }: { className?: string }) { const { userInfo } = useUserStore( useShallow((state) => ({ diff --git a/src/components/Header/UserCard.tsx b/src/components/Header/UserCard.tsx index e2e9ac6..d176d6e 100644 --- a/src/components/Header/UserCard.tsx +++ b/src/components/Header/UserCard.tsx @@ -6,9 +6,10 @@ import { useShallow } from 'zustand/react/shallow'; import logout from '@/utils/logout'; -import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import useUserStore from '@/store/user'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; + interface Props { className?: string; } diff --git a/src/components/Song/SongCardList.tsx b/src/components/Song/SongCardList.tsx index ca3516d..60c3f0f 100644 --- a/src/components/Song/SongCardList.tsx +++ b/src/components/Song/SongCardList.tsx @@ -17,9 +17,7 @@ interface Props { export default function JournalItem({ listId, songList, className }: Props) { const { setPlayList, setAudioId, playListId } = useAudioStore( useShallow((state) => ({ - setplayList: state.setPlayList, setAudioId: state.setAudioId, - playList: state.playList, setPlayList: state.setPlayList, playListId: state.playListId, })), diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx index 0309cc6..acef0d1 100644 --- a/src/components/ui/avatar.tsx +++ b/src/components/ui/avatar.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import * as AvatarPrimitive from '@radix-ui/react-avatar'; -import { cn } from '/src/lib/utils'; +import { cn } from '@/lib/utils'; const Avatar = React.forwardRef< React.ElementRef, diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx deleted file mode 100644 index 8f2d55a..0000000 --- a/src/components/ui/button.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import * as React from 'react'; - -import { Slot } from '@radix-ui/react-slot'; -import { cva, type VariantProps } from 'class-variance-authority'; - -import { cn } from '/src/lib/utils'; - -const buttonVariants = cva( - 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', - { - variants: { - variant: { - default: 'bg-primary text-primary-foreground hover:bg-primary/90', - destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90', - outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground', - secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80', - ghost: 'hover:bg-accent hover:text-accent-foreground', - link: 'text-primary underline-offset-4 hover:underline', - }, - size: { - default: 'h-10 px-4 py-2', - sm: 'h-9 rounded-md px-3', - lg: 'h-11 rounded-md px-8', - icon: 'h-10 w-10', - }, - }, - defaultVariants: { - variant: 'default', - size: 'default', - }, - }, -); - -export interface ButtonProps - extends React.ButtonHTMLAttributes, - VariantProps { - asChild?: boolean; -} - -const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : 'button'; - return ; - }, -); -Button.displayName = 'Button'; - -export { Button, buttonVariants }; diff --git a/src/components/ui/hover-card.tsx b/src/components/ui/hover-card.tsx index 9eb3b19..4c5c0b3 100644 --- a/src/components/ui/hover-card.tsx +++ b/src/components/ui/hover-card.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import * as HoverCardPrimitive from '@radix-ui/react-hover-card'; -import { cn } from '/src/lib/utils'; +import { cn } from '@/lib/utils'; const HoverCard = HoverCardPrimitive.Root; diff --git a/src/store/audio.ts b/src/store/audio.ts index 94271b6..35796cd 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -16,7 +16,6 @@ interface AuioState { showCard: boolean; /** 当前音频id */ audioId: string; - audioInfo: SongInfo | null; /** 歌单列表 */ playList: SongInfo[]; /** 播放队列 */ @@ -104,7 +103,6 @@ const useAuioState = create()( playListId: '', playList: [], playQueue: [], - audioInfo: get()?.playList.length ? get().playList.find((item) => item.id === get().audioId) : null, setAudioId, setOrder, setShow: (value) =>