perf: eslint

mack-mac
mackt 7 months ago
parent 129b7ac7c7
commit 5846c05e08

@ -1,53 +1,58 @@
{ {
"extends": [ "extends": [
"next/core-web-vitals", "next/core-web-vitals",
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended", "plugin:prettier/recommended",
"eslint-config-prettier" "eslint-config-prettier"
], ],
"plugins": ["prettier"], "plugins": ["prettier"],
"rules": { "rules": {
"@typescript-eslint/no-explicit-any": ["off"], // 使any "@typescript-eslint/no-explicit-any": ["off"], // 使any
"@typescript-eslint/ban-ts-comment": "off", // 使@ts-ignore "@typescript-eslint/ban-ts-comment": "off", // 使@ts-ignore
"@typescript-eslint/no-non-null-assertion": "off", // 使 "@typescript-eslint/no-non-null-assertion": "off", // 使
"@typescript-eslint/no-var-requires": "off", // 使CommonJS "@typescript-eslint/no-var-requires": "off", // 使CommonJS
"no-console": ["warn", { "allow": ["warn", "error"] }], // console.log "no-console": ["warn", { "allow": ["warn", "error"] }], // console.log
"no-debugger": "warn", "no-debugger": "warn",
"import/order": [ "import/order": [
"error", "error",
{ {
"groups": ["builtin", "external", "parent", "sibling", "index", "internal", "object", "type"], // "groups": ["builtin", "external", "parent", "sibling", "index", "internal", "object", "type"], //
// //
"pathGroups": [ "pathGroups": [
{ {
"pattern": "react*", "pattern": "@/components/ui/**", //
"group": "builtin", "group": "internal", //
"position": "before" "position": "after"
}, },
{ {
"pattern": "@/components/**", "pattern": "react*",
"group": "parent", "group": "builtin",
"position": "before" "position": "before"
}, },
{ {
"pattern": "@/utils/**", "pattern": "@/components/**",
"group": "parent", "group": "parent",
"position": "after" "position": "before"
}, },
{ {
"pattern": "@/apis/**", "pattern": "@/utils/**",
"group": "parent", "group": "parent",
"position": "after" "position": "after"
} },
], {
"pathGroupsExcludedImportTypes": ["react"], "pattern": "@/apis/**",
"newlines-between": "always", // "group": "parent",
// "position": "after"
"alphabetize": { }
"order": "asc", ],
"caseInsensitive": true "pathGroupsExcludedImportTypes": ["react"],
} "newlines-between": "always", //
} //
] "alphabetize": {
} "order": "asc",
} "caseInsensitive": true
}
}
]
}
}

@ -18,7 +18,7 @@ export default function AudioPlayer({
className?: string; className?: string;
onSwitchShowCard: () => void; onSwitchShowCard: () => void;
}) { }) {
const { audioId, order, playQueue, showCard, switchSongByDiff, setOrder, setShowCard } = useAudioStore( const { audioId, order, playQueue, showCard, switchSongByDiff, setOrder } = useAudioStore(
useShallow((state) => { useShallow((state) => {
return { return {
audioId: state.audioId, audioId: state.audioId,
@ -27,7 +27,6 @@ export default function AudioPlayer({
showCard: state.showCard, showCard: state.showCard,
setOrder: state.setOrder, setOrder: state.setOrder,
switchSongByDiff: state.switchSongByDiff, switchSongByDiff: state.switchSongByDiff,
setShowCard: state.setShowCard,
}; };
}), }),
); );

@ -1,5 +1,5 @@
'use client'; 'use client';
import { useEffect, useState } from 'react'; import { useEffect } from 'react';
import dynamic from 'next/dynamic'; import dynamic from 'next/dynamic';
import { useShallow } from 'zustand/react/shallow'; import { useShallow } from 'zustand/react/shallow';
@ -10,17 +10,13 @@ import PlayerCard from './PlayerCard';
import useAudioStore from '@/store/audio'; import useAudioStore from '@/store/audio';
const PlayerBar = ({ className }: { className?: string }) => { const PlayerBar = ({ className }: { className?: string }) => {
const { show, audioId, order, playQueue, showCard, setShow, setOrder, setShowCard } = useAudioStore( const { show, audioId, showCard, setShow, setShowCard } = useAudioStore(
useShallow((state) => { useShallow((state) => {
return { return {
show: state.show, show: state.show,
audioId: state.audioId, audioId: state.audioId,
order: state.order,
playQueue: state.playQueue,
showCard: state.showCard, showCard: state.showCard,
setShow: state.setShow, setShow: state.setShow,
setOrder: state.setOrder,
switchSongByDiff: state.switchSongByDiff,
setShowCard: state.setShowCard, setShowCard: state.setShowCard,
}; };
}), }),

@ -2,13 +2,13 @@
import { useShallow } from 'zustand/react/shallow'; 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 UserCard from './UserCard';
import useUserStore from '@/store/user'; 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 }) { export default function HeaderAvatar({ className }: { className?: string }) {
const { userInfo } = useUserStore( const { userInfo } = useUserStore(
useShallow((state) => ({ useShallow((state) => ({

@ -6,9 +6,10 @@ import { useShallow } from 'zustand/react/shallow';
import logout from '@/utils/logout'; import logout from '@/utils/logout';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import useUserStore from '@/store/user'; import useUserStore from '@/store/user';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
interface Props { interface Props {
className?: string; className?: string;
} }

@ -17,9 +17,7 @@ interface Props {
export default function JournalItem({ listId, songList, className }: Props) { export default function JournalItem({ listId, songList, className }: Props) {
const { setPlayList, setAudioId, playListId } = useAudioStore( const { setPlayList, setAudioId, playListId } = useAudioStore(
useShallow((state) => ({ useShallow((state) => ({
setplayList: state.setPlayList,
setAudioId: state.setAudioId, setAudioId: state.setAudioId,
playList: state.playList,
setPlayList: state.setPlayList, setPlayList: state.setPlayList,
playListId: state.playListId, playListId: state.playListId,
})), })),

@ -2,7 +2,7 @@ import * as React from 'react';
import * as AvatarPrimitive from '@radix-ui/react-avatar'; import * as AvatarPrimitive from '@radix-ui/react-avatar';
import { cn } from '/src/lib/utils'; import { cn } from '@/lib/utils';
const Avatar = React.forwardRef< const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>, React.ElementRef<typeof AvatarPrimitive.Root>,

@ -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<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button';
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
},
);
Button.displayName = 'Button';
export { Button, buttonVariants };

@ -2,7 +2,7 @@ import * as React from 'react';
import * as HoverCardPrimitive from '@radix-ui/react-hover-card'; import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
import { cn } from '/src/lib/utils'; import { cn } from '@/lib/utils';
const HoverCard = HoverCardPrimitive.Root; const HoverCard = HoverCardPrimitive.Root;

@ -16,7 +16,6 @@ interface AuioState {
showCard: boolean; showCard: boolean;
/** 当前音频id */ /** 当前音频id */
audioId: string; audioId: string;
audioInfo: SongInfo | null;
/** 歌单列表 */ /** 歌单列表 */
playList: SongInfo[]; playList: SongInfo[];
/** 播放队列 */ /** 播放队列 */
@ -104,7 +103,6 @@ const useAuioState = create<AuioState>()(
playListId: '', playListId: '',
playList: [], playList: [],
playQueue: [], playQueue: [],
audioInfo: get()?.playList.length ? get().playList.find((item) => item.id === get().audioId) : null,
setAudioId, setAudioId,
setOrder, setOrder,
setShow: (value) => setShow: (value) =>

Loading…
Cancel
Save