feat: update eslint & prettier rules

This commit is contained in:
HYana
2025-04-30 17:36:46 +08:00
parent d4af2d4326
commit 460e065eed
53 changed files with 2241 additions and 2102 deletions
@@ -1,17 +1,17 @@
"use client";
'use client';
import styles from "./HomeSidebar.module.css";
import { useEffect, useState } from "react";
import styles from './HomeSidebar.module.css';
import { useEffect, useState } from 'react';
import {
SidebarChild,
SidebarChildVO
} from "@/app/home/components/home-sidebar/HomeSidebarChild";
import { useRouter, usePathname } from "next/navigation";
import { sidebarConfigList } from "@/app/home/components/home-sidebar/sidbarConfigList";
SidebarChildVO,
} from '@/app/home/components/home-sidebar/HomeSidebarChild';
import { useRouter, usePathname } from 'next/navigation';
import { sidebarConfigList } from '@/app/home/components/home-sidebar/sidbarConfigList';
// TODO 侧边导航栏要加动画
export default function HomeSidebar({
onSelectedChangeAction
onSelectedChangeAction,
}: {
onSelectedChangeAction: (sidebarChild: SidebarChildVO) => void;
}) {
@@ -24,13 +24,13 @@ export default function HomeSidebar({
}, [pathname]);
const [selectedChild, setSelectedChild] = useState<SidebarChildVO>(
sidebarConfigList[0]
sidebarConfigList[0],
);
useEffect(() => {
console.log("HomeSidebar挂载完成");
console.log('HomeSidebar挂载完成');
initSelect();
return () => console.log("HomeSidebar卸载");
return () => console.log('HomeSidebar卸载');
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -52,14 +52,14 @@ export default function HomeSidebar({
function handleRouteChange(pathname: string) {
// TODO 这段逻辑并不好,未来router封装好后改掉
// 判断在home下,并且路由更改的是自己的路由子组件则更新UI
const routeList = pathname.split("/");
const routeList = pathname.split('/');
if (
routeList[1] === "home" &&
routeList[1] === 'home' &&
sidebarConfigList.find((childConfig) => childConfig.route === pathname)
) {
console.log("find success");
console.log('find success');
const routeSelectChild = sidebarConfigList.find(
(childConfig) => childConfig.route === pathname
(childConfig) => childConfig.route === pathname,
);
if (routeSelectChild) {
setSelectedChild(routeSelectChild);
@@ -67,42 +67,34 @@ export default function HomeSidebar({
}
}
return (
<div className={`${styles.sidebarContainer}`}>
{/* LangBot、ICON区域 */}
<div className={`${styles.langbotIconContainer}`}>
{/* icon */}
<div className={`${styles.langbotIcon}`}>
L
</div>
<div className={`${styles.langbotText}`}>
Langbot
</div>
return (
<div className={`${styles.sidebarContainer}`}>
{/* LangBot、ICON区域 */}
<div className={`${styles.langbotIconContainer}`}>
{/* icon */}
<div className={`${styles.langbotIcon}`}>L</div>
<div className={`${styles.langbotText}`}>Langbot</div>
</div>
{/* 菜单列表,后期可升级成配置驱动 */}
<div>
{sidebarConfigList.map((config) => {
return (
<div
key={config.id}
onClick={() => {
console.log('click:', config.id);
handleChildClick(config);
}}
>
<SidebarChild
isSelected={selectedChild.id === config.id}
icon={config.icon}
name={config.name}
/>
</div>
{/* 菜单列表,后期可升级成配置驱动 */}
<div>
{
sidebarConfigList.map(config => {
return (
<div
key={config.id}
onClick={() => {
console.log('click:', config.id)
handleChildClick(config)
}}
>
<SidebarChild
isSelected={selectedChild.id === config.id}
icon={config.icon}
name={config.name}
/>
</div>
)
})
}
</div>
</div>
);
}
);
})}
</div>
</div>
);
}
@@ -1,4 +1,4 @@
import styles from "./HomeSidebar.module.css";
import styles from './HomeSidebar.module.css';
export interface ISidebarChildVO {
id: string;
@@ -24,7 +24,7 @@ export class SidebarChildVO {
export function SidebarChild({
icon,
name,
isSelected
isSelected,
}: {
icon: string;
name: string;
@@ -1,28 +1,28 @@
import {SidebarChildVO} from "@/app/home/components/home-sidebar/HomeSidebarChild";
import { SidebarChildVO } from '@/app/home/components/home-sidebar/HomeSidebarChild';
export const sidebarConfigList = [
new SidebarChildVO({
id: "models",
name: "模型配置",
icon: "",
route: "/home/models",
}),
new SidebarChildVO({
id: "bots",
name: "机器人",
icon: "",
route: "/home/bots",
}),
new SidebarChildVO({
id: "pipelines",
name: "流水线",
icon: "",
route: "/home/pipelines",
}),
new SidebarChildVO({
id: "plugins",
name: "插件管理",
icon: "",
route: "/home/plugins",
}),
]
new SidebarChildVO({
id: 'models',
name: '模型配置',
icon: '',
route: '/home/models',
}),
new SidebarChildVO({
id: 'bots',
name: '机器人',
icon: '',
route: '/home/bots',
}),
new SidebarChildVO({
id: 'pipelines',
name: '流水线',
icon: '',
route: '/home/pipelines',
}),
new SidebarChildVO({
id: 'plugins',
name: '插件管理',
icon: '',
route: '/home/plugins',
}),
];