style(web): translate the comments in the src/views directory into English
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
import { type FC } from 'react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Progress } from 'antd'
|
||||
import type { Data } from '../types'
|
||||
|
||||
import Tag from '@/components/Tag'
|
||||
|
||||
const bgList = [
|
||||
'linear-gradient( 180deg, #F1F6FE 0%, #FBFDFF 100%)',
|
||||
'linear-gradient( 180deg, #F1F9FE 0%, #FBFDFF 100%)',
|
||||
'linear-gradient( 180deg, #FEFBF7 0%, #FBFDFF 100%)',
|
||||
'linear-gradient( 180deg, #F1F9FE 0%, #FBFDFF 100%)',
|
||||
]
|
||||
interface CardListProps {
|
||||
data: Data[]
|
||||
handleViewDetail: (id: string | number) => void
|
||||
}
|
||||
const CardList: FC<CardListProps> = ({
|
||||
data,
|
||||
handleViewDetail
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="rb:grid rb:grid-cols-3 rb:gap-[16px]">
|
||||
{data.map((item, index) => {
|
||||
return (
|
||||
<div
|
||||
key={item.id}
|
||||
className="rb:p-[20px] rb:rounded-[12px] rb:border-[1px] rb:border-[#DFE4ED] rb:cursor-pointer"
|
||||
style={{
|
||||
background: bgList[index % bgList.length],
|
||||
}}
|
||||
onClick={() => handleViewDetail(item.id)}
|
||||
>
|
||||
<div className="rb:flex rb:items-center">
|
||||
<div className="rb:w-[48px] rb:h-[48px] rb:text-center rb:font-semibold rb:text-[28px] rb:leading-[48px] rb:rounded-[8px] rb:text-[#FBFDFF] rb:bg-[#155EEF]">{item.username[0]}</div>
|
||||
<div className="rb:text-base rb:font-medium rb:leading-[24px] rb:ml-[12px]">
|
||||
{item.username}<br/>
|
||||
<Tag color={item.role === 'administrator' ? 'processing' : 'error'}>{item.role}</Tag>
|
||||
</div>
|
||||
</div>
|
||||
<div className="rb:grid rb:grid-cols-3 rb:gap-[12px] rb:mt-[28px] rb:mb-[28px]">
|
||||
{['knowledgeEntryCount', 'interactionCount', 'averageTimeConsumption'].map(key => (
|
||||
<div key={key} className="rb:text-center">
|
||||
<div className="rb:text-[24px] rb:leading-[30px] rb:font-extrabold">{item[key] || 0}</div>
|
||||
<div className="rb:break-words">{t(`memory.${key}`)}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="rb:flex rb:items-center rb:justify-between rb:w-full rb:text-[#5B6167] rb:text-[12px]">{t('memory.dataCompletionDegree')}<span>{item.dataCompletionDegree || 0}%</span></div>
|
||||
<Progress percent={item.dataCompletionDegree || 0} showInfo={false} size={{height: 8}} />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default CardList
|
||||
@@ -1,9 +1,20 @@
|
||||
/*
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 17:53:44
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-02-03 17:54:33
|
||||
*/
|
||||
/**
|
||||
* User Memory Page
|
||||
* Displays list of end users with their memory statistics and configuration
|
||||
*/
|
||||
|
||||
import { useEffect, useState, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Row, Col, List, Skeleton } from 'antd';
|
||||
import Empty from '@/components/Empty'
|
||||
|
||||
import Empty from '@/components/Empty'
|
||||
import type { Data } from './types'
|
||||
import { getUserMemoryList } from '@/api/memory';
|
||||
import { useUser } from '@/store/user'
|
||||
@@ -18,11 +29,12 @@ export default function UserMemory() {
|
||||
const [data, setData] = useState<Data[]>([]);
|
||||
const [search, setSearch] = useState<string | undefined>(undefined);
|
||||
|
||||
// 获取数据
|
||||
/** Fetch user memory list */
|
||||
useEffect(() => {
|
||||
getData()
|
||||
}, []);
|
||||
|
||||
/** Get data from API */
|
||||
const getData = () => {
|
||||
setLoading(true)
|
||||
getUserMemoryList().then((res) => {
|
||||
@@ -32,6 +44,7 @@ export default function UserMemory() {
|
||||
setLoading(false)
|
||||
})
|
||||
}
|
||||
/** Navigate to user memory detail */
|
||||
const handleViewDetail = (id: string | number) => {
|
||||
switch (storageType) {
|
||||
case 'neo4j':
|
||||
@@ -41,12 +54,14 @@ export default function UserMemory() {
|
||||
navigate(`/user-memory/${id}`)
|
||||
}
|
||||
}
|
||||
/** Navigate to memory configuration */
|
||||
const handleViewMemoryConfig = (e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
navigate(`/memory`)
|
||||
}
|
||||
|
||||
/** Filter data by search term */
|
||||
const filterData = useMemo(() => {
|
||||
if (search && search.trim() !== '') {
|
||||
return data.filter((item) => {
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 17:53:36
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-02-03 17:53:36
|
||||
*/
|
||||
/**
|
||||
* User memory data structure
|
||||
*/
|
||||
export interface Data {
|
||||
end_user: {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user