1
0

完成初始化

This commit is contained in:
2025-05-08 19:15:32 +08:00
commit 956750a4c7
16 changed files with 6304 additions and 0 deletions

24
.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

21
index.html Normal file
View File

@@ -0,0 +1,21 @@
<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>AMIS AI</title>
<style>
html, body, #root {
position: absolute;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>

31
package.json Normal file
View File

@@ -0,0 +1,31 @@
{
"name": "amis-ai",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview"
},
"dependencies": {
"@ant-design/icons": "^6.0.0",
"@tinyflow-ai/react": "^0.1.6",
"amis": "^6.12.0",
"antd": "^5.25.0",
"licia": "^1.48.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^7.5.3"
},
"devDependencies": {
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@vitejs/plugin-react-swc": "^3.9.0",
"globals": "^16.0.0",
"sass": "^1.87.0",
"typescript": "~5.8.3",
"typescript-eslint": "^8.30.1",
"vite": "^6.3.5"
}
}

6015
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

0
src/components/Flow.scss Normal file
View File

25
src/components/Flow.tsx Normal file
View File

@@ -0,0 +1,25 @@
import {Tinyflow} from '@tinyflow-ai/react'
import {type FormControlProps, FormItem} from 'amis'
import React from 'react'
import './Flow.scss'
import '@tinyflow-ai/react/dist/index.css'
const Flow: React.FC<FormControlProps> = props => {
const {onChange} = props
return (
<div className="flowable">
<Tinyflow
className="tinyflow-instance"
style={{height: '800px'}}
onDataChange={(value) => {
onChange(value)
}}
/>
</div>
)
}
FormItem({
type: 'flow',
autoVar: true,
})(Flow)

View File

@@ -0,0 +1 @@
import './Flow.tsx'

29
src/index.tsx Normal file
View File

@@ -0,0 +1,29 @@
import {createRoot} from 'react-dom/client'
import {createBrowserRouter, RouterProvider} from 'react-router'
import './components/Registry.ts'
import App from './pages/App.tsx'
import Conversation from './pages/Conversation.tsx'
import Home from './pages/Home.tsx'
const routes = createBrowserRouter([
{
path: '/',
Component: App,
children: [
{
index: true,
Component: Home,
},
{
path: 'conversation',
Component: Conversation,
},
],
},
])
createRoot(document.getElementById('root')!).render(
<RouterProvider router={routes}/>,
)

12
src/pages/App.scss Normal file
View File

@@ -0,0 +1,12 @@
.app {
height: 100%;
.header {
display: flex;
align-items: center;
}
.content {
padding: 10px;
}
}

47
src/pages/App.tsx Normal file
View File

@@ -0,0 +1,47 @@
import './App.scss'
import {Layout, Menu} from 'antd'
import type {ItemType, MenuItemType} from 'antd/es/menu/interface'
import {isEqual} from 'licia'
import React, {useEffect, useState} from 'react'
import {NavLink, Outlet, useLocation} from 'react-router'
const {Header, Content} = Layout
const headerNav: Array<MenuItemType> = [
{key: '/', label: '首页'},
{key: '/conversation', label: '对话'},
]
const App: React.FC = () => {
const [_, setCurrentMenu] = useState<ItemType>()
const [selectedKeys, setSelectedKeys] = useState<Array<string>>([])
const location = useLocation()
useEffect(() => {
setSelectedKeys([location.pathname])
setCurrentMenu(headerNav.find((nav => isEqual(nav?.key, location.pathname))))
}, [location])
return (
<Layout className="app">
<Header className="header">
<Menu
className="header-nav"
theme="dark"
mode="horizontal"
selectedKeys={selectedKeys}
items={headerNav.map(nav => ({
key: nav.key,
label: <NavLink to={nav.key as string}>{nav.label}</NavLink>
}))}
/>
</Header>
<Layout>
<Content className="content">
<Outlet/>
</Content>
</Layout>
</Layout>
)
}
export default App

View File

@@ -0,0 +1,23 @@
import {amisRender} from '../util/amis.ts'
function Conversation() {
return (
<div className="conversation">
{amisRender(
{
type: 'form',
debug: true,
body: [
{
type: 'flow',
name: 'flowData',
label: '流程图',
},
],
},
)}
</div>
)
}
export default Conversation

19
src/pages/Home.tsx Normal file
View File

@@ -0,0 +1,19 @@
import {amisRender} from '../util/amis.ts'
function Home() {
return (
<div className="home">
{amisRender(
{
type: 'page',
title: 'Home Page',
body: [
'Hello amis'
]
}
)}
</div>
)
}
export default Home

18
src/util/amis.ts Normal file
View File

@@ -0,0 +1,18 @@
import type {Schema} from 'amis'
import {render} from 'amis'
import 'amis/lib/themes/antd.css'
import 'amis/lib/helper.css'
import 'amis/sdk/iconfont.css'
export const amisRender = (schema: Schema) => {
return render(
schema,
{
data: {
baseUrl: 'http://localhost:8080',
},
theme: 'antd',
},
)
}

1
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

31
tsconfig.json Normal file
View File

@@ -0,0 +1,31 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": [
"src"
]
}

7
vite.config.ts Normal file
View File

@@ -0,0 +1,7 @@
import react from '@vitejs/plugin-react-swc'
import {defineConfig} from 'vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
})