diff --git a/web/src/app/home/plugins/plugin-installed/PluginCardVO.ts b/web/src/app/home/plugins/plugin-installed/PluginCardVO.ts index ee96f5d1..0e880543 100644 --- a/web/src/app/home/plugins/plugin-installed/PluginCardVO.ts +++ b/web/src/app/home/plugins/plugin-installed/PluginCardVO.ts @@ -1,26 +1,38 @@ export interface IPluginCardVO { author: string; - version: string; name: string; description: string; - handlerCount: number; - isInitialized: boolean; + version: string; + enabled: boolean; + priority: number; + status: string; + tools: object[]; + event_handlers: object; + repository: string; } export class PluginCardVO implements IPluginCardVO { - description: string; - handlerCount: number; - name: string; author: string; + name: string; + description: string; version: string; - isInitialized: boolean; + enabled: boolean; + priority: number; + status: string; + tools: object[]; + event_handlers: object; + repository: string; constructor(prop: IPluginCardVO) { - this.description = prop.description; - this.handlerCount = prop.handlerCount; - this.name = prop.name; this.author = prop.author; + this.description = prop.description; + this.enabled = prop.enabled; + this.event_handlers = prop.event_handlers; + this.name = prop.name; + this.priority = prop.priority; + this.repository = prop.repository; + this.status = prop.status; + this.tools = prop.tools; this.version = prop.version; - this.isInitialized = prop.isInitialized; } } diff --git a/web/src/app/home/plugins/plugin-installed/PluginInstalledComponent.tsx b/web/src/app/home/plugins/plugin-installed/PluginInstalledComponent.tsx index d9b4487e..334ab671 100644 --- a/web/src/app/home/plugins/plugin-installed/PluginInstalledComponent.tsx +++ b/web/src/app/home/plugins/plugin-installed/PluginInstalledComponent.tsx @@ -40,10 +40,14 @@ const PluginInstalledComponent = forwardRef((props, return new PluginCardVO({ author: plugin.author, description: plugin.description.zh_CN, - handlerCount: 0, + enabled: plugin.enabled, name: plugin.name, version: plugin.version, - isInitialized: plugin.status === 'initialized', + status: plugin.status, + tools: plugin.tools, + event_handlers: plugin.event_handlers, + repository: plugin.repository, + priority: plugin.priority, }); }), ); diff --git a/web/src/app/home/plugins/plugin-installed/plugin-card/PluginCardComponent.tsx b/web/src/app/home/plugins/plugin-installed/plugin-card/PluginCardComponent.tsx index 02469915..92ac329c 100644 --- a/web/src/app/home/plugins/plugin-installed/plugin-card/PluginCardComponent.tsx +++ b/web/src/app/home/plugins/plugin-installed/plugin-card/PluginCardComponent.tsx @@ -1,24 +1,25 @@ import styles from './pluginCard.module.css'; import { PluginCardVO } from '@/app/home/plugins/plugin-installed/PluginCardVO'; -import { GithubOutlined, LinkOutlined, ToolOutlined } from '@ant-design/icons'; -import { Switch, Tag } from 'antd'; import { useState } from 'react'; import { httpClient } from '@/app/infra/http/HttpClient'; +import { Badge } from "@/components/ui/badge" +import { Switch } from "@/components/ui/switch" +import { Button } from "@/components/ui/button" export default function PluginCardComponent({ cardVO, }: { cardVO: PluginCardVO; }) { - const [initialized, setInitialized] = useState(cardVO.isInitialized); + const [enabled, setEnabled] = useState(cardVO.enabled); const [switchEnable, setSwitchEnable] = useState(true); function handleEnable() { setSwitchEnable(false); httpClient - .togglePlugin(cardVO.author, cardVO.name, !initialized) + .togglePlugin(cardVO.author, cardVO.name, !enabled) .then(() => { - setInitialized(!initialized); + setEnabled(!enabled); }) .catch((err) => { console.log('error: ', err); @@ -29,38 +30,53 @@ export default function PluginCardComponent({ } return (
- {/* header */} -
- {/* left author */} -
{cardVO.author}
- {/* right icon & version */} -
- - v{cardVO.version} -
-
- {/* content */} -
-
{cardVO.name}
-
{cardVO.description}
-
- {/* footer */} -
-
-
-
- - 1 +
+ + +
+ +
+ +
+
{cardVO.author} /
+
+
{cardVO.name}
+ v{cardVO.version} +
- + +
{cardVO.description}
-
+ +
+
+ +
事件 11
+
+ +
+ +
工具 45
+
+ +
+ +
+ +
+
+ +
+ {/* */} +
diff --git a/web/src/app/home/plugins/plugin-installed/plugin-card/pluginCard.module.css b/web/src/app/home/plugins/plugin-installed/plugin-card/pluginCard.module.css index 1d09d462..f0365ffc 100644 --- a/web/src/app/home/plugins/plugin-installed/plugin-card/pluginCard.module.css +++ b/web/src/app/home/plugins/plugin-installed/plugin-card/pluginCard.module.css @@ -1,94 +1,140 @@ .cardContainer { + width: 26rem; + height: 10rem; + background-color: #fff; + border-radius: 10px; + box-shadow: 0px 2px 2px 0 rgba(0, 0, 0, 0.2); + padding: 1.2rem; + cursor: pointer; +} + +.contentContainer { width: 100%; - /* 修改为 100% 以撑满整个网格单元 */ - height: 140px; - box-sizing: border-box; - background-color: #FFF; - border-radius: 9px; - padding-top: 10px; - padding-bottom: 10px; - box-shadow: rgba(0, 0, 0, 0.4) 0 1px 1px -1px; + height: 100%; + display: flex; + flex-direction: row; + align-items: flex-start; + justify-content: flex-start; + gap: 1.2rem; +} + +.pluginIcon { + width: 4rem; + height: 4rem; + color: #2288ee; +} + +.infoContainer { + width: 100%; + height: 100%; + /* background-color: aqua; */ display: flex; flex-direction: column; - align-items: center; - justify-content: space-evenly; + align-items: flex-start; + justify-content: space-between; } -.cardHeader { - width: 90%; - height: 30px; +.basicInfoContainer { + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; +} + + +.nameContainer { + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; +} + +.author { + font-size: 0.7rem; + color: #666; +} + +.nameAndVersionContainer { display: flex; flex-direction: row; align-items: center; - justify-content: space-between; - - .iconVersionContainer { - width: 90px; - height: 100%; - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - } + justify-content: flex-start; + gap: 0.2rem; } -.cardContent { - width: 90%; - - height: 70px; +.name { + font-size: 1.2rem; + color: #000; } -.cardFooter { - width: 90%; - height: 30px; - position: relative; +.description { + font-size: 1rem; + color: #666; + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + overflow: hidden; } -.footerContainer { - width: 100%; +.componentContainer { + display: flex; + flex-direction: row; + align-items: flex-start; + justify-content: flex-start; + gap: 0.6rem; +} + +.componentEntryContainer { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + gap: 0.2rem; +} + +.componentIcon { + width: 1.2rem; + height: 1.2rem; + color: #555; +} + + +.componentText { + font-size: 1rem; + color: #555; + font-weight: 500; +} + +.version { + font-size: 0.8rem; + color: #666; +} + +.toolContainer { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; +} + +.operationContainer { height: 100%; display: flex; - flex-direction: row; - align-items: center; + flex-direction: column; + align-items: flex-end; justify-content: space-between; } -.linkAndToolContainer { +.operationTop { display: flex; flex-direction: row; align-items: center; - gap: 10px; + justify-content: center; } -.switchContainer { - display: flex; - justify-content: flex-end; -} - -.fontGray { - color: #6C6C6C; -} - -.boldFont { - font-size: 22px; - font-weight: bold; -} - -.linkSettingContainer { - width: 80px; - height: 100%; +.operationBottom { display: flex; flex-direction: row; align-items: center; - justify-content: space-between; - - .link { - width: 32px; - cursor: pointer; - text-align: center; - display: flex; - flex-direction: row; - align-self: center; - justify-content: space-between; - } + justify-content: center; } \ No newline at end of file diff --git a/web/src/components/ui/badge.tsx b/web/src/components/ui/badge.tsx new file mode 100644 index 00000000..02054139 --- /dev/null +++ b/web/src/components/ui/badge.tsx @@ -0,0 +1,46 @@ +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const badgeVariants = cva( + "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90", + secondary: + "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90", + destructive: + "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", + outline: + "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Badge({ + className, + variant, + asChild = false, + ...props +}: React.ComponentProps<"span"> & + VariantProps & { asChild?: boolean }) { + const Comp = asChild ? Slot : "span" + + return ( + + ) +} + +export { Badge, badgeVariants } diff --git a/web/src/components/ui/button.tsx b/web/src/components/ui/button.tsx index a2df8dce..f5445cf0 100644 --- a/web/src/components/ui/button.tsx +++ b/web/src/components/ui/button.tsx @@ -10,7 +10,7 @@ const buttonVariants = cva( variants: { variant: { default: - "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90", + "bg-[#2288ee] text-primary-foreground shadow-xs hover:bg-primary/90", destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", outline: