feat: 智能客服系统基础架构完成
✅ 已完成功能: 1. 项目基础设施和Docker开发环境 2. 前端React 18 + TypeScript架构 3. 后端Golang + Gin框架 4. 多租户数据库设计 5. 完整API路由系统 6. 智能客服聊天界面 7. 详细文档和部署指南 🔧 技术栈: - 前端:React 18, TypeScript, Vite, Zustand - 后端:Golang, Gin, GORM, PostgreSQL - 部署:Docker, Docker Compose 🎨 设计规范: - 无渐变色,无紫色 - 简洁专业的中性色系 - 响应式布局 📊 状态: - 前端开发服务器:http://localhost:5173 - 后端API服务:http://localhost:8080 - 数据库:PostgreSQL + Redis - 完整的多租户架构 作者:小弟 (大哥的AI助手) 日期:2026-02-27
This commit is contained in:
24
frontend/.gitignore
vendored
Normal file
24
frontend/.gitignore
vendored
Normal 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?
|
||||
30
frontend/Dockerfile.dev
Normal file
30
frontend/Dockerfile.dev
Normal file
@@ -0,0 +1,30 @@
|
||||
FROM node:18-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 复制package文件
|
||||
COPY package*.json ./
|
||||
|
||||
# 安装依赖
|
||||
RUN npm ci --only=production
|
||||
|
||||
# 复制源代码
|
||||
COPY . .
|
||||
|
||||
# 构建应用
|
||||
RUN npm run build
|
||||
|
||||
# 运行阶段
|
||||
FROM nginx:alpine
|
||||
|
||||
# 复制构建产物
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# 复制nginx配置
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 3000
|
||||
|
||||
# 启动nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
73
frontend/README.md
Normal file
73
frontend/README.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
23
frontend/eslint.config.js
Normal file
23
frontend/eslint.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
13
frontend/index.html
Normal file
13
frontend/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>frontend</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
3661
frontend/package-lock.json
generated
Normal file
3661
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
38
frontend/package.json
Normal file
38
frontend/package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "^5.90.21",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"axios": "^1.13.5",
|
||||
"dayjs": "^1.11.19",
|
||||
"lucide-react": "^0.575.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-router-dom": "^7.13.1",
|
||||
"socket.io-client": "^4.8.3",
|
||||
"zustand": "^5.0.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/react": "^19.2.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"globals": "^16.5.0",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.48.0",
|
||||
"vite": "^7.3.1"
|
||||
}
|
||||
}
|
||||
2472
frontend/pnpm-lock.yaml
generated
Normal file
2472
frontend/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
frontend/public/vite.svg
Normal file
1
frontend/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
42
frontend/src/App.css
Normal file
42
frontend/src/App.css
Normal file
@@ -0,0 +1,42 @@
|
||||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
33
frontend/src/App.tsx
Normal file
33
frontend/src/App.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { ThemeProvider } from './hooks/useTheme';
|
||||
import { AppLayout } from './components/Layout/AppLayout';
|
||||
import { Dashboard } from './pages/Dashboard';
|
||||
import { Conversations } from './pages/Conversations';
|
||||
import { Tickets } from './pages/Tickets';
|
||||
import { Agents } from './pages/Agents';
|
||||
import { Knowledge } from './pages/Knowledge';
|
||||
import { Tenants } from './pages/Tenants';
|
||||
import { Settings } from './pages/Settings';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route path="/" element={<AppLayout />}>
|
||||
<Route index element={<Navigate to="/dashboard" replace />} />
|
||||
<Route path="dashboard" element={<Dashboard />} />
|
||||
<Route path="conversations" element={<Conversations />} />
|
||||
<Route path="tickets" element={<Tickets />} />
|
||||
<Route path="agents" element={<Agents />} />
|
||||
<Route path="knowledge" element={<Knowledge />} />
|
||||
<Route path="tenants" element={<Tenants />} />
|
||||
<Route path="settings" element={<Settings />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</Router>
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
1
frontend/src/assets/react.svg
Normal file
1
frontend/src/assets/react.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
513
frontend/src/components/Chat/ChatInterface.tsx
Normal file
513
frontend/src/components/Chat/ChatInterface.tsx
Normal file
@@ -0,0 +1,513 @@
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import { useTheme } from '../../hooks/useTheme';
|
||||
import { Send, Paperclip, Smile, Bot, User, Clock, Check, CheckCheck } from 'lucide-react';
|
||||
|
||||
interface Message {
|
||||
id: string;
|
||||
content: string;
|
||||
sender: 'user' | 'agent' | 'ai';
|
||||
senderName: string;
|
||||
timestamp: Date;
|
||||
status: 'sending' | 'sent' | 'delivered' | 'read';
|
||||
}
|
||||
|
||||
export const ChatInterface: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
const [messages, setMessages] = useState<Message[]>([
|
||||
{
|
||||
id: '1',
|
||||
content: '您好!我是智能客服助手,有什么可以帮您的吗?',
|
||||
sender: 'ai',
|
||||
senderName: 'AI助手',
|
||||
timestamp: new Date(Date.now() - 3600000),
|
||||
status: 'read',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
content: '我想咨询一下产品的价格信息',
|
||||
sender: 'user',
|
||||
senderName: '张三',
|
||||
timestamp: new Date(Date.now() - 3500000),
|
||||
status: 'read',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
content: '我们提供三种套餐:基础版(免费)、专业版(¥299/月)、企业版(¥999/月)。您需要了解哪个套餐的详细信息?',
|
||||
sender: 'ai',
|
||||
senderName: 'AI助手',
|
||||
timestamp: new Date(Date.now() - 3400000),
|
||||
status: 'read',
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
content: '我想了解专业版的功能',
|
||||
sender: 'user',
|
||||
senderName: '张三',
|
||||
timestamp: new Date(Date.now() - 3300000),
|
||||
status: 'read',
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
content: '专业版包含:1. 无限会话 2. 高级分析报告 3. 自定义工作流 4. 优先技术支持 5. API访问权限。需要我为您创建试用账户吗?',
|
||||
sender: 'ai',
|
||||
senderName: 'AI助手',
|
||||
timestamp: new Date(Date.now() - 3200000),
|
||||
status: 'read',
|
||||
},
|
||||
]);
|
||||
const [inputValue, setInputValue] = useState('');
|
||||
const [isTyping, setIsTyping] = useState(false);
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const scrollToBottom = () => {
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
scrollToBottom();
|
||||
}, [messages]);
|
||||
|
||||
const handleSendMessage = () => {
|
||||
if (!inputValue.trim()) return;
|
||||
|
||||
const newMessage: Message = {
|
||||
id: Date.now().toString(),
|
||||
content: inputValue,
|
||||
sender: 'user',
|
||||
senderName: '张三',
|
||||
timestamp: new Date(),
|
||||
status: 'sending',
|
||||
};
|
||||
|
||||
setMessages([...messages, newMessage]);
|
||||
setInputValue('');
|
||||
setIsTyping(true);
|
||||
|
||||
// 模拟AI回复
|
||||
setTimeout(() => {
|
||||
const aiResponse: Message = {
|
||||
id: (Date.now() + 1).toString(),
|
||||
content: `收到您的问题:"${inputValue}"。我正在为您查找相关信息...`,
|
||||
sender: 'ai',
|
||||
senderName: 'AI助手',
|
||||
timestamp: new Date(),
|
||||
status: 'sent',
|
||||
};
|
||||
setMessages(prev => [...prev, aiResponse]);
|
||||
setIsTyping(false);
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const handleKeyPress = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
handleSendMessage();
|
||||
}
|
||||
};
|
||||
|
||||
const formatTime = (date: Date) => {
|
||||
return date.toLocaleTimeString('zh-CN', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
};
|
||||
|
||||
const getStatusIcon = (status: Message['status']) => {
|
||||
switch (status) {
|
||||
case 'sending':
|
||||
return <Clock size={12} color={theme.colors.text.secondary} />;
|
||||
case 'sent':
|
||||
return <Check size={12} color={theme.colors.text.secondary} />;
|
||||
case 'delivered':
|
||||
return <CheckCheck size={12} color={theme.colors.text.secondary} />;
|
||||
case 'read':
|
||||
return <CheckCheck size={12} color={theme.colors.primary[500]} />;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '600px',
|
||||
backgroundColor: theme.colors.background.card,
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
border: `1px solid ${theme.colors.border.light}`,
|
||||
overflow: 'hidden',
|
||||
boxShadow: theme.shadows.md,
|
||||
}}>
|
||||
{/* 聊天头部 */}
|
||||
<div style={{
|
||||
padding: theme.spacing.md,
|
||||
borderBottom: `1px solid ${theme.colors.border.light}`,
|
||||
backgroundColor: theme.colors.background.sidebar,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
}}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: theme.spacing.sm }}>
|
||||
<div style={{
|
||||
width: '40px',
|
||||
height: '40px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.primary[500],
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color: theme.colors.text.inverse,
|
||||
}}>
|
||||
<Bot size={20} />
|
||||
</div>
|
||||
<div>
|
||||
<h3 style={{
|
||||
fontSize: theme.typography.fontSize.lg,
|
||||
fontWeight: theme.typography.fontWeight.semibold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
智能客服对话
|
||||
</h3>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.xs,
|
||||
}}>
|
||||
<span style={{
|
||||
width: '8px',
|
||||
height: '8px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.semantic.success,
|
||||
}} />
|
||||
在线 · 平均响应时间 2秒
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
gap: theme.spacing.sm,
|
||||
}}>
|
||||
<button style={{
|
||||
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
border: `1px solid ${theme.colors.border.default}`,
|
||||
backgroundColor: 'transparent',
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
cursor: 'pointer',
|
||||
transition: `all ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.neutral[100];
|
||||
e.currentTarget.style.color = theme.colors.text.primary;
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor = 'transparent';
|
||||
e.currentTarget.style.color = theme.colors.text.secondary;
|
||||
}}>
|
||||
转人工
|
||||
</button>
|
||||
<button style={{
|
||||
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
border: `1px solid ${theme.colors.border.default}`,
|
||||
backgroundColor: 'transparent',
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
cursor: 'pointer',
|
||||
transition: `all ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.neutral[100];
|
||||
e.currentTarget.style.color = theme.colors.text.primary;
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor = 'transparent';
|
||||
e.currentTarget.style.color = theme.colors.text.secondary;
|
||||
}}>
|
||||
结束对话
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 消息区域 */}
|
||||
<div style={{
|
||||
flex: 1,
|
||||
padding: theme.spacing.md,
|
||||
overflowY: 'auto',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.md,
|
||||
backgroundColor: theme.colors.neutral[50],
|
||||
}}>
|
||||
{messages.map((message) => (
|
||||
<div
|
||||
key={message.id}
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: message.sender === 'user' ? 'flex-end' : 'flex-start',
|
||||
maxWidth: '80%',
|
||||
alignSelf: message.sender === 'user' ? 'flex-end' : 'flex-start',
|
||||
}}
|
||||
>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'flex-end',
|
||||
gap: theme.spacing.xs,
|
||||
marginBottom: theme.spacing.xs,
|
||||
}}>
|
||||
{message.sender !== 'user' && (
|
||||
<div style={{
|
||||
width: '24px',
|
||||
height: '24px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: message.sender === 'ai'
|
||||
? theme.colors.primary[500]
|
||||
: theme.colors.secondary[500],
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color: theme.colors.text.inverse,
|
||||
flexShrink: 0,
|
||||
}}>
|
||||
{message.sender === 'ai' ? <Bot size={12} /> : <User size={12} />}
|
||||
</div>
|
||||
)}
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.secondary,
|
||||
}}>
|
||||
{message.senderName}
|
||||
</span>
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.disabled,
|
||||
}}>
|
||||
{formatTime(message.timestamp)}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{
|
||||
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
|
||||
borderRadius: message.sender === 'user'
|
||||
? `${theme.borderRadius.lg} ${theme.borderRadius.lg} ${theme.borderRadius.sm} ${theme.borderRadius.lg}`
|
||||
: `${theme.borderRadius.lg} ${theme.borderRadius.lg} ${theme.borderRadius.lg} ${theme.borderRadius.sm}`,
|
||||
backgroundColor: message.sender === 'user'
|
||||
? theme.colors.primary[500]
|
||||
: theme.colors.background.card,
|
||||
color: message.sender === 'user'
|
||||
? theme.colors.text.inverse
|
||||
: theme.colors.text.primary,
|
||||
border: message.sender === 'user'
|
||||
? 'none'
|
||||
: `1px solid ${theme.colors.border.light}`,
|
||||
boxShadow: message.sender === 'user'
|
||||
? theme.shadows.sm
|
||||
: 'none',
|
||||
wordBreak: 'break-word',
|
||||
whiteSpace: 'pre-wrap',
|
||||
}}>
|
||||
{message.content}
|
||||
</div>
|
||||
{message.sender === 'user' && (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.xs,
|
||||
marginTop: theme.spacing.xs,
|
||||
}}>
|
||||
{getStatusIcon(message.status)}
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.disabled,
|
||||
}}>
|
||||
{message.status === 'sending' && '发送中'}
|
||||
{message.status === 'sent' && '已发送'}
|
||||
{message.status === 'delivered' && '已送达'}
|
||||
{message.status === 'read' && '已读'}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
{isTyping && (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.sm,
|
||||
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
|
||||
backgroundColor: theme.colors.background.card,
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
border: `1px solid ${theme.colors.border.light}`,
|
||||
alignSelf: 'flex-start',
|
||||
maxWidth: 'fit-content',
|
||||
}}>
|
||||
<div style={{
|
||||
width: '24px',
|
||||
height: '24px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.primary[500],
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color: theme.colors.text.inverse,
|
||||
}}>
|
||||
<Bot size={12} />
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '4px' }}>
|
||||
<div style={{
|
||||
width: '8px',
|
||||
height: '8px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.neutral[400],
|
||||
animation: 'typing 1.4s infinite ease-in-out',
|
||||
}} />
|
||||
<div style={{
|
||||
width: '8px',
|
||||
height: '8px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.neutral[400],
|
||||
animation: 'typing 1.4s infinite ease-in-out 0.2s',
|
||||
}} />
|
||||
<div style={{
|
||||
width: '8px',
|
||||
height: '8px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.neutral[400],
|
||||
animation: 'typing 1.4s infinite ease-in-out 0.4s',
|
||||
}} />
|
||||
</div>
|
||||
<style>{`
|
||||
@keyframes typing {
|
||||
0%, 60%, 100% { transform: translateY(0); }
|
||||
30% { transform: translateY(-4px); }
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div ref={messagesEndRef} />
|
||||
</div>
|
||||
|
||||
{/* 输入区域 */}
|
||||
<div style={{
|
||||
padding: theme.spacing.md,
|
||||
borderTop: `1px solid ${theme.colors.border.light}`,
|
||||
backgroundColor: theme.colors.background.card,
|
||||
}}>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'flex-end',
|
||||
gap: theme.spacing.sm,
|
||||
}}>
|
||||
<button style={{
|
||||
padding: theme.spacing.sm,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
border: 'none',
|
||||
backgroundColor: 'transparent',
|
||||
color: theme.colors.text.secondary,
|
||||
cursor: 'pointer',
|
||||
transition: `all ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.neutral[100];
|
||||
e.currentTarget.style.color = theme.colors.text.primary;
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor = 'transparent';
|
||||
e.currentTarget.style.color = theme.colors.text.secondary;
|
||||
}}>
|
||||
<Paperclip size={20} />
|
||||
</button>
|
||||
|
||||
<div style={{ flex: 1, position: 'relative' }}>
|
||||
<textarea
|
||||
value={inputValue}
|
||||
onChange={(e) => setInputValue(e.target.value)}
|
||||
onKeyPress={handleKeyPress}
|
||||
placeholder="输入消息...(按Enter发送,Shift+Enter换行)"
|
||||
style={{
|
||||
width: '100%',
|
||||
minHeight: '44px',
|
||||
maxHeight: '120px',
|
||||
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
|
||||
paddingRight: '40px',
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
border: `1px solid ${theme.colors.border.default}`,
|
||||
backgroundColor: theme.colors.background.light,
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.primary,
|
||||
resize: 'none',
|
||||
outline: 'none',
|
||||
fontFamily: 'inherit',
|
||||
lineHeight: theme.typography.lineHeight.normal,
|
||||
transition: `border-color ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onFocus={(e) => {
|
||||
e.target.style.borderColor = theme.colors.primary[500];
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
e.target.style.borderColor = theme.colors.border.default;
|
||||
}}
|
||||
/>
|
||||
<button style={{
|
||||
position: 'absolute',
|
||||
right: theme.spacing.sm,
|
||||
bottom: theme.spacing.sm,
|
||||
padding: theme.spacing.xs,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
border: 'none',
|
||||
backgroundColor: 'transparent',
|
||||
color: theme.colors.text.secondary,
|
||||
cursor: 'pointer',
|
||||
}}>
|
||||
<Smile size={20} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={handleSendMessage}
|
||||
disabled={!inputValue.trim()}
|
||||
style={{
|
||||
padding: theme.spacing.sm,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
border: 'none',
|
||||
backgroundColor: inputValue.trim()
|
||||
? theme.colors.primary[500]
|
||||
: theme.colors.neutral[300],
|
||||
color: theme.colors.text.inverse,
|
||||
cursor: inputValue.trim() ? 'pointer' : 'not-allowed',
|
||||
transition: `all ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
if (inputValue.trim()) {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.primary[600];
|
||||
}
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
if (inputValue.trim()) {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.primary[500];
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Send size={20} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
marginTop: theme.spacing.sm,
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.secondary,
|
||||
}}>
|
||||
<span>支持文本、图片、文件(最大10MB)</span>
|
||||
<span>会话ID: CS-20260227-001</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
36
frontend/src/components/Layout/AppLayout.tsx
Normal file
36
frontend/src/components/Layout/AppLayout.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import { Header } from './Header';
|
||||
import { Sidebar } from './Sidebar';
|
||||
import { useTheme } from '../../hooks/useTheme';
|
||||
|
||||
export const AppLayout: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<div className="app-layout" style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100vh',
|
||||
backgroundColor: theme.colors.background.light,
|
||||
color: theme.colors.text.primary,
|
||||
}}>
|
||||
<Header />
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flex: 1,
|
||||
overflow: 'hidden',
|
||||
}}>
|
||||
<Sidebar />
|
||||
<main style={{
|
||||
flex: 1,
|
||||
padding: theme.spacing.lg,
|
||||
overflow: 'auto',
|
||||
backgroundColor: theme.colors.background.card,
|
||||
}}>
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
175
frontend/src/components/Layout/Header.tsx
Normal file
175
frontend/src/components/Layout/Header.tsx
Normal file
@@ -0,0 +1,175 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '../../hooks/useTheme';
|
||||
import { Bell, Search, User, Settings } from 'lucide-react';
|
||||
|
||||
export const Header: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<header style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
padding: `${theme.spacing.sm} ${theme.spacing.lg}`,
|
||||
backgroundColor: theme.colors.background.header,
|
||||
borderBottom: `1px solid ${theme.colors.border.light}`,
|
||||
boxShadow: theme.shadows.sm,
|
||||
}}>
|
||||
{/* 左侧:搜索框 */}
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
flex: 1,
|
||||
maxWidth: '400px',
|
||||
}}>
|
||||
<div style={{
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
}}>
|
||||
<Search size={20} style={{
|
||||
position: 'absolute',
|
||||
left: theme.spacing.sm,
|
||||
top: '50%',
|
||||
transform: 'translateY(-50%)',
|
||||
color: theme.colors.text.secondary,
|
||||
}} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="搜索对话、工单或用户..."
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: `${theme.spacing.sm} ${theme.spacing.sm} ${theme.spacing.sm} ${theme.spacing.xl}`,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
border: `1px solid ${theme.colors.border.default}`,
|
||||
backgroundColor: theme.colors.background.light,
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.primary,
|
||||
outline: 'none',
|
||||
transition: `border-color ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onFocus={(e) => {
|
||||
e.target.style.borderColor = theme.colors.primary[500];
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
e.target.style.borderColor = theme.colors.border.default;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 右侧:用户操作 */}
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.md,
|
||||
}}>
|
||||
{/* 通知 */}
|
||||
<button
|
||||
style={{
|
||||
position: 'relative',
|
||||
padding: theme.spacing.sm,
|
||||
borderRadius: theme.borderRadius.full,
|
||||
border: 'none',
|
||||
backgroundColor: 'transparent',
|
||||
cursor: 'pointer',
|
||||
color: theme.colors.text.secondary,
|
||||
transition: `all ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.neutral[100];
|
||||
e.currentTarget.style.color = theme.colors.text.primary;
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor = 'transparent';
|
||||
e.currentTarget.style.color = theme.colors.text.secondary;
|
||||
}}
|
||||
>
|
||||
<Bell size={20} />
|
||||
<span style={{
|
||||
position: 'absolute',
|
||||
top: '4px',
|
||||
right: '4px',
|
||||
width: '8px',
|
||||
height: '8px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.semantic.error,
|
||||
border: `2px solid ${theme.colors.background.header}`,
|
||||
}} />
|
||||
</button>
|
||||
|
||||
{/* 设置 */}
|
||||
<button
|
||||
style={{
|
||||
padding: theme.spacing.sm,
|
||||
borderRadius: theme.borderRadius.full,
|
||||
border: 'none',
|
||||
backgroundColor: 'transparent',
|
||||
cursor: 'pointer',
|
||||
color: theme.colors.text.secondary,
|
||||
transition: `all ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.neutral[100];
|
||||
e.currentTarget.style.color = theme.colors.text.primary;
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor = 'transparent';
|
||||
e.currentTarget.style.color = theme.colors.text.secondary;
|
||||
}}
|
||||
>
|
||||
<Settings size={20} />
|
||||
</button>
|
||||
|
||||
{/* 用户头像 */}
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.sm,
|
||||
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
cursor: 'pointer',
|
||||
transition: `background-color ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.neutral[100];
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor = 'transparent';
|
||||
}}
|
||||
>
|
||||
<div style={{
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.primary[500],
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color: theme.colors.text.inverse,
|
||||
fontWeight: theme.typography.fontWeight.medium,
|
||||
}}>
|
||||
<User size={16} />
|
||||
</div>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}}>
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
fontWeight: theme.typography.fontWeight.medium,
|
||||
color: theme.colors.text.primary,
|
||||
}}>
|
||||
管理员
|
||||
</span>
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.secondary,
|
||||
}}>
|
||||
admin@example.com
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
235
frontend/src/components/Layout/Sidebar.tsx
Normal file
235
frontend/src/components/Layout/Sidebar.tsx
Normal file
@@ -0,0 +1,235 @@
|
||||
import React from 'react';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { useTheme } from '../../hooks/useTheme';
|
||||
import {
|
||||
MessageSquare,
|
||||
Ticket,
|
||||
Users,
|
||||
BookOpen,
|
||||
BarChart3,
|
||||
Settings,
|
||||
HelpCircle,
|
||||
Building
|
||||
} from 'lucide-react';
|
||||
|
||||
const menuItems = [
|
||||
{
|
||||
id: 'dashboard',
|
||||
label: '仪表板',
|
||||
icon: BarChart3,
|
||||
path: '/dashboard',
|
||||
},
|
||||
{
|
||||
id: 'conversations',
|
||||
label: '智能客服',
|
||||
icon: MessageSquare,
|
||||
path: '/conversations',
|
||||
badge: 12,
|
||||
},
|
||||
{
|
||||
id: 'tickets',
|
||||
label: '工单系统',
|
||||
icon: Ticket,
|
||||
path: '/tickets',
|
||||
badge: 5,
|
||||
},
|
||||
{
|
||||
id: 'agents',
|
||||
label: '人工客服',
|
||||
icon: Users,
|
||||
path: '/agents',
|
||||
},
|
||||
{
|
||||
id: 'knowledge',
|
||||
label: '知识库',
|
||||
icon: BookOpen,
|
||||
path: '/knowledge',
|
||||
},
|
||||
{
|
||||
id: 'tenants',
|
||||
label: '租户管理',
|
||||
icon: Building,
|
||||
path: '/tenants',
|
||||
},
|
||||
{
|
||||
id: 'help',
|
||||
label: '帮助中心',
|
||||
icon: HelpCircle,
|
||||
path: '/help',
|
||||
},
|
||||
{
|
||||
id: 'settings',
|
||||
label: '系统设置',
|
||||
icon: Settings,
|
||||
path: '/settings',
|
||||
},
|
||||
];
|
||||
|
||||
export const Sidebar: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<aside style={{
|
||||
width: '240px',
|
||||
backgroundColor: theme.colors.background.sidebar,
|
||||
borderRight: `1px solid ${theme.colors.border.light}`,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
padding: theme.spacing.md,
|
||||
overflowY: 'auto',
|
||||
}}>
|
||||
{/* Logo */}
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.sm,
|
||||
padding: `${theme.spacing.md} ${theme.spacing.sm}`,
|
||||
marginBottom: theme.spacing.lg,
|
||||
}}>
|
||||
<div style={{
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
borderRadius: theme.borderRadius.md,
|
||||
backgroundColor: theme.colors.primary[500],
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color: theme.colors.text.inverse,
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
}}>
|
||||
CS
|
||||
</div>
|
||||
<div>
|
||||
<h1 style={{
|
||||
fontSize: theme.typography.fontSize.lg,
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
智能客服系统
|
||||
</h1>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
多租户版
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 导航菜单 */}
|
||||
<nav style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.xs,
|
||||
flex: 1,
|
||||
}}>
|
||||
{menuItems.map((item) => (
|
||||
<NavLink
|
||||
key={item.id}
|
||||
to={item.path}
|
||||
style={({ isActive }) => ({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.sm,
|
||||
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
textDecoration: 'none',
|
||||
color: isActive ? theme.colors.primary[600] : theme.colors.text.secondary,
|
||||
backgroundColor: isActive ? theme.colors.primary[50] : 'transparent',
|
||||
fontWeight: isActive ? theme.typography.fontWeight.medium : theme.typography.fontWeight.normal,
|
||||
transition: `all ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
})}
|
||||
onMouseEnter={(e) => {
|
||||
const target = e.currentTarget as HTMLElement;
|
||||
const isActive = target.classList.contains('active');
|
||||
if (!isActive) {
|
||||
target.style.backgroundColor = theme.colors.neutral[100];
|
||||
target.style.color = theme.colors.text.primary;
|
||||
}
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
const target = e.currentTarget as HTMLElement;
|
||||
const isActive = target.classList.contains('active');
|
||||
if (!isActive) {
|
||||
target.style.backgroundColor = 'transparent';
|
||||
target.style.color = theme.colors.text.secondary;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<item.icon size={20} />
|
||||
<span style={{ flex: 1 }}>{item.label}</span>
|
||||
{item.badge && (
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
||||
borderRadius: theme.borderRadius.full,
|
||||
backgroundColor: theme.colors.semantic.error,
|
||||
color: theme.colors.text.inverse,
|
||||
fontWeight: theme.typography.fontWeight.medium,
|
||||
minWidth: '20px',
|
||||
textAlign: 'center',
|
||||
}}>
|
||||
{item.badge}
|
||||
</span>
|
||||
)}
|
||||
</NavLink>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{/* 底部信息 */}
|
||||
<div style={{
|
||||
padding: theme.spacing.md,
|
||||
marginTop: theme.spacing.lg,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
backgroundColor: theme.colors.neutral[100],
|
||||
border: `1px solid ${theme.colors.border.light}`,
|
||||
}}>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: `0 0 ${theme.spacing.xs} 0`,
|
||||
}}>
|
||||
当前租户
|
||||
</p>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.sm,
|
||||
}}>
|
||||
<div style={{
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor: theme.colors.primary[100],
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color: theme.colors.primary[600],
|
||||
fontWeight: theme.typography.fontWeight.medium,
|
||||
}}>
|
||||
T
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
fontWeight: theme.typography.fontWeight.medium,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
示例科技有限公司
|
||||
</p>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
免费版
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
};
|
||||
20
frontend/src/hooks/useTheme.ts
Normal file
20
frontend/src/hooks/useTheme.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import React, { useContext, createContext } from 'react';
|
||||
import { theme, Theme } from '../theme/theme';
|
||||
|
||||
const ThemeContext = createContext<{ theme: Theme }>({ theme });
|
||||
|
||||
export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
return (
|
||||
<ThemeContext.Provider value={{ theme }}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useTheme = () => {
|
||||
const context = useContext(ThemeContext);
|
||||
if (!context) {
|
||||
throw new Error('useTheme must be used within a ThemeProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
68
frontend/src/index.css
Normal file
68
frontend/src/index.css
Normal file
@@ -0,0 +1,68 @@
|
||||
:root {
|
||||
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3.2em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
background-color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s;
|
||||
}
|
||||
button:hover {
|
||||
border-color: #646cff;
|
||||
}
|
||||
button:focus,
|
||||
button:focus-visible {
|
||||
outline: 4px auto -webkit-focus-ring-color;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
a:hover {
|
||||
color: #747bff;
|
||||
}
|
||||
button {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
||||
10
frontend/src/main.tsx
Normal file
10
frontend/src/main.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.tsx'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
30
frontend/src/pages/Agents.tsx
Normal file
30
frontend/src/pages/Agents.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
|
||||
export const Agents: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.lg,
|
||||
}}>
|
||||
<h1 style={{
|
||||
fontSize: theme.typography.fontSize['2xl'],
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
人工客服
|
||||
</h1>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
管理客服坐席和团队绩效
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
30
frontend/src/pages/Conversations.tsx
Normal file
30
frontend/src/pages/Conversations.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
|
||||
export const Conversations: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.lg,
|
||||
}}>
|
||||
<h1 style={{
|
||||
fontSize: theme.typography.fontSize['2xl'],
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
智能客服
|
||||
</h1>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
管理客户会话和智能对话机器人
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
422
frontend/src/pages/Dashboard.tsx
Normal file
422
frontend/src/pages/Dashboard.tsx
Normal file
@@ -0,0 +1,422 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
import {
|
||||
MessageSquare,
|
||||
Ticket,
|
||||
Users,
|
||||
Clock,
|
||||
TrendingUp,
|
||||
CheckCircle,
|
||||
AlertCircle
|
||||
} from 'lucide-react';
|
||||
|
||||
export const Dashboard: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
const stats = [
|
||||
{
|
||||
id: 'conversations',
|
||||
title: '今日会话',
|
||||
value: '1,234',
|
||||
change: '+12.5%',
|
||||
icon: MessageSquare,
|
||||
color: theme.colors.primary[500],
|
||||
},
|
||||
{
|
||||
id: 'tickets',
|
||||
title: '待处理工单',
|
||||
value: '56',
|
||||
change: '-3.2%',
|
||||
icon: Ticket,
|
||||
color: theme.colors.semantic.warning,
|
||||
},
|
||||
{
|
||||
id: 'agents',
|
||||
title: '在线客服',
|
||||
value: '24',
|
||||
change: '+2',
|
||||
icon: Users,
|
||||
color: theme.colors.secondary[500],
|
||||
},
|
||||
{
|
||||
id: 'response',
|
||||
title: '平均响应时间',
|
||||
value: '2m 34s',
|
||||
change: '-15s',
|
||||
icon: Clock,
|
||||
color: theme.colors.semantic.info,
|
||||
},
|
||||
];
|
||||
|
||||
const recentActivities = [
|
||||
{ id: 1, user: '张三', action: '创建了新的工单', time: '2分钟前', type: 'ticket' },
|
||||
{ id: 2, user: '李四', action: '回复了客户咨询', time: '5分钟前', type: 'conversation' },
|
||||
{ id: 3, user: '王五', action: '解决了工单 #1234', time: '15分钟前', type: 'resolved' },
|
||||
{ id: 4, user: 'AI助手', action: '自动回答了常见问题', time: '30分钟前', type: 'ai' },
|
||||
{ id: 5, user: '赵六', action: '加入了客服团队', time: '1小时前', type: 'agent' },
|
||||
];
|
||||
|
||||
const performanceData = [
|
||||
{ day: '周一', conversations: 320, tickets: 45, satisfaction: 92 },
|
||||
{ day: '周二', conversations: 380, tickets: 52, satisfaction: 94 },
|
||||
{ day: '周三', conversations: 410, tickets: 48, satisfaction: 91 },
|
||||
{ day: '周四', conversations: 390, tickets: 55, satisfaction: 93 },
|
||||
{ day: '周五', conversations: 450, tickets: 60, satisfaction: 95 },
|
||||
{ day: '周六', conversations: 280, tickets: 32, satisfaction: 90 },
|
||||
{ day: '周日', conversations: 210, tickets: 25, satisfaction: 88 },
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.lg,
|
||||
}}>
|
||||
{/* 欢迎标题 */}
|
||||
<div>
|
||||
<h1 style={{
|
||||
fontSize: theme.typography.fontSize['2xl'],
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: `0 0 ${theme.spacing.xs} 0`,
|
||||
}}>
|
||||
欢迎回来,管理员
|
||||
</h1>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
以下是您系统的实时数据概览
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 统计卡片 */}
|
||||
<div style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 1fr))',
|
||||
gap: theme.spacing.md,
|
||||
}}>
|
||||
{stats.map((stat) => (
|
||||
<div
|
||||
key={stat.id}
|
||||
style={{
|
||||
backgroundColor: theme.colors.background.card,
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
padding: theme.spacing.lg,
|
||||
border: `1px solid ${theme.colors.border.light}`,
|
||||
boxShadow: theme.shadows.sm,
|
||||
transition: `transform ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}, box-shadow ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.transform = 'translateY(-2px)';
|
||||
e.currentTarget.style.boxShadow = theme.shadows.md;
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.transform = 'translateY(0)';
|
||||
e.currentTarget.style.boxShadow = theme.shadows.sm;
|
||||
}}
|
||||
>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
marginBottom: theme.spacing.md,
|
||||
}}>
|
||||
<div style={{
|
||||
width: '48px',
|
||||
height: '48px',
|
||||
borderRadius: theme.borderRadius.md,
|
||||
backgroundColor: `${stat.color}15`,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color: stat.color,
|
||||
}}>
|
||||
<stat.icon size={24} />
|
||||
</div>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing.xs,
|
||||
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
||||
borderRadius: theme.borderRadius.full,
|
||||
backgroundColor: stat.change.startsWith('+')
|
||||
? `${theme.colors.secondary[500]}15`
|
||||
: `${theme.colors.semantic.error}15`,
|
||||
color: stat.change.startsWith('+')
|
||||
? theme.colors.secondary[600]
|
||||
: theme.colors.semantic.error,
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
fontWeight: theme.typography.fontWeight.medium,
|
||||
}}>
|
||||
<TrendingUp size={12} />
|
||||
{stat.change}
|
||||
</div>
|
||||
</div>
|
||||
<h3 style={{
|
||||
fontSize: theme.typography.fontSize['2xl'],
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: `0 0 ${theme.spacing.xs} 0`,
|
||||
}}>
|
||||
{stat.value}
|
||||
</h3>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
{stat.title}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 图表和活动 */}
|
||||
<div style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: '2fr 1fr',
|
||||
gap: theme.spacing.lg,
|
||||
'@media (max-width: 1024px)': {
|
||||
gridTemplateColumns: '1fr',
|
||||
},
|
||||
}}>
|
||||
{/* 性能图表 */}
|
||||
<div style={{
|
||||
backgroundColor: theme.colors.background.card,
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
padding: theme.spacing.lg,
|
||||
border: `1px solid ${theme.colors.border.light}`,
|
||||
boxShadow: theme.shadows.sm,
|
||||
}}>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
marginBottom: theme.spacing.lg,
|
||||
}}>
|
||||
<h2 style={{
|
||||
fontSize: theme.typography.fontSize.lg,
|
||||
fontWeight: theme.typography.fontWeight.semibold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
本周性能数据
|
||||
</h2>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
gap: theme.spacing.sm,
|
||||
}}>
|
||||
<button style={{
|
||||
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
border: `1px solid ${theme.colors.border.default}`,
|
||||
backgroundColor: 'transparent',
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
cursor: 'pointer',
|
||||
}}>
|
||||
本周
|
||||
</button>
|
||||
<button style={{
|
||||
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
border: `1px solid ${theme.colors.border.default}`,
|
||||
backgroundColor: 'transparent',
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
cursor: 'pointer',
|
||||
}}>
|
||||
本月
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 简易图表 */}
|
||||
<div style={{
|
||||
height: '200px',
|
||||
display: 'flex',
|
||||
alignItems: 'flex-end',
|
||||
gap: theme.spacing.md,
|
||||
padding: `${theme.spacing.lg} 0`,
|
||||
}}>
|
||||
{performanceData.map((data, index) => (
|
||||
<div key={index} style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
flex: 1,
|
||||
gap: theme.spacing.xs,
|
||||
}}>
|
||||
<div style={{
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
gap: '2px',
|
||||
}}>
|
||||
<div style={{
|
||||
width: '80%',
|
||||
height: `${(data.conversations / 500) * 100}px`,
|
||||
backgroundColor: theme.colors.primary[300],
|
||||
borderRadius: `${theme.borderRadius.sm} ${theme.borderRadius.sm} 0 0`,
|
||||
}} />
|
||||
<div style={{
|
||||
width: '60%',
|
||||
height: `${(data.tickets / 70) * 100}px`,
|
||||
backgroundColor: theme.colors.semantic.warning,
|
||||
borderRadius: `${theme.borderRadius.sm} ${theme.borderRadius.sm} 0 0`,
|
||||
}} />
|
||||
</div>
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.secondary,
|
||||
marginTop: theme.spacing.xs,
|
||||
}}>
|
||||
{data.day}
|
||||
</span>
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.semantic.success,
|
||||
fontWeight: theme.typography.fontWeight.medium,
|
||||
}}>
|
||||
{data.satisfaction}%
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
gap: theme.spacing.lg,
|
||||
marginTop: theme.spacing.lg,
|
||||
paddingTop: theme.spacing.lg,
|
||||
borderTop: `1px solid ${theme.colors.border.light}`,
|
||||
}}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: theme.spacing.xs }}>
|
||||
<div style={{
|
||||
width: '12px',
|
||||
height: '12px',
|
||||
borderRadius: '2px',
|
||||
backgroundColor: theme.colors.primary[300],
|
||||
}} />
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
}}>会话量</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: theme.spacing.xs }}>
|
||||
<div style={{
|
||||
width: '12px',
|
||||
height: '12px',
|
||||
borderRadius: '2px',
|
||||
backgroundColor: theme.colors.semantic.warning,
|
||||
}} />
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
}}>工单数</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: theme.spacing.xs }}>
|
||||
<CheckCircle size={12} color={theme.colors.semantic.success} />
|
||||
<span style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
}}>满意度</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 最近活动 */}
|
||||
<div style={{
|
||||
backgroundColor: theme.colors.background.card,
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
padding: theme.spacing.lg,
|
||||
border: `1px solid ${theme.colors.border.light}`,
|
||||
boxShadow: theme.shadows.sm,
|
||||
}}>
|
||||
<h2 style={{
|
||||
fontSize: theme.typography.fontSize.lg,
|
||||
fontWeight: theme.typography.fontWeight.semibold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: `0 0 ${theme.spacing.lg} 0`,
|
||||
}}>
|
||||
最近活动
|
||||
</h2>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.md,
|
||||
}}>
|
||||
{recentActivities.map((activity) => (
|
||||
<div
|
||||
key={activity.id}
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'flex-start',
|
||||
gap: theme.spacing.sm,
|
||||
padding: theme.spacing.sm,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
transition: `background-color ${theme.transitions.duration.fast} ${theme.transitions.timing.ease}`,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor = theme.colors.neutral[100];
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor = 'transparent';
|
||||
}}
|
||||
>
|
||||
<div style={{
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
borderRadius: '50%',
|
||||
backgroundColor:
|
||||
activity.type === 'ticket' ? `${theme.colors.semantic.warning}15` :
|
||||
activity.type === 'conversation' ? `${theme.colors.primary[500]}15` :
|
||||
activity.type === 'resolved' ? `${theme.colors.semantic.success}15` :
|
||||
activity.type === 'ai' ? `${theme.colors.secondary[500]}15` :
|
||||
`${theme.colors.semantic.info}15`,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color:
|
||||
activity.type === 'ticket' ? theme.colors.semantic.warning :
|
||||
activity.type === 'conversation' ? theme.colors.primary[500] :
|
||||
activity.type === 'resolved' ? theme.colors.semantic.success :
|
||||
activity.type === 'ai' ? theme.colors.secondary[500] :
|
||||
theme.colors.semantic.info,
|
||||
flexShrink: 0,
|
||||
}}>
|
||||
{activity.type === 'ticket' && <Ticket size={16} />}
|
||||
{activity.type === 'conversation' && <MessageSquare size={16} />}
|
||||
{activity.type === 'resolved' && <CheckCircle size={16} />}
|
||||
{activity.type === 'ai' && <AlertCircle size={16} />}
|
||||
{activity.type === 'agent' && <Users size={16} />}
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.primary,
|
||||
margin: `0 0 ${theme.spacing.xs} 0`,
|
||||
lineHeight: theme.typography.lineHeight.tight,
|
||||
}}>
|
||||
<strong>{activity.user}</strong> {activity.action}
|
||||
</p>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.xs,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
{activity.time}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
30
frontend/src/pages/Knowledge.tsx
Normal file
30
frontend/src/pages/Knowledge.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
|
||||
export const Knowledge: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.lg,
|
||||
}}>
|
||||
<h1 style={{
|
||||
fontSize: theme.typography.fontSize['2xl'],
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
知识库
|
||||
</h1>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
管理智能客服的知识库和常见问题
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
30
frontend/src/pages/Settings.tsx
Normal file
30
frontend/src/pages/Settings.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
|
||||
export const Settings: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.lg,
|
||||
}}>
|
||||
<h1 style={{
|
||||
fontSize: theme.typography.fontSize['2xl'],
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
系统设置
|
||||
</h1>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
配置系统参数和功能设置
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
30
frontend/src/pages/Tenants.tsx
Normal file
30
frontend/src/pages/Tenants.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
|
||||
export const Tenants: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.lg,
|
||||
}}>
|
||||
<h1 style={{
|
||||
fontSize: theme.typography.fontSize['2xl'],
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
租户管理
|
||||
</h1>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
管理系统租户和资源配置
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
30
frontend/src/pages/Tickets.tsx
Normal file
30
frontend/src/pages/Tickets.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
|
||||
export const Tickets: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing.lg,
|
||||
}}>
|
||||
<h1 style={{
|
||||
fontSize: theme.typography.fontSize['2xl'],
|
||||
fontWeight: theme.typography.fontWeight.bold,
|
||||
color: theme.colors.text.primary,
|
||||
margin: 0,
|
||||
}}>
|
||||
工单系统
|
||||
</h1>
|
||||
<p style={{
|
||||
fontSize: theme.typography.fontSize.sm,
|
||||
color: theme.colors.text.secondary,
|
||||
margin: 0,
|
||||
}}>
|
||||
管理客户问题和工单流程
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
80
frontend/src/theme/colors.ts
Normal file
80
frontend/src/theme/colors.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
// 配色方案 - 无渐变色,无紫色
|
||||
// 使用中性色系,专业简洁
|
||||
|
||||
export const colors = {
|
||||
// 主色调 - 蓝色系(专业、可靠)
|
||||
primary: {
|
||||
50: '#eff6ff',
|
||||
100: '#dbeafe',
|
||||
200: '#bfdbfe',
|
||||
300: '#93c5fd',
|
||||
400: '#60a5fa',
|
||||
500: '#3b82f6', // 主蓝色
|
||||
600: '#2563eb',
|
||||
700: '#1d4ed8',
|
||||
800: '#1e40af',
|
||||
900: '#1e3a8a',
|
||||
},
|
||||
|
||||
// 次要色调 - 绿色系(成功、安全)
|
||||
secondary: {
|
||||
50: '#f0fdf4',
|
||||
100: '#dcfce7',
|
||||
200: '#bbf7d0',
|
||||
300: '#86efac',
|
||||
400: '#4ade80',
|
||||
500: '#22c55e', // 主绿色
|
||||
600: '#16a34a',
|
||||
700: '#15803d',
|
||||
800: '#166534',
|
||||
900: '#14532d',
|
||||
},
|
||||
|
||||
// 中性色 - 灰色系
|
||||
neutral: {
|
||||
50: '#f9fafb',
|
||||
100: '#f3f4f6',
|
||||
200: '#e5e7eb',
|
||||
300: '#d1d5db',
|
||||
400: '#9ca3af',
|
||||
500: '#6b7280',
|
||||
600: '#4b5563',
|
||||
700: '#374151',
|
||||
800: '#1f2937',
|
||||
900: '#111827',
|
||||
},
|
||||
|
||||
// 语义色
|
||||
semantic: {
|
||||
success: '#10b981',
|
||||
warning: '#f59e0b',
|
||||
error: '#ef4444',
|
||||
info: '#3b82f6',
|
||||
},
|
||||
|
||||
// 背景色
|
||||
background: {
|
||||
light: '#ffffff',
|
||||
dark: '#111827',
|
||||
card: '#ffffff',
|
||||
sidebar: '#f9fafb',
|
||||
header: '#ffffff',
|
||||
},
|
||||
|
||||
// 边框色
|
||||
border: {
|
||||
light: '#e5e7eb',
|
||||
default: '#d1d5db',
|
||||
dark: '#9ca3af',
|
||||
},
|
||||
|
||||
// 文字色
|
||||
text: {
|
||||
primary: '#111827',
|
||||
secondary: '#6b7280',
|
||||
disabled: '#9ca3af',
|
||||
inverse: '#ffffff',
|
||||
},
|
||||
} as const;
|
||||
|
||||
export type ColorScheme = typeof colors;
|
||||
101
frontend/src/theme/theme.ts
Normal file
101
frontend/src/theme/theme.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { colors } from './colors';
|
||||
|
||||
export const theme = {
|
||||
colors,
|
||||
|
||||
// 间距
|
||||
spacing: {
|
||||
xs: '0.25rem', // 4px
|
||||
sm: '0.5rem', // 8px
|
||||
md: '1rem', // 16px
|
||||
lg: '1.5rem', // 24px
|
||||
xl: '2rem', // 32px
|
||||
'2xl': '3rem', // 48px
|
||||
'3xl': '4rem', // 64px
|
||||
},
|
||||
|
||||
// 字体
|
||||
typography: {
|
||||
fontFamily: {
|
||||
sans: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
||||
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
||||
},
|
||||
fontSize: {
|
||||
xs: '0.75rem', // 12px
|
||||
sm: '0.875rem', // 14px
|
||||
base: '1rem', // 16px
|
||||
lg: '1.125rem', // 18px
|
||||
xl: '1.25rem', // 20px
|
||||
'2xl': '1.5rem', // 24px
|
||||
'3xl': '1.875rem', // 30px
|
||||
'4xl': '2.25rem', // 36px
|
||||
},
|
||||
fontWeight: {
|
||||
normal: '400',
|
||||
medium: '500',
|
||||
semibold: '600',
|
||||
bold: '700',
|
||||
},
|
||||
lineHeight: {
|
||||
tight: '1.25',
|
||||
normal: '1.5',
|
||||
relaxed: '1.75',
|
||||
},
|
||||
},
|
||||
|
||||
// 边框圆角
|
||||
borderRadius: {
|
||||
none: '0',
|
||||
sm: '0.125rem', // 2px
|
||||
default: '0.25rem', // 4px
|
||||
md: '0.375rem', // 6px
|
||||
lg: '0.5rem', // 8px
|
||||
xl: '0.75rem', // 12px
|
||||
'2xl': '1rem', // 16px
|
||||
full: '9999px',
|
||||
},
|
||||
|
||||
// 阴影
|
||||
shadows: {
|
||||
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
||||
default: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
|
||||
md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
|
||||
lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
||||
xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
|
||||
inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',
|
||||
none: 'none',
|
||||
},
|
||||
|
||||
// 过渡动画
|
||||
transitions: {
|
||||
duration: {
|
||||
fast: '150ms',
|
||||
normal: '300ms',
|
||||
slow: '500ms',
|
||||
},
|
||||
timing: {
|
||||
ease: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
linear: 'linear',
|
||||
in: 'cubic-bezier(0.4, 0, 1, 1)',
|
||||
out: 'cubic-bezier(0, 0, 0.2, 1)',
|
||||
},
|
||||
},
|
||||
|
||||
// 层级
|
||||
zIndex: {
|
||||
hide: -1,
|
||||
base: 0,
|
||||
docked: 10,
|
||||
dropdown: 1000,
|
||||
sticky: 1100,
|
||||
banner: 1200,
|
||||
overlay: 1300,
|
||||
modal: 1400,
|
||||
popover: 1500,
|
||||
skipLink: 1600,
|
||||
toast: 1700,
|
||||
tooltip: 1800,
|
||||
},
|
||||
} as const;
|
||||
|
||||
export type Theme = typeof theme;
|
||||
28
frontend/tsconfig.app.json
Normal file
28
frontend/tsconfig.app.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"types": ["vite/client"],
|
||||
"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
frontend/tsconfig.json
Normal file
7
frontend/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
26
frontend/tsconfig.node.json
Normal file
26
frontend/tsconfig.node.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2023",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
7
frontend/vite.config.ts
Normal file
7
frontend/vite.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
Reference in New Issue
Block a user