Skip to content

Commit

Permalink
翻译+页面调整
Browse files Browse the repository at this point in the history
  • Loading branch information
DazingBusing committed Jan 4, 2024
1 parent a8cd8c7 commit b10ac24
Show file tree
Hide file tree
Showing 22 changed files with 239 additions and 260 deletions.
2 changes: 0 additions & 2 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,10 @@ export class App {
const chatflow = await this.AppDataSource.getRepository(ChatFlow).findOneBy({
id: req.params.id
})

if (!chatflow) {
res.status(404).send(`Chatflow ${req.params.id} not found`)
return
}

const body = req.body
const updateChatFlow = new ChatFlow()
Object.assign(updateChatFlow, body)
Expand Down
40 changes: 6 additions & 34 deletions packages/ui/src/layout/MainLayout/Main.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,18 @@

.Main .Header_Bar {
flex: 2;
overflow-x: scroll;
white-space: nowrap;
overflow: hidden;
box-sizing: border-box;
border-bottom: 1px solid #cac4c4;
}

.Main .Header_Bar .Header_BarItem {
display: inline-block;
margin-left: 1.5vw;
margin-right: 1.5vw;
text-align: center;
overflow: hidden;
font-size: 14px;
line-height: 10vh;
border: none;
cursor: pointer;
background: none;
}

.Main .Header_Bar .Header_BarItem span:first-child {
margin-right: 0.5vw;
}

.Main .Header_Bar .Header_BarItem:last-child {
display: flex;
justify-content: center;
align-items: center;
float: right;
margin-right: 1.5vw;
position: relative;
top: 4vh;
width: 2vw;
height: 2vw;
border-radius: 10px;
left: 75%;
}

.Main .Header_Bar .Header_BarItem:last-child:hover {
background-color: #3187d8;
color: white;
.Main .Header_Bar .Header_BarItem:hover {
color: #3187d8;
cursor: pointer;
}

.Main .Content {
Expand Down Expand Up @@ -89,8 +61,8 @@
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
border-radius: 10px;
position: absolute;
left: 88%;
top: 8%;
left: 89%;
top: 6%;
background: white;
}

Expand Down
38 changes: 6 additions & 32 deletions packages/ui/src/layout/MainLayout/Main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,15 @@
flex-direction: column;
.Header_Bar {
flex: 2;
overflow-x: scroll;
white-space: nowrap;
overflow: hidden;
box-sizing: border-box;
border-bottom: 1px solid #cac4c4;
.Header_BarItem {
display: inline-block;
margin-left: 1.5vw;
margin-right: 1.5vw;
text-align: center;
overflow: hidden;
font-size: 14px;
line-height: 10vh;
border: none;
cursor: pointer;
background: none;
span:first-child {
margin-right: 0.5vw;
}
}
.Header_BarItem:last-child {
display: flex;
justify-content: center;
align-items: center;
float: right;
margin-right: 1.5vw;
position: relative;
top: 4vh;
width: 2vw;
height: 2vw;
border-radius: 10px;
left: 75%;
}
.Header_BarItem:last-child:hover {
background-color: rgb(49, 135, 216);
color: white;
.Header_BarItem:hover {
color: rgb(49, 135, 216);
cursor: pointer;
}
}
.Content {
Expand Down Expand Up @@ -87,8 +61,8 @@
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
border-radius: 10px;
position: absolute;
left: 88%;
top: 8%;
left: 89%;
top: 6%;
background: white;
.RouterItem {
border-radius: 10px;
Expand Down
120 changes: 82 additions & 38 deletions packages/ui/src/layout/MainLayout/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
import { useDispatch } from 'react-redux'
import { Outlet, useNavigate } from 'react-router-dom'
import './Main.css'
import { MAIN_STATE } from '../../store/actions'
// import ProfileSection from './ProfileSection'
import { useState } from 'react'
import { IconSettings } from '@tabler/icons'
import dashboard from '../../menu-items/dashboard'
const MainLayout = () => {
let navigate = useNavigate()
let dispatch = useDispatch()
import * as React from 'react'
import PropTypes from 'prop-types'
import Tabs from '@mui/material/Tabs'
import Tab from '@mui/material/Tab'
import Typography from '@mui/material/Typography'
import Box from '@mui/material/Box'
import ChatFlows from '../../views/chatflows'
import Marketplaces from '../../views/marketplaces'
function CustomTabPanel(props) {
const { children, value, index, ...other } = props

return (
<div role='tabpanel' hidden={value !== index} id={`simple-tabpanel-${index}`} aria-labelledby={`simple-tab-${index}`} {...other}>
{value === index && (
<Box sx={{ p: 3 }}>
<Typography>{children}</Typography>
</Box>
)}
</div>
)
}

CustomTabPanel.propTypes = {
children: PropTypes.node,
index: PropTypes.number.isRequired,
value: PropTypes.number.isRequired
}
export default function MainLayout() {
let [ModalState, SetModalState] = useState(false)
let [ShowComp, SetShowComp] = useState(null)
let [chooseState, SetChooseState] = useState(false)
let [headerState, SetHeaderState] = useState(0)

const close = () => {
SetModalState(false)
SetShowComp(null)
Expand All @@ -32,16 +53,16 @@ const MainLayout = () => {
const Content = (ev) => {
ev.stopPropagation()
}
const ChangePath = (item, idx) => {
SetHeaderState(idx)
navigate(item.url)
dispatch({
type: MAIN_STATE,
state: item.id
})
}
// const ChangePath = (item, idx) => {
// SetHeaderState(idx)
// navigate(item.url)
// dispatch({
// type: MAIN_STATE,
// state: item.id
// })
// }
const OpenList = (ev) => {
SetChooseState(true)
chooseState === true ? SetChooseState(false) : SetChooseState(true)
ev.stopPropagation()
}
const chooseComponent = (component, state) => {
Expand All @@ -51,32 +72,56 @@ const MainLayout = () => {
const Close = () => {
SetChooseState(false)
}
const [value, setValue] = React.useState(0)

const handleChange = (event, newValue) => {
setValue(newValue)
}

return (
<div className='Main' onClick={() => Close()} role='button' tabIndex={0} onKeyDown={() => KeyDownContent()}>
<div className='Header_Bar'>
{dashboard.children.slice(0, 2).map((item, index) => (
<button
style={headerState === index ? { color: 'rgb(55,150,241)' } : {}}
onClick={() => ChangePath(item, index)}
<Tabs sx={{ lineHeight: '7.5vh' }} value={value} onChange={handleChange} aria-label='basic tabs example'>
{dashboard.children.slice(0, 2).map((item, index) => (
<Tab
key={item.id}
label={
<Box sx={{ width: '8vw', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{item.icon}
<span>{`${item.title}`}</span>
</Box>
}
id={`simple-tab-${index}`}
/>
// <button
// style={headerState === index ? { color: 'rgb(55,150,241)' } : {}}
// onClick={() => ChangePath(item, index)}
// className='Header_BarItem'
// key={item.id}
// >
// <span>{item.icon}</span>
// <span>{item.title}</span>
// </button>
))}
<div
tabIndex={0}
role='button'
onKeyDown={() => KeyDownContent()}
className='Header_BarItem'
key={item.id}
onClick={(ev) => OpenList(ev)}
>
<span>{item.icon}</span>
<span>{item.title}</span>
</button>
))}
<div
tabIndex={0}
role='button'
onKeyDown={() => KeyDownContent()}
className='Header_BarItem'
onClick={(ev) => OpenList(ev)}
>
<IconSettings stroke={1.5} size='1rem' />
</div>
<IconSettings stroke={1.5} size='1.3rem' />
</div>
</Tabs>
</div>
<div className='Content'>
<Outlet />
{/* <Outlet /> */}
<CustomTabPanel value={value} index={0}>
<ChatFlows />
</CustomTabPanel>
<CustomTabPanel value={value} index={1}>
<Marketplaces />
</CustomTabPanel>
</div>
<div
role='button'
Expand Down Expand Up @@ -117,5 +162,4 @@ const MainLayout = () => {
</div>
)
}

export default MainLayout
// export default MainLayout
12 changes: 6 additions & 6 deletions packages/ui/src/menu-items/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const dashboard = {
children: [
{
id: 'chatflows',
title: 'Chatflows',
title: '智能体',
type: 'item',
url: '/chatflows',
icon: <IconHierarchy />,
Expand All @@ -31,7 +31,7 @@ const dashboard = {
},
{
id: 'marketplaces',
title: 'Marketplaces',
title: '模板',
type: 'item',
url: '/marketplaces',
icon: <IconBuildingStore />,
Expand All @@ -40,7 +40,7 @@ const dashboard = {
},
{
id: 'tools',
title: 'Tools',
title: '工具',
type: 'item',
url: '/tools',
icon: <IconTool />,
Expand All @@ -49,7 +49,7 @@ const dashboard = {
},
{
id: 'credentials',
title: 'Credentials',
title: '凭证',
type: 'item',
url: '/credentials',
icon: <IconLock />,
Expand All @@ -58,7 +58,7 @@ const dashboard = {
},
{
id: 'apikey',
title: 'API Keys',
title: 'API密钥',
type: 'item',
url: '/apikey',
icon: <IconKey />,
Expand All @@ -67,7 +67,7 @@ const dashboard = {
}
// {
// id: 'assistants',
// title: 'Assistants',
// title: '助理',
// type: 'item',
// url: '/assistants',
// icon: <IconRobot />,
Expand Down
14 changes: 7 additions & 7 deletions packages/ui/src/menu-items/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,49 @@ const settings = {
children: [
{
id: 'conversationStarters',
title: 'Starter Prompts',
title: '初始提示',
type: 'item',
url: '',
icon: icons.IconPictureInPictureOff
},
{
id: 'viewMessages',
title: 'View Messages',
title: '视图信息',
type: 'item',
url: '',
icon: icons.IconMessage
},
{
id: 'duplicateChatflow',
title: 'Duplicate Chatflow',
title: '复制',
type: 'item',
url: '',
icon: icons.IconCopy
},
{
id: 'loadChatflow',
title: 'Load Chatflow',
title: '上传',
type: 'item',
url: '',
icon: icons.IconFileUpload
},
{
id: 'exportChatflow',
title: 'Export Chatflow',
title: '下载',
type: 'item',
url: '',
icon: icons.IconFileExport
},
{
id: 'analyseChatflow',
title: 'Analyse Chatflow',
title: '分析智能体',
type: 'item',
url: '',
icon: icons.IconSearch
},
{
id: 'deleteChatflow',
title: 'Delete Chatflow',
title: '删除',
type: 'item',
url: '',
icon: icons.IconTrash
Expand Down
Loading

0 comments on commit b10ac24

Please sign in to comment.