Compare commits
62 Commits
7fe519df28
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0344ff2862 | |||
| 17bae862ed | |||
| fb64b1a768 | |||
| 05c1f339e6 | |||
| f822e319ba | |||
| 2962865857 | |||
| 5415da5b6c | |||
| 5149b68237 | |||
| a6e7cca92b | |||
| 2c3700f4f8 | |||
| 1bcc63d5de | |||
| 9db3dfe675 | |||
| 9ee93bea60 | |||
| 04fd9f8c0e | |||
| 5f8e55a3a3 | |||
| 01ae26e869 | |||
| bf61c4af4e | |||
| f566a33865 | |||
| d96fac324b | |||
| c8129ce658 | |||
| 5b0783097d | |||
| 9cde482dfe | |||
| 8e793ea37f | |||
| dde1212a57 | |||
| 6527eec133 | |||
| 2109903ba2 | |||
| 46dc2d4682 | |||
| 3c9d0dae22 | |||
| b6a81848ea | |||
| 096fbb661d | |||
| 035c4ab000 | |||
| 1efff107f9 | |||
| 1795cd73c7 | |||
| 5f21126a62 | |||
| 2085588556 | |||
| 025a67ce45 | |||
| cb806e19b1 | |||
| d4680d258c | |||
| a832883f17 | |||
| c086285340 | |||
| 7fa05b0004 | |||
| 65cf893a5f | |||
| e20ee8e065 | |||
| 7d8723715c | |||
| 49bb348707 | |||
| ef6de1d12b | |||
| c76a4e2018 | |||
| e504f806a9 | |||
| 68d9767bd8 | |||
| ccbf6de863 | |||
| d3a315525e | |||
| 38e15ed562 | |||
| c7fba23e3b | |||
| b60583008b | |||
| 542895c61c | |||
| 538e153473 | |||
| 78d1fd93c8 | |||
| 032f258912 | |||
| 9bd4a44ab6 | |||
| 4174c424fc | |||
| 0d946c050e | |||
| 95f020047d |
@@ -38,10 +38,10 @@ module.exports = {
|
||||
'@typescript-eslint/no-redeclare': 'error',
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
'warn',
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_|props|watch',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
@@ -64,6 +64,11 @@ module.exports = {
|
||||
'vue/no-parsing-error': 'off',
|
||||
'vue/no-deprecated-v-on-native-modifier': 'off',
|
||||
'vue/multi-word-component-names': 'off',
|
||||
'vue/no-reserved-component-names': 'off',
|
||||
'vue/no-v-for-template-key': 'off',
|
||||
'vue/no-unused-vars': 'off',
|
||||
'vue/no-mutating-props': 'off',
|
||||
'no-mixed-spaces-and-tabs': 'off',
|
||||
'no-useless-escape': 'off',
|
||||
'no-sparse-arrays': 'off',
|
||||
'no-prototype-builtins': 'off',
|
||||
@@ -77,8 +82,8 @@ module.exports = {
|
||||
'no-unused-vars': 'off',
|
||||
'no-v-model-argument': 'off',
|
||||
'no-case-declarations': 'off',
|
||||
'no-console': 'error',
|
||||
'no-debugger': 'error',
|
||||
'no-console': 'off',
|
||||
'no-debugger': 'warn',
|
||||
'no-redeclare': 'off',
|
||||
},
|
||||
};
|
||||
|
||||
11
.gitea/workflows/deploy.yaml
Normal file
11
.gitea/workflows/deploy.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
name: 自动部署
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
jobs:
|
||||
部署应用:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 启动部署
|
||||
run: |
|
||||
docker exec gitea-runner /opt/deploy.sh
|
||||
@@ -1,68 +0,0 @@
|
||||
name: 全局K3s部署
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
jobs:
|
||||
deploy:
|
||||
# ========== 核心修复:替换为具体Ubuntu版本,解决运行期匹配问题 ==========
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
# 从组织级Secrets读取,不用在仓库重复配置
|
||||
K3S_HOST: ${{ secrets.K3S_HOST }}
|
||||
APP_NAME: ${{ gitea.repo_name }}
|
||||
# 补充:若后续要推送镜像,需替换为实际镜像仓库地址(比如你的Gitea镜像仓库)
|
||||
REGISTRY: 116.204.74.41:3000/red-future
|
||||
steps:
|
||||
# ========== 核心:新增国内Git代理,彻底解决GitHub拉取慢 ==========
|
||||
- name: 配置国内GitHub代理加速
|
||||
run: |
|
||||
# 全局Git代理:所有GitHub请求走国内镜像站
|
||||
git config --global url."https://ghproxy.com/https://github.com/".insteadOf "https://github.com/"
|
||||
# 可选:替换Ubuntu源为清华源,加速依赖安装
|
||||
sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
|
||||
apt update -y
|
||||
# ========== 核心修改:替换checkout源,避开GitHub ==========
|
||||
- name: 拉取代码(Gitea官方源)
|
||||
uses: gitea/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # 可选:拉取完整历史,加速后续操作
|
||||
timeout-minutes: 10 # 增加超时,避免拉取中断
|
||||
|
||||
# 1. 初始化 Docker Buildx(原内容不变)
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 2. 可选:登录镜像仓库(若需推送镜像,取消注释并配置密钥)
|
||||
# - name: Login to Gitea Registry
|
||||
# uses: docker/login-action@v3
|
||||
# with:
|
||||
# registry: 116.204.74.41:3000
|
||||
# username: ${{ secrets.GITEA_USER }}
|
||||
# password: ${{ secrets.GITEA_PWD }}
|
||||
|
||||
# 3. 构建+推送(原内容不变)
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ env.REGISTRY }}/${{ env.APP_NAME }}:${{ gitea.sha }}
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.APP_NAME }}:buildcache
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.APP_NAME }}:buildcache,mode=max
|
||||
|
||||
# 4. 修复后的SSH部署步骤(解决路径+命名空间问题)
|
||||
- name: SSH部署K3s
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.K3S_PEM_KEY }}" > k3s.pem
|
||||
chmod 600 k3s.pem
|
||||
|
||||
# ========== 修正1:上传仓库根目录的deploy.yaml到K3s临时目录 ==========
|
||||
scp -i k3s.pem -o StrictHostKeyChecking=no ./deploy.yaml root@${K3S_HOST}:/tmp/
|
||||
|
||||
# ========== 修正2:kubectl指向临时文件+补充命名空间 ==========
|
||||
ssh -i k3s.pem -o StrictHostKeyChecking=no root@${K3S_HOST} << CMD
|
||||
kubectl apply -f /tmp/deploy.yaml
|
||||
kubectl rollout restart deployment ${APP_NAME} -n default
|
||||
rm -f /tmp/deploy.yaml # 可选:清理临时文件
|
||||
CMD
|
||||
110
CLAUDE.md
Normal file
110
CLAUDE.md
Normal file
@@ -0,0 +1,110 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is the **GFast UI** project (`gfast-ui`), a Vue 3 admin management system based on the vue-next-admin template, customized for a digital advertising/trading platform.
|
||||
|
||||
## Commands
|
||||
|
||||
- `npm install` - Install dependencies (use `npm install --registry=https://registry.npmmirror.com` for China mainland)
|
||||
- `npm run dev` - Start development server
|
||||
- `npm run build` - Build for production
|
||||
- `npm run lint` - Run ESLint check
|
||||
- `npm run lint-fix` - Fix ESLint issues automatically
|
||||
- `npm run type-check` - Run TypeScript type checking
|
||||
- `npm run quality` - Run both lint and type-check
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
**Tech Stack:**
|
||||
- Vue 3 with Composition API (script setup)
|
||||
- TypeScript
|
||||
- Vite
|
||||
- Element Plus (UI framework)
|
||||
- Pinia (state management)
|
||||
- Vue Router (with hash mode)
|
||||
- Axios (HTTP client)
|
||||
- i18n (internationalization)
|
||||
- mitt (event bus)
|
||||
|
||||
**Directory Structure:**
|
||||
- `src/api/` - API client methods organized by business domain (ads, assets, cid, customerService, digitalHuman, knowledge, login, menu, settings, system, etc.)
|
||||
- `src/components/` - Reusable Vue components
|
||||
- `src/directives/` - Custom Vue directives
|
||||
- `src/i18n/` - Internationalization configuration
|
||||
- `src/layout/` - Main layout components
|
||||
- `src/router/` - Route configuration
|
||||
- `index.ts` - Router setup and guard
|
||||
- `backEnd.ts` - Backend-controlled route initialization
|
||||
- `frontEnd.ts` - Frontend-controlled route initialization
|
||||
- `route.ts` - Static route definitions
|
||||
- `src/stores/` - Pinia state stores
|
||||
- `themeConfig.ts` - Theme and global configuration
|
||||
- `userInfo.ts` - User information
|
||||
- `routesList.ts` - Dynamic route management
|
||||
- `keepAliveNames.ts` - keep-alive cache management
|
||||
- `src/theme/` - Theme related styles
|
||||
- `src/types/` - TypeScript type definitions
|
||||
- `src/utils/` - Utility functions
|
||||
- `request.ts` - Axios instance with interceptors, error handling, and token management
|
||||
- `storage.ts` - Session storage wrapper
|
||||
- `gfast.ts` - GFast-specific helpers (file URL construction, tree building, date formatting)
|
||||
- `diffUtils.ts` - Field change detection for PUT requests
|
||||
- `src/views/` - Page components organized by business module
|
||||
|
||||
**Key Patterns:**
|
||||
|
||||
1. **Routing**: Supports both frontend and backend controlled routing. When backend control is enabled (`isRequestRoutes: true` in themeConfig), routes are fetched from the backend and dynamically added.
|
||||
|
||||
2. **API Requests**:
|
||||
- API methods are organized by domain in `src/api/` (each subdomain has its own directory structure)
|
||||
- The Axios instance in `src/utils/request.ts` is pre-configured with:
|
||||
- 50 second request timeout
|
||||
- `qs` serialization of query parameters with dot notation for nested objects
|
||||
- Automatically adds Bearer token (from cookies via Session utility) to all requests
|
||||
- Automatically sends only changed fields for PUT requests (diff comparison with original data via `_originalData` field)
|
||||
- Handles token expiration globally with redirect to login (prevents multiple overlapping popups)
|
||||
- Provides error message extraction from multiple response formats (`message`, `msg`, `error`, `detail`)
|
||||
- Error throttling: maximum one error message every 2 seconds
|
||||
- Supports error mode configuration via `requestOptions.errorMode`:
|
||||
- `global`: (default) Global error popup with backend message
|
||||
- `page`: No automatic popup, reject the error for page-level handling
|
||||
- `silent`: Completely silent, no error display
|
||||
- Special handling for `code === 402`: Triggers module not enabled subscription flow (except for specific asset endpoints)
|
||||
- Response format expects `code`, `message`/`msg`, and data. Known success codes: `0`, `200`.
|
||||
- Use `getApiErrorMessage(error)` from `/@/utils/request` to extract user-friendly error messages in catch blocks when using `page` or `silent` mode.
|
||||
|
||||
3. **Global Properties & Components**:
|
||||
- Helpers registered globally for template use:
|
||||
- `getUpFileUrl`, `handleTree`, `useDict`, `selectDictLabel`, `parseTime`, `getItems`, `setItems`, `getOptionValue`, `isEmpty`
|
||||
- Global components:
|
||||
- `pagination` - Reusable pagination component
|
||||
- Global plugins registered:
|
||||
- `vue-simple-uploader` - Large file upload component
|
||||
- Global event bus via mitt: `app.config.globalProperties.mittBus`
|
||||
|
||||
4. **Authentication**:
|
||||
- Token is stored in cookies via `js-cookie` (through the `Session` utility). Other user session data is stored in `sessionStorage`.
|
||||
- The `Session.clearAuth()` method only clears authentication-related keys (`token`, `userInfo`, `userMenu`, `permissions`), preserving other local preferences.
|
||||
- 401 responses (HTTP or business code) containing token expiration signals trigger automatic logout with a single confirmation popup.
|
||||
|
||||
5. **Keep-alive**: Route components can be cached via keep-alive, managed by the `useKeepALiveNames` store.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `.env.development` - Development environment settings
|
||||
- `.env.production` - Production environment settings
|
||||
- `VITE_API_URL` - Backend API base URL
|
||||
- `VITE_PORT` - Dev server port
|
||||
- `VITE_PUBLIC_PATH` - Public base path for production build
|
||||
- `VITE_OPEN_CDN` - Enable CDN for external dependencies
|
||||
|
||||
## Development Notes
|
||||
|
||||
- The project uses `/@` alias for `src/`
|
||||
- Components use the Composition API with `<script setup lang="ts">`
|
||||
- Styling is done with SCSS
|
||||
- ESLint enforces code quality
|
||||
- Node version requirement: `>=16.0.0` (supported: v16.x ~ v20.x)
|
||||
44
deploy.yaml
44
deploy.yaml
@@ -1,44 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ${APP_NAME}
|
||||
namespace: default
|
||||
labels:
|
||||
app: ${APP_NAME}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ${APP_NAME}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ${APP_NAME}
|
||||
spec:
|
||||
containers:
|
||||
- name: ${APP_NAME}
|
||||
image: ${REGISTRY}/${APP_NAME}:${gitea.sha}
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80 # 你的项目实际端口(比如前端80、后端8080)
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: ${APP_NAME}-service
|
||||
namespace: default
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
app: ${APP_NAME}
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
nodePort: 30001 # 必须在30000-32767之间
|
||||
26
k8s/deployment.yaml
Normal file
26
k8s/deployment.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: admin-ui
|
||||
namespace: default
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: admin-ui
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: admin-ui
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-ui
|
||||
image: 116.204.74.41:3000/red-future/admin-ui:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80
|
||||
- containerPort: 443
|
||||
resources:
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
20
k8s/ingress.yaml
Normal file
20
k8s/ingress.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: admin-ui
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||
spec:
|
||||
tls:
|
||||
- secretName: admin-ui-tls
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: admin-ui
|
||||
port:
|
||||
number: 443
|
||||
15
k8s/service.yaml
Normal file
15
k8s/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: admin-ui
|
||||
spec:
|
||||
selector:
|
||||
app: admin-ui
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 80
|
||||
- name: https
|
||||
port: 443
|
||||
targetPort: 443
|
||||
type: ClusterIP
|
||||
201
package-lock.json
generated
201
package-lock.json
generated
@@ -14,6 +14,10 @@
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@logicflow/core": "^2.2.1",
|
||||
"@logicflow/extension": "^2.2.1",
|
||||
"@vue-flow/background": "^1.3.2",
|
||||
"@vue-flow/controls": "^1.1.3",
|
||||
"@vue-flow/core": "^1.48.2",
|
||||
"@vue-flow/minimap": "^1.5.4",
|
||||
"@wangeditor/editor": "^5.1.23",
|
||||
"axios": "1.8.2",
|
||||
"codemirror": "^6.0.1",
|
||||
@@ -2243,6 +2247,98 @@
|
||||
"vscode-uri": "^3.0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue-flow/background": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@vue-flow/background/-/background-1.3.2.tgz",
|
||||
"integrity": "sha512-eJPhDcLj1wEo45bBoqTXw1uhl0yK2RaQGnEINqvvBsAFKh/camHJd5NPmOdS1w+M9lggc9igUewxaEd3iCQX2w==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@vue-flow/core": "^1.23.0",
|
||||
"vue": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue-flow/controls": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@vue-flow/controls/-/controls-1.1.3.tgz",
|
||||
"integrity": "sha512-XCf+G+jCvaWURdFlZmOjifZGw3XMhN5hHlfMGkWh9xot+9nH9gdTZtn+ldIJKtarg3B21iyHU8JjKDhYcB6JMw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@vue-flow/core": "^1.23.0",
|
||||
"vue": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue-flow/core": {
|
||||
"version": "1.48.2",
|
||||
"resolved": "https://registry.npmjs.org/@vue-flow/core/-/core-1.48.2.tgz",
|
||||
"integrity": "sha512-raxhgKWE+G/mcEvXJjGFUDYW9rAI3GOtiHR3ZkNpwBWuIaCC1EYiBmKGwJOoNzVFgwO7COgErnK7i08i287AFA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vueuse/core": "^10.5.0",
|
||||
"d3-drag": "^3.0.0",
|
||||
"d3-interpolate": "^3.0.1",
|
||||
"d3-selection": "^3.0.0",
|
||||
"d3-zoom": "^3.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue-flow/core/node_modules/@types/web-bluetooth": {
|
||||
"version": "0.0.20",
|
||||
"resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz",
|
||||
"integrity": "sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@vue-flow/core/node_modules/@vueuse/core": {
|
||||
"version": "10.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@vueuse/core/-/core-10.11.1.tgz",
|
||||
"integrity": "sha512-guoy26JQktXPcz+0n3GukWIy/JDNKti9v6VEMu6kV2sYBsWuGiTU8OWdg+ADfUbHg3/3DlqySDe7JmdHrktiww==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/web-bluetooth": "^0.0.20",
|
||||
"@vueuse/metadata": "10.11.1",
|
||||
"@vueuse/shared": "10.11.1",
|
||||
"vue-demi": ">=0.14.8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/antfu"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue-flow/core/node_modules/@vueuse/metadata": {
|
||||
"version": "10.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-10.11.1.tgz",
|
||||
"integrity": "sha512-IGa5FXd003Ug1qAZmyE8wF3sJ81xGLSqTqtQ6jaVfkeZ4i5kS2mwQF61yhVqojRnenVew5PldLyRgvdl4YYuSw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/antfu"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue-flow/core/node_modules/@vueuse/shared": {
|
||||
"version": "10.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-10.11.1.tgz",
|
||||
"integrity": "sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vue-demi": ">=0.14.8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/antfu"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue-flow/minimap": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue-flow/minimap/-/minimap-1.5.4.tgz",
|
||||
"integrity": "sha512-l4C+XTAXnRxsRpUdN7cAVFBennC1sVRzq4bDSpVK+ag7tdMczAnhFYGgbLkUw3v3sY6gokyWwMl8CDonp8eB2g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"d3-selection": "^3.0.0",
|
||||
"d3-zoom": "^3.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue-flow/core": "^1.23.0",
|
||||
"vue": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-core": {
|
||||
"version": "3.5.25",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.25.tgz",
|
||||
@@ -2950,6 +3046,111 @@
|
||||
"node": ">=0.12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-color": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz",
|
||||
"integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-dispatch": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz",
|
||||
"integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-drag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz",
|
||||
"integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-dispatch": "1 - 3",
|
||||
"d3-selection": "3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-ease": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz",
|
||||
"integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-interpolate": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz",
|
||||
"integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-color": "1 - 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-selection": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
|
||||
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-timer": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz",
|
||||
"integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-transition": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz",
|
||||
"integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-color": "1 - 3",
|
||||
"d3-dispatch": "1 - 3",
|
||||
"d3-ease": "1 - 3",
|
||||
"d3-interpolate": "1 - 3",
|
||||
"d3-timer": "1 - 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"d3-selection": "2 - 3"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-zoom": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz",
|
||||
"integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-dispatch": "1 - 3",
|
||||
"d3-drag": "2 - 3",
|
||||
"d3-interpolate": "1 - 3",
|
||||
"d3-selection": "2 - 3",
|
||||
"d3-transition": "2 - 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/dayjs": {
|
||||
"version": "1.11.19",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz",
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@logicflow/core": "^2.2.1",
|
||||
"@logicflow/extension": "^2.2.1",
|
||||
"@vue-flow/background": "^1.3.2",
|
||||
"@vue-flow/controls": "^1.1.3",
|
||||
"@vue-flow/core": "^1.48.2",
|
||||
"@vue-flow/minimap": "^1.5.4",
|
||||
"@wangeditor/editor": "^5.1.23",
|
||||
"axios": "1.8.2",
|
||||
"codemirror": "^6.0.1",
|
||||
|
||||
@@ -5,30 +5,42 @@ export interface knowledgeQueryParams {
|
||||
keyword?: string;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
datasetType?: number; // 1=文本,2=视频
|
||||
}
|
||||
|
||||
// 创建知识库参数
|
||||
export interface CreateknowledgeParams {
|
||||
name: string; // 必传
|
||||
datasetType: number; // 1=文本,2=视频
|
||||
description?: string; // 可选
|
||||
embeddingModel?: string; // 向量模型
|
||||
status?: string; // 状态
|
||||
}
|
||||
|
||||
// 更新知识库参数
|
||||
export interface UpdateknowledgeParams {
|
||||
id: string; // 必传
|
||||
name?: string; // 可选
|
||||
datasetType?: number; // 1=文本,2=视频
|
||||
description?: string; // 可选
|
||||
embeddingModel?: string; // 向量模型
|
||||
status?: string; // 状态
|
||||
}
|
||||
|
||||
// 数据集信息
|
||||
export interface knowledgeInfo {
|
||||
id?: string;
|
||||
name: string;
|
||||
datasetType?: number; // 1=文本,2=视频
|
||||
description?: string;
|
||||
fileCount?: number;
|
||||
totalSize?: number;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
embeddingModel?: string; // 向量模型
|
||||
documentCount?: number; // 文档数量
|
||||
charCount?: number; // 字符数量
|
||||
status?: string; // 状态
|
||||
}
|
||||
|
||||
// 获取知识库列表
|
||||
|
||||
@@ -20,6 +20,41 @@ export interface ModelFormEntry {
|
||||
value: string;
|
||||
}
|
||||
|
||||
// 提示词管理接口类型
|
||||
export interface PromptItem {
|
||||
id: number | string;
|
||||
tenantId?: number;
|
||||
creator?: string;
|
||||
createdAt?: string;
|
||||
updater?: string;
|
||||
updatedAt?: string;
|
||||
deletedAt?: string | null;
|
||||
nodeType: string;
|
||||
prompt: string;
|
||||
sourceType: number; // 0-自定义 1-公共
|
||||
}
|
||||
|
||||
export interface PromptListResponse {
|
||||
list: PromptItem[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface PromptListParams {
|
||||
pageNum?: number;
|
||||
pageSize?: number;
|
||||
keyword?: string;
|
||||
}
|
||||
|
||||
export interface CreatePromptParams {
|
||||
nodeType: string;
|
||||
prompt: string;
|
||||
sourceType: number;
|
||||
}
|
||||
|
||||
export interface UpdatePromptParams extends CreatePromptParams {
|
||||
id: number | string;
|
||||
}
|
||||
|
||||
/** 模型类型(listType 接口项,字段名以后端为准,前端做兼容解析) */
|
||||
export interface ModelTypeListItem {
|
||||
id?: number | string;
|
||||
@@ -251,3 +286,46 @@ export function getOperatorList() {
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户提示词列表
|
||||
*/
|
||||
export function getMyPromptList(params: PromptListParams) {
|
||||
return request<PromptListResponse>({
|
||||
url: '/node/prompt/listMy',
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建提示词
|
||||
*/
|
||||
export function createPrompt(data: CreatePromptParams) {
|
||||
return request({
|
||||
url: '/node/prompt/create',
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改提示词
|
||||
*/
|
||||
export function updatePrompt(data: UpdatePromptParams) {
|
||||
return request({
|
||||
url: '/node/prompt/update',
|
||||
method: 'put',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除提示词
|
||||
*/
|
||||
export function deletePrompt(id: number | string) {
|
||||
return request({
|
||||
url: `/node/prompt/delete/${id}`,
|
||||
method: 'delete',
|
||||
});
|
||||
}
|
||||
|
||||
110
src/api/settings/promptManager/index.ts
Normal file
110
src/api/settings/promptManager/index.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
import request from '/@/utils/request';
|
||||
|
||||
// 提示词管理接口类型
|
||||
export interface PromptItem {
|
||||
id: number | string;
|
||||
tenantId?: number;
|
||||
creator?: string;
|
||||
createdAt?: string;
|
||||
updater?: string;
|
||||
updatedAt?: string;
|
||||
deletedAt?: string | null;
|
||||
nodeType: string;
|
||||
prompt: string;
|
||||
sourceType: number; // 0-自定义 1-公共
|
||||
}
|
||||
|
||||
export interface PromptListResponse {
|
||||
list: PromptItem[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface PromptListParams {
|
||||
pageNum?: number;
|
||||
pageSize?: number;
|
||||
keyword?: string;
|
||||
}
|
||||
|
||||
export interface CreatePromptParams {
|
||||
nodeType: string;
|
||||
prompt: string;
|
||||
sourceType: number;
|
||||
}
|
||||
|
||||
export interface UpdatePromptParams extends CreatePromptParams {
|
||||
id: number | string;
|
||||
}
|
||||
|
||||
// 节点库项接口类型
|
||||
export interface NodeLibraryNode {
|
||||
nodeId: string;
|
||||
nodeCode: string;
|
||||
modelType: number;
|
||||
nodeName: string;
|
||||
skillOption: boolean;
|
||||
promptOption: boolean;
|
||||
}
|
||||
|
||||
export interface NodeLibraryGroup {
|
||||
group: string;
|
||||
label: string;
|
||||
items: NodeLibraryNode[];
|
||||
}
|
||||
|
||||
export interface NodeLibraryResponse {
|
||||
groups: NodeLibraryGroup[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节点类型列表(节点库)
|
||||
*/
|
||||
export function getNodeLibraryList() {
|
||||
return request<NodeLibraryResponse>({
|
||||
url: '/ai-agent/node/library/list',
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户提示词列表
|
||||
*/
|
||||
export function getMyPromptList(params: PromptListParams) {
|
||||
return request<PromptListResponse>({
|
||||
url: '/ai-agent/node/prompt/listMy',
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建提示词
|
||||
*/
|
||||
export function createPrompt(data: CreatePromptParams) {
|
||||
return request({
|
||||
url: '/ai-agent/node/prompt/create',
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改提示词
|
||||
*/
|
||||
export function updatePrompt(data: UpdatePromptParams) {
|
||||
return request({
|
||||
url: '/ai-agent/node/prompt/update',
|
||||
method: 'put',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除提示词
|
||||
*/
|
||||
export function deletePrompt(id: number | string) {
|
||||
return request({
|
||||
url: '/ai-agent/node/prompt/delete',
|
||||
method: 'delete',
|
||||
data: { id },
|
||||
});
|
||||
}
|
||||
@@ -219,9 +219,28 @@ watch(
|
||||
|
||||
const getModelTypeName = (type: number | string) => {
|
||||
const typeMap: Record<number, string> = {
|
||||
1: '推理模型',
|
||||
2: '图片模型',
|
||||
3: '音频模型',
|
||||
100: '推理模型',
|
||||
200: '图片模型',
|
||||
201: '图片模型-文生图',
|
||||
202: '图片模型-图生图',
|
||||
203: '图片模型-图片编辑',
|
||||
204: '图片模型-图片变体',
|
||||
300: '音频模型',
|
||||
301: '音频模型-文生音',
|
||||
302: '音频模型-音生文',
|
||||
303: '音频模型-音生音',
|
||||
400: '向量化模型',
|
||||
401: '向量化模型-文本嵌入',
|
||||
402: '向量化模型-重排序',
|
||||
500: '全模态模型',
|
||||
501: '全模态模型-文图音',
|
||||
502: '全模态模型-视觉理解',
|
||||
600: '视频模型',
|
||||
601: '视频模型-文生视频',
|
||||
602: '视频模型-图生视频',
|
||||
603: '视频模型-图文生视频',
|
||||
604: '视频模型-视频生视频',
|
||||
605: '视频模型-视频编辑',
|
||||
};
|
||||
return typeMap[Number(type)] || '未知类型';
|
||||
};
|
||||
|
||||
@@ -32,22 +32,12 @@
|
||||
<div class="table-body">
|
||||
<div v-for="(attr, index) in ruleForm.attrs" :key="index" class="table-row">
|
||||
<div class="col col-name">
|
||||
<el-input
|
||||
v-if="!isDictType(attr.type)"
|
||||
v-model="attr.name"
|
||||
placeholder="请输入属性名称"
|
||||
clearable
|
||||
/>
|
||||
<el-input v-if="!isDictType(attr.type)" v-model="attr.name" placeholder="请输入属性名称" clearable />
|
||||
<span v-else class="dict-name">{{ attr.name || '请选择字典' }}</span>
|
||||
</div>
|
||||
<div class="col col-type">
|
||||
<el-select v-model="attr.type" placeholder="属性类型" class="w100" @change="onAttrTypeChange(attr)">
|
||||
<el-option
|
||||
v-for="item in attrTypeOptions"
|
||||
:key="item.key"
|
||||
:label="item.value"
|
||||
:value="item.key"
|
||||
/>
|
||||
<el-option v-for="item in attrTypeOptions" :key="item.key" :label="item.value" :value="item.key" />
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="col col-required">
|
||||
@@ -155,13 +145,6 @@ interface DictInfo {
|
||||
remark: string;
|
||||
}
|
||||
|
||||
interface DictValue {
|
||||
key: string;
|
||||
value: string;
|
||||
isDefault: number;
|
||||
remark: string;
|
||||
}
|
||||
|
||||
interface RuleForm {
|
||||
id: string | '';
|
||||
parentId: string;
|
||||
@@ -219,15 +202,11 @@ const fetchDictTypeOptions = () => {
|
||||
.then((res: any) => {
|
||||
const list = res.data?.list ?? [];
|
||||
// 提取所有字典类型信息
|
||||
dictTypeOptions.value = list
|
||||
.map((item: any) => item.info)
|
||||
.filter((info: DictInfo) => info && info.name);
|
||||
dictTypeOptions.value = list.map((item: any) => item.info).filter((info: DictInfo) => info && info.name);
|
||||
// 保存完整的字典数据列表(包含info和values)
|
||||
dictValueOptions.value = list;
|
||||
|
||||
})
|
||||
.catch((err: any) => {
|
||||
|
||||
dictTypeOptions.value = [];
|
||||
dictValueOptions.value = [];
|
||||
})
|
||||
@@ -270,7 +249,9 @@ const isDictOptionDisabled = (dictName: string, currentAttr: CustomAttr) => {
|
||||
const dictInfo = dictTypeOptions.value.find((item) => item.name === dictName);
|
||||
const dictType = dictInfo?.type || '';
|
||||
// 检查该字典是否已被其他属性使用(使用 dictType 判断)
|
||||
return ruleForm.attrs.some((attr) => attr !== currentAttr && isDictType(attr.type) && (attr.dictType === dictType || (!attr.dictType && attr.name === dictName)));
|
||||
return ruleForm.attrs.some(
|
||||
(attr) => attr !== currentAttr && isDictType(attr.type) && (attr.dictType === dictType || (!attr.dictType && attr.name === dictName))
|
||||
);
|
||||
};
|
||||
|
||||
// 添加自定义属性
|
||||
@@ -325,16 +306,16 @@ const openDialog = (row?: CategoryRow | string, edit?: boolean) => {
|
||||
// 获取分类树数据
|
||||
getCategoryTree().then((res: any) => {
|
||||
const tree = res.data?.tree ?? [];
|
||||
|
||||
|
||||
// 递归函数,将所有id字段转换为字符串
|
||||
const convertIdsToString = (items: any[]): any[] => {
|
||||
return items.map(item => ({
|
||||
return items.map((item) => ({
|
||||
...item,
|
||||
id: item.id?.toString(),
|
||||
children: item.children && item.children.length > 0 ? convertIdsToString(item.children) : []
|
||||
children: item.children && item.children.length > 0 ? convertIdsToString(item.children) : [],
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
categoryData.value = convertIdsToString(tree);
|
||||
});
|
||||
|
||||
@@ -472,7 +453,7 @@ const onSubmit = () => {
|
||||
...submitData,
|
||||
_originalData: originalData,
|
||||
};
|
||||
|
||||
|
||||
updateCategory(requestData)
|
||||
.then(() => {
|
||||
ElMessage.success('修改成功');
|
||||
|
||||
@@ -3,18 +3,10 @@
|
||||
<div class="chat-divider">今天 15:14</div>
|
||||
|
||||
<div v-for="msg in messages" :key="msg.id" class="message-row" :class="{ 'is-user': msg.isUser }">
|
||||
<div v-if="!msg.isUser" class="avatar-wrap">
|
||||
<div class="ai-avatar">AI</div>
|
||||
</div>
|
||||
|
||||
<div class="bubble-wrap">
|
||||
<div class="bubble">{{ msg.content }}</div>
|
||||
<div class="time">{{ msg.time }}</div>
|
||||
</div>
|
||||
|
||||
<div v-if="msg.isUser" class="avatar-wrap">
|
||||
<el-avatar :size="28" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -64,16 +56,20 @@ const messages = ref<Message[]>([
|
||||
.chat-divider {
|
||||
align-self: center;
|
||||
font-size: 12px;
|
||||
color: #8b95a7;
|
||||
color: #64748b;
|
||||
line-height: 1;
|
||||
padding: 0 12px;
|
||||
padding: 4px 16px;
|
||||
background: rgba(255, 255, 255, 0.7);
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(226, 233, 244, 0.8);
|
||||
letter-spacing: 0.2px;
|
||||
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
|
||||
}
|
||||
|
||||
.message-row {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
max-width: 100%;
|
||||
|
||||
&.is-user {
|
||||
@@ -81,27 +77,6 @@ const messages = ref<Message[]>([
|
||||
}
|
||||
}
|
||||
|
||||
.avatar-wrap {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.ai-avatar {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: #53607a;
|
||||
background: linear-gradient(145deg, #f7f9fc 0%, #e9eef6 100%);
|
||||
border: 1px solid #dfe6f0;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
|
||||
}
|
||||
|
||||
.bubble-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -112,30 +87,35 @@ const messages = ref<Message[]>([
|
||||
.bubble {
|
||||
font-size: 14px;
|
||||
line-height: 1.75;
|
||||
padding: 12px 14px;
|
||||
border-radius: 12px;
|
||||
padding: 14px 16px;
|
||||
border-radius: 16px;
|
||||
word-break: break-word;
|
||||
color: #1f2937;
|
||||
background: rgba(255, 255, 255, 0.84);
|
||||
background: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 255, 0.92) 100%);
|
||||
border: 1px solid rgba(226, 233, 244, 0.95);
|
||||
backdrop-filter: blur(8px);
|
||||
box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
|
||||
box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
.message-row.is-user & {
|
||||
background: linear-gradient(135deg, #58a6ff 0%, #3b82f6 52%, #2563eb 100%);
|
||||
border-color: rgba(59, 130, 246, 0.32);
|
||||
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
|
||||
border-color: rgba(59, 130, 246, 0.4);
|
||||
color: #fff;
|
||||
box-shadow: 0 8px 20px rgba(37, 99, 235, 0.33);
|
||||
box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
|
||||
}
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 11px;
|
||||
color: #8f9aae;
|
||||
padding: 0 4px;
|
||||
padding: 4px 6px;
|
||||
|
||||
.message-row.is-user & {
|
||||
text-align: right;
|
||||
color: rgba(148, 163, 184, 0.9);
|
||||
}
|
||||
.message-row:not(.is-user) & {
|
||||
padding-left: 2px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -16,84 +16,152 @@
|
||||
<el-button circle class="tool-btn" @click="handleAttachment">
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-button>
|
||||
<el-dropdown trigger="click" @command="handleCommandSelect">
|
||||
<el-button class="pill-btn">快捷指令</el-button>
|
||||
<el-dropdown trigger="click" @command="handleSkillSelect">
|
||||
<el-button class="pill-btn">
|
||||
{{ currentSkillDisplay }}
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="rewrite">帮我润色这段文案</el-dropdown-item>
|
||||
<el-dropdown-item command="summary">总结当前对话重点</el-dropdown-item>
|
||||
<el-dropdown-item command="todo">整理下一步 TODO</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
|
||||
<el-dropdown trigger="click" @command="handleReplySelect">
|
||||
<el-button class="pill-btn">快捷回复</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="ok">收到,我马上处理</el-dropdown-item>
|
||||
<el-dropdown-item command="confirm">这个方向可以,继续</el-dropdown-item>
|
||||
<el-dropdown-item command="adjust">这个比例还要再调一下</el-dropdown-item>
|
||||
<el-dropdown-item command="default">默认对话</el-dropdown-item>
|
||||
<el-dropdown-item command="code-review">代码审查</el-dropdown-item>
|
||||
<el-dropdown-item command="refactor">代码重构</el-dropdown-item>
|
||||
<el-dropdown-item command="writing">内容写作</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-right">
|
||||
<el-button class="mode-btn">启动</el-button>
|
||||
<el-button circle class="send-btn" :disabled="!message.trim()" @click="handleSend">
|
||||
<el-icon><Top /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 常用工作流胶囊 -->
|
||||
<div class="workflow-pills" v-if="commonWorkflows.length > 0">
|
||||
<div
|
||||
v-for="wf in commonWorkflows"
|
||||
:key="wf.id"
|
||||
class="workflow-pill"
|
||||
:class="{ active: selectedWorkflowId === wf.id }"
|
||||
@click="selectWorkflow(wf)"
|
||||
>
|
||||
<el-icon class="pill-icon">
|
||||
<component :is="wf.icon" />
|
||||
</el-icon>
|
||||
<span class="pill-text">{{ wf.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { Top, Plus } from '@element-plus/icons-vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { Top, Plus, MagicStick, Document, CircleCheck } from '@element-plus/icons-vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
interface Emits {
|
||||
(e: 'send', message: string): void;
|
||||
}
|
||||
|
||||
interface Workflow {
|
||||
id: number;
|
||||
name: string;
|
||||
icon: any;
|
||||
prefix: string;
|
||||
editPath: string;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
const router = useRouter();
|
||||
const message = ref('');
|
||||
const selectedSkill = ref('default');
|
||||
const selectedWorkflowId = ref<number | null>(null);
|
||||
|
||||
const quickCommands: Record<string, string> = {
|
||||
rewrite: '请帮我润色下面这段内容,保持原意并提升表达质感:',
|
||||
summary: '请总结我们当前对话的重点,并给出 3 条执行建议。',
|
||||
todo: '请把当前需求拆解成可执行的 TODO 列表。',
|
||||
const skillLabels: Record<string, string> = {
|
||||
default: '选择技能',
|
||||
'code-review': '代码审查',
|
||||
refactor: '代码重构',
|
||||
writing: '内容写作',
|
||||
};
|
||||
|
||||
const quickReplies: Record<string, string> = {
|
||||
ok: '收到,我马上处理。',
|
||||
confirm: '这个方向可以,继续。',
|
||||
adjust: '这个比例还要再调一下。',
|
||||
const currentSkillDisplay = computed(() => {
|
||||
return selectedSkill.value === 'default' ? '选择技能' : skillLabels[selectedSkill.value];
|
||||
});
|
||||
|
||||
const skills: Record<string, string> = {
|
||||
default: '',
|
||||
'code-review': '[技能:代码审查] 请帮我审查下面这段代码,找出潜在问题并给出改进建议:\n',
|
||||
refactor: '[技能:代码重构] 请帮我重构下面这段代码,提升可读性和可维护性:\n',
|
||||
writing: '[技能:内容写作] 请根据下面的需求帮我创作内容:\n',
|
||||
};
|
||||
|
||||
// 常用工作流列表
|
||||
const commonWorkflows: Workflow[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: '审查+测试',
|
||||
icon: Document,
|
||||
prefix: '[工作流:审查+测试] 完成后请自动生成单元测试:\n',
|
||||
editPath: '/settings/workflow',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '文档再编码',
|
||||
icon: Document,
|
||||
prefix: '[工作流:文档再编码] 请先编写接口文档,再实现代码:\n',
|
||||
editPath: '/settings/workflow',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '代码重构',
|
||||
icon: Document,
|
||||
prefix: '[工作流:代码重构] 请帮我重构这段代码:\n',
|
||||
editPath: '/settings/workflow',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '需求分析',
|
||||
icon: Document,
|
||||
prefix: '[工作流:需求分析] 请帮我分析这个需求并拆解任务:\n',
|
||||
editPath: '/settings/workflow',
|
||||
},
|
||||
];
|
||||
|
||||
const handleSend = (event?: KeyboardEvent) => {
|
||||
if (event) event.preventDefault();
|
||||
const msg = message.value.trim();
|
||||
if (!msg) return;
|
||||
emit('send', msg);
|
||||
const skillPrefix = skills[selectedSkill.value] || '';
|
||||
const workflowPrefix = selectedWorkflowId.value !== null ? commonWorkflows.find((w) => w.id === selectedWorkflowId.value)?.prefix || '' : '';
|
||||
const finalMessage = (skillPrefix + workflowPrefix + msg).trim();
|
||||
emit('send', finalMessage);
|
||||
message.value = '';
|
||||
// 发送后清空选择
|
||||
selectedWorkflowId.value = null;
|
||||
};
|
||||
|
||||
const handleAttachment = () => {
|
||||
ElMessage.info('附件上传功能开发中...');
|
||||
};
|
||||
|
||||
const handleCommandSelect = (key: string | number | object) => {
|
||||
const k = String(key);
|
||||
message.value = quickCommands[k] || message.value;
|
||||
const handleSkillSelect = (key: string | number | object) => {
|
||||
selectedSkill.value = String(key);
|
||||
if (selectedSkill.value !== 'default') {
|
||||
ElMessage.success(`已选择技能:${skillLabels[selectedSkill.value]}`);
|
||||
}
|
||||
};
|
||||
|
||||
const handleReplySelect = (key: string | number | object) => {
|
||||
const k = String(key);
|
||||
message.value = quickReplies[k] || message.value;
|
||||
const selectWorkflow = (wf: Workflow) => {
|
||||
if (selectedWorkflowId.value === wf.id) {
|
||||
selectedWorkflowId.value = null;
|
||||
ElMessage.info('已取消工作流');
|
||||
} else {
|
||||
selectedWorkflowId.value = wf.id;
|
||||
ElMessage.success(`已选择工作流:${wf.name}`);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -110,16 +178,17 @@ const handleReplySelect = (key: string | number | object) => {
|
||||
width: min(1060px, 82%);
|
||||
margin: 0 auto;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(255, 255, 255, 0.92) 100%),
|
||||
radial-gradient(120% 180% at 0% 0%, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0) 38%);
|
||||
border: 1px solid rgba(191, 219, 254, 0.62);
|
||||
border-radius: 18px;
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.94) 100%),
|
||||
radial-gradient(120% 180% at 0% 0%, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0) 38%),
|
||||
radial-gradient(80% 120% at 100% 100%, rgba(168, 85, 247, 0.08) 0%, rgba(168, 85, 247, 0) 38%);
|
||||
border: 1px solid rgba(59, 130, 246, 0.28);
|
||||
border-radius: 20px;
|
||||
box-shadow:
|
||||
0 20px 44px rgba(15, 23, 42, 0.14),
|
||||
0 0 0 1px rgba(59, 130, 246, 0.09) inset,
|
||||
0 10px 24px rgba(37, 99, 235, 0.16);
|
||||
padding: 14px 16px 12px;
|
||||
backdrop-filter: blur(14px);
|
||||
0 24px 48px rgba(15, 23, 42, 0.12),
|
||||
0 0 0 1px rgba(59, 130, 246, 0.08) inset,
|
||||
0 8px 16px rgba(37, 99, 235, 0.1);
|
||||
padding: 16px 18px 18px;
|
||||
backdrop-filter: blur(16px);
|
||||
}
|
||||
|
||||
.message-input {
|
||||
@@ -158,59 +227,106 @@ const handleReplySelect = (key: string | number | object) => {
|
||||
}
|
||||
|
||||
.tool-btn {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid #d9e4f5;
|
||||
color: #5b6b84;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
|
||||
box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
|
||||
box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
color: #2b4d8f;
|
||||
background: #f3f8ff;
|
||||
background: linear-gradient(135deg, #f0f7ff 0%, #e0edff 100%);
|
||||
border-color: #bfdbfe;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
.pill-btn {
|
||||
height: 30px;
|
||||
padding: 0 12px;
|
||||
height: 32px;
|
||||
padding: 0 14px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #dbe7f7;
|
||||
color: #30435f;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
transition: all 0.2s ease;
|
||||
|
||||
.mode-btn {
|
||||
height: 30px;
|
||||
padding: 0 13px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #dbe7f7;
|
||||
color: #30435f;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.2px;
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #f0f7ff 0%, #e0edff 100%);
|
||||
border-color: #bfdbfe;
|
||||
color: #1d4ed8;
|
||||
}
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 55%, #2563eb 100%);
|
||||
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
|
||||
color: #fff;
|
||||
box-shadow: 0 6px 14px rgba(59, 130, 246, 0.4);
|
||||
box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
filter: brightness(1.06);
|
||||
filter: brightness(1.08);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 8px 20px rgba(59, 130, 246, 0.5);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.55;
|
||||
opacity: 0.5;
|
||||
box-shadow: none;
|
||||
background: #cbd5e1;
|
||||
background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
|
||||
}
|
||||
}
|
||||
|
||||
/* 工作流胶囊样式 */
|
||||
.workflow-pills {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid rgba(59, 130, 246, 0.15);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.workflow-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(59, 130, 246, 0.3);
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
color: #475569;
|
||||
|
||||
&:hover {
|
||||
border-color: #3b82f6;
|
||||
background: rgba(59, 130, 246, 0.08);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: #3b82f6;
|
||||
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
|
||||
color: #ffffff;
|
||||
box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
.pill-icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.pill-text {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,31 +3,20 @@
|
||||
<div v-if="activeMenu !== 'chat'" class="content-header">
|
||||
<h2 class="content-title">{{ currentTitle }}</h2>
|
||||
<div class="content-actions">
|
||||
<el-button v-if="showAddButton" type="primary" size="small" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新建
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-body">
|
||||
<ChatList v-if="activeMenu === 'chat'" />
|
||||
<DiaryList v-else-if="activeMenu === 'diary'" />
|
||||
<FileList v-else-if="activeMenu === 'files'" />
|
||||
<CommandList v-else-if="activeMenu === 'commands'" />
|
||||
<ReplyList v-else-if="activeMenu === 'replies'" />
|
||||
<div class="chat-container" v-if="activeMenu === 'chat'">
|
||||
<ChatList />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import ChatList from './ChatList.vue';
|
||||
import DiaryList from './DiaryList.vue';
|
||||
import FileList from './FileList.vue';
|
||||
import CommandList from './CommandList.vue';
|
||||
import ReplyList from './ReplyList.vue';
|
||||
|
||||
interface Props {
|
||||
activeMenu: string;
|
||||
@@ -37,19 +26,11 @@ const props = defineProps<Props>();
|
||||
|
||||
const menuTitles: Record<string, string> = {
|
||||
chat: '对话',
|
||||
diary: '我的日记',
|
||||
files: '文件管理',
|
||||
commands: '快捷指令',
|
||||
replies: '快捷回复',
|
||||
models: '模型管理',
|
||||
creation: '内容创作',
|
||||
};
|
||||
|
||||
const currentTitle = computed(() => menuTitles[props.activeMenu] || '首页');
|
||||
|
||||
const showAddButton = computed(() => ['diary', 'files', 'commands', 'replies'].includes(props.activeMenu));
|
||||
|
||||
const handleAdd = () => {
|
||||
console.log('新建:', props.activeMenu);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -97,17 +78,11 @@ const handleAdd = () => {
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
// 聊天界面的特殊样式
|
||||
&:has(.chat-list) {
|
||||
padding: 0 8% 130px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
// 其他列表的样式
|
||||
&:not(:has(.chat-list)) {
|
||||
padding: 20px 24px;
|
||||
background: #f9fafb;
|
||||
}
|
||||
.chat-container {
|
||||
width: min(1060px, 82%);
|
||||
margin: 0 auto;
|
||||
padding: 20px 0 130px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,99 +1,87 @@
|
||||
<template>
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<div class="brand-dot"></div>
|
||||
<div class="user-info">
|
||||
<el-avatar :size="42" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
|
||||
<div class="user-details">
|
||||
<div class="user-name">助手</div>
|
||||
<div class="user-status">在线</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-button class="new-chat-btn" @click="handleNewChat">
|
||||
<el-icon><Plus /></el-icon>
|
||||
<el-icon>
|
||||
<Plus />
|
||||
</el-icon>
|
||||
新增对话
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-menu">
|
||||
<div v-for="item in menuItems" :key="item.key" class="menu-item" :class="{ active: activeMenu === item.key }" @click="handleMenuClick(item)">
|
||||
<el-icon :size="18" class="menu-icon">
|
||||
<component :is="item.icon" />
|
||||
</el-icon>
|
||||
<span class="menu-label">{{ item.label }}</span>
|
||||
<el-badge v-if="item.badge" :value="item.badge" class="menu-badge" />
|
||||
<div v-if="historyList.length" class="history-section">
|
||||
<div class="history-title">历史对话</div>
|
||||
<div class="history-list">
|
||||
<div
|
||||
v-for="item in historyList"
|
||||
:key="item.id"
|
||||
class="history-item"
|
||||
:class="{ active: activeHistoryId === item.id }"
|
||||
@click="handleSelectHistory(item.id)"
|
||||
>
|
||||
<div class="history-main">
|
||||
<div class="history-name">{{ item.title }}</div>
|
||||
<div class="history-time">{{ item.time }}</div>
|
||||
</div>
|
||||
<el-button text class="delete-btn" @click.stop="handleDeleteHistory(item.id)">
|
||||
<el-icon>
|
||||
<Delete />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<el-button text class="footer-btn" @click="handleSettings">
|
||||
<el-icon><Setting /></el-icon>
|
||||
设置
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Document, Folder, ChatDotRound, MagicStick, Cpu, VideoPlay, Setting, Plus } from '@element-plus/icons-vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { Plus, Delete } from '@element-plus/icons-vue';
|
||||
|
||||
interface MenuItem {
|
||||
key: string;
|
||||
label: string;
|
||||
icon: any;
|
||||
badge?: number;
|
||||
route?: string;
|
||||
interface HistoryItem {
|
||||
id: number;
|
||||
title: string;
|
||||
time: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
activeMenu: string;
|
||||
activeHistoryId: number;
|
||||
historyList: HistoryItem[];
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'menu-change', key: string): void;
|
||||
(e: 'new-chat'): void;
|
||||
(e: 'select-history', id: number): void;
|
||||
(e: 'delete-history', id: number): void;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
const router = useRouter();
|
||||
|
||||
const menuItems: MenuItem[] = [
|
||||
{ key: 'chat', label: '对话', icon: ChatDotRound },
|
||||
{ key: 'diary', label: '日记', icon: Document, badge: 3 },
|
||||
{ key: 'files', label: '文件', icon: Folder },
|
||||
{ key: 'skills', label: '技能管理', icon: MagicStick, route: '/settings/skill' },
|
||||
{ key: 'models', label: '模型管理', icon: Cpu, route: '/settings/modelConfig/modelModule' },
|
||||
{ key: 'creation', label: '内容创作', icon: VideoPlay, route: '/settings/creation' },
|
||||
];
|
||||
|
||||
const handleMenuClick = (item: MenuItem) => {
|
||||
if (item.route) {
|
||||
router.push(item.route);
|
||||
} else {
|
||||
emit('menu-change', item.key);
|
||||
}
|
||||
};
|
||||
|
||||
const handleNewChat = () => {
|
||||
emit('new-chat');
|
||||
};
|
||||
|
||||
const handleSettings = () => {
|
||||
router.push('/personal');
|
||||
const handleSelectHistory = (id: number) => {
|
||||
emit('select-history', id);
|
||||
};
|
||||
|
||||
const handleDeleteHistory = (id: number) => {
|
||||
emit('delete-history', id);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.sidebar {
|
||||
width: 252px;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(249, 251, 255, 0.92) 100%);
|
||||
border-right: 1px solid #e7edf7;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
box-shadow: 6px 0 20px rgba(15, 23, 42, 0.04);
|
||||
box-shadow: 8px 0 30px rgba(15, 23, 42, 0.06);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
@@ -103,65 +91,48 @@ const handleSettings = () => {
|
||||
}
|
||||
|
||||
.new-chat-btn {
|
||||
margin-top: 10px;
|
||||
margin-top: 0;
|
||||
width: 100%;
|
||||
height: 34px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #dbe7f7;
|
||||
background: linear-gradient(135deg, #f8fbff 0%, #eff6ff 100%);
|
||||
color: #1f4db8;
|
||||
height: 40px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(59, 130, 246, 0.28);
|
||||
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.2px;
|
||||
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.26);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
color: #1e40af;
|
||||
border-color: #bfdbfe;
|
||||
background: linear-gradient(135deg, #eff6ff 0%, #e0eeff 100%);
|
||||
transform: translateY(-1px);
|
||||
color: #ffffff;
|
||||
border-color: rgba(59, 130, 246, 0.4);
|
||||
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
|
||||
box-shadow: 0 6px 16px rgba(37, 99, 235, 0.32);
|
||||
}
|
||||
}
|
||||
|
||||
.brand-dot {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
top: 18px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
|
||||
box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
|
||||
}
|
||||
|
||||
.user-info {
|
||||
.history-section {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 8px 8px 6px;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(248, 251, 255, 0.92) 100%);
|
||||
border: 1px solid #e7edf7;
|
||||
flex-direction: column;
|
||||
margin-top: 8px;
|
||||
min-height: 0;
|
||||
background: linear-gradient(180deg, rgba(249, 251, 255, 0.5) 0%, rgba(249, 251, 255, 0.9) 100%);
|
||||
}
|
||||
|
||||
.user-details {
|
||||
.history-title {
|
||||
padding: 12px 12px 8px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.8px;
|
||||
}
|
||||
|
||||
.history-list {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
margin-bottom: 4px;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.user-status {
|
||||
font-size: 12px;
|
||||
color: #10b981;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
flex: 1;
|
||||
padding: 12px 10px;
|
||||
padding: 0 8px 10px;
|
||||
overflow-y: auto;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
@@ -171,80 +142,66 @@ const handleSettings = () => {
|
||||
}
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
.history-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 11px 12px;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 10px 10px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 11px;
|
||||
cursor: pointer;
|
||||
transition: all 0.22s ease;
|
||||
color: #64748b;
|
||||
position: relative;
|
||||
border-radius: 10px;
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
|
||||
&:hover {
|
||||
background: #f3f7ff;
|
||||
color: #1f2937;
|
||||
border-color: #e3ecfb;
|
||||
border-color: #bfdbfe;
|
||||
background: linear-gradient(135deg, rgba(239, 246, 255, 0.9) 0%, rgba(219, 234, 254, 0.7) 100%);
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: linear-gradient(135deg, rgba(59, 130, 246, 0.16) 0%, rgba(37, 99, 235, 0.12) 100%);
|
||||
color: #1f4db8;
|
||||
font-weight: 600;
|
||||
border-color: rgba(59, 130, 246, 0.2);
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
|
||||
border-color: #3b82f6;
|
||||
background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0.04) 100%);
|
||||
box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -2px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 3px;
|
||||
height: 18px;
|
||||
background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
|
||||
border-radius: 0 4px 4px 0;
|
||||
.delete-btn {
|
||||
opacity: 0;
|
||||
color: #94a3b8;
|
||||
transition: all 0.2s ease;
|
||||
padding: 4px;
|
||||
|
||||
&:hover {
|
||||
color: #ef4444;
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover .delete-btn {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-icon {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.menu-label {
|
||||
.history-main {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.menu-badge {
|
||||
:deep(.el-badge__content) {
|
||||
background: #ef4444;
|
||||
border: none;
|
||||
box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
|
||||
}
|
||||
.history-name {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: #1e293b;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
padding: 10px;
|
||||
border-top: 1px solid #e9eef7;
|
||||
}
|
||||
|
||||
.footer-btn {
|
||||
width: 100%;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
color: #64748b;
|
||||
font-size: 13px;
|
||||
border-radius: 10px;
|
||||
padding: 10px 12px;
|
||||
|
||||
&:hover {
|
||||
background: #f4f7fd;
|
||||
color: #1f2937;
|
||||
}
|
||||
.history-time {
|
||||
font-size: 11px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,56 +1,78 @@
|
||||
<template>
|
||||
<div class="home-chat-container">
|
||||
<Sidebar :active-menu="activeMenu" @menu-change="handleMenuChange" @new-chat="handleCreateHistory" />
|
||||
<Sidebar
|
||||
:active-menu="activeMenu"
|
||||
:active-history-id="activeHistoryId"
|
||||
:history-list="historyList"
|
||||
@menu-change="handleMenuChange"
|
||||
@new-chat="handleCreateHistory"
|
||||
@select-history="handleSelectHistory"
|
||||
@delete-history="handleDeleteHistory"
|
||||
/>
|
||||
<div class="main-wrapper">
|
||||
<MainContent :active-menu="activeMenu" />
|
||||
<InputBar @send="handleSend" />
|
||||
</div>
|
||||
|
||||
<div class="history-float" @click="historyDrawerVisible = true">
|
||||
<el-icon :size="16"><Clock /></el-icon>
|
||||
<span>历史对话</span>
|
||||
<em>{{ historyList.length }}</em>
|
||||
<!-- 右侧:工作空间(树形结构) -->
|
||||
<div class="workspace-panel">
|
||||
<div class="workspace-tree-wrap" v-loading="treeLoading">
|
||||
<el-empty v-if="!treeLoading && treeNodes.length === 0" description="暂无作品数据" />
|
||||
<el-tree
|
||||
v-else
|
||||
:data="treeNodes"
|
||||
node-key="id"
|
||||
:props="treeProps"
|
||||
default-expand-all
|
||||
:highlight-current="true"
|
||||
:expand-on-click-node="true"
|
||||
@node-click="handleTreeNodeClick"
|
||||
>
|
||||
<template #default="{ data }">
|
||||
<div
|
||||
class="tree-node"
|
||||
:class="[
|
||||
data.nodeType === 'date' ? 'level-date' :
|
||||
data.nodeType === 'contentType' ? 'level-flow' : 'level-file',
|
||||
data.fileType ? data.fileType.replace(/\\/g, ' ').split(' ')[0] : ''
|
||||
]"
|
||||
>
|
||||
<span class="ellipsis">{{ data.label }}</span>
|
||||
<div v-if="data.nodeType === 'title' && data.fileUrl" class="tree-node-actions">
|
||||
<el-button type="primary" link size="small" @click.stop="previewNode(data)"> 预览 </el-button>
|
||||
<el-button type="primary" link size="small" @click.stop="downloadNode(data)"> 下载 </el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-tree>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-drawer v-model="historyDrawerVisible" direction="rtl" :with-header="false" size="360px" class="history-drawer">
|
||||
<div class="drawer-panel">
|
||||
<div class="drawer-header">
|
||||
<div class="drawer-title">历史对话</div>
|
||||
<el-button type="primary" class="new-btn" @click="handleCreateHistory">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新建会话
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div class="history-list">
|
||||
<div
|
||||
v-for="item in historyList"
|
||||
:key="item.id"
|
||||
class="history-item"
|
||||
:class="{ active: activeHistoryId === item.id }"
|
||||
@click="handleSelectHistory(item.id)"
|
||||
>
|
||||
<div class="history-main">
|
||||
<div class="history-title">{{ item.title }}</div>
|
||||
<div class="history-meta">{{ item.time }}</div>
|
||||
</div>
|
||||
<el-button text class="delete-btn" @click.stop="handleDeleteHistory(item.id)">
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 预览弹窗 - 放在外层,避免被右侧容器限制宽度 -->
|
||||
<el-dialog v-model="previewDialogVisible" title="预览" width="95%" top="2vh" :close-on-click-modal="false" destroy-on-close>
|
||||
<div class="preview-container">
|
||||
<el-image v-if="previewUrl && previewMode === 'image'" :src="previewUrl" fit="contain" style="width: 100%; height: 100%" />
|
||||
<video
|
||||
v-else-if="previewUrl && previewMode === 'video'"
|
||||
:src="previewUrl"
|
||||
controls
|
||||
style="width: 100%; height: 100%; background: #000"
|
||||
></video>
|
||||
<audio v-else-if="previewUrl && previewMode === 'audio'" :src="previewUrl" controls style="width: 100%"></audio>
|
||||
<iframe v-else-if="previewUrl" :src="previewUrl" class="preview-iframe" frameborder="0"></iframe>
|
||||
<el-empty v-else description="无法加载预览内容" />
|
||||
</div>
|
||||
</el-drawer>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { Clock, Plus, Delete } from '@element-plus/icons-vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import Sidebar from './components/Sidebar.vue';
|
||||
import MainContent from './components/MainContent.vue';
|
||||
import InputBar from './components/InputBar.vue';
|
||||
import type { ExecutionTreeItem } from '/@/api/settings/creation';
|
||||
import { getExecutionList } from '/@/api/settings/creation';
|
||||
|
||||
interface HistoryItem {
|
||||
id: number;
|
||||
@@ -58,9 +80,25 @@ interface HistoryItem {
|
||||
time: string;
|
||||
}
|
||||
|
||||
interface TreeNode {
|
||||
id: string;
|
||||
label: string;
|
||||
nodeType: string;
|
||||
children?: TreeNode[];
|
||||
fileUrl?: string;
|
||||
workflowId?: number | string;
|
||||
fileType?: string;
|
||||
sessionId?: string;
|
||||
}
|
||||
|
||||
const activeMenu = ref('chat');
|
||||
const historyDrawerVisible = ref(false);
|
||||
const activeHistoryId = ref(1);
|
||||
const treeLoading = ref(false);
|
||||
const treeNodes = ref<TreeNode[]>([]);
|
||||
const imgAddressPrefix = ref('');
|
||||
const previewDialogVisible = ref(false);
|
||||
const previewUrl = ref('');
|
||||
const previewMode = ref<'iframe' | 'image' | 'video' | 'audio'>('iframe');
|
||||
|
||||
const historyList = ref<HistoryItem[]>([
|
||||
{ id: 1, title: '首页风格优化方案', time: '刚刚' },
|
||||
@@ -69,6 +107,133 @@ const historyList = ref<HistoryItem[]>([
|
||||
{ id: 4, title: '快捷回复产品设计', time: '2 天前' },
|
||||
]);
|
||||
|
||||
const treeProps = { children: 'children', label: 'label' };
|
||||
const apiBaseUrl = (import.meta.env.VITE_API_URL || '').replace(/\/$/, '');
|
||||
|
||||
const joinUrl = (b: string, p: string) => `${b.replace(/\/$/, '')}${p.startsWith('/') ? p : `/${p}`}`;
|
||||
const buildAssetUrl = (p?: string) =>
|
||||
!p
|
||||
? ''
|
||||
: /^https?:\/\//i.test(p)
|
||||
? p
|
||||
: /^https?:\/\//i.test(imgAddressPrefix.value || '')
|
||||
? joinUrl(imgAddressPrefix.value, p)
|
||||
: imgAddressPrefix.value
|
||||
? joinUrl(joinUrl(apiBaseUrl, imgAddressPrefix.value), p)
|
||||
: joinUrl(apiBaseUrl, p);
|
||||
|
||||
const buildTreeNodes = (tree: ExecutionTreeItem[]): TreeNode[] =>
|
||||
tree.map((d, di) => ({
|
||||
id: `date-${di}`,
|
||||
label: d.createDate,
|
||||
nodeType: 'date',
|
||||
children: (d.flows || []).map((f, fi) => ({
|
||||
id: `flow-${di}-${fi}`,
|
||||
label: f.flowName || '未命名工作流',
|
||||
nodeType: 'contentType',
|
||||
workflowId: f.Id,
|
||||
sessionId: f.sessionId,
|
||||
children: (f.items || []).map((item, ii) => ({
|
||||
id: `item-${di}-${fi}-${ii}`,
|
||||
label: item.label || `作品${ii + 1}`,
|
||||
nodeType: 'title',
|
||||
fileUrl: item.content,
|
||||
fileType: item.type,
|
||||
workflowId: f.Id,
|
||||
sessionId: f.sessionId,
|
||||
})),
|
||||
})),
|
||||
}));
|
||||
|
||||
// 模拟mock数据
|
||||
const mockTreeData: ExecutionTreeItem[] = [
|
||||
{
|
||||
createDate: '今天',
|
||||
flows: [
|
||||
{
|
||||
Id: 1,
|
||||
flowName: '代码审查任务',
|
||||
sessionId: 'session-1',
|
||||
items: [
|
||||
{ label: '审查结果.md', content: 'https://placekitten.com/800/600', type: 'text/markdown' },
|
||||
{ label: '流程图.png', content: 'https://placekitten.com/800/600', type: 'image/png' },
|
||||
],
|
||||
},
|
||||
{
|
||||
Id: 2,
|
||||
flowName: '需求分析',
|
||||
sessionId: 'session-2',
|
||||
items: [{ label: '需求拆解.txt', content: '# 需求分析结果\n\n- 功能点一\n- 功能点二\n- 需要优化', type: 'text/plain' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
createDate: '昨天',
|
||||
flows: [
|
||||
{
|
||||
Id: 3,
|
||||
flowName: '生成演示视频',
|
||||
sessionId: 'session-3',
|
||||
items: [{ label: '输出视频.mp4', content: 'https://www.w3schools.com/html/mov_bbb.mp4', type: 'video/mp4' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const getList = async () => {
|
||||
treeLoading.value = true;
|
||||
try {
|
||||
const res = await getExecutionList();
|
||||
imgAddressPrefix.value = res.data?.imgAddressPrefix || '';
|
||||
const data = res.data?.tree || [];
|
||||
// 如果后端没有数据,使用mock数据展示
|
||||
treeNodes.value = data.length > 0 ? buildTreeNodes(data) : buildTreeNodes(mockTreeData);
|
||||
} catch {
|
||||
// 出错时使用mock数据展示
|
||||
treeNodes.value = buildTreeNodes(mockTreeData);
|
||||
imgAddressPrefix.value = '';
|
||||
} finally {
|
||||
treeLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const getPreviewMode = (fileType?: string): 'image' | 'video' | 'audio' | 'iframe' => {
|
||||
if (!fileType) return 'iframe';
|
||||
const lower = fileType.toLowerCase();
|
||||
if (lower.includes('image') || lower.includes('jpg') || lower.includes('png') || lower.includes('gif')) {
|
||||
return 'image';
|
||||
}
|
||||
if (lower.includes('video') || lower.includes('mp4') || lower.includes('webm')) {
|
||||
return 'video';
|
||||
}
|
||||
if (lower.includes('audio') || lower.includes('mp3') || lower.includes('wav')) {
|
||||
return 'audio';
|
||||
}
|
||||
return 'iframe';
|
||||
};
|
||||
|
||||
const previewNode = (data: TreeNode) => {
|
||||
if (!data.fileUrl) return;
|
||||
previewUrl.value = buildAssetUrl(data.fileUrl);
|
||||
previewMode.value = getPreviewMode(data.fileType);
|
||||
previewDialogVisible.value = true;
|
||||
};
|
||||
|
||||
const downloadNode = (data: TreeNode) => {
|
||||
if (!data.fileUrl) return;
|
||||
const url = buildAssetUrl(data.fileUrl);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = data.label;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
};
|
||||
|
||||
const handleTreeNodeClick = () => {
|
||||
// 点击节点不需要额外操作
|
||||
};
|
||||
|
||||
const handleMenuChange = (menu: string) => {
|
||||
activeMenu.value = menu;
|
||||
};
|
||||
@@ -104,6 +269,10 @@ const handleDeleteHistory = (id: number) => {
|
||||
}
|
||||
ElMessage.success('已删除会话');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -116,8 +285,11 @@ const handleDeleteHistory = (id: number) => {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
background:
|
||||
radial-gradient(1200px 460px at 65% -140px, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0) 68%),
|
||||
linear-gradient(180deg, #f7faff 0%, #f4f7fc 100%);
|
||||
radial-gradient(1200px 600px at 0% 0%, rgba(59, 130, 246, 0.18) 0%, rgba(59, 130, 246, 0) 45%),
|
||||
radial-gradient(1000px 500px at 100% 0%, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0) 50%),
|
||||
radial-gradient(800px 400px at 0% 100%, rgba(236, 72, 153, 0.12) 0%, rgba(236, 72, 153, 0) 55%),
|
||||
radial-gradient(600px 300px at 100% 100%, rgba(16, 185, 129, 0.10) 0%, rgba(16, 185, 129, 0) 60%),
|
||||
linear-gradient(135deg, #f8fbff 0%, #e6f0ff 60%, #f0f4fa 100%);
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
@@ -134,141 +306,163 @@ const handleDeleteHistory = (id: number) => {
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 28%),
|
||||
radial-gradient(1000px 380px at 10% 110%, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0) 72%);
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 32%),
|
||||
radial-gradient(900px 360px at 15% 115%, rgba(99, 102, 241, 0.06) 0%, rgba(99, 102, 241, 0) 70%);
|
||||
}
|
||||
}
|
||||
|
||||
.history-float {
|
||||
position: fixed;
|
||||
right: 18px;
|
||||
top: 52%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 30;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
color: #1e3a8a;
|
||||
background: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(239, 246, 255, 0.96) 100%);
|
||||
border: 1px solid #dbeafe;
|
||||
box-shadow: 0 10px 24px rgba(30, 64, 175, 0.16);
|
||||
transition: all 0.2s ease;
|
||||
user-select: none;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-50%) translateX(-2px);
|
||||
box-shadow: 0 14px 30px rgba(30, 64, 175, 0.22);
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
em {
|
||||
height: 18px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
font-style: normal;
|
||||
font-size: 11px;
|
||||
line-height: 18px;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.history-drawer .el-drawer) {
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
|
||||
}
|
||||
|
||||
.drawer-panel {
|
||||
height: 100%;
|
||||
/* 右侧工作空间面板 - 渐变玻璃风格 */
|
||||
.workspace-panel {
|
||||
width: 260px;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(255, 255, 255, 0.85) 0%,
|
||||
rgba(249, 251, 255, 0.7) 50%,
|
||||
rgba(235, 241, 252, 0.6) 100%
|
||||
);
|
||||
border-left: 1px solid rgba(59, 130, 246, 0.15);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 16px 14px;
|
||||
height: 100%;
|
||||
box-shadow: -6px 0 35px rgba(59, 130, 246, 0.08);
|
||||
backdrop-filter: blur(16px);
|
||||
}
|
||||
|
||||
.drawer-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.drawer-title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.new-btn {
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.history-list {
|
||||
.workspace-tree-wrap {
|
||||
flex: 1;
|
||||
padding: 8px 8px 12px;
|
||||
overflow-y: auto;
|
||||
padding-right: 2px;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-tree) {
|
||||
background: transparent;
|
||||
|
||||
.el-tree-node {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
// 一级节点(日期)- 蓝色渐变
|
||||
:deep(.level-date) .el-tree-node__content {
|
||||
height: 42px;
|
||||
background: linear-gradient(135deg, rgba(59, 130, 246, 0.20) 0%, rgba(59, 130, 246, 0.05) 100%);
|
||||
border: 1px solid rgba(59, 130, 246, 0.28);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
// 二级节点(工作流)- 紫色渐变
|
||||
:deep(.level-flow) .el-tree-node__content {
|
||||
margin-left: 8px;
|
||||
background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.03) 100%);
|
||||
border: 1px solid rgba(139, 92, 246, 0.18);
|
||||
}
|
||||
|
||||
// 三级节点(文件)- 根据文件类型区分颜色
|
||||
:deep(.level-file.image) .el-tree-node__content,
|
||||
:deep(.level-file.jpg) .el-tree-node__content,
|
||||
:deep(.level-file.png) .el-tree-node__content,
|
||||
:deep(.level-file.gif) .el-tree-node__content {
|
||||
margin-left: 16px;
|
||||
background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(16, 185, 129, 0.04) 100%);
|
||||
border: 1px solid rgba(16, 185, 129, 0.15);
|
||||
}
|
||||
|
||||
:deep(.level-file.video) .el-tree-node__content,
|
||||
:deep(.level-file.mp4) .el-tree-node__content,
|
||||
:deep(.level-file.webm) .el-tree-node__content {
|
||||
margin-left: 16px;
|
||||
background: linear-gradient(135deg, rgba(245, 158, 11, 0.18) 0%, rgba(245, 158, 11, 0.04) 100%);
|
||||
border: 1px solid rgba(245, 158, 11, 0.15);
|
||||
}
|
||||
|
||||
:deep(.level-file.audio) .el-tree-node__content,
|
||||
:deep(.level-file.mp3) .el-tree-node__content,
|
||||
:deep(.level-file.wav) .el-tree-node__content {
|
||||
margin-left: 16px;
|
||||
background: linear-gradient(135deg, rgba(236, 72, 153, 0.18) 0%, rgba(236, 72, 153, 0.04) 100%);
|
||||
border: 1px solid rgba(236, 72, 153, 0.15);
|
||||
}
|
||||
|
||||
:deep(.level-file.text) .el-tree-node__content,
|
||||
:deep(.level-file.md) .el-tree-node__content,
|
||||
:deep(.level-file.txt) .el-tree-node__content,
|
||||
:deep(.level-file.markdown) .el-tree-node__content {
|
||||
margin-left: 16px;
|
||||
background: linear-gradient(135deg, rgba(79, 70, 229, 0.18) 0%, rgba(79, 70, 229, 0.04) 100%);
|
||||
border: 1px solid rgba(79, 70, 229, 0.15);
|
||||
}
|
||||
|
||||
// 默认其他文件
|
||||
:deep(.level-file:not(.image):not(.video):not(.audio):not(.text)) .el-tree-node__content {
|
||||
margin-left: 16px;
|
||||
background: linear-gradient(135deg, rgba(100, 116, 139, 0.15) 0%, rgba(100, 116, 139, 0.04) 100%);
|
||||
border: 1px solid rgba(100, 116, 139, 0.15);
|
||||
}
|
||||
|
||||
.el-tree-node__content {
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
border-radius: 8px;
|
||||
margin: 2px 0;
|
||||
backdrop-filter: blur(8px);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-width: 2px;
|
||||
transform: translateX(2px);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
}
|
||||
|
||||
.el-tree-node.is-current > .el-tree-node__content {
|
||||
border-width: 2px;
|
||||
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.el-tree-node__expand-icon {
|
||||
color: rgba(59, 130, 246, 0.7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.history-item {
|
||||
.tree-node {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 10px 10px;
|
||||
margin-bottom: 8px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e6eef9;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
width: 100%;
|
||||
gap: 6px;
|
||||
|
||||
&:hover {
|
||||
border-color: #cfe0fb;
|
||||
background: #f5f9ff;
|
||||
.ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: #bcd5fa;
|
||||
background: linear-gradient(135deg, rgba(219, 234, 254, 0.8) 0%, rgba(239, 246, 255, 0.9) 100%);
|
||||
.tree-node-actions {
|
||||
flex-shrink: 0;
|
||||
.el-button {
|
||||
font-size: 11px;
|
||||
padding: 2px 4px;
|
||||
margin: 0;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.history-main {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
.preview-container {
|
||||
max-height: 85vh;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.history-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #334155;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.history-meta {
|
||||
font-size: 11px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
opacity: 0;
|
||||
color: #94a3b8;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.history-item:hover .delete-btn {
|
||||
opacity: 1;
|
||||
.preview-iframe {
|
||||
width: 100%;
|
||||
min-height: 60vh;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,62 +1,61 @@
|
||||
<template>
|
||||
<el-dialog :title="isEdit ? '编辑数据集' : '新增数据集'" v-model="isShowDialog" width="600px" :close-on-click-modal="false" @close="onCancel">
|
||||
<el-form ref="formRef" :model="ruleForm" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="数据集名称" prop="name">
|
||||
<el-input v-model="ruleForm.name" placeholder="请输入数据集名称" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="数据集类型" prop="type">
|
||||
<el-select v-model="ruleForm.type" placeholder="请选择类型" clearable style="width: 100%">
|
||||
<el-option label="文本" value="text" />
|
||||
<el-option label="问答" value="qa" />
|
||||
<el-option label="表格" value="table" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="向量模型" prop="embeddingModel">
|
||||
<el-select v-model="ruleForm.embeddingModel" placeholder="请选择向量模型" clearable style="width: 100%">
|
||||
<el-option label="text-embedding-ada-002" value="text-embedding-ada-002" />
|
||||
<el-option label="text-embedding-3-small" value="text-embedding-3-small" />
|
||||
<el-option label="text-embedding-3-large" value="text-embedding-3-large" />
|
||||
<el-option label="bge-large-zh" value="bge-large-zh" />
|
||||
<el-option label="m3e-base" value="m3e-base" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model="ruleForm.description" type="textarea" :rows="4" placeholder="请输入数据集描述" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20" v-if="isEdit">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="文档数量">
|
||||
<el-input :value="ruleForm.documentCount" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="字符数量">
|
||||
<el-input :value="ruleForm.charCount" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :loading="submitLoading">{{ isEdit ? '保 存' : '创 建' }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog :title="isEdit ? '编辑数据集' : '新增数据集'" v-model="isShowDialog" width="600px" :close-on-click-modal="false" @close="onCancel">
|
||||
<el-form ref="formRef" :model="ruleForm" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="数据集名称" prop="name">
|
||||
<el-input v-model="ruleForm.name" placeholder="请输入数据集名称" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="数据集类型" prop="datasetType">
|
||||
<el-select v-model="ruleForm.datasetType" placeholder="请选择类型" clearable style="width: 100%">
|
||||
<el-option label="文本" :value="1" />
|
||||
<el-option label="视频" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="向量模型" prop="embeddingModel">
|
||||
<el-select v-model="ruleForm.embeddingModel" placeholder="请选择向量模型" clearable style="width: 100%">
|
||||
<el-option label="text-embedding-ada-002" value="text-embedding-ada-002" />
|
||||
<el-option label="text-embedding-3-small" value="text-embedding-3-small" />
|
||||
<el-option label="text-embedding-3-large" value="text-embedding-3-large" />
|
||||
<el-option label="bge-large-zh" value="bge-large-zh" />
|
||||
<el-option label="m3e-base" value="m3e-base" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model="ruleForm.description" type="textarea" :rows="4" placeholder="请输入数据集描述" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20" v-if="isEdit">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="文档数量">
|
||||
<el-input :value="ruleForm.documentCount" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="字符数量">
|
||||
<el-input :value="ruleForm.charCount" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :loading="submitLoading">{{ isEdit ? '保 存' : '创 建' }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -86,7 +85,7 @@ const submitLoading = ref(false);
|
||||
const ruleForm = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
type: 'text',
|
||||
datasetType: 1 as number,
|
||||
description: '',
|
||||
embeddingModel: 'text-embedding-ada-002',
|
||||
documentCount: 0,
|
||||
@@ -96,7 +95,7 @@ const ruleForm = reactive({
|
||||
// 表单验证规则
|
||||
const rules = reactive<FormRules>({
|
||||
name: [{ required: true, message: '请输入数据集名称', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '请选择数据集类型', trigger: 'change' }],
|
||||
datasetType: [{ required: true, message: '请选择数据集类型', trigger: 'change' }],
|
||||
embeddingModel: [{ required: true, message: '请选择向量模型', trigger: 'change' }],
|
||||
});
|
||||
|
||||
@@ -104,7 +103,7 @@ const rules = reactive<FormRules>({
|
||||
const resetForm = () => {
|
||||
ruleForm.id = '';
|
||||
ruleForm.name = '';
|
||||
ruleForm.type = 'text';
|
||||
ruleForm.datasetType = 1;
|
||||
ruleForm.description = '';
|
||||
ruleForm.embeddingModel = 'text-embedding-ada-002';
|
||||
ruleForm.documentCount = 0;
|
||||
@@ -122,7 +121,7 @@ const openDialog = async (row?: any) => {
|
||||
const data = res.data || row;
|
||||
ruleForm.id = data.id || '';
|
||||
ruleForm.name = data.name || '';
|
||||
ruleForm.type = data.type || 'text';
|
||||
ruleForm.datasetType = data.datasetType || 1;
|
||||
ruleForm.description = data.description || '';
|
||||
ruleForm.embeddingModel = data.embeddingModel || 'text-embedding-ada-002';
|
||||
ruleForm.documentCount = data.documentCount || 0;
|
||||
@@ -132,7 +131,7 @@ const openDialog = async (row?: any) => {
|
||||
// 使用传入的row数据
|
||||
ruleForm.id = row.id || '';
|
||||
ruleForm.name = row.name || '';
|
||||
ruleForm.type = row.type || 'text';
|
||||
ruleForm.datasetType = row.datasetType || 1;
|
||||
ruleForm.description = row.description || '';
|
||||
ruleForm.embeddingModel = row.embeddingModel || 'text-embedding-ada-002';
|
||||
ruleForm.documentCount = row.documentCount || 0;
|
||||
@@ -161,7 +160,7 @@ const onSubmit = async () => {
|
||||
const data = {
|
||||
id: ruleForm.id || undefined,
|
||||
name: ruleForm.name,
|
||||
type: ruleForm.type,
|
||||
datasetType: ruleForm.datasetType,
|
||||
description: ruleForm.description,
|
||||
embeddingModel: ruleForm.embeddingModel,
|
||||
status: 'enable',
|
||||
|
||||
@@ -1,107 +1,106 @@
|
||||
<template>
|
||||
<div class="knowledge-knowledge-page">
|
||||
<div class="knowledge-knowledge-container">
|
||||
<el-card shadow="hover">
|
||||
<div class="knowledge-knowledge-search mb15">
|
||||
<el-form :inline="true">
|
||||
<el-form-item label="数据集名称">
|
||||
<el-input size="default" v-model="tableData.param.keyword" placeholder="请输入数据集名称" clearable style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数据集类型">
|
||||
<el-select size="default" v-model="tableData.param.type" placeholder="请选择类型" clearable style="width: 150px">
|
||||
<el-option label="文本" value="text" />
|
||||
<el-option label="问答" value="qa" />
|
||||
<el-option label="表格" value="table" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
||||
<el-option label="启用" value="enable" />
|
||||
<el-option label="禁用" value="disable" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button size="default" type="primary" @click="getknowledgeList">
|
||||
<el-icon><ele-Search /></el-icon>
|
||||
查询
|
||||
</el-button>
|
||||
<el-button size="default" @click="onResetQuery">
|
||||
<el-icon><ele-Refresh /></el-icon>
|
||||
重置
|
||||
</el-button>
|
||||
<el-button size="default" type="success" @click="onOpenAdd" v-auth="'api/v1/knowledge/knowledge/create'">
|
||||
<el-icon><ele-Plus /></el-icon>
|
||||
新增
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading" border>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="name" label="数据集名称" min-width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-link type="primary" @click="onViewDetail(scope.row)">{{ scope.row.name }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="类型" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getTypeTagType(scope.row.type)">{{ getTypeText(scope.row.type) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="documentCount" label="文档数" width="100" align="center" />
|
||||
<el-table-column prop="charCount" label="字符数" width="120" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatCharCount(scope.row.charCount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="embeddingModel" label="向量模型" width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="状态" width="80" align="center">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.statusEnabled"
|
||||
inline-prompt
|
||||
active-text="启"
|
||||
inactive-text="停"
|
||||
@change="onStatusChange(scope.row)"
|
||||
v-auth="'api/v1/knowledge/knowledge/updateStatus'"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdAt" label="创建时间" width="170" show-overflow-tooltip />
|
||||
<el-table-column prop="updatedAt" label="更新时间" width="170" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="200" fixed="right" align="center">
|
||||
<template #default="scope">
|
||||
<el-button size="small" text type="primary" @click="onEdit(scope.row)" v-auth="'api/v1/knowledge/knowledge/update'">编辑</el-button>
|
||||
<el-button size="small" text type="success" @click="onManageDocuments(scope.row)">文档</el-button>
|
||||
<el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-auth="'api/v1/knowledge/knowledge/delete'">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<div class="mt15" style="text-align: right">
|
||||
<el-pagination
|
||||
v-model:current-page="tableData.param.pageNum"
|
||||
v-model:page-size="tableData.param.pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="tableData.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="onSizeChange"
|
||||
@current-change="onCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
<div class="knowledge-knowledge-page">
|
||||
<div class="knowledge-knowledge-container">
|
||||
<el-card shadow="hover">
|
||||
<div class="knowledge-knowledge-search mb15">
|
||||
<el-form :inline="true">
|
||||
<el-form-item label="数据集名称">
|
||||
<el-input size="default" v-model="tableData.param.keyword" placeholder="请输入数据集名称" clearable style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数据集类型">
|
||||
<el-select size="default" v-model="tableData.param.datasetType" placeholder="请选择类型" clearable style="width: 150px">
|
||||
<el-option label="文本" :value="1" />
|
||||
<el-option label="视频" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
||||
<el-option label="启用" value="enable" />
|
||||
<el-option label="禁用" value="disable" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button size="default" type="primary" @click="getknowledgeList">
|
||||
<el-icon><ele-Search /></el-icon>
|
||||
查询
|
||||
</el-button>
|
||||
<el-button size="default" @click="onResetQuery">
|
||||
<el-icon><ele-Refresh /></el-icon>
|
||||
重置
|
||||
</el-button>
|
||||
<el-button size="default" type="success" @click="onOpenAdd" v-auth="'api/v1/knowledge/knowledge/create'">
|
||||
<el-icon><ele-Plus /></el-icon>
|
||||
新增
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading" border>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="name" label="数据集名称" min-width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-link type="primary" @click="onViewDetail(scope.row)">{{ scope.row.name }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="datasetType" label="类型" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getTypeTagType(scope.row.datasetType)">{{ getTypeText(scope.row.datasetType) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="documentCount" label="文档数" width="100" align="center" />
|
||||
<el-table-column prop="charCount" label="字符数" width="120" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatCharCount(scope.row.charCount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="embeddingModel" label="向量模型" width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="状态" width="80" align="center">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.statusEnabled"
|
||||
inline-prompt
|
||||
active-text="启"
|
||||
inactive-text="停"
|
||||
@change="onStatusChange(scope.row)"
|
||||
v-auth="'api/v1/knowledge/knowledge/updateStatus'"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdAt" label="创建时间" width="170" show-overflow-tooltip />
|
||||
<el-table-column prop="updatedAt" label="更新时间" width="170" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="200" fixed="right" align="center">
|
||||
<template #default="scope">
|
||||
<el-button size="small" text type="primary" @click="onEdit(scope.row)" v-auth="'api/v1/knowledge/knowledge/update'">编辑</el-button>
|
||||
<el-button size="small" text type="success" @click="onManageDocuments(scope.row)">文档</el-button>
|
||||
<el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-auth="'api/v1/knowledge/knowledge/delete'">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<div class="mt15" style="text-align: right">
|
||||
<el-pagination
|
||||
v-model:current-page="tableData.param.pageNum"
|
||||
v-model:page-size="tableData.param.pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="tableData.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="onSizeChange"
|
||||
@current-change="onCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
<Editknowledge ref="editknowledgeRef" @getknowledgeList="getknowledgeList" />
|
||||
</div>
|
||||
<Editknowledge ref="editknowledgeRef" @getknowledgeList="getknowledgeList" />
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'knowledgeknowledge',
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
@@ -117,7 +116,7 @@ const tableData = reactive({
|
||||
loading: false,
|
||||
param: {
|
||||
keyword: '',
|
||||
type: '',
|
||||
datasetType: undefined as number | undefined,
|
||||
status: undefined as string | undefined,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
@@ -148,30 +147,26 @@ const getknowledgeList = async () => {
|
||||
};
|
||||
|
||||
// 获取类型标签类型
|
||||
const getTypeTagType = (type: string) => {
|
||||
switch (type) {
|
||||
case 'text':
|
||||
const getTypeTagType = (datasetType: number) => {
|
||||
switch (datasetType) {
|
||||
case 1:
|
||||
return 'primary';
|
||||
case 'qa':
|
||||
case 2:
|
||||
return 'success';
|
||||
case 'table':
|
||||
return 'warning';
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
};
|
||||
|
||||
// 获取类型文本
|
||||
const getTypeText = (type: string) => {
|
||||
switch (type) {
|
||||
case 'text':
|
||||
const getTypeText = (datasetType: number) => {
|
||||
switch (datasetType) {
|
||||
case 1:
|
||||
return '文本';
|
||||
case 'qa':
|
||||
return '问答';
|
||||
case 'table':
|
||||
return '表格';
|
||||
case 2:
|
||||
return '视频';
|
||||
default:
|
||||
return type;
|
||||
return String(datasetType);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -187,7 +182,7 @@ const formatCharCount = (count: number) => {
|
||||
// 重置查询
|
||||
const onResetQuery = () => {
|
||||
tableData.param.keyword = '';
|
||||
tableData.param.type = '';
|
||||
tableData.param.datasetType = undefined;
|
||||
tableData.param.status = undefined;
|
||||
tableData.param.pageNum = 1;
|
||||
getknowledgeList();
|
||||
@@ -261,9 +256,9 @@ const onCurrentChange = (page: number) => {
|
||||
onMounted(() => {
|
||||
getknowledgeList();
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
<style scoped lang="scss">
|
||||
.knowledge-knowledge-page {
|
||||
padding: 15px;
|
||||
.knowledge-knowledge-container {
|
||||
@@ -274,4 +269,4 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
<template #default="{ row }">
|
||||
<el-button text size="small" v-debounce @click="onPreviewFile(row)">预览</el-button>
|
||||
<el-button v-if="row.vectorStatus === 1" text size="small" type="primary" v-debounce @click="onGenerateVector(row)"
|
||||
>生成向量</el-button
|
||||
>生成向量</el-button
|
||||
>
|
||||
<el-button v-else text size="small" type="primary" v-debounce @click="onViewTaskList(row)">查看任务</el-button>
|
||||
<el-button text size="small" type="danger" v-debounce @click="onDeleteFile(row)">删除</el-button>
|
||||
@@ -233,6 +233,12 @@
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="knowledgeForm.name" placeholder="请输入知识库名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数据集类型" prop="datasetType">
|
||||
<el-select v-model="knowledgeForm.datasetType" placeholder="请选择类型" clearable style="width: 100%">
|
||||
<el-option label="文本" :value="1" />
|
||||
<el-option label="视频" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model="knowledgeForm.description" type="textarea" :rows="3" placeholder="请输入描述" />
|
||||
</el-form-item>
|
||||
@@ -469,10 +475,12 @@ const knowledgeFormRef = ref<FormInstance>();
|
||||
const knowledgeForm = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
datasetType: undefined as number | undefined,
|
||||
description: '',
|
||||
});
|
||||
const knowledgeRules = reactive<FormRules>({
|
||||
name: [{ required: true, message: '请输入知识库名称', trigger: 'blur' }],
|
||||
datasetType: [{ required: true, message: '请选择数据集类型', trigger: 'change' }],
|
||||
});
|
||||
|
||||
// 文件列表(含OSS上传结果)
|
||||
@@ -555,6 +563,7 @@ const getknowledgeList = async () => {
|
||||
const response = await listknowledges({
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
datasetType: 1,
|
||||
});
|
||||
knowledgeList.value = response.data.list || [];
|
||||
} catch (_error) {
|
||||
@@ -576,6 +585,7 @@ const onSelectknowledge = (item: any) => {
|
||||
const onAddknowledge = () => {
|
||||
knowledgeForm.id = '';
|
||||
knowledgeForm.name = '';
|
||||
knowledgeForm.datasetType = undefined;
|
||||
knowledgeForm.description = '';
|
||||
showknowledgeDialog.value = true;
|
||||
};
|
||||
@@ -594,6 +604,7 @@ const onCardContextMenu = (event: MouseEvent, item: any) => {
|
||||
const onRenameknowledge = (item: any) => {
|
||||
knowledgeForm.id = item.id;
|
||||
knowledgeForm.name = item.name;
|
||||
knowledgeForm.datasetType = item.datasetType;
|
||||
knowledgeForm.description = item.description || '';
|
||||
showknowledgeDialog.value = true;
|
||||
};
|
||||
@@ -634,14 +645,17 @@ const onSaveknowledge = async () => {
|
||||
await updateknowledge({
|
||||
id: knowledgeForm.id,
|
||||
name: knowledgeForm.name,
|
||||
datasetType: knowledgeForm.datasetType,
|
||||
description: knowledgeForm.description,
|
||||
});
|
||||
} else {
|
||||
// 创建知识库
|
||||
await createknowledge({
|
||||
const params = {
|
||||
name: knowledgeForm.name,
|
||||
datasetType: knowledgeForm.datasetType as number,
|
||||
description: knowledgeForm.description,
|
||||
});
|
||||
};
|
||||
await createknowledge(params);
|
||||
}
|
||||
|
||||
ElMessage.success(knowledgeForm.id ? '保存成功' : '创建成功');
|
||||
@@ -988,7 +1002,7 @@ const onSaveModelConfig = async () => {
|
||||
// 构建请求数据,只传递接口需要的字段
|
||||
const data = {
|
||||
modelType: selectedModelType.value,
|
||||
configType: selectedConfigType.value,
|
||||
configType: selectedConfigType,
|
||||
modelName: modelFormData.value.modelName,
|
||||
modelDesc: modelFormData.value.modelDesc,
|
||||
configContent: {} as Record<string, any>,
|
||||
|
||||
@@ -1093,6 +1093,12 @@ const availableParentParams = computed(() => {
|
||||
// 如果是判断节点,跳过不添加其字段
|
||||
if (isJudge) return;
|
||||
|
||||
// 首先添加节点的整体输出选项
|
||||
params.push({
|
||||
label: `${parentNodeName}【整体输出】`,
|
||||
value: `\${${parentId}}`,
|
||||
});
|
||||
|
||||
// 只添加可引用字段(HTTP节点仅允许结果返回结构;其他节点维持原逻辑)
|
||||
if (parentProps.formConfig && Array.isArray(parentProps.formConfig)) {
|
||||
if (nodeCode === 'http') {
|
||||
@@ -1184,15 +1190,24 @@ const workflowDsl = computed(() => ({
|
||||
const rawValue = item.value;
|
||||
let normalizedValue: any = rawValue;
|
||||
if (typeof rawValue === 'string') {
|
||||
const matched = rawValue.match(/^\$\{([^\.}]+)\.([^}]+)\}$/);
|
||||
if (matched) {
|
||||
normalizedValue = {
|
||||
field: matched[2],
|
||||
nodeId: matched[1],
|
||||
quoteOutput: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
const matched = rawValue.match(/^\$\{([^\.}]+)\.([^}]+)\}$/);
|
||||
if (matched) {
|
||||
normalizedValue = {
|
||||
field: matched[2],
|
||||
nodeId: matched[1],
|
||||
quoteOutput: false,
|
||||
};
|
||||
} else {
|
||||
const nodeOutputMatched = rawValue.match(/^\$\{([^}]+)\}$/);
|
||||
if (nodeOutputMatched) {
|
||||
normalizedValue = {
|
||||
field: 'nodeOutputResult',
|
||||
nodeId: nodeOutputMatched[1],
|
||||
quoteOutput: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const normalizedItem: any = {
|
||||
key: realKey,
|
||||
@@ -2550,6 +2565,14 @@ const getHttpBodyData = (field: string) => {
|
||||
rawItem.fieldConstraint = rawItem.fieldConstraint && typeof rawItem.fieldConstraint === 'object' ? rawItem.fieldConstraint : {};
|
||||
} else {
|
||||
rawItem.showInForm = false;
|
||||
// 回显上级节点引用:对象结构转回选择器可识别的字符串
|
||||
if (rawItem.value && typeof rawItem.value === 'object' && !Array.isArray(rawItem.value)) {
|
||||
const refNodeId = String(rawItem.value.nodeId || '').trim();
|
||||
const refField = String(rawItem.value.field || '').trim();
|
||||
if (refNodeId) {
|
||||
rawItem.value = refField === 'nodeOutputResult' ? `\${${refNodeId}}` : refField ? `\${${refNodeId}.${refField}}` : rawItem.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
@@ -2736,7 +2759,7 @@ const confirmHttpBodyConfig = () => {
|
||||
const rawValue = item?.value;
|
||||
let normalizedValue: any = rawValue;
|
||||
|
||||
// 如果 value 选择了上级参数(形如 ${nodeId.field}),转成对象结构传给后端
|
||||
// 如果 value 选择了上级参数(形如 ${nodeId.field})或上级节点整体输出(形如 ${nodeId}),转成对象结构传给后端
|
||||
if (typeof rawValue === 'string') {
|
||||
const matched = rawValue.match(/^\$\{([^\.}]+)\.([^}]+)\}$/);
|
||||
if (matched) {
|
||||
@@ -2745,6 +2768,15 @@ const confirmHttpBodyConfig = () => {
|
||||
nodeId: matched[1],
|
||||
quoteOutput: false,
|
||||
};
|
||||
} else {
|
||||
const nodeOutputMatched = rawValue.match(/^\$\{([^}]+)\}$/);
|
||||
if (nodeOutputMatched) {
|
||||
normalizedValue = {
|
||||
field: 'nodeOutputResult',
|
||||
nodeId: nodeOutputMatched[1],
|
||||
quoteOutput: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3856,15 +3888,11 @@ const deleteSelectedElement = async () => {
|
||||
if (affectedNodeNames.length > 0) {
|
||||
const previewNames = affectedNodeNames.slice(0, 8);
|
||||
const overflowText = affectedNodeNames.length > 8 ? `\n...等 ${affectedNodeNames.length} 个节点` : '';
|
||||
await ElMessageBox.confirm(
|
||||
`删除该节点将清理以下下级节点中的引用:\n${previewNames.join('、')}${overflowText}`,
|
||||
'删除确认',
|
||||
{
|
||||
confirmButtonText: '继续删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
);
|
||||
await ElMessageBox.confirm(`删除该节点将清理以下下级节点中的引用:\n${previewNames.join('、')}${overflowText}`, '删除确认', {
|
||||
confirmButtonText: '继续删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
affectedCount = cleanupReferencesToNode(cur.id);
|
||||
@@ -3878,7 +3906,7 @@ const deleteSelectedElement = async () => {
|
||||
if (error === 'cancel') return;
|
||||
ElMessage.error('删除失败');
|
||||
}
|
||||
};// 从后端 DSL 恢复工作流
|
||||
}; // 从后端 DSL 恢复工作流
|
||||
const loadWorkflowFromDsl = (dsl: any) => {
|
||||
const lf = logicFlowInstance.value;
|
||||
if (!lf || !dsl) return;
|
||||
@@ -5627,6 +5655,3 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="system-edit-module-container">
|
||||
<el-dialog :title="state.dialog.title" v-model="state.dialog.isShowDialog" width="900px">
|
||||
<el-form
|
||||
@@ -213,13 +213,126 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 自定义字段配置弹窗 -->
|
||||
<el-dialog v-model="showFormDialog" title="配置表单字段" width="600px" :close-on-click-modal="false">
|
||||
<el-dialog v-model="showFormDialog" title="配置表单字段" width="900px" :close-on-click-modal="false">
|
||||
<div class="form-config-container">
|
||||
<div v-for="(field, index) in state.formFields" :key="index" class="form-field-item">
|
||||
<el-input v-model="field.key" placeholder="请输入字段名 (Key)" style="width: 40%" clearable></el-input>
|
||||
<span class="separator">=</span>
|
||||
<el-input v-model="field.value" placeholder="请输入字段值 (Value)" style="width: 40%" clearable></el-input>
|
||||
<el-button type="danger" link @click="removeFormField(index)">删除</el-button>
|
||||
<!-- 删除按钮 - 右上角 -->
|
||||
<el-button type="danger" link size="small" @click="removeFormField(index)" class="delete-btn">删除</el-button>
|
||||
|
||||
<!-- 第一行 -->
|
||||
<div class="field-row">
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label required">字段描述</label>
|
||||
<el-input v-model="field.label" placeholder="字段显示名称" clearable style="width: 100%"></el-input>
|
||||
</div>
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label required">字段名称</label>
|
||||
<el-input v-model="field.key" placeholder="字段Key,如 user_name" clearable style="width: 100%"></el-input>
|
||||
</div>
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label required">字段类型</label>
|
||||
<el-select v-model="field.type" placeholder="选择字段类型" clearable style="width: 100%" @change="onFieldTypeChange(index)">
|
||||
<el-option label="字符串" value="string"></el-option>
|
||||
<el-option label="数字" value="number"></el-option>
|
||||
<el-option label="下拉菜单" value="select"></el-option>
|
||||
<el-option label="单选按钮" value="radio"></el-option>
|
||||
<el-option label="附件上传" value="file"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label">默认值</label>
|
||||
<el-input v-model="field.defaultValue" placeholder="默认值" clearable style="width: 100%"></el-input>
|
||||
</div>
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label">是否必填</label>
|
||||
<div class="switch-wrapper">
|
||||
<el-switch v-model="field.required"></el-switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 第二行:类型特定配置 -->
|
||||
<div class="field-row">
|
||||
<!-- 字符串额外配置 -->
|
||||
<template v-if="field.type === 'string'">
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label">最大长度</label>
|
||||
<el-input-number v-model="field.maxLength" :min="0" :max="10000" placeholder="最大长度" style="width: 100%"></el-input-number>
|
||||
</div>
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
</template>
|
||||
|
||||
<!-- 数字额外配置 -->
|
||||
<template v-if="field.type === 'number'">
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label">数字类型</label>
|
||||
<el-select v-model="field.numberType" placeholder="选择数字类型" clearable style="width: 100%">
|
||||
<el-option label="任意数字" value="any"></el-option>
|
||||
<el-option label="整数" value="integer"></el-option>
|
||||
<el-option label="浮点数(小数)" value="float"></el-option>
|
||||
<el-option label="正整数" value="positive-int"></el-option>
|
||||
<el-option label="正浮点数" value="positive-float"></el-option>
|
||||
<el-option label="负整数" value="negative-int"></el-option>
|
||||
<el-option label="负浮点数" value="negative-float"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label">最小值</label>
|
||||
<el-input-number v-model="field.min" placeholder="最小值" style="width: 100%"></el-input-number>
|
||||
</div>
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label">最大值</label>
|
||||
<el-input-number v-model="field.max" placeholder="最大值" style="width: 100%"></el-input-number>
|
||||
</div>
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
</template>
|
||||
|
||||
<!-- 附件上传额外配置 -->
|
||||
<template v-if="field.type === 'file'">
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label">最大文件(MB)</label>
|
||||
<el-input-number v-model="field.maxSize" :min="1" :max="1000" style="width: 100%"></el-input-number>
|
||||
</div>
|
||||
<div class="field-col field-col-sm">
|
||||
<label class="field-label">最大上传数量</label>
|
||||
<el-input-number v-model="field.maxCount" :min="1" :max="100" :default-value="1" style="width: 100%"></el-input-number>
|
||||
</div>
|
||||
<div class="field-col field-col-md">
|
||||
<label class="field-label">允许格式</label>
|
||||
<el-input v-model="field.allowedTypes" placeholder=".jpg,.png,.pdf" clearable style="width: 100%"></el-input>
|
||||
</div>
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
</template>
|
||||
|
||||
<!-- 下拉框和单选不需要第二行额外配置 -->
|
||||
<template v-if="field.type === 'select' || field.type === 'radio'">
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
<div class="field-col"></div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 下拉菜单/单选框 选项配置 -->
|
||||
<div v-if="field.type === 'select' || field.type === 'radio'" class="options-row">
|
||||
<div class="options-label">选项配置</div>
|
||||
<div v-for="(opt, optIndex) in field.options" :key="optIndex" class="option-item">
|
||||
<div class="option-col">
|
||||
<el-input v-model="opt.label" placeholder="显示文本" style="width: 100%" clearable></el-input>
|
||||
</div>
|
||||
<span class="separator">:</span>
|
||||
<div class="option-col">
|
||||
<el-input v-model="opt.value" placeholder="值" style="width: 100%" clearable></el-input>
|
||||
</div>
|
||||
<el-button type="danger" link size="small" @click="removeFieldOption(field, optIndex)">删除</el-button>
|
||||
</div>
|
||||
<el-button type="primary" link size="small" @click="addFieldOption(field)">+ 添加选项</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-button type="primary" link @click="addFormField" style="margin-top: 10px">+ 添加字段</el-button>
|
||||
</div>
|
||||
@@ -426,6 +539,33 @@ import {
|
||||
|
||||
export type ModelTypeOption = { id: number | string; label: string };
|
||||
|
||||
// 定义自定义字段选项类型
|
||||
export interface FormFieldOption {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
// 定义自定义字段类型
|
||||
export interface FormField {
|
||||
label: string; // 字段描述
|
||||
key: string; // 字段名称
|
||||
type: 'string' | 'number' | 'select' | 'radio' | 'file'; // 字段类型
|
||||
defaultValue: string; // 默认值
|
||||
required: boolean; // 是否必填
|
||||
// 字符串配置
|
||||
maxLength?: number; // 最大长度
|
||||
// 数字配置
|
||||
min?: number; // 最小值
|
||||
max?: number; // 最大值
|
||||
numberType?: 'any' | 'integer' | 'float' | 'positive-int' | 'positive-float' | 'negative-int' | 'negative-float'; // 数字子类型
|
||||
// 文件上传配置
|
||||
maxSize?: number; // 最大文件大小(MB)
|
||||
maxCount?: number; // 最大上传数量
|
||||
allowedTypes?: string; // 允许的文件格式,逗号分隔
|
||||
// 下拉框/单选框配置
|
||||
options?: FormFieldOption[]; // 选项列表
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelTypes?: ModelTypeOption[];
|
||||
@@ -492,6 +632,7 @@ const queryResponseTypeOptions = [
|
||||
{ label: '等候回调', value: 'callback' },
|
||||
{ label: '主动拉取', value: 'pull' },
|
||||
];
|
||||
|
||||
const state = reactive({
|
||||
ruleForm: {
|
||||
id: '',
|
||||
@@ -680,7 +821,7 @@ const state = reactive({
|
||||
},
|
||||
showAdvanced: false,
|
||||
headers: [] as Array<{ key: string; value: string }>,
|
||||
formFields: [] as Array<{ key: string; value: string }>,
|
||||
formFields: [] as Array<FormField>,
|
||||
requestMappingFields: [] as Array<{ key: string; value: string }>,
|
||||
responseMappingFields: [] as Array<{ key: string; value: string; isMainBody?: boolean; isTokenField?: boolean }>,
|
||||
extendMappingFields: [] as Array<{ key: string; value: string }>,
|
||||
@@ -688,6 +829,25 @@ const state = reactive({
|
||||
mainBodyIndex: -1, // 记录哪一行被设置为返回主体
|
||||
});
|
||||
|
||||
// 创建空字段
|
||||
const createEmptyFormField = (): FormField => {
|
||||
return {
|
||||
label: '',
|
||||
key: '',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
required: false,
|
||||
maxLength: undefined,
|
||||
min: undefined,
|
||||
max: undefined,
|
||||
numberType: 'any',
|
||||
maxSize: 10,
|
||||
maxCount: 1,
|
||||
allowedTypes: '',
|
||||
options: [{ label: '', value: '' }],
|
||||
};
|
||||
};
|
||||
|
||||
// 将数组转换为对象
|
||||
const fieldsToObject = (fields: Array<{ key: string; value: string }>) => {
|
||||
const obj: Record<string, string> = {};
|
||||
@@ -703,7 +863,7 @@ const parseHeaders = (headMsg: string) => parseKeyValueString(headMsg);
|
||||
// 统一的字段解析函数:支持数组、对象、JSON字符串
|
||||
const parseFieldsUnified = (raw: unknown): Array<{ key: string; value: string }> => {
|
||||
if (!raw) return [];
|
||||
|
||||
|
||||
// 如果是字符串,尝试解析为JSON
|
||||
if (typeof raw === 'string') {
|
||||
try {
|
||||
@@ -713,7 +873,7 @@ const parseFieldsUnified = (raw: unknown): Array<{ key: string; value: string }>
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 如果是数组格式 [{ key, value }]
|
||||
if (Array.isArray(raw)) {
|
||||
return (raw as ModelFormEntry[])
|
||||
@@ -723,18 +883,22 @@ const parseFieldsUnified = (raw: unknown): Array<{ key: string; value: string }>
|
||||
value: String(item.value ?? '').trim(),
|
||||
}));
|
||||
}
|
||||
|
||||
// 如果是对象格式 { key: value }
|
||||
|
||||
// 如果是对象格式 { key: value } 或者 { key: { value: value } }
|
||||
if (typeof raw === 'object') {
|
||||
const fields: Array<{ key: string; value: string }> = [];
|
||||
Object.keys(raw as Record<string, unknown>).forEach((key) => {
|
||||
const v = (raw as Record<string, unknown>)[key];
|
||||
let v = (raw as Record<string, unknown>)[key];
|
||||
// 处理 { key: { value: value } } 格式(后端可能返回这种结构)
|
||||
if (v && typeof v === 'object' && !Array.isArray(v) && 'value' in v) {
|
||||
v = (v as { value: unknown }).value;
|
||||
}
|
||||
const value = String(v ?? '');
|
||||
fields.push({ key, value });
|
||||
});
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
||||
return [];
|
||||
};
|
||||
// 解析 requestMapping 对象为数组
|
||||
@@ -878,7 +1042,7 @@ const confirmHeaders = () => {
|
||||
};
|
||||
// 添加表单字段
|
||||
const addFormField = () => {
|
||||
state.formFields.push({ key: '', value: '' });
|
||||
state.formFields.push(createEmptyFormField());
|
||||
};
|
||||
|
||||
// 删除表单字段
|
||||
@@ -886,6 +1050,29 @@ const removeFormField = (index: number) => {
|
||||
state.formFields.splice(index, 1);
|
||||
};
|
||||
|
||||
// 字段类型变化时初始化默认配置
|
||||
const onFieldTypeChange = (index: number) => {
|
||||
const field = state.formFields[index];
|
||||
if ((field.type === 'select' || field.type === 'radio') && !field.options) {
|
||||
field.options = [{ label: '', value: '' }];
|
||||
}
|
||||
};
|
||||
|
||||
// 添加选项
|
||||
const addFieldOption = (field: FormField) => {
|
||||
if (!field.options) {
|
||||
field.options = [];
|
||||
}
|
||||
field.options.push({ label: '', value: '' });
|
||||
};
|
||||
|
||||
// 删除选项
|
||||
const removeFieldOption = (field: FormField, optIndex: number) => {
|
||||
if (field.options) {
|
||||
field.options.splice(optIndex, 1);
|
||||
}
|
||||
};
|
||||
|
||||
// 确认表单字段配置
|
||||
const confirmFormFields = () => {
|
||||
showFormDialog.value = false;
|
||||
@@ -955,12 +1142,36 @@ const setPullMainBody = (index: number) => {
|
||||
|
||||
const ensureKeyValueRows = (rows: Array<{ key: string; value: string }>) => (rows.length ? rows : [{ key: '', value: '' }]);
|
||||
|
||||
const ensureResponseMappingRows = (rows: Array<{ key: string; value: string; isMainBody?: boolean; isTokenField?: boolean }>) => {
|
||||
if (!rows.length) return [{ key: '', value: '', isMainBody: false, isTokenField: false }];
|
||||
return rows.map((row) => ({ ...row, isMainBody: row.isMainBody || false, isTokenField: row.isTokenField || false }));
|
||||
// 解析旧格式的form数据兼容到新格式
|
||||
const parseFormFieldsUnified = (raw: unknown): Array<FormField> => {
|
||||
if (!raw) return [createEmptyFormField()];
|
||||
|
||||
// 如果已经是新格式数组(每个元素有 type 字段),直接返回
|
||||
if (Array.isArray(raw)) {
|
||||
if (raw.length === 0) return [createEmptyFormField()];
|
||||
// 确保新增字段有默认值
|
||||
return (raw as any[]).map(item => {
|
||||
const field = createEmptyFormField();
|
||||
return { ...field, ...item };
|
||||
}) as FormField[];
|
||||
}
|
||||
|
||||
// 旧格式对象 { key: value } -> 转换为新格式数组
|
||||
if (typeof raw === 'object') {
|
||||
const fields: FormField[] = [];
|
||||
Object.entries(raw as Record<string, unknown>).forEach(([key, value]) => {
|
||||
const field = createEmptyFormField();
|
||||
field.key = key;
|
||||
field.label = key;
|
||||
field.defaultValue = String(value ?? '').trim();
|
||||
fields.push(field);
|
||||
});
|
||||
return fields.length ? fields : [createEmptyFormField()];
|
||||
}
|
||||
|
||||
return [createEmptyFormField()];
|
||||
};
|
||||
|
||||
/** 从 getModel 返回的 data 中取出单条模型对象 */
|
||||
const unwrapModelDetailPayload = (data: unknown): Record<string, unknown> | null => {
|
||||
if (data == null) return null;
|
||||
if (Array.isArray(data)) return null;
|
||||
@@ -1014,9 +1225,9 @@ const fillFormFromDetailRow = (row: Record<string, unknown>) => {
|
||||
tokenConfig: '{}',
|
||||
};
|
||||
state.headers = ensureKeyValueRows(parseHeaders(String(row.headMsg || '')));
|
||||
state.formFields = ensureKeyValueRows(parseFieldsUnified(row.form));
|
||||
state.formFields = parseFormFieldsUnified(row.form);
|
||||
state.requestMappingFields = ensureKeyValueRows(parseRequestMappingFields(row.requestMapping));
|
||||
state.responseMappingFields = ensureResponseMappingRows(parseResponseMappingFields(row.responseMapping));
|
||||
state.responseMappingFields = ensureKeyValueRows(parseResponseMappingFields(row.responseMapping));
|
||||
state.extendMappingFields = ensureKeyValueRows(parseFieldsUnified(row.extendMapping));
|
||||
state.tokenConfigFields = ensureKeyValueRows(parseFieldsUnified(row.tokenConfig));
|
||||
|
||||
@@ -1131,7 +1342,7 @@ const openDialog = async (type: string, row?: Record<string, unknown>) => {
|
||||
tokenConfig: '{}',
|
||||
};
|
||||
state.headers = [{ key: '', value: '' }];
|
||||
state.formFields = [{ key: '', value: '' }];
|
||||
state.formFields = [createEmptyFormField()];
|
||||
state.requestMappingFields = [{ key: '', value: '' }];
|
||||
state.responseMappingFields = [{ key: '', value: '', isMainBody: false, isTokenField: false }];
|
||||
state.mainBodyIndex = -1;
|
||||
@@ -1170,33 +1381,55 @@ const onSubmit = () => {
|
||||
if (state.ruleForm.queryResponseType === 'pull') {
|
||||
await editModuleFormRef.value?.validateField?.('queryPullConfig');
|
||||
}
|
||||
|
||||
|
||||
// 验证响应映射(如果有配置)
|
||||
const validResponseFields = state.responseMappingFields.filter((x) => String(x.key || '').trim() !== '');
|
||||
if (validResponseFields.length > 0) {
|
||||
await editModuleFormRef.value?.validateField?.('responseMapping');
|
||||
}
|
||||
|
||||
|
||||
// 验证请求映射(如果有配置)
|
||||
const validRequestFields = state.requestMappingFields.filter((x) => String(x.key || '').trim() !== '');
|
||||
if (validRequestFields.length > 0) {
|
||||
await editModuleFormRef.value?.validateField?.('requestMapping');
|
||||
}
|
||||
|
||||
|
||||
state.ruleForm.headMsg = stringifyHeaders();
|
||||
|
||||
|
||||
// 过滤掉空键名的字段
|
||||
const requestMapping = fieldsToObject(state.requestMappingFields.filter((f) => String(f.key || '').trim() !== ''));
|
||||
const responseMapping = fieldsToObject(state.responseMappingFields.filter((f) => String(f.key || '').trim() !== ''));
|
||||
|
||||
|
||||
// 获取被设置为返回主体的字段 {key: value}
|
||||
const responseBodyField = state.responseMappingFields.find((f) => f.isMainBody && String(f.key || '').trim() !== '');
|
||||
const responseBody = responseBodyField ? { [responseBodyField.key.trim()]: responseBodyField.value } : {};
|
||||
|
||||
|
||||
// 获取计费字段(可选)
|
||||
const responseTokenField =
|
||||
state.responseMappingFields.find((f) => f.isTokenField)?.key?.trim() || String(state.ruleForm.responseTokenField || '').trim();
|
||||
|
||||
|
||||
// 过滤掉空key的自定义字段
|
||||
const processedFormFields = state.formFields
|
||||
.filter((f) => String(f.key || '').trim() !== '')
|
||||
.map((f) => ({
|
||||
key: String(f.key).trim(),
|
||||
value: f.defaultValue || '',
|
||||
label: f.label?.trim() || f.key,
|
||||
type: f.type,
|
||||
defaultValue: f.defaultValue || '',
|
||||
required: Boolean(f.required),
|
||||
maxLength: f.type === 'string' && f.maxLength ? f.maxLength : undefined,
|
||||
min: f.type === 'number' && f.min !== undefined ? f.min : undefined,
|
||||
max: f.type === 'number' && f.max !== undefined ? f.max : undefined,
|
||||
numberType: f.type === 'number' ? f.numberType || 'any' : undefined,
|
||||
maxSize: f.type === 'file' && f.maxSize ? f.maxSize : undefined,
|
||||
maxCount: f.type === 'file' && f.maxCount ? f.maxCount : undefined,
|
||||
allowedTypes: f.type === 'file' && f.allowedTypes ? f.allowedTypes.trim() : undefined,
|
||||
options: (f.type === 'select' || f.type === 'radio') && f.options
|
||||
? f.options.filter(opt => String(opt.label || '').trim() !== '' || String(opt.value || '').trim() !== '')
|
||||
: undefined,
|
||||
})) as unknown as ModelFormEntry[];
|
||||
|
||||
const submitData: CreateModelParams = {
|
||||
modelName: state.ruleForm.modelName,
|
||||
modelType: state.ruleForm.modelType as number | string,
|
||||
@@ -1209,9 +1442,7 @@ const onSubmit = () => {
|
||||
isChatModel: state.ruleForm.isChatModel,
|
||||
// 确保 API 密钥只在 isPrivate=1 时提交
|
||||
apiKey: state.ruleForm.isPrivate === 1 ? String(state.ruleForm.apiKey ?? '').trim() : '',
|
||||
form: state.formFields
|
||||
.filter((f) => String(f.key || '').trim() !== '')
|
||||
.map((f) => ({ key: String(f.key).trim(), value: String(f.value ?? '') })),
|
||||
form: processedFormFields,
|
||||
requestMapping,
|
||||
responseMapping,
|
||||
responseBody,
|
||||
@@ -1272,15 +1503,89 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.form-config-container {
|
||||
max-height: 400px;
|
||||
max-height: 550px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
padding: 5px 0;
|
||||
|
||||
.form-field-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
.form-field-item {
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
padding: 16px 16px 12px 16px;
|
||||
padding-right: 80px;
|
||||
margin-bottom: 16px;
|
||||
background-color: #fafafa;
|
||||
position: relative;
|
||||
|
||||
.delete-btn {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.field-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
|
||||
.field-col {
|
||||
flex: 1;
|
||||
|
||||
&.field-col-sm {
|
||||
flex: 0 0 140px;
|
||||
}
|
||||
&.field-col-md {
|
||||
flex: 0 0 200px;
|
||||
}
|
||||
&.field-col-xs {
|
||||
flex: 0 0 80px;
|
||||
}
|
||||
}
|
||||
|
||||
.field-label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.2;
|
||||
|
||||
&.required::before {
|
||||
content: '*';
|
||||
color: #f56c6c;
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.switch-wrapper {
|
||||
padding-top: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.options-row {
|
||||
margin-top: 8px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px dashed #e4e7ed;
|
||||
|
||||
.options-label {
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
margin-bottom: 10px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.option-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.option-col {
|
||||
flex: 1;
|
||||
max-width: 180px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ml5 {
|
||||
|
||||
314
src/views/settings/promptManager/index.vue
Normal file
314
src/views/settings/promptManager/index.vue
Normal file
@@ -0,0 +1,314 @@
|
||||
<template>
|
||||
<div class="prompt-manager-container">
|
||||
<!-- 搜索栏 -->
|
||||
<div class="search-bar">
|
||||
<el-input v-model="searchQuery" placeholder="搜索提示词内容..." prefix-icon="Search" style="width: 300px" clearable @input="handleSearch" />
|
||||
<el-button type="primary" @click="showCreateDialog = true">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新增提示词
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<div class="table-container">
|
||||
<el-table :data="filteredList" v-loading="loading" border style="width: 100%">
|
||||
<el-table-column prop="nodeType" label="节点类型" width="150" />
|
||||
<el-table-column prop="prompt" label="提示词内容" min-width="350">
|
||||
<template #default="{ row }">
|
||||
<el-tooltip v-if="row.prompt.length > 80" content="hover" :enterable="false">
|
||||
<template #content>
|
||||
<div style="max-width: 400px; white-space: pre-wrap">{{ row.prompt }}</div>
|
||||
</template>
|
||||
<span>{{ row.prompt.slice(0, 80) }}...</span>
|
||||
</el-tooltip>
|
||||
<span v-else>{{ row.prompt }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sourceType" label="来源" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.sourceType === 0">自定义</el-tag>
|
||||
<el-tag v-else-if="row.sourceType === 1" type="success">公共</el-tag>
|
||||
<el-tag v-else type="info">{{ row.sourceType }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="creator" label="创建者" width="120" />
|
||||
<el-table-column prop="createdAt" label="创建时间" width="170" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link size="small" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button type="danger" link size="small" @click="handleDeleteConfirm(row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.current"
|
||||
v-model:page-size="pagination.size"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, ->, prev, pager, next, jumper"
|
||||
:total="pagination.total"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增/编辑弹窗 -->
|
||||
<el-dialog v-model="showCreateDialog" :title="isEdit ? '编辑提示词' : '新增提示词'" width="600px" :close-on-click-modal="false">
|
||||
<el-form ref="createFormRef" :model="createForm" label-width="100px">
|
||||
<el-form-item label="节点类型" required>
|
||||
<el-select v-model="createForm.nodeType" placeholder="请选择节点类型" style="width: 100%" clearable v-loading="nodeLibraryLoading">
|
||||
<el-option v-for="option in nodeOptions" :key="option.value" :label="option.label" :value="option.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="提示词内容" required>
|
||||
<el-input v-model="createForm.prompt" type="textarea" :rows="8" placeholder="请输入提示词内容..." clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="cancelCreate">取 消</el-button>
|
||||
<el-button type="primary" @click="handleSubmitCreate" :loading="submitLoading">
|
||||
{{ isEdit ? '保存修改' : '确 定' }}
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 删除确认弹窗 -->
|
||||
<el-dialog v-model="showDeleteDialog" title="确认删除" width="400px" :close-on-click-modal="false">
|
||||
<div>确定要删除这个提示词吗?</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="showDeleteDialog = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleDelete" :loading="deleteLoading">确 定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="promptManager">
|
||||
import { ref, reactive, computed, onMounted } from 'vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { getNodeLibraryList, getMyPromptList, createPrompt, updatePrompt, deletePrompt, type NodeLibraryGroup, type NodeLibraryNode, type PromptItem } from '/@/api/settings/promptManager/index';
|
||||
|
||||
const searchQuery = ref('');
|
||||
const loading = ref(false);
|
||||
const list = ref<PromptItem[]>([]);
|
||||
const showCreateDialog = ref(false);
|
||||
const isEdit = ref(false);
|
||||
const submitLoading = ref(false);
|
||||
const createFormRef = ref();
|
||||
const editId = ref<number | string | null>(null);
|
||||
const nodeLibraryLoading = ref(false);
|
||||
const nodeLibraryGroups = ref<NodeLibraryGroup[]>([]);
|
||||
const showDeleteDialog = ref(false);
|
||||
const deleteLoading = ref(false);
|
||||
const deleteId = ref<number | string | null>(null);
|
||||
const nodeOptions = computed(() => {
|
||||
const options: Array<{ label: string; value: string }> = [];
|
||||
nodeLibraryGroups.value.forEach((group: NodeLibraryGroup) => {
|
||||
group.items.forEach((item: NodeLibraryNode) => {
|
||||
// 只显示支持提示词配置的节点
|
||||
if (item.promptOption) {
|
||||
options.push({
|
||||
label: item.nodeName,
|
||||
value: item.nodeCode,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
return options;
|
||||
});
|
||||
|
||||
const createForm = reactive({
|
||||
nodeType: '',
|
||||
prompt: '',
|
||||
sourceType: 0 as number,
|
||||
});
|
||||
|
||||
// 加载节点库
|
||||
const loadNodeLibrary = async () => {
|
||||
nodeLibraryLoading.value = true;
|
||||
try {
|
||||
const res = await getNodeLibraryList();
|
||||
if (res && res.data && res.data.groups) {
|
||||
nodeLibraryGroups.value = res.data.groups;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('加载节点库失败:', e);
|
||||
ElMessage.error('加载节点类型失败');
|
||||
} finally {
|
||||
nodeLibraryLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
});
|
||||
|
||||
// 过滤后的列表
|
||||
const filteredList = computed(() => {
|
||||
if (!searchQuery.value) {
|
||||
return list.value;
|
||||
}
|
||||
const query = searchQuery.value.toLowerCase();
|
||||
return list.value.filter(
|
||||
(item) => item.nodeType.toLowerCase().includes(query) || item.prompt.toLowerCase().includes(query) || item.creator?.toLowerCase().includes(query)
|
||||
);
|
||||
});
|
||||
|
||||
// 加载列表
|
||||
const loadList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getMyPromptList({
|
||||
pageNum: pagination.current,
|
||||
pageSize: pagination.size,
|
||||
});
|
||||
if (res && res.data && res.data.list) {
|
||||
list.value = res.data.list;
|
||||
pagination.total = res.data.total || 0;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
ElMessage.error('加载失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
pagination.current = 1;
|
||||
loadList();
|
||||
};
|
||||
|
||||
// 新增
|
||||
const handleSubmitCreate = async () => {
|
||||
// 验证
|
||||
if (!createForm.nodeType?.trim()) {
|
||||
ElMessage.warning('请选择节点类型');
|
||||
return;
|
||||
}
|
||||
if (!createForm.prompt?.trim()) {
|
||||
ElMessage.warning('请输入提示词内容');
|
||||
return;
|
||||
}
|
||||
|
||||
submitLoading.value = true;
|
||||
try {
|
||||
if (isEdit.value && editId.value) {
|
||||
await updatePrompt({
|
||||
id: editId.value,
|
||||
...createForm,
|
||||
});
|
||||
ElMessage.success('修改成功');
|
||||
} else {
|
||||
await createPrompt({
|
||||
nodeType: createForm.nodeType.trim(),
|
||||
prompt: createForm.prompt.trim(),
|
||||
sourceType: createForm.sourceType,
|
||||
});
|
||||
ElMessage.success('创建成功');
|
||||
}
|
||||
showCreateDialog.value = false;
|
||||
cancelCreate();
|
||||
loadList();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
ElMessage.error('操作失败');
|
||||
} finally {
|
||||
submitLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 编辑
|
||||
const handleEdit = (row: PromptItem) => {
|
||||
isEdit.value = true;
|
||||
editId.value = row.id;
|
||||
createForm.nodeType = row.nodeType || '';
|
||||
createForm.prompt = row.prompt || '';
|
||||
createForm.sourceType = row.sourceType || 0;
|
||||
showCreateDialog.value = true;
|
||||
};
|
||||
|
||||
// 打开删除确认弹窗
|
||||
const handleDeleteConfirm = (id: number | string) => {
|
||||
deleteId.value = id;
|
||||
showDeleteDialog.value = true;
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = async () => {
|
||||
if (!deleteId.value) return;
|
||||
deleteLoading.value = true;
|
||||
try {
|
||||
await deletePrompt(deleteId.value);
|
||||
ElMessage.success('删除成功');
|
||||
showDeleteDialog.value = false;
|
||||
loadList();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
ElMessage.error('删除失败');
|
||||
} finally {
|
||||
deleteLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 取消
|
||||
const cancelCreate = () => {
|
||||
createFormRef.value?.resetFields();
|
||||
isEdit.value = false;
|
||||
editId.value = null;
|
||||
createForm.nodeType = '';
|
||||
createForm.prompt = '';
|
||||
createForm.sourceType = 0;
|
||||
};
|
||||
|
||||
// 分页
|
||||
const handleSizeChange = (size: number) => {
|
||||
pagination.size = size;
|
||||
pagination.current = 1;
|
||||
loadList();
|
||||
};
|
||||
|
||||
const handleCurrentChange = (current: number) => {
|
||||
pagination.current = current;
|
||||
loadList();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadNodeLibrary();
|
||||
loadList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.prompt-manager-container {
|
||||
padding: 16px;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
|
||||
.search-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
.pagination-container {
|
||||
margin-top: 16px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
279
src/views/settings/workflow/component/InputSourceManager.vue
Normal file
279
src/views/settings/workflow/component/InputSourceManager.vue
Normal file
@@ -0,0 +1,279 @@
|
||||
<template>
|
||||
<div class="input-source-manager">
|
||||
<el-divider content-position="left">上级参数引用</el-divider>
|
||||
|
||||
<!-- 已引用的参数列表 -->
|
||||
<div v-if="currentInputSource && currentInputSource.length > 0" class="input-source-list">
|
||||
<div v-for="(sourceNode, index) in currentInputSource" :key="index" class="input-source-item">
|
||||
<div class="input-source-header">
|
||||
<span class="input-source-node-name">{{ getNodeName(sourceNode.nodeId) }}</span>
|
||||
</div>
|
||||
<div v-if="sourceNode.field && sourceNode.field.length > 0" class="input-source-fields">
|
||||
<div v-for="fieldName in sourceNode.field" :key="fieldName" class="field-tag">
|
||||
<el-tag size="small">{{ fieldName }}</el-tag>
|
||||
<el-button type="danger" link size="small" @click="emit('removeField', sourceNode.nodeId, fieldName)">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-source-output">
|
||||
<el-switch
|
||||
:model-value="sourceNode.quoteOutput === true"
|
||||
@change="(val: boolean) => emit('toggleOutput', sourceNode.nodeId, val)"
|
||||
size="small"
|
||||
active-text="引入输出"
|
||||
inactive-text=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 显示所有上级节点的输出引用选项 -->
|
||||
<div v-if="availableParentNodes.length > 0" class="parent-nodes-output">
|
||||
<div class="parent-nodes-title">上级节点输出</div>
|
||||
<div v-for="parentNode in availableParentNodes" :key="parentNode.id" class="parent-node-output-item">
|
||||
<span class="parent-node-name">{{ parentNode.name }}</span>
|
||||
<el-switch
|
||||
:model-value="isNodeOutputQuoted(parentNode.id)"
|
||||
@change="(val: boolean) => emit('toggleOutput', parentNode.id, val)"
|
||||
size="small"
|
||||
active-text="引入输出"
|
||||
inactive-text=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 选择参数下拉框 -->
|
||||
<el-form-item label="选择参数">
|
||||
<el-select :model-value="selectedParam" @update:model-value="handleParamSelect" placeholder="选择上级节点的参数" class="w100">
|
||||
<el-option v-for="param in availableParams" :key="param.value" :label="param.label" :value="param.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue';
|
||||
import type { Node } from '@vue-flow/core';
|
||||
|
||||
interface NodeData {
|
||||
label?: string;
|
||||
nodeCode?: string;
|
||||
inputSource?: Array<{ nodeId: string; field: string[]; quoteOutput?: boolean }> | null;
|
||||
formConfig?: any[];
|
||||
modelConfig?: any;
|
||||
skillName?: string;
|
||||
}
|
||||
|
||||
interface ParentNode {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface ParamOption {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
selectedNode: Node<NodeData, any, string> | null;
|
||||
nodes: Node<NodeData, any, string>[];
|
||||
edges: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'removeField', nodeId: string, fieldName: string): void;
|
||||
(e: 'toggleOutput', nodeId: string, enabled: boolean): void;
|
||||
(e: 'addParam', paramValue: string): void;
|
||||
}>();
|
||||
|
||||
const selectedParam = ref('');
|
||||
|
||||
// 当前节点的 inputSource
|
||||
const currentInputSource = computed(() => {
|
||||
if (!props.selectedNode?.data?.inputSource) return [];
|
||||
return props.selectedNode.data.inputSource.filter((item) => item.field && item.field.length > 0);
|
||||
});
|
||||
|
||||
// 获取节点名称
|
||||
const getNodeName = (nodeId: string) => {
|
||||
const node = props.nodes.find((n) => n.id === nodeId);
|
||||
return node?.data?.label || nodeId;
|
||||
};
|
||||
|
||||
// 获取所有上级节点(用于显示输出引用选项)
|
||||
const availableParentNodes = computed(() => {
|
||||
if (!props.selectedNode?.data) return [];
|
||||
|
||||
// 获取已经引用了字段的节点ID列表
|
||||
const inputSource = props.selectedNode.data.inputSource;
|
||||
const nodesWithFields = new Set<string>();
|
||||
if (Array.isArray(inputSource)) {
|
||||
inputSource.forEach((item) => {
|
||||
if (item.field && item.field.length > 0) {
|
||||
nodesWithFields.add(item.nodeId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 递归查找所有上级节点
|
||||
const findAllParentNodes = (nodeId: string, visited = new Set<string>()): string[] => {
|
||||
if (visited.has(nodeId)) return [];
|
||||
visited.add(nodeId);
|
||||
|
||||
const incomingEdges = props.edges.filter((e) => e.target === nodeId);
|
||||
const parentIds: string[] = [];
|
||||
|
||||
incomingEdges.forEach((edge) => {
|
||||
parentIds.push(edge.source);
|
||||
parentIds.push(...findAllParentNodes(edge.source, visited));
|
||||
});
|
||||
|
||||
return parentIds;
|
||||
};
|
||||
|
||||
const allParentIds = findAllParentNodes(props.selectedNode.id);
|
||||
const parentNodes = allParentIds
|
||||
.map((parentId) => {
|
||||
const parentNode = props.nodes.find((n) => n.id === parentId);
|
||||
if (!parentNode?.data) return null;
|
||||
|
||||
const nodeCode = String(parentNode.data.nodeCode || '').toLowerCase();
|
||||
const isJudge = ['判断', 'judge', 'condition', 'if', 'branch', 'gateway'].some((k) => nodeCode.includes(k));
|
||||
const isStart = nodeCode === '__start__';
|
||||
|
||||
if (isJudge || isStart || nodesWithFields.has(parentId)) return null;
|
||||
|
||||
return {
|
||||
id: parentId,
|
||||
name: parentNode.data.label || parentId,
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
return parentNodes as ParentNode[];
|
||||
});
|
||||
|
||||
// 检查节点输出是否被引用
|
||||
const isNodeOutputQuoted = (nodeId: string): boolean => {
|
||||
if (!props.selectedNode?.data) return false;
|
||||
const inputSource = props.selectedNode.data.inputSource;
|
||||
if (!Array.isArray(inputSource)) return false;
|
||||
|
||||
const node = inputSource.find((item) => item.nodeId === nodeId);
|
||||
return node?.quoteOutput === true;
|
||||
};
|
||||
|
||||
// 获取可用的参数选项
|
||||
const availableParams = computed(() => {
|
||||
if (!props.selectedNode) return [];
|
||||
|
||||
const params: ParamOption[] = [];
|
||||
const visited = new Set<string>();
|
||||
|
||||
const findParents = (nodeId: string) => {
|
||||
if (visited.has(nodeId)) return;
|
||||
visited.add(nodeId);
|
||||
|
||||
props.edges
|
||||
.filter((e) => e.target === nodeId)
|
||||
.forEach((edge) => {
|
||||
const parent = props.nodes.find((n) => n.id === edge.source);
|
||||
if (parent?.data && parent.data.nodeCode !== '__start__' && parent.data.nodeCode !== 'judge') {
|
||||
params.push({
|
||||
label: `${parent.data.label}.output`,
|
||||
value: `\${${parent.id}.output}`,
|
||||
});
|
||||
}
|
||||
findParents(edge.source);
|
||||
});
|
||||
};
|
||||
|
||||
findParents(props.selectedNode.id);
|
||||
return params;
|
||||
});
|
||||
|
||||
const handleParamSelect = (value: string) => {
|
||||
if (!value) return;
|
||||
emit('addParam', value);
|
||||
selectedParam.value = '';
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.input-source-manager {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.input-source-list {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.input-source-item {
|
||||
padding: 12px;
|
||||
margin-bottom: 12px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.input-source-header {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.input-source-node-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
.input-source-fields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.field-tag {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.input-source-output {
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.parent-nodes-output {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.parent-nodes-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.parent-node-output-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 12px;
|
||||
margin-bottom: 6px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.parent-node-name {
|
||||
font-size: 13px;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.w100 {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
263
src/views/settings/workflow/component/NodeConfigPanel.vue
Normal file
263
src/views/settings/workflow/component/NodeConfigPanel.vue
Normal file
@@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<div class="config-panel">
|
||||
<h3>节点配置</h3>
|
||||
<div v-if="selectedNode">
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="节点名称">
|
||||
<el-input :model-value="selectedNode.data?.label" @update:model-value="updateNodeLabel" />
|
||||
</el-form-item>
|
||||
<el-form-item label="节点类型">
|
||||
<el-tag>{{ selectedNode.data?.nodeCode }}</el-tag>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 模型选择 -->
|
||||
<el-form-item v-if="nodeConfig?.modelConfig && nodeConfig.modelConfig.length > 0" label="选择模型">
|
||||
<el-button type="primary" @click="emit('openModelSelector')" style="width: 100%">选择模型</el-button>
|
||||
<div v-if="selectedNode.data?.modelConfig?.modelName" class="selected-tag">
|
||||
<el-tag type="success" size="large" closable @close="emit('removeModel')">
|
||||
{{ selectedNode.data.modelConfig.modelName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 技能选择 -->
|
||||
<el-form-item v-if="nodeConfig?.skillOption" label="选择技能">
|
||||
<el-button type="primary" @click="emit('openSkillSelector')" style="width: 100%">选择技能</el-button>
|
||||
<div v-if="selectedNode.data?.skillName" class="selected-tag">
|
||||
<el-tag type="success" size="large" closable @close="emit('removeSkill')">
|
||||
{{ selectedNode.data.skillName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 动态表单字段 -->
|
||||
<template v-if="nodeConfig?.formConfig && nodeConfig.formConfig.length > 0">
|
||||
<el-divider content-position="left">节点参数</el-divider>
|
||||
<el-form-item v-for="field in nodeConfig.formConfig" :key="field.field" :label="field.label" :required="field.required">
|
||||
<el-input
|
||||
v-if="field.type === 'input' || field.type === 'string'"
|
||||
:model-value="getFieldValue(field.field)"
|
||||
@update:model-value="updateFieldValue(field.field, $event)"
|
||||
:placeholder="field.required ? '必填' : '选填'"
|
||||
/>
|
||||
<el-input-number
|
||||
v-else-if="field.type === 'number' || field.type === 'inputNumber'"
|
||||
:model-value="getFieldValue(field.field)"
|
||||
@update:model-value="updateFieldValue(field.field, $event)"
|
||||
class="w100"
|
||||
/>
|
||||
<el-input
|
||||
v-else-if="field.type === 'textarea'"
|
||||
:model-value="getFieldValue(field.field)"
|
||||
@update:model-value="updateFieldValue(field.field, $event)"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
:placeholder="field.required ? '必填' : '选填'"
|
||||
/>
|
||||
<el-switch
|
||||
v-else-if="field.type === 'switch'"
|
||||
:model-value="getFieldValue(field.field)"
|
||||
@update:model-value="updateFieldValue(field.field, $event)"
|
||||
/>
|
||||
<el-select
|
||||
v-else-if="field.type === 'select' && field.options"
|
||||
:model-value="getFieldValue(field.field)"
|
||||
@update:model-value="updateFieldValue(field.field, $event)"
|
||||
:placeholder="field.required ? '必填' : '选填'"
|
||||
class="w100"
|
||||
>
|
||||
<el-option v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
<el-input
|
||||
v-else
|
||||
:model-value="getFieldValue(field.field)"
|
||||
@update:model-value="updateFieldValue(field.field, $event)"
|
||||
:placeholder="field.required ? '必填' : '选填'"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-form>
|
||||
|
||||
<!-- 上级参数管理 -->
|
||||
<InputSourceManager
|
||||
v-if="selectedNode.data?.nodeCode !== '__start__'"
|
||||
:selected-node="selectedNode"
|
||||
:nodes="allNodes"
|
||||
:edges="allEdges"
|
||||
@remove-field="(nodeId: string, fieldName: string) => emit('removeField', nodeId, fieldName)"
|
||||
@toggle-output="(nodeId: string, enabled: boolean) => emit('toggleOutput', nodeId, enabled)"
|
||||
@add-param="(paramValue: string) => emit('addParamByValue', paramValue)"
|
||||
/>
|
||||
</div>
|
||||
<el-empty v-else description="请选择一个节点" :image-size="100" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Node } from '@vue-flow/core';
|
||||
import InputSourceManager from './InputSourceManager.vue';
|
||||
|
||||
interface NodeData {
|
||||
label?: string;
|
||||
nodeCode?: string;
|
||||
inputSource?: Array<{ nodeId: string; field: string[]; quoteOutput?: boolean }> | null;
|
||||
formConfig?: any[];
|
||||
modelConfig?: any;
|
||||
skillName?: string;
|
||||
}
|
||||
|
||||
interface ParamRef {
|
||||
id: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface NodeConfig {
|
||||
formConfig: any[];
|
||||
modelConfig: any[];
|
||||
skillOption: boolean;
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
selectedNode: Node<NodeData, any, string> | null;
|
||||
availableParams: ParamRef[];
|
||||
nodeConfig: NodeConfig | null;
|
||||
allNodes: Node<NodeData, any, string>[];
|
||||
allEdges: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:selectedNode', node: Node<NodeData, any, string>): void;
|
||||
(e: 'addParam', param: ParamRef): void;
|
||||
(e: 'openModelSelector'): void;
|
||||
(e: 'removeModel'): void;
|
||||
(e: 'openSkillSelector'): void;
|
||||
(e: 'removeSkill'): void;
|
||||
(e: 'removeField', nodeId: string, fieldName: string): void;
|
||||
(e: 'toggleOutput', nodeId: string, enabled: boolean): void;
|
||||
(e: 'addParamByValue', paramValue: string): void;
|
||||
}>();
|
||||
|
||||
const updateNodeLabel = (newLabel: string) => {
|
||||
if (!props.selectedNode?.data) return;
|
||||
const updatedNode = {
|
||||
...props.selectedNode,
|
||||
data: {
|
||||
...props.selectedNode.data,
|
||||
label: newLabel,
|
||||
},
|
||||
};
|
||||
emit('update:selectedNode', updatedNode);
|
||||
};
|
||||
|
||||
const getFieldValue = (fieldName: string) => {
|
||||
if (!props.selectedNode?.data?.formConfig) return '';
|
||||
const field = props.selectedNode.data.formConfig.find((f: any) => f.field === fieldName);
|
||||
return field?.value ?? '';
|
||||
};
|
||||
|
||||
const updateFieldValue = (fieldName: string, value: any) => {
|
||||
if (!props.selectedNode?.data) return;
|
||||
|
||||
const formConfig = props.selectedNode.data.formConfig || [];
|
||||
const existingIndex = formConfig.findIndex((f: any) => f.field === fieldName);
|
||||
|
||||
let updatedFormConfig;
|
||||
if (existingIndex >= 0) {
|
||||
updatedFormConfig = [...formConfig];
|
||||
updatedFormConfig[existingIndex] = { ...updatedFormConfig[existingIndex], value };
|
||||
} else {
|
||||
const fieldDef = props.nodeConfig?.formConfig.find((f) => f.field === fieldName);
|
||||
if (fieldDef) {
|
||||
updatedFormConfig = [...formConfig, { ...fieldDef, value }];
|
||||
} else {
|
||||
updatedFormConfig = formConfig;
|
||||
}
|
||||
}
|
||||
|
||||
const updatedNode = {
|
||||
...props.selectedNode,
|
||||
data: {
|
||||
...props.selectedNode.data,
|
||||
formConfig: updatedFormConfig,
|
||||
},
|
||||
};
|
||||
emit('update:selectedNode', updatedNode);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.config-panel {
|
||||
background: #ffffff;
|
||||
border-radius: 10px;
|
||||
padding: 16px;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
|
||||
border: 1px solid #e6eaf0;
|
||||
|
||||
h3 {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #334155;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
:deep(.el-form) {
|
||||
.el-form-item {
|
||||
margin-bottom: 14px;
|
||||
|
||||
.el-form-item__label {
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
margin-bottom: 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.el-input__wrapper {
|
||||
border-radius: 6px;
|
||||
box-shadow: none;
|
||||
border: 1px solid #dbe3ee;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: #b8c4d6;
|
||||
}
|
||||
|
||||
&.is-focus {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.param-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 8px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: #cbd5e1;
|
||||
background: #f1f5f9;
|
||||
}
|
||||
}
|
||||
|
||||
.selected-tag {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.w100 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.el-empty) {
|
||||
padding: 32px 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
164
src/views/settings/workflow/component/NodeLibraryPanel.vue
Normal file
164
src/views/settings/workflow/component/NodeLibraryPanel.vue
Normal file
@@ -0,0 +1,164 @@
|
||||
<template>
|
||||
<div class="node-library-panel" :class="{ collapsed: collapsed }">
|
||||
<div class="node-library-header">
|
||||
<span>节点库</span>
|
||||
<el-button class="collapse-btn" text circle @click="emit('update:collapsed', !collapsed)">
|
||||
<el-icon>
|
||||
<ArrowRightBold v-if="collapsed" />
|
||||
<ArrowLeftBold v-else />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="!collapsed" class="node-library-content">
|
||||
<el-empty v-if="nodeLibraryGroups.length === 0" description="暂无节点" :image-size="40" />
|
||||
<div v-else class="node-library-groups">
|
||||
<div v-for="group in nodeLibraryGroups" :key="group.group" class="node-group">
|
||||
<div class="node-group-title">{{ group.label }}</div>
|
||||
<div class="node-group-items">
|
||||
<el-button
|
||||
v-for="item in group.items"
|
||||
:key="item.nodeCode"
|
||||
text
|
||||
class="node-item"
|
||||
@click="emit('addNode', item.nodeCode, item.nodeName)"
|
||||
>
|
||||
{{ item.nodeName }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
|
||||
import type { NodeLibraryGroup } from '/@/api/settings/creation';
|
||||
|
||||
defineProps<{
|
||||
nodeLibraryGroups: NodeLibraryGroup[];
|
||||
collapsed: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:collapsed', value: boolean): void;
|
||||
(e: 'addNode', nodeCode: string, nodeName: string): void;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.node-library-panel {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
z-index: 10;
|
||||
background: #fff;
|
||||
border: 1px solid #d8e0eb;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
|
||||
width: 132px;
|
||||
max-height: calc(100% - 20px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
transition: width 0.18s ease;
|
||||
|
||||
&.collapsed {
|
||||
width: 40px;
|
||||
|
||||
.node-library-header {
|
||||
padding: 8px;
|
||||
border-bottom: none;
|
||||
|
||||
> span {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.node-library-content {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.node-library-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid #e7ecf3;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #1f2937;
|
||||
background: #f8fafc;
|
||||
|
||||
.collapse-btn {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 1px solid #cfd8e6;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
.node-library-content {
|
||||
padding: 12px;
|
||||
overflow-y: auto;
|
||||
max-height: 480px;
|
||||
}
|
||||
|
||||
.node-library-groups {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.node-group {
|
||||
.node-group-title {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #64748b;
|
||||
margin-bottom: 8px;
|
||||
padding-bottom: 4px;
|
||||
border-bottom: 1px solid #e7ecf3;
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
.node-group-items {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.node-item {
|
||||
justify-content: flex-start !important;
|
||||
width: 100%;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
color: #475569;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
background: transparent;
|
||||
border: none;
|
||||
transition: all 0.15s ease;
|
||||
text-align: left !important;
|
||||
min-height: 34px;
|
||||
height: auto !important;
|
||||
display: block !important;
|
||||
|
||||
&:hover {
|
||||
background: #f1f5f9;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
:deep(.el-button__inner) {
|
||||
width: 100%;
|
||||
padding: 8px !important;
|
||||
margin: 0 !important;
|
||||
text-align: left !important;
|
||||
justify-content: flex-start !important;
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
40
src/views/settings/workflow/component/SaveWorkflowDialog.vue
Normal file
40
src/views/settings/workflow/component/SaveWorkflowDialog.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="500px" :close-on-click-modal="false">
|
||||
<el-form :model="saveForm" label-position="top">
|
||||
<el-form-item label="工作流名称" required>
|
||||
<el-input v-model="saveForm.flowName" placeholder="请输入工作流名称" maxlength="50" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="工作流描述">
|
||||
<el-input v-model="saveForm.description" type="textarea" :rows="4" placeholder="请输入工作流描述(选填)" maxlength="200" show-word-limit />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="emit('confirm')">{{ confirmText }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean;
|
||||
saveForm: { flowName: string; description: string };
|
||||
currentEditingWorkflowId: string | null;
|
||||
saving: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void;
|
||||
(e: 'confirm'): void;
|
||||
}>();
|
||||
|
||||
const dialogVisible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: boolean) => emit('update:modelValue', value),
|
||||
});
|
||||
|
||||
const dialogTitle = computed(() => (props.currentEditingWorkflowId ? '编辑工作流' : '保存工作流'));
|
||||
const confirmText = computed(() => (props.currentEditingWorkflowId ? '确定更新' : '确定保存'));
|
||||
</script>
|
||||
190
src/views/settings/workflow/component/WorkflowListPanel.vue
Normal file
190
src/views/settings/workflow/component/WorkflowListPanel.vue
Normal file
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<div class="workflow-list-panel">
|
||||
<div class="panel-header">
|
||||
<el-tabs v-model="activeTab" class="workflow-tabs">
|
||||
<el-tab-pane label="我的工作流" name="user"></el-tab-pane>
|
||||
<el-tab-pane label="模板工作流" name="template"></el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
<div class="workflow-list-content" v-loading="loading">
|
||||
<el-empty v-if="currentList.length === 0" description="暂无工作流" :image-size="60" />
|
||||
<div v-else class="workflow-items">
|
||||
<div
|
||||
v-for="workflow in currentList"
|
||||
:key="workflow.id"
|
||||
class="workflow-item"
|
||||
:class="{ active: currentEditingId === workflow.id }"
|
||||
@click="emit('edit', workflow)"
|
||||
>
|
||||
<div class="workflow-item-content">
|
||||
<div class="workflow-item-name">{{ workflow.flowName || workflow.flowTemplateName || '未命名工作流' }}</div>
|
||||
<div class="workflow-item-desc">{{ workflow.description || '暂无描述' }}</div>
|
||||
</div>
|
||||
<div class="workflow-item-actions">
|
||||
<el-button type="primary" link size="small" @click.stop="emit('edit', workflow)">编辑</el-button>
|
||||
<el-button type="danger" link size="small" @click.stop="emit('delete', workflow)">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue';
|
||||
import type { WorkflowItem } from '/@/api/settings/creation';
|
||||
|
||||
const props = defineProps<{
|
||||
userWorkflowList: WorkflowItem[];
|
||||
templateWorkflowList: WorkflowItem[];
|
||||
currentEditingId: string | null;
|
||||
loading: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'edit', workflow: WorkflowItem): void;
|
||||
(e: 'delete', workflow: WorkflowItem): void;
|
||||
(e: 'create'): void;
|
||||
}>();
|
||||
|
||||
const activeTab = ref<'user' | 'template'>('user');
|
||||
|
||||
const currentList = computed(() => {
|
||||
return activeTab.value === 'user' ? props.userWorkflowList : props.templateWorkflowList;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.workflow-list-panel {
|
||||
background: #ffffff;
|
||||
border-radius: 10px;
|
||||
padding: 16px;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
|
||||
border: 1px solid #e6eaf0;
|
||||
|
||||
.panel-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 14px;
|
||||
|
||||
:deep(.el-button) {
|
||||
border-radius: 6px;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
padding: 6px 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.workflow-tabs {
|
||||
flex: 1;
|
||||
|
||||
:deep(.el-tabs__header) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__nav-wrap::after) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__item) {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
padding: 0 16px;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
|
||||
&.is-active {
|
||||
color: #3b82f6;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-tabs__active-bar) {
|
||||
background-color: #3b82f6;
|
||||
}
|
||||
}
|
||||
|
||||
.workflow-list-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: rgba(102, 126, 234, 0.05);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.workflow-items {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.workflow-item {
|
||||
padding: 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
background: #fff;
|
||||
|
||||
&:hover {
|
||||
border-color: #c5d2e6;
|
||||
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: #3b82f6;
|
||||
background: #eff6ff;
|
||||
}
|
||||
}
|
||||
|
||||
.workflow-item-content {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.workflow-item-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
margin-bottom: 4px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.workflow-item-desc {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.workflow-item-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
|
||||
:deep(.el-button) {
|
||||
border-radius: 6px;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
1064
src/views/settings/workflow/index.vue
Normal file
1064
src/views/settings/workflow/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user