mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: add GraphAvatar to graph list #918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -111,7 +111,12 @@ export const useSetFlow = () => {
|
|||||||
mutateAsync,
|
mutateAsync,
|
||||||
} = useMutation({
|
} = useMutation({
|
||||||
mutationKey: ['setFlow'],
|
mutationKey: ['setFlow'],
|
||||||
mutationFn: async (params: { id?: string; title?: string; dsl?: DSL }) => {
|
mutationFn: async (params: {
|
||||||
|
id?: string;
|
||||||
|
title?: string;
|
||||||
|
dsl?: DSL;
|
||||||
|
avatar?: string;
|
||||||
|
}) => {
|
||||||
const { data } = await flowService.setCanvas(params);
|
const { data } = await flowService.setCanvas(params);
|
||||||
if (data.retcode === 0) {
|
if (data.retcode === 0) {
|
||||||
message.success(
|
message.success(
|
||||||
|
|||||||
@ -1,20 +1,11 @@
|
|||||||
import { ReactComponent as NothingIcon } from '@/assets/svg/nothing.svg';
|
|
||||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||||
import { useTranslate } from '@/hooks/commonHooks';
|
import { useTranslate } from '@/hooks/commonHooks';
|
||||||
import { useFetchFlowTemplates } from '@/hooks/flow-hooks';
|
import { useFetchFlowTemplates } from '@/hooks/flow-hooks';
|
||||||
import { useSelectItem } from '@/hooks/logicHooks';
|
import { useSelectItem } from '@/hooks/logicHooks';
|
||||||
import {
|
import { Card, Flex, Form, Input, Modal, Space, Typography } from 'antd';
|
||||||
Avatar,
|
|
||||||
Card,
|
|
||||||
Flex,
|
|
||||||
Form,
|
|
||||||
Input,
|
|
||||||
Modal,
|
|
||||||
Space,
|
|
||||||
Typography,
|
|
||||||
} from 'antd';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import GraphAvatar from './graph-avatar';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
@ -90,11 +81,7 @@ const CreateFlowModal = ({
|
|||||||
onClick={handleItemClick(x.id)}
|
onClick={handleItemClick(x.id)}
|
||||||
>
|
>
|
||||||
<Space size={'middle'}>
|
<Space size={'middle'}>
|
||||||
{x.avatar ? (
|
<GraphAvatar avatar={x.avatar}></GraphAvatar>
|
||||||
<Avatar size={40} icon={<NothingIcon />} src={x.avatar} />
|
|
||||||
) : (
|
|
||||||
<NothingIcon width={40} height={30} />
|
|
||||||
)}
|
|
||||||
<b>{x.title}</b>
|
<b>{x.title}</b>
|
||||||
</Space>
|
</Space>
|
||||||
<p>{x.description}</p>
|
<p>{x.description}</p>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
.container {
|
.container {
|
||||||
height: 251px;
|
height: 160px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import { formatDate } from '@/utils/date';
|
import { formatDate } from '@/utils/date';
|
||||||
import { CalendarOutlined, UserOutlined } from '@ant-design/icons';
|
import { CalendarOutlined } from '@ant-design/icons';
|
||||||
import { Avatar, Card } from 'antd';
|
import { Card, Typography } from 'antd';
|
||||||
import { useNavigate } from 'umi';
|
import { useNavigate } from 'umi';
|
||||||
|
|
||||||
import OperateDropdown from '@/components/operate-dropdown';
|
import OperateDropdown from '@/components/operate-dropdown';
|
||||||
import { useDeleteFlow } from '@/hooks/flow-hooks';
|
import { useDeleteFlow } from '@/hooks/flow-hooks';
|
||||||
import { IFlow } from '@/interfaces/database/flow';
|
import { IFlow } from '@/interfaces/database/flow';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
import GraphAvatar from '../graph-avatar';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -29,11 +30,16 @@ const FlowCard = ({ item }: IProps) => {
|
|||||||
<Card className={styles.card} onClick={handleCardClick}>
|
<Card className={styles.card} onClick={handleCardClick}>
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<Avatar size={34} icon={<UserOutlined />} src={item.avatar} />
|
<GraphAvatar avatar={item.avatar}></GraphAvatar>
|
||||||
<OperateDropdown deleteItem={removeFlow}></OperateDropdown>
|
<OperateDropdown deleteItem={removeFlow}></OperateDropdown>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.titleWrapper}>
|
<div className={styles.titleWrapper}>
|
||||||
<span className={styles.title}>{item.title}</span>
|
<Typography.Title
|
||||||
|
className={styles.title}
|
||||||
|
ellipsis={{ tooltip: item.title }}
|
||||||
|
>
|
||||||
|
{item.title}
|
||||||
|
</Typography.Title>
|
||||||
<p>{item.description}</p>
|
<p>{item.description}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.footer}>
|
<div className={styles.footer}>
|
||||||
|
|||||||
16
web/src/pages/flow/list/graph-avatar.tsx
Normal file
16
web/src/pages/flow/list/graph-avatar.tsx
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { ReactComponent as NothingIcon } from '@/assets/svg/nothing.svg';
|
||||||
|
import { Avatar } from 'antd';
|
||||||
|
|
||||||
|
const GraphAvatar = ({ avatar }: { avatar?: string | null }) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{avatar ? (
|
||||||
|
<Avatar size={40} icon={<NothingIcon />} src={avatar} />
|
||||||
|
) : (
|
||||||
|
<NothingIcon width={40} height={30} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GraphAvatar;
|
||||||
@ -45,6 +45,7 @@ export const useSaveFlow = () => {
|
|||||||
const ret = await setFlow({
|
const ret = await setFlow({
|
||||||
title,
|
title,
|
||||||
dsl,
|
dsl,
|
||||||
|
avatar: templateItem?.avatar,
|
||||||
// dsl: dslJson,
|
// dsl: dslJson,
|
||||||
// dsl: {
|
// dsl: {
|
||||||
// ...retrievalRelevantRewriteAndGenerateBase,
|
// ...retrievalRelevantRewriteAndGenerateBase,
|
||||||
|
|||||||
Reference in New Issue
Block a user