Compare commits
15 Commits
7555de2275
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7202a6244 | ||
|
|
c6f64de4cc | ||
|
|
724e3e1073 | ||
|
|
b02f249166 | ||
|
|
8f2bd92ee0 | ||
|
|
205ae6aa4e | ||
|
|
2de394ccae | ||
|
|
3bc9304fa9 | ||
|
|
a2ba73e33d | ||
|
|
bb669ef422 | ||
|
|
44beaa164d | ||
|
|
2f38a0b77a | ||
|
|
ed47286955 | ||
|
|
4c1b70e9d6 | ||
|
|
149cc5f6b0 |
339
.drone.yml
339
.drone.yml
@@ -1,8 +1,8 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: deploy-test
|
name: build-and-push-test
|
||||||
|
|
||||||
# 测试环境:test 分支触发,部署到 kpl
|
# 测试环境:test 分支触发,构建并推送到 ACR
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- test
|
- test
|
||||||
@@ -10,64 +10,61 @@ trigger:
|
|||||||
- push
|
- push
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: sync-code
|
# 构建并推送后端镜像
|
||||||
image: appleboy/drone-ssh
|
- name: build-push-backend
|
||||||
settings:
|
image: docker:dind
|
||||||
host: 120.79.247.16
|
volumes:
|
||||||
username: root
|
- name: docker-sock
|
||||||
password:
|
path: /var/run/docker.sock
|
||||||
from_secret: prod_ssh_password
|
environment:
|
||||||
port: 22
|
DOCKER_REGISTRY:
|
||||||
command_timeout: 5m
|
from_secret: docker_registry
|
||||||
script:
|
DOCKER_USERNAME:
|
||||||
- echo "=== 测试环境 同步代码 ==="
|
from_secret: docker_username
|
||||||
- cd /root/aiedu
|
DOCKER_PASSWORD:
|
||||||
- git fetch cicd
|
from_secret: docker_password
|
||||||
- git checkout test 2>/dev/null || git checkout -b test cicd/test
|
commands:
|
||||||
- git reset --hard cicd/test
|
- echo "$DOCKER_PASSWORD" | docker login "$DOCKER_REGISTRY" -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- echo "代码同步完成"
|
- cd backend
|
||||||
|
- docker build -t $DOCKER_REGISTRY/ireborn/kaopeilian-backend:test -f Dockerfile .
|
||||||
|
- docker tag $DOCKER_REGISTRY/ireborn/kaopeilian-backend:test $DOCKER_REGISTRY/ireborn/kaopeilian-backend:${DRONE_COMMIT_SHA:0:8}
|
||||||
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-backend:test
|
||||||
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-backend:${DRONE_COMMIT_SHA:0:8}
|
||||||
|
- echo "后端镜像推送完成"
|
||||||
|
|
||||||
- name: build-frontend-test
|
# 构建并推送前端镜像
|
||||||
image: appleboy/drone-ssh
|
- name: build-push-frontend
|
||||||
settings:
|
image: docker:dind
|
||||||
host: 120.79.247.16
|
volumes:
|
||||||
username: root
|
- name: docker-sock
|
||||||
password:
|
path: /var/run/docker.sock
|
||||||
from_secret: prod_ssh_password
|
environment:
|
||||||
port: 22
|
DOCKER_REGISTRY:
|
||||||
command_timeout: 10m
|
from_secret: docker_registry
|
||||||
script:
|
DOCKER_USERNAME:
|
||||||
- echo "=== 测试环境 编译前端到 dist-test ==="
|
from_secret: docker_username
|
||||||
- cd /root/aiedu/frontend
|
DOCKER_PASSWORD:
|
||||||
- npm install --silent
|
from_secret: docker_password
|
||||||
- npm run build
|
commands:
|
||||||
- rm -rf /root/aiedu/dist-test/*
|
- echo "$DOCKER_PASSWORD" | docker login "$DOCKER_REGISTRY" -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- cp -r dist/* /root/aiedu/dist-test/
|
- cd frontend
|
||||||
- echo "前端编译完成 dist-test"
|
- docker build -t $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:test -f Dockerfile --target production --build-arg VITE_API_BASE_URL=https://kpl.ireborn.com.cn .
|
||||||
|
- docker tag $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:test $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:${DRONE_COMMIT_SHA:0:8}
|
||||||
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:test
|
||||||
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:${DRONE_COMMIT_SHA:0:8}
|
||||||
|
- echo "前端镜像推送完成"
|
||||||
|
|
||||||
- name: deploy-backend
|
volumes:
|
||||||
image: appleboy/drone-ssh
|
- name: docker-sock
|
||||||
settings:
|
host:
|
||||||
host: 120.79.247.16
|
path: /var/run/docker.sock
|
||||||
username: root
|
|
||||||
password:
|
|
||||||
from_secret: prod_ssh_password
|
|
||||||
port: 22
|
|
||||||
command_timeout: 5m
|
|
||||||
script:
|
|
||||||
- echo "=== 测试环境 部署后端 ==="
|
|
||||||
- cp -r /root/aiedu/backend/app/* /root/aiedu/backend-test/app/
|
|
||||||
- docker restart kpl-backend-dev
|
|
||||||
- sleep 5
|
|
||||||
- docker ps | grep kpl-
|
|
||||||
- echo "=== 测试环境部署完成 ==="
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: deploy-staging
|
name: build-and-push-staging
|
||||||
|
|
||||||
# 预生产环境:staging 分支触发,部署到 aiedu
|
# 预生产环境:staging 分支触发
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- staging
|
- staging
|
||||||
@@ -75,71 +72,53 @@ trigger:
|
|||||||
- push
|
- push
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: sync-code
|
- name: build-push-backend
|
||||||
image: appleboy/drone-ssh
|
image: docker:dind
|
||||||
settings:
|
volumes:
|
||||||
host: 120.79.247.16
|
- name: docker-sock
|
||||||
username: root
|
path: /var/run/docker.sock
|
||||||
password:
|
environment:
|
||||||
from_secret: prod_ssh_password
|
DOCKER_REGISTRY:
|
||||||
port: 22
|
from_secret: docker_registry
|
||||||
command_timeout: 5m
|
DOCKER_USERNAME:
|
||||||
script:
|
from_secret: docker_username
|
||||||
- echo "=== 预生产 同步代码 ==="
|
DOCKER_PASSWORD:
|
||||||
- cd /root/aiedu
|
from_secret: docker_password
|
||||||
- git fetch cicd
|
commands:
|
||||||
- git checkout staging 2>/dev/null || git checkout -b staging cicd/staging
|
- echo "$DOCKER_PASSWORD" | docker login "$DOCKER_REGISTRY" -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- git reset --hard cicd/staging
|
- cd backend
|
||||||
- echo "代码同步完成"
|
- docker build -t $DOCKER_REGISTRY/ireborn/kaopeilian-backend:staging -f Dockerfile .
|
||||||
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-backend:staging
|
||||||
|
|
||||||
- name: build-frontend-staging
|
- name: build-push-frontend
|
||||||
image: appleboy/drone-ssh
|
image: docker:dind
|
||||||
settings:
|
volumes:
|
||||||
host: 120.79.247.16
|
- name: docker-sock
|
||||||
username: root
|
path: /var/run/docker.sock
|
||||||
password:
|
environment:
|
||||||
from_secret: prod_ssh_password
|
DOCKER_REGISTRY:
|
||||||
port: 22
|
from_secret: docker_registry
|
||||||
command_timeout: 10m
|
DOCKER_USERNAME:
|
||||||
script:
|
from_secret: docker_username
|
||||||
- echo "=== 预生产 编译前端到 dist-staging ==="
|
DOCKER_PASSWORD:
|
||||||
- cd /root/aiedu/frontend
|
from_secret: docker_password
|
||||||
- npm install --silent
|
commands:
|
||||||
- npm run build
|
- echo "$DOCKER_PASSWORD" | docker login "$DOCKER_REGISTRY" -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- rm -rf /root/aiedu/dist-staging/*
|
- cd frontend
|
||||||
- cp -r dist/* /root/aiedu/dist-staging/
|
- docker build -t $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:staging -f Dockerfile --target production --build-arg VITE_API_BASE_URL=https://aiedu.ireborn.com.cn .
|
||||||
- echo "前端编译完成 dist-staging"
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:staging
|
||||||
|
|
||||||
- name: deploy-backend
|
volumes:
|
||||||
image: appleboy/drone-ssh
|
- name: docker-sock
|
||||||
settings:
|
host:
|
||||||
host: 120.79.247.16
|
path: /var/run/docker.sock
|
||||||
username: root
|
|
||||||
password:
|
|
||||||
from_secret: prod_ssh_password
|
|
||||||
port: 22
|
|
||||||
command_timeout: 5m
|
|
||||||
script:
|
|
||||||
- echo "=== 预生产 部署后端 ==="
|
|
||||||
- cp -r /root/aiedu/backend/app/* /root/aiedu/backend-staging/app/
|
|
||||||
- docker restart kaopeilian-backend
|
|
||||||
- sleep 5
|
|
||||||
- docker ps | grep kaopeilian-
|
|
||||||
- echo "=== 预生产部署完成 ==="
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: deploy-prod
|
name: build-and-push-prod
|
||||||
|
|
||||||
# 生产环境:main 分支触发,部署到所有租户
|
# 生产环境:main 分支触发
|
||||||
#
|
|
||||||
# 使用方法:
|
|
||||||
# git commit -m "feat: xxx [all]" - 部署所有租户
|
|
||||||
# git commit -m "feat: xxx [hua]" - 仅部署 hua
|
|
||||||
# git commit -m "feat: xxx [cxw,yy,hl]" - 部署指定多个租户
|
|
||||||
# git commit -m "feat: xxx" - 默认部署所有租户
|
|
||||||
#
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
@@ -147,107 +126,47 @@ trigger:
|
|||||||
- push
|
- push
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: sync-code-to-server
|
- name: build-push-backend
|
||||||
image: appleboy/drone-ssh
|
image: docker:dind
|
||||||
settings:
|
volumes:
|
||||||
host: 120.79.247.16
|
- name: docker-sock
|
||||||
username: root
|
path: /var/run/docker.sock
|
||||||
password:
|
environment:
|
||||||
from_secret: prod_ssh_password
|
DOCKER_REGISTRY:
|
||||||
port: 22
|
from_secret: docker_registry
|
||||||
command_timeout: 10m
|
DOCKER_USERNAME:
|
||||||
script:
|
from_secret: docker_username
|
||||||
- echo "=== 生产 同步代码 ==="
|
DOCKER_PASSWORD:
|
||||||
- cd /root/aiedu
|
from_secret: docker_password
|
||||||
- git fetch cicd
|
|
||||||
- git reset --hard cicd/main
|
|
||||||
- echo "代码同步完成"
|
|
||||||
|
|
||||||
- name: build-frontend-prod
|
|
||||||
image: appleboy/drone-ssh
|
|
||||||
settings:
|
|
||||||
host: 120.79.247.16
|
|
||||||
username: root
|
|
||||||
password:
|
|
||||||
from_secret: prod_ssh_password
|
|
||||||
port: 22
|
|
||||||
command_timeout: 10m
|
|
||||||
script:
|
|
||||||
- echo "=== 生产 编译前端到 dist-prod ==="
|
|
||||||
- cd /root/aiedu/frontend
|
|
||||||
- npm install --silent
|
|
||||||
- npm run build
|
|
||||||
- rm -rf /root/aiedu/dist-prod/*
|
|
||||||
- cp -r dist/* /root/aiedu/dist-prod/
|
|
||||||
- echo "前端编译完成 dist-prod 所有生产租户已更新"
|
|
||||||
|
|
||||||
- name: deploy-backend
|
|
||||||
image: appleboy/drone-ssh
|
|
||||||
settings:
|
|
||||||
host: 120.79.247.16
|
|
||||||
username: root
|
|
||||||
password:
|
|
||||||
from_secret: prod_ssh_password
|
|
||||||
port: 22
|
|
||||||
command_timeout: 15m
|
|
||||||
script:
|
|
||||||
- echo "=== 生产 部署后端 ==="
|
|
||||||
- |
|
|
||||||
# 同步后端代码到生产环境目录
|
|
||||||
cp -r /root/aiedu/backend/app/* /root/aiedu/backend-prod/app/
|
|
||||||
echo "后端代码已同步到生产目录"
|
|
||||||
|
|
||||||
# 获取 commit message
|
|
||||||
COMMIT_MSG="${DRONE_COMMIT_MESSAGE}"
|
|
||||||
echo "Commit: $COMMIT_MSG"
|
|
||||||
|
|
||||||
# 所有可用租户
|
|
||||||
ALL_TENANTS="hua yy hl xy fw ex cxw"
|
|
||||||
|
|
||||||
# 解析要部署的租户
|
|
||||||
if echo "$COMMIT_MSG" | grep -q '\[all\]'; then
|
|
||||||
TENANTS="$ALL_TENANTS"
|
|
||||||
echo "部署所有租户: $TENANTS"
|
|
||||||
elif echo "$COMMIT_MSG" | grep -oP '\[\K[a-z,]+(?=\])' > /tmp/tenants.txt 2>/dev/null; then
|
|
||||||
TENANTS=$(cat /tmp/tenants.txt | tr ',' ' ')
|
|
||||||
echo "部署指定租户: $TENANTS"
|
|
||||||
else
|
|
||||||
TENANTS="$ALL_TENANTS"
|
|
||||||
echo "默认部署所有租户: $TENANTS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 重启指定租户的后端容器
|
|
||||||
for t in $TENANTS; do
|
|
||||||
echo "重启 ${t}-backend ..."
|
|
||||||
docker restart ${t}-backend || echo "警告: ${t}-backend 不存在或重启失败"
|
|
||||||
done
|
|
||||||
|
|
||||||
sleep 10
|
|
||||||
docker ps | grep backend
|
|
||||||
echo "=== 生产 部署完成 ==="
|
|
||||||
echo "已更新租户: $TENANTS"
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: code-check
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- push
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: python-lint
|
|
||||||
image: python:3.9-slim
|
|
||||||
commands:
|
commands:
|
||||||
|
- echo "$DOCKER_PASSWORD" | docker login "$DOCKER_REGISTRY" -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- cd backend
|
- cd backend
|
||||||
- pip install flake8 -q
|
- docker build -t $DOCKER_REGISTRY/ireborn/kaopeilian-backend:main -f Dockerfile .
|
||||||
- flake8 app --count --select=E9,F63,F7,F82 --show-source --statistics || true
|
- docker tag $DOCKER_REGISTRY/ireborn/kaopeilian-backend:main $DOCKER_REGISTRY/ireborn/kaopeilian-backend:latest
|
||||||
- echo "Python lint completed"
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-backend:main
|
||||||
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-backend:latest
|
||||||
|
|
||||||
- name: frontend-check
|
- name: build-push-frontend
|
||||||
image: node:18-alpine
|
image: docker:dind
|
||||||
|
volumes:
|
||||||
|
- name: docker-sock
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
environment:
|
||||||
|
DOCKER_REGISTRY:
|
||||||
|
from_secret: docker_registry
|
||||||
|
DOCKER_USERNAME:
|
||||||
|
from_secret: docker_username
|
||||||
|
DOCKER_PASSWORD:
|
||||||
|
from_secret: docker_password
|
||||||
commands:
|
commands:
|
||||||
|
- echo "$DOCKER_PASSWORD" | docker login "$DOCKER_REGISTRY" -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- cd frontend
|
- cd frontend
|
||||||
- echo "Frontend check completed"
|
- docker build -t $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:main -f Dockerfile --target production --build-arg VITE_API_BASE_URL=https://hua.ireborn.com.cn .
|
||||||
|
- docker tag $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:main $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:latest
|
||||||
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:main
|
||||||
|
- docker push $DOCKER_REGISTRY/ireborn/kaopeilian-frontend:latest
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: docker-sock
|
||||||
|
host:
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ UPLOAD_DIR=uploads
|
|||||||
COZE_OAUTH_CLIENT_ID=1114009328887
|
COZE_OAUTH_CLIENT_ID=1114009328887
|
||||||
COZE_OAUTH_PUBLIC_KEY_ID=GGs9pw0BDHx2k9vGGehUyRgKV-PyUWLBncDs-YNNN_I
|
COZE_OAUTH_PUBLIC_KEY_ID=GGs9pw0BDHx2k9vGGehUyRgKV-PyUWLBncDs-YNNN_I
|
||||||
COZE_OAUTH_PRIVATE_KEY_PATH=/app/secrets/coze_private_key.pem
|
COZE_OAUTH_PRIVATE_KEY_PATH=/app/secrets/coze_private_key.pem
|
||||||
|
COZE_WORKSPACE_ID=7461992708538974244
|
||||||
COZE_PRACTICE_BOT_ID=7602204855037591602
|
COZE_PRACTICE_BOT_ID=7602204855037591602
|
||||||
|
|
||||||
# Dify 工作流 API Key 配置
|
# Dify 工作流 API Key 配置
|
||||||
|
|||||||
@@ -734,14 +734,27 @@ async def end_practice_session(
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# 将 ORM 对象转换为响应格式,避免 DetachedInstanceError
|
||||||
|
session_data = PracticeSessionResponse(
|
||||||
|
id=session.id,
|
||||||
|
session_id=session.session_id,
|
||||||
|
user_id=session.user_id,
|
||||||
|
scene_id=session.scene_id,
|
||||||
|
scene_name=session.scene_name or "",
|
||||||
|
scene_type=session.scene_type,
|
||||||
|
conversation_id=session.conversation_id,
|
||||||
|
start_time=session.start_time,
|
||||||
|
end_time=session.end_time,
|
||||||
|
duration_seconds=session.duration_seconds or 0,
|
||||||
|
turns=session.turns or 0,
|
||||||
|
status=session.status,
|
||||||
|
created_at=session.created_at
|
||||||
|
)
|
||||||
|
|
||||||
return ResponseModel(
|
return ResponseModel(
|
||||||
code=200,
|
code=200,
|
||||||
message="会话已结束",
|
message="会话已结束",
|
||||||
data={
|
data=session_data
|
||||||
"session": session,
|
|
||||||
"exp_result": exp_result,
|
|
||||||
"new_badges": new_badges
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
@@ -815,7 +828,23 @@ async def analyze_practice_session(
|
|||||||
# 解析分析结果
|
# 解析分析结果
|
||||||
analysis_result = analysis_data.get("analysis", {})
|
analysis_result = analysis_data.get("analysis", {})
|
||||||
|
|
||||||
# 保存分析报告
|
# 检查报告是否已存在
|
||||||
|
existing_report = await db.execute(
|
||||||
|
select(PracticeReport).where(PracticeReport.session_id == session_id)
|
||||||
|
)
|
||||||
|
report = existing_report.scalar_one_or_none()
|
||||||
|
|
||||||
|
if report:
|
||||||
|
# 更新现有报告
|
||||||
|
report.total_score = analysis_result.get("total_score")
|
||||||
|
report.score_breakdown = analysis_result.get("score_breakdown")
|
||||||
|
report.ability_dimensions = analysis_result.get("ability_dimensions")
|
||||||
|
report.dialogue_review = analysis_result.get("dialogue_annotations")
|
||||||
|
report.suggestions = analysis_result.get("suggestions")
|
||||||
|
report.workflow_run_id = f"{v2_result.ai_provider}_{v2_result.ai_latency_ms}ms"
|
||||||
|
logger.info(f"更新现有分析报告: session_id={session_id}")
|
||||||
|
else:
|
||||||
|
# 创建新报告
|
||||||
report = PracticeReport(
|
report = PracticeReport(
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
total_score=analysis_result.get("total_score"),
|
total_score=analysis_result.get("total_score"),
|
||||||
@@ -826,8 +855,8 @@ async def analyze_practice_session(
|
|||||||
workflow_run_id=f"{v2_result.ai_provider}_{v2_result.ai_latency_ms}ms",
|
workflow_run_id=f"{v2_result.ai_provider}_{v2_result.ai_latency_ms}ms",
|
||||||
task_id=None
|
task_id=None
|
||||||
)
|
)
|
||||||
|
|
||||||
db.add(report)
|
db.add(report)
|
||||||
|
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
|
||||||
logger.info(f"分析报告已保存: session_id={session_id}, total_score={report.total_score}")
|
logger.info(f"分析报告已保存: session_id={session_id}, total_score={report.total_score}")
|
||||||
@@ -883,7 +912,53 @@ async def get_practice_report(
|
|||||||
report = result.scalar_one_or_none()
|
report = result.scalar_one_or_none()
|
||||||
|
|
||||||
if not report:
|
if not report:
|
||||||
raise HTTPException(status_code=404, detail="分析报告不存在,请先生成报告")
|
# 报告不存在,自动生成
|
||||||
|
logger.info(f"报告不存在,自动生成: session_id={session_id}")
|
||||||
|
|
||||||
|
# 查询对话历史
|
||||||
|
result = await db.execute(
|
||||||
|
select(PracticeDialogue).where(
|
||||||
|
PracticeDialogue.session_id == session_id
|
||||||
|
).order_by(PracticeDialogue.sequence)
|
||||||
|
)
|
||||||
|
dialogue_list = result.scalars().all()
|
||||||
|
|
||||||
|
if not dialogue_list:
|
||||||
|
raise HTTPException(status_code=404, detail="没有对话记录,无法生成报告")
|
||||||
|
|
||||||
|
# 构建对话历史
|
||||||
|
dialogue_history = [
|
||||||
|
{"role": "user" if d.speaker == "user" else "assistant", "content": d.content}
|
||||||
|
for d in dialogue_list
|
||||||
|
]
|
||||||
|
|
||||||
|
# 调用分析服务
|
||||||
|
from app.services.ai.practice_analysis_service import PracticeAnalysisService
|
||||||
|
import json
|
||||||
|
|
||||||
|
practice_analysis_service = PracticeAnalysisService()
|
||||||
|
analysis_result = await practice_analysis_service.analyze(dialogue_history, db=db)
|
||||||
|
|
||||||
|
if not analysis_result.success:
|
||||||
|
raise HTTPException(status_code=500, detail=f"分析失败: {analysis_result.error}")
|
||||||
|
|
||||||
|
analysis_data = analysis_result.to_dict()
|
||||||
|
|
||||||
|
# 保存报告
|
||||||
|
report = PracticeReport(
|
||||||
|
session_id=session_id,
|
||||||
|
total_score=analysis_data.get("overall_score", 0),
|
||||||
|
score_breakdown=analysis_data.get("score_breakdown", []),
|
||||||
|
ability_dimensions=analysis_data.get("ability_dimensions", []),
|
||||||
|
dialogue_review=analysis_data.get("dialogue_review", []),
|
||||||
|
suggestions=analysis_data.get("suggestions", []),
|
||||||
|
summary=analysis_data.get("summary", ""),
|
||||||
|
raw_response=json.dumps(analysis_data, ensure_ascii=False)
|
||||||
|
)
|
||||||
|
db.add(report)
|
||||||
|
await db.commit()
|
||||||
|
await db.refresh(report)
|
||||||
|
logger.info(f"报告自动生成成功: session_id={session_id}, 总分={report.total_score}")
|
||||||
|
|
||||||
# 3. 查询完整对话记录(从数据库)
|
# 3. 查询完整对话记录(从数据库)
|
||||||
result = await db.execute(
|
result = await db.execute(
|
||||||
|
|||||||
@@ -47,20 +47,23 @@ async def get_current_user_statistics(
|
|||||||
获取当前用户学习统计
|
获取当前用户学习统计
|
||||||
|
|
||||||
返回字段:
|
返回字段:
|
||||||
- learningDays: 学习天数(按陪练会话开始日期去重)
|
- learningDays: 学习天数(从注册日期到今天的天数,至少为1)
|
||||||
- totalHours: 学习总时长(小时,取整到1位小数)
|
- totalHours: 学习总时长(小时,取整到1位小数)
|
||||||
- practiceQuestions: 练习题数(答题记录条数汇总)
|
- practiceQuestions: 练习题数(答题记录条数汇总)
|
||||||
- averageScore: 平均成绩(已提交考试的平均分,保留1位小数)
|
- averageScore: 平均成绩(已提交考试的平均分,保留1位小数)
|
||||||
- examsCompleted: 已完成考试数量
|
- examsCompleted: 已完成考试数量
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
from datetime import date
|
||||||
user_id = current_user.id
|
user_id = current_user.id
|
||||||
|
|
||||||
# 学习天数:按会话开始日期去重
|
# 学习天数:从注册日期到今天的天数(至少为1天)
|
||||||
learning_days_stmt = select(func.count(func.distinct(func.date(TrainingSession.start_time)))).where(
|
if current_user.created_at:
|
||||||
TrainingSession.user_id == user_id
|
registration_date = current_user.created_at.date() if hasattr(current_user.created_at, 'date') else current_user.created_at
|
||||||
)
|
learning_days = (date.today() - registration_date).days + 1 # +1 是因为注册当天也算第1天
|
||||||
learning_days = (await db.scalar(learning_days_stmt)) or 0
|
learning_days = max(1, learning_days) # 确保至少为1
|
||||||
|
else:
|
||||||
|
learning_days = 1
|
||||||
|
|
||||||
# 总时长(小时)
|
# 总时长(小时)
|
||||||
total_seconds_stmt = select(func.coalesce(func.sum(TrainingSession.duration_seconds), 0)).where(
|
total_seconds_stmt = select(func.coalesce(func.sum(TrainingSession.duration_seconds), 0)).where(
|
||||||
|
|||||||
@@ -309,6 +309,7 @@ class MistakeService:
|
|||||||
ExamMistake.question_type,
|
ExamMistake.question_type,
|
||||||
ExamMistake.knowledge_point_id,
|
ExamMistake.knowledge_point_id,
|
||||||
KnowledgePoint.name.label("knowledge_point_name"),
|
KnowledgePoint.name.label("knowledge_point_name"),
|
||||||
|
ExamMistake.mastery_status,
|
||||||
ExamMistake.created_at
|
ExamMistake.created_at
|
||||||
).select_from(ExamMistake).join(
|
).select_from(ExamMistake).join(
|
||||||
Exam, ExamMistake.exam_id == Exam.id
|
Exam, ExamMistake.exam_id == Exam.id
|
||||||
@@ -339,6 +340,7 @@ class MistakeService:
|
|||||||
"question_type": row.question_type,
|
"question_type": row.question_type,
|
||||||
"knowledge_point_id": row.knowledge_point_id,
|
"knowledge_point_id": row.knowledge_point_id,
|
||||||
"knowledge_point_name": row.knowledge_point_name,
|
"knowledge_point_name": row.knowledge_point_name,
|
||||||
|
"mastery_status": row.mastery_status,
|
||||||
"created_at": row.created_at
|
"created_at": row.created_at
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
218
deploy/scripts/deploy-tenant.sh
Normal file
218
deploy/scripts/deploy-tenant.sh
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ================================================================
|
||||||
|
# 租户后端部署脚本
|
||||||
|
# 用于创建/更新租户的后端容器,确保包含所有必要的挂载
|
||||||
|
#
|
||||||
|
# 使用方法:
|
||||||
|
# ./deploy-tenant.sh <tenant_code> [image_tag]
|
||||||
|
#
|
||||||
|
# 示例:
|
||||||
|
# ./deploy-tenant.sh ex main # 部署 ex 租户,使用 main 镜像
|
||||||
|
# ./deploy-tenant.sh hua # 部署 hua 租户,默认 main 镜像
|
||||||
|
# ./deploy-tenant.sh all # 部署所有租户
|
||||||
|
#
|
||||||
|
# 注意:
|
||||||
|
# - 此脚本需要在服务器 120.79.247.16 上执行
|
||||||
|
# - 确保 secrets 目录存在:/data/prod-envs/secrets/coze_private_key.pem
|
||||||
|
# ================================================================
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# 配置
|
||||||
|
IMAGE_REGISTRY="crpi-na6dit5kd0bonqed.cn-guangzhou.personal.cr.aliyuncs.com/ireborn/kaopeilian-backend"
|
||||||
|
ENV_DIR="/root/aiedu/kaopeilian-backend"
|
||||||
|
DATA_DIR="/data/prod-envs"
|
||||||
|
SECRETS_DIR="/data/prod-envs/secrets"
|
||||||
|
|
||||||
|
# 租户配置(端口映射)
|
||||||
|
declare -A TENANT_PORTS=(
|
||||||
|
["hua"]="8010"
|
||||||
|
["yy"]="8011"
|
||||||
|
["hl"]="8012"
|
||||||
|
["xy"]="8013"
|
||||||
|
["fw"]="8014"
|
||||||
|
["ex"]="8015"
|
||||||
|
["cxw"]="8016"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 所有租户列表
|
||||||
|
ALL_TENANTS=("hua" "yy" "hl" "xy" "fw" "ex" "cxw")
|
||||||
|
|
||||||
|
# 颜色输出
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
||||||
|
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||||
|
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||||
|
|
||||||
|
# 检查前置条件
|
||||||
|
check_prerequisites() {
|
||||||
|
log_info "检查前置条件..."
|
||||||
|
|
||||||
|
# 检查 Docker
|
||||||
|
if ! docker info > /dev/null 2>&1; then
|
||||||
|
log_error "Docker 未运行"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查 secrets 目录
|
||||||
|
if [ ! -f "${SECRETS_DIR}/coze_private_key.pem" ]; then
|
||||||
|
log_error "私钥文件不存在: ${SECRETS_DIR}/coze_private_key.pem"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_info "前置条件检查通过"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 部署单个租户
|
||||||
|
deploy_tenant() {
|
||||||
|
local tenant=$1
|
||||||
|
local image_tag=${2:-main}
|
||||||
|
local port=${TENANT_PORTS[$tenant]}
|
||||||
|
|
||||||
|
if [ -z "$port" ]; then
|
||||||
|
log_error "未知租户: $tenant"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local container_name="${tenant}-backend"
|
||||||
|
local env_file="${ENV_DIR}/.env.${tenant}"
|
||||||
|
local image="${IMAGE_REGISTRY}:${image_tag}"
|
||||||
|
|
||||||
|
log_info "=========================================="
|
||||||
|
log_info "部署租户: ${tenant}"
|
||||||
|
log_info "容器名: ${container_name}"
|
||||||
|
log_info "端口: ${port}:8000"
|
||||||
|
log_info "镜像: ${image}"
|
||||||
|
log_info "=========================================="
|
||||||
|
|
||||||
|
# 检查环境变量文件
|
||||||
|
if [ ! -f "$env_file" ]; then
|
||||||
|
log_error "环境变量文件不存在: $env_file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建必要的目录
|
||||||
|
mkdir -p "${DATA_DIR}/uploads-${tenant}"
|
||||||
|
mkdir -p "${DATA_DIR}/logs-${tenant}"
|
||||||
|
|
||||||
|
# 拉取最新镜像
|
||||||
|
log_info "拉取镜像..."
|
||||||
|
docker pull "$image" || {
|
||||||
|
log_warn "拉取镜像失败,使用本地镜像"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 停止并删除旧容器
|
||||||
|
if docker ps -a --format '{{.Names}}' | grep -q "^${container_name}$"; then
|
||||||
|
log_info "停止旧容器..."
|
||||||
|
docker stop "$container_name" 2>/dev/null || true
|
||||||
|
docker rm "$container_name" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建新容器
|
||||||
|
log_info "创建新容器..."
|
||||||
|
docker run -d \
|
||||||
|
--name "$container_name" \
|
||||||
|
--restart unless-stopped \
|
||||||
|
--env-file "$env_file" \
|
||||||
|
-e TZ=Asia/Shanghai \
|
||||||
|
-e PYTHONPATH=/app \
|
||||||
|
-e WORKERS=4 \
|
||||||
|
-e RELOAD=false \
|
||||||
|
-p "${port}:8000" \
|
||||||
|
-v "${DATA_DIR}/uploads-${tenant}:/app/uploads:rw" \
|
||||||
|
-v "${DATA_DIR}/logs-${tenant}:/app/logs:rw" \
|
||||||
|
-v "${SECRETS_DIR}:/app/secrets:ro" \
|
||||||
|
-v /etc/localtime:/etc/localtime:ro \
|
||||||
|
-v /etc/timezone:/etc/timezone:ro \
|
||||||
|
--network kaopeilian-network \
|
||||||
|
--label "com.centurylinklabs.watchtower.enable=false" \
|
||||||
|
"$image"
|
||||||
|
|
||||||
|
# 连接到 prod-network
|
||||||
|
log_info "连接网络..."
|
||||||
|
docker network connect prod-network "$container_name" 2>/dev/null || true
|
||||||
|
|
||||||
|
# 等待容器启动
|
||||||
|
log_info "等待容器启动..."
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# 检查容器状态
|
||||||
|
local status=$(docker inspect "$container_name" --format '{{.State.Status}}' 2>/dev/null)
|
||||||
|
if [ "$status" = "running" ]; then
|
||||||
|
log_info "✓ ${container_name} 部署成功"
|
||||||
|
|
||||||
|
# 验证 secrets 挂载
|
||||||
|
if docker exec "$container_name" ls /app/secrets/coze_private_key.pem > /dev/null 2>&1; then
|
||||||
|
log_info "✓ secrets 挂载验证成功"
|
||||||
|
else
|
||||||
|
log_warn "✗ secrets 挂载验证失败"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_error "✗ ${container_name} 启动失败,状态: $status"
|
||||||
|
docker logs "$container_name" --tail 20
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 部署所有租户
|
||||||
|
deploy_all_tenants() {
|
||||||
|
local image_tag=${1:-main}
|
||||||
|
|
||||||
|
log_info "部署所有租户 (镜像标签: $image_tag)"
|
||||||
|
|
||||||
|
for tenant in "${ALL_TENANTS[@]}"; do
|
||||||
|
deploy_tenant "$tenant" "$image_tag"
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
log_info "所有租户部署完成"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 显示帮助
|
||||||
|
show_help() {
|
||||||
|
echo "用法: $0 <tenant_code|all> [image_tag]"
|
||||||
|
echo ""
|
||||||
|
echo "租户代码:"
|
||||||
|
echo " hua - 华尔倍丽"
|
||||||
|
echo " yy - 杨扬宠物"
|
||||||
|
echo " hl - 武汉禾丽"
|
||||||
|
echo " xy - 芯颜定制"
|
||||||
|
echo " fw - 飞沃"
|
||||||
|
echo " ex - 恩喜成都总院"
|
||||||
|
echo " cxw - 崔曦文"
|
||||||
|
echo " all - 所有租户"
|
||||||
|
echo ""
|
||||||
|
echo "镜像标签 (可选, 默认: main):"
|
||||||
|
echo " main - 生产环境"
|
||||||
|
echo " staging - 预发布环境"
|
||||||
|
echo " test - 测试环境"
|
||||||
|
echo ""
|
||||||
|
echo "示例:"
|
||||||
|
echo " $0 ex main # 部署 ex 租户"
|
||||||
|
echo " $0 all # 部署所有租户"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 主函数
|
||||||
|
main() {
|
||||||
|
local tenant=${1:-}
|
||||||
|
local image_tag=${2:-main}
|
||||||
|
|
||||||
|
if [ -z "$tenant" ] || [ "$tenant" = "-h" ] || [ "$tenant" = "--help" ]; then
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_prerequisites
|
||||||
|
|
||||||
|
if [ "$tenant" = "all" ]; then
|
||||||
|
deploy_all_tenants "$image_tag"
|
||||||
|
else
|
||||||
|
deploy_tenant "$tenant" "$image_tag"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
@@ -28,7 +28,8 @@ COPY package*.json ./
|
|||||||
RUN npm config set registry https://registry.npmmirror.com
|
RUN npm config set registry https://registry.npmmirror.com
|
||||||
|
|
||||||
# 安装所有依赖(包括开发依赖,跳过husky)
|
# 安装所有依赖(包括开发依赖,跳过husky)
|
||||||
RUN npm install --silent --ignore-scripts
|
# 注意:NODE_ENV=production 会跳过 devDependencies,所以用 --include=dev
|
||||||
|
RUN npm install --silent --ignore-scripts --include=dev
|
||||||
|
|
||||||
# 复制源代码
|
# 复制源代码
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -43,7 +44,8 @@ RUN echo "======================================" && \
|
|||||||
echo "======================================"
|
echo "======================================"
|
||||||
|
|
||||||
# 构建应用(使用环境变量中的API地址)
|
# 构建应用(使用环境变量中的API地址)
|
||||||
RUN npm run build
|
# 增加 Node.js 内存限制避免 OOM
|
||||||
|
RUN NODE_OPTIONS="--max-old-space-size=4096" npm run build
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# 生产阶段 - 轻量级nginx镜像
|
# 生产阶段 - 轻量级nginx镜像
|
||||||
|
|||||||
@@ -379,6 +379,8 @@ const menuConfig = [
|
|||||||
|
|
||||||
// 获取菜单路由
|
// 获取菜单路由
|
||||||
const menuRoutes = computed(() => {
|
const menuRoutes = computed(() => {
|
||||||
|
const userRole = authManager.getUserRole()
|
||||||
|
|
||||||
// 仅保留当前用户可访问的菜单项和启用的功能
|
// 仅保留当前用户可访问的菜单项和启用的功能
|
||||||
const filterChildren = (children: any[] = []) =>
|
const filterChildren = (children: any[] = []) =>
|
||||||
children.filter((child: any) => {
|
children.filter((child: any) => {
|
||||||
@@ -389,7 +391,22 @@ const menuRoutes = computed(() => {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 根据角色预过滤顶级菜单
|
||||||
|
const roleMenuFilter = (route: any): boolean => {
|
||||||
|
// 管理者中心:仅 admin 和 manager 可见
|
||||||
|
if (route.path === '/manager') {
|
||||||
|
return userRole === 'admin' || userRole === 'manager'
|
||||||
|
}
|
||||||
|
// 系统管理:仅 admin 可见
|
||||||
|
if (route.path === '/admin') {
|
||||||
|
return userRole === 'admin'
|
||||||
|
}
|
||||||
|
// 数据分析:所有登录用户可见(但子菜单会进一步过滤)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
return menuConfig
|
return menuConfig
|
||||||
|
.filter(roleMenuFilter) // 先按角色过滤顶级菜单
|
||||||
.map((route: any) => {
|
.map((route: any) => {
|
||||||
const next = { ...route }
|
const next = { ...route }
|
||||||
if (route.children && route.children.length > 0) {
|
if (route.children && route.children.length > 0) {
|
||||||
@@ -398,8 +415,10 @@ const menuRoutes = computed(() => {
|
|||||||
return next
|
return next
|
||||||
})
|
})
|
||||||
.filter((route: any) => {
|
.filter((route: any) => {
|
||||||
// 有子菜单且至少一个可访问
|
// 有子菜单的必须至少有一个可访问的子项
|
||||||
if (route.children && route.children.length > 0) return true
|
if (route.children !== undefined) {
|
||||||
|
return route.children.length > 0
|
||||||
|
}
|
||||||
// 无子菜单时检查自身路径
|
// 无子菜单时检查自身路径
|
||||||
return authManager.canAccessRoute(route.path)
|
return authManager.canAccessRoute(route.path)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -583,7 +583,7 @@ const loadMistakes = async () => {
|
|||||||
id: item.id,
|
id: item.id,
|
||||||
type: item.question_type || 'single',
|
type: item.question_type || 'single',
|
||||||
difficulty: 'medium', // 暂无此字段
|
difficulty: 'medium', // 暂无此字段
|
||||||
masteryStatus: 'unmastered', // 暂无此字段
|
masteryStatus: item.mastery_status || 'unmastered',
|
||||||
title: item.question_content,
|
title: item.question_content,
|
||||||
yourAnswer: item.user_answer,
|
yourAnswer: item.user_answer,
|
||||||
correctAnswer: item.correct_answer,
|
correctAnswer: item.correct_answer,
|
||||||
|
|||||||
@@ -4,7 +4,15 @@
|
|||||||
<div class="welcome-card card">
|
<div class="welcome-card card">
|
||||||
<div class="welcome-content">
|
<div class="welcome-content">
|
||||||
<h1 class="welcome-title">欢迎回来,{{ userName }}!</h1>
|
<h1 class="welcome-title">欢迎回来,{{ userName }}!</h1>
|
||||||
<p class="welcome-desc">今天是您学习的第 <span class="highlight">{{ learningDays }}</span> 天,继续加油!</p>
|
<p class="welcome-desc" v-if="userRole === 'trainee'">
|
||||||
|
今天是您学习的第 <span class="highlight">{{ learningDays }}</span> 天,继续加油!
|
||||||
|
</p>
|
||||||
|
<p class="welcome-desc" v-else-if="userRole === 'manager'">
|
||||||
|
管理您的团队,助力成员成长
|
||||||
|
</p>
|
||||||
|
<p class="welcome-desc" v-else>
|
||||||
|
系统运行正常,一切尽在掌控
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="welcome-image">
|
<div class="welcome-image">
|
||||||
<el-icon :size="120" color="#667eea">
|
<el-icon :size="120" color="#667eea">
|
||||||
@@ -13,8 +21,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 统计卡片 -->
|
<!-- 统计卡片 - 仅学员显示 -->
|
||||||
<div class="stats-grid">
|
<div class="stats-grid" v-if="userRole === 'trainee'">
|
||||||
<div class="stat-card card" v-for="stat in stats" :key="stat.title">
|
<div class="stat-card card" v-for="stat in stats" :key="stat.title">
|
||||||
<div class="stat-icon" :style="{ backgroundColor: stat.bgColor }">
|
<div class="stat-icon" :style="{ backgroundColor: stat.bgColor }">
|
||||||
<el-icon :size="24" :color="stat.color">
|
<el-icon :size="24" :color="stat.color">
|
||||||
@@ -24,7 +32,7 @@
|
|||||||
<div class="stat-content">
|
<div class="stat-content">
|
||||||
<div class="stat-value">{{ stat.value }}</div>
|
<div class="stat-value">{{ stat.value }}</div>
|
||||||
<div class="stat-title">{{ stat.title }}</div>
|
<div class="stat-title">{{ stat.title }}</div>
|
||||||
<div class="stat-trend" :class="stat.trend > 0 ? 'up' : 'down'">
|
<div class="stat-trend" :class="stat.trend > 0 ? 'up' : 'down'" v-if="stat.trend !== 0">
|
||||||
<el-icon :size="12">
|
<el-icon :size="12">
|
||||||
<component :is="stat.trend > 0 ? 'Top' : 'Bottom'" />
|
<component :is="stat.trend > 0 ? 'Top' : 'Bottom'" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -48,8 +56,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 最近考试 -->
|
<!-- 最近考试 - 仅学员显示 -->
|
||||||
<div class="recent-exams">
|
<div class="recent-exams" v-if="userRole === 'trainee'">
|
||||||
<h2 class="section-title">最近考试</h2>
|
<h2 class="section-title">最近考试</h2>
|
||||||
<div v-if="recentExams.length > 0" class="exam-list">
|
<div v-if="recentExams.length > 0" class="exam-list">
|
||||||
<div class="exam-item card" v-for="exam in recentExams" :key="exam.id">
|
<div class="exam-item card" v-for="exam in recentExams" :key="exam.id">
|
||||||
@@ -99,6 +107,7 @@ const router = useRouter()
|
|||||||
// 获取当前用户信息
|
// 获取当前用户信息
|
||||||
const currentUser = computed(() => authManager.getCurrentUser())
|
const currentUser = computed(() => authManager.getCurrentUser())
|
||||||
const userName = computed(() => currentUser.value?.full_name || currentUser.value?.username || '用户')
|
const userName = computed(() => currentUser.value?.full_name || currentUser.value?.username || '用户')
|
||||||
|
const userRole = computed(() => authManager.getUserRole())
|
||||||
const learningDays = ref(0)
|
const learningDays = ref(0)
|
||||||
|
|
||||||
// 统计数据
|
// 统计数据
|
||||||
@@ -156,37 +165,64 @@ const loadStatistics = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 快捷操作
|
// 快捷操作配置(包含角色限制)
|
||||||
const quickActions = ref([
|
const allQuickActions = [
|
||||||
{
|
{
|
||||||
title: '智能工牌分析',
|
title: '智能工牌分析',
|
||||||
desc: 'AI能力评估与成长路径规划',
|
desc: 'AI能力评估与成长路径规划',
|
||||||
icon: 'TrendCharts',
|
icon: 'TrendCharts',
|
||||||
color: '#e6a23c',
|
color: '#e6a23c',
|
||||||
path: '/trainee/growth-path'
|
path: '/trainee/growth-path',
|
||||||
|
roles: ['trainee'] // 仅学员可见
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '课程中心',
|
title: '课程中心',
|
||||||
desc: '查看可用课程',
|
desc: '查看可用课程',
|
||||||
icon: 'Collection',
|
icon: 'Collection',
|
||||||
color: '#67c23a',
|
color: '#67c23a',
|
||||||
path: '/trainee/course-center'
|
path: '/trainee/course-center',
|
||||||
|
roles: ['trainee', 'manager', 'admin'] // 所有角色可见
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '查分中心',
|
title: '查分中心',
|
||||||
desc: '查看成绩和分析报告',
|
desc: '查看成绩和分析报告',
|
||||||
icon: 'DataAnalysis',
|
icon: 'DataAnalysis',
|
||||||
color: '#409eff',
|
color: '#409eff',
|
||||||
path: '/trainee/score-report'
|
path: '/trainee/score-report',
|
||||||
|
roles: ['trainee'] // 仅学员可见
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'AI陪练',
|
title: 'AI陪练',
|
||||||
desc: '智能陪练系统',
|
desc: '智能陪练系统',
|
||||||
icon: 'ChatLineRound',
|
icon: 'ChatLineRound',
|
||||||
color: '#f56c6c',
|
color: '#f56c6c',
|
||||||
path: '/trainee/ai-practice-center'
|
path: '/trainee/ai-practice-center',
|
||||||
|
roles: ['trainee', 'manager', 'admin'] // 所有角色可见
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '团队看板',
|
||||||
|
desc: '查看团队学习情况',
|
||||||
|
icon: 'DataBoard',
|
||||||
|
color: '#667eea',
|
||||||
|
path: '/manager/team-dashboard',
|
||||||
|
roles: ['manager', 'admin'] // 管理者和管理员可见
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '课程管理',
|
||||||
|
desc: '管理培训课程内容',
|
||||||
|
icon: 'Notebook',
|
||||||
|
color: '#909399',
|
||||||
|
path: '/manager/course-management',
|
||||||
|
roles: ['manager', 'admin'] // 管理者和管理员可见
|
||||||
}
|
}
|
||||||
])
|
]
|
||||||
|
|
||||||
|
// 根据角色过滤快捷操作
|
||||||
|
const quickActions = computed(() => {
|
||||||
|
const role = userRole.value
|
||||||
|
if (!role) return []
|
||||||
|
return allQuickActions.filter(action => action.roles.includes(role))
|
||||||
|
})
|
||||||
|
|
||||||
// 最近考试
|
// 最近考试
|
||||||
const recentExams = ref<any[]>([])
|
const recentExams = ref<any[]>([])
|
||||||
|
|||||||
@@ -552,6 +552,13 @@
|
|||||||
<el-icon><Search /></el-icon>
|
<el-icon><Search /></el-icon>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
:plain="!isAllSelected"
|
||||||
|
@click="toggleSelectAll"
|
||||||
|
>
|
||||||
|
{{ isAllSelected ? '取消全选' : '全选' }}
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="available-positions">
|
<div class="available-positions">
|
||||||
@@ -719,6 +726,30 @@ const filteredAvailablePositions = computed(() => {
|
|||||||
return filtered
|
return filtered
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 是否全选
|
||||||
|
const isAllSelected = computed(() => {
|
||||||
|
if (filteredAvailablePositions.value.length === 0) return false
|
||||||
|
return filteredAvailablePositions.value.every(
|
||||||
|
(p: any) => selectedPositions.value.includes(p.id)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
// 全选/取消全选
|
||||||
|
const toggleSelectAll = () => {
|
||||||
|
if (isAllSelected.value) {
|
||||||
|
// 取消全选:移除当前筛选结果中的所有岗位
|
||||||
|
const filteredIds = filteredAvailablePositions.value.map((p: any) => p.id)
|
||||||
|
selectedPositions.value = selectedPositions.value.filter(
|
||||||
|
id => !filteredIds.includes(id)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// 全选:添加当前筛选结果中的所有岗位
|
||||||
|
const filteredIds = filteredAvailablePositions.value.map((p: any) => p.id)
|
||||||
|
const newSelection = new Set([...selectedPositions.value, ...filteredIds])
|
||||||
|
selectedPositions.value = Array.from(newSelection)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 考试设置相关
|
// 考试设置相关
|
||||||
const examSettingsLoading = ref(false)
|
const examSettingsLoading = ref(false)
|
||||||
const examSettings = reactive({
|
const examSettings = reactive({
|
||||||
@@ -2920,6 +2951,9 @@ const loadAvailablePositions = async () => {
|
|||||||
// 岗位选择器样式
|
// 岗位选择器样式
|
||||||
.position-selector-content {
|
.position-selector-content {
|
||||||
.selector-header {
|
.selector-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,14 @@
|
|||||||
<div class="ability-radar card">
|
<div class="ability-radar card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title">能力评估</h3>
|
<h3 class="card-title">能力评估</h3>
|
||||||
<el-button type="primary" size="small" @click="analyzeSmartBadgeData" :loading="analyzing">
|
<!-- AI智能工牌分析仅对学员开放 -->
|
||||||
|
<el-button
|
||||||
|
v-if="userInfo.role === 'trainee'"
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="analyzeSmartBadgeData"
|
||||||
|
:loading="analyzing"
|
||||||
|
>
|
||||||
<el-icon><TrendCharts /></el-icon>
|
<el-icon><TrendCharts /></el-icon>
|
||||||
AI 分析智能工牌数据
|
AI 分析智能工牌数据
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -302,7 +309,7 @@
|
|||||||
<p class="empty-description">
|
<p class="empty-description">
|
||||||
{{ analyzing ? '正在分析您的智能工牌数据,为您推荐最适合的课程' : '暂无智能工牌数据,请先使用智能工牌记录对话' }}
|
{{ analyzing ? '正在分析您的智能工牌数据,为您推荐最适合的课程' : '暂无智能工牌数据,请先使用智能工牌记录对话' }}
|
||||||
</p>
|
</p>
|
||||||
<el-button v-if="!analyzing" type="primary" @click="analyzeSmartBadgeData">
|
<el-button v-if="!analyzing && userInfo.role === 'trainee'" type="primary" @click="analyzeSmartBadgeData">
|
||||||
<el-icon><Refresh /></el-icon>
|
<el-icon><Refresh /></el-icon>
|
||||||
重新分析
|
重新分析
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|||||||
@@ -2,118 +2,134 @@
|
|||||||
<div class="practice-records-container">
|
<div class="practice-records-container">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1 class="page-title">陪练记录</h1>
|
<h1 class="page-title">陪练记录</h1>
|
||||||
<div class="header-actions">
|
|
||||||
<el-date-picker
|
|
||||||
v-model="dateRange"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="至"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
@change="handleDateChange"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" @click="refreshData">
|
|
||||||
<el-icon class="el-icon--left"><Refresh /></el-icon>
|
|
||||||
刷新数据
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 陪练统计概览 -->
|
<!-- 陪练统计概览 -->
|
||||||
<div class="stats-overview">
|
<div class="stats-section">
|
||||||
<div class="stat-card card" v-for="stat in practiceStats" :key="stat.label">
|
<div class="stat-card card">
|
||||||
<div class="stat-icon" :style="{ backgroundColor: stat.bgColor }">
|
<el-statistic title="总陪练次数" :value="practiceStatsData.totalCount">
|
||||||
<el-icon :size="32" :color="stat.color">
|
<template #suffix>
|
||||||
<component :is="stat.icon" />
|
<span style="font-size: 14px">次</span>
|
||||||
</el-icon>
|
</template>
|
||||||
|
</el-statistic>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat-content">
|
<div class="stat-card card">
|
||||||
<div class="stat-value">{{ stat.value }}</div>
|
<el-statistic title="平均评分" :value="practiceStatsData.avgScore" :precision="1">
|
||||||
<div class="stat-label">{{ stat.label }}</div>
|
<template #suffix>
|
||||||
<div class="stat-trend" :class="stat.trend > 0 ? 'up' : 'down'" v-if="stat.trend !== 0">
|
<span style="font-size: 14px">分</span>
|
||||||
<el-icon><component :is="stat.trend > 0 ? 'Top' : 'Bottom'" /></el-icon>
|
</template>
|
||||||
{{ Math.abs(stat.trend) }}%
|
</el-statistic>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="stat-card card">
|
||||||
|
<el-statistic title="总陪练时长" :value="practiceStatsData.totalHours" :precision="1">
|
||||||
|
<template #suffix>
|
||||||
|
<span style="font-size: 14px">小时</span>
|
||||||
|
</template>
|
||||||
|
</el-statistic>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="stat-card card">
|
||||||
|
<el-statistic title="本月进步" :value="practiceStatsData.monthImprovement">
|
||||||
|
<template #prefix>+</template>
|
||||||
|
<template #suffix>%</template>
|
||||||
|
</el-statistic>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 筛选区域 -->
|
<!-- 搜索和筛选 -->
|
||||||
<div class="filter-section card">
|
<div class="filter-section card">
|
||||||
<el-form :inline="true" :model="filterForm" class="filter-form">
|
<div class="filter-toolbar">
|
||||||
<el-form-item label="关键词">
|
<!-- 搜索框 -->
|
||||||
|
<div class="search-box">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="filterForm.keyword"
|
v-model="filterForm.keyword"
|
||||||
placeholder="搜索陪练内容或场景"
|
placeholder="搜索陪练内容或场景..."
|
||||||
clearable
|
clearable
|
||||||
@input="handleRealTimeSearch"
|
@input="handleRealTimeSearch"
|
||||||
style="width: 200px"
|
class="search-input"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon><Search /></el-icon>
|
<el-icon class="search-icon"><Search /></el-icon>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</div>
|
||||||
<el-form-item label="陪练场景">
|
|
||||||
|
<!-- 筛选项 -->
|
||||||
|
<div class="filter-items">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="filterForm.scene"
|
v-model="filterForm.scene"
|
||||||
placeholder="全部场景"
|
placeholder="陪练场景"
|
||||||
clearable
|
clearable
|
||||||
@change="handleRealTimeSearch"
|
@change="handleRealTimeSearch"
|
||||||
style="width: 120px"
|
class="filter-select"
|
||||||
>
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<span class="select-prefix-icon">🎯</span>
|
||||||
|
</template>
|
||||||
<el-option label="客户咨询" value="customer_consultation" />
|
<el-option label="客户咨询" value="customer_consultation" />
|
||||||
<el-option label="美容护理" value="beauty_care" />
|
<el-option label="美容护理" value="beauty_care" />
|
||||||
<el-option label="产品介绍" value="product_introduction" />
|
<el-option label="产品介绍" value="product_introduction" />
|
||||||
<el-option label="问题处理" value="problem_handling" />
|
<el-option label="问题处理" value="problem_handling" />
|
||||||
<el-option label="服务礼仪" value="service_etiquette" />
|
<el-option label="服务礼仪" value="service_etiquette" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="陪练结果">
|
|
||||||
<el-select
|
<el-select
|
||||||
v-model="filterForm.result"
|
v-model="filterForm.result"
|
||||||
placeholder="全部结果"
|
placeholder="陪练结果"
|
||||||
clearable
|
clearable
|
||||||
@change="handleRealTimeSearch"
|
@change="handleRealTimeSearch"
|
||||||
style="width: 120px"
|
class="filter-select"
|
||||||
>
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<span class="select-prefix-icon">⭐</span>
|
||||||
|
</template>
|
||||||
<el-option label="优秀" value="excellent" />
|
<el-option label="优秀" value="excellent" />
|
||||||
<el-option label="良好" value="good" />
|
<el-option label="良好" value="good" />
|
||||||
<el-option label="一般" value="average" />
|
<el-option label="一般" value="average" />
|
||||||
<el-option label="需改进" value="needs_improvement" />
|
<el-option label="需改进" value="needs_improvement" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="时间周期">
|
|
||||||
<el-select
|
<el-select
|
||||||
v-model="filterForm.timePeriod"
|
v-model="filterForm.timePeriod"
|
||||||
placeholder="全部时间"
|
placeholder="时间周期"
|
||||||
clearable
|
clearable
|
||||||
@change="handleRealTimeSearch"
|
@change="handleRealTimeSearch"
|
||||||
style="width: 120px"
|
class="filter-select"
|
||||||
>
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<span class="select-prefix-icon">📅</span>
|
||||||
|
</template>
|
||||||
<el-option label="最近一周" value="week" />
|
<el-option label="最近一周" value="week" />
|
||||||
<el-option label="最近一月" value="month" />
|
<el-option label="最近一月" value="month" />
|
||||||
<el-option label="最近三月" value="quarter" />
|
<el-option label="最近三月" value="quarter" />
|
||||||
<el-option label="自定义" value="custom" />
|
<el-option label="自定义" value="custom" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item v-if="filterForm.timePeriod === 'custom'" label="自定义时间">
|
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
|
v-if="filterForm.timePeriod === 'custom'"
|
||||||
v-model="customDateRange"
|
v-model="customDateRange"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
range-separator="至"
|
range-separator="~"
|
||||||
start-placeholder="开始日期"
|
start-placeholder="开始"
|
||||||
end-placeholder="结束日期"
|
end-placeholder="结束"
|
||||||
@change="handleRealTimeSearch"
|
@change="handleRealTimeSearch"
|
||||||
style="width: 240px"
|
class="date-picker"
|
||||||
|
format="MM/DD"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</div>
|
||||||
<el-form-item>
|
|
||||||
<el-button @click="handleReset">
|
<!-- 重置按钮 -->
|
||||||
<el-icon class="el-icon--left"><Refresh /></el-icon>
|
<el-button
|
||||||
|
v-if="hasActiveFilters"
|
||||||
|
@click="handleReset"
|
||||||
|
class="reset-btn"
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
>
|
||||||
|
<el-icon><Refresh /></el-icon>
|
||||||
重置
|
重置
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</div>
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<!-- 当前筛选条件显示 -->
|
<!-- 当前筛选条件显示 -->
|
||||||
<div v-if="hasActiveFilters" class="filter-tags">
|
<div v-if="hasActiveFilters" class="filter-tags">
|
||||||
@@ -123,6 +139,7 @@
|
|||||||
closable
|
closable
|
||||||
@close="clearKeyword"
|
@close="clearKeyword"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
effect="light"
|
||||||
>
|
>
|
||||||
关键词:{{ filterForm.keyword }}
|
关键词:{{ filterForm.keyword }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
@@ -283,8 +300,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 对话记录 -->
|
<!-- 对话记录 -->
|
||||||
<div class="conversation-replay">
|
<div class="conversation-replay" v-loading="replayLoading">
|
||||||
<div class="conversation-list">
|
<!-- 空状态提示 -->
|
||||||
|
<el-empty
|
||||||
|
v-if="!replayLoading && (!currentRecord.conversation || currentRecord.conversation.length === 0)"
|
||||||
|
description="暂无对话记录"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 对话列表 -->
|
||||||
|
<div class="conversation-list" v-else>
|
||||||
<div
|
<div
|
||||||
v-for="(message, index) in currentRecord.conversation"
|
v-for="(message, index) in currentRecord.conversation"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -342,6 +366,7 @@ const total = ref(0)
|
|||||||
|
|
||||||
// 弹窗状态
|
// 弹窗状态
|
||||||
const replayDialogVisible = ref(false)
|
const replayDialogVisible = ref(false)
|
||||||
|
const replayLoading = ref(false)
|
||||||
const currentRecord = ref<any>(null)
|
const currentRecord = ref<any>(null)
|
||||||
|
|
||||||
// 筛选表单
|
// 筛选表单
|
||||||
@@ -373,6 +398,17 @@ interface PracticeStat {
|
|||||||
// 陪练统计数据
|
// 陪练统计数据
|
||||||
const practiceStats = ref<PracticeStat[]>([])
|
const practiceStats = ref<PracticeStat[]>([])
|
||||||
|
|
||||||
|
// 简化的统计数据(用于 el-statistic 组件)
|
||||||
|
const practiceStatsData = computed(() => {
|
||||||
|
const stats = practiceStats.value
|
||||||
|
return {
|
||||||
|
totalCount: parseInt(stats.find(s => s.label === '总陪练次数')?.value || '0'),
|
||||||
|
avgScore: parseFloat(stats.find(s => s.label === '平均评分')?.value || '0'),
|
||||||
|
totalHours: parseFloat(stats.find(s => s.label === '总陪练时长')?.value?.replace('h', '') || '0'),
|
||||||
|
monthImprovement: parseInt(stats.find(s => s.label === '本月进步')?.value?.replace('+', '').replace('%', '') || '0')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// 陪练记录数据(直接使用后端返回的已筛选、已分页的数据)
|
// 陪练记录数据(直接使用后端返回的已筛选、已分页的数据)
|
||||||
const recordsList = ref([])
|
const recordsList = ref([])
|
||||||
|
|
||||||
@@ -608,9 +644,32 @@ const viewPracticeReport = (record: any) => {
|
|||||||
/**
|
/**
|
||||||
* 回放陪练对话
|
* 回放陪练对话
|
||||||
*/
|
*/
|
||||||
const replayPractice = (record: any) => {
|
const replayPractice = async (record: any) => {
|
||||||
currentRecord.value = record
|
try {
|
||||||
|
// 先设置基本信息并打开弹窗
|
||||||
|
currentRecord.value = { ...record, conversation: [] }
|
||||||
replayDialogVisible.value = true
|
replayDialogVisible.value = true
|
||||||
|
replayLoading.value = true
|
||||||
|
|
||||||
|
// 调用 API 获取对话详情
|
||||||
|
const response: any = await practiceApi.getPracticeReport(record.sessionId)
|
||||||
|
|
||||||
|
if (response.code === 200 && response.data?.analysis?.dialogue_review) {
|
||||||
|
// 转换对话数据格式
|
||||||
|
const dialogueReview = response.data.analysis.dialogue_review
|
||||||
|
currentRecord.value.conversation = dialogueReview.map((item: any) => ({
|
||||||
|
role: item.speaker === 'user' ? 'user' : 'ai',
|
||||||
|
content: item.content,
|
||||||
|
timestamp: item.time || '',
|
||||||
|
feedback: item.comment || ''
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('获取对话详情失败:', error)
|
||||||
|
ElMessage.error('获取对话详情失败,请稍后重试')
|
||||||
|
} finally {
|
||||||
|
replayLoading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -738,95 +797,143 @@ const loadRecords = async () => {
|
|||||||
max-width: 1400px;
|
max-width: 1400px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
||||||
|
}
|
||||||
|
|
||||||
.page-header {
|
.page-header {
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
|
|
||||||
.page-title {
|
.page-title {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #333;
|
color: #1f2937;
|
||||||
}
|
|
||||||
|
|
||||||
.header-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-overview {
|
// 统计区域 - 参考错题分析风格
|
||||||
|
.stats-section {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
|
|
||||||
.stat-card {
|
.stat-card {
|
||||||
padding: 24px;
|
text-align: center;
|
||||||
display: flex;
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||||
align-items: center;
|
|
||||||
gap: 20px;
|
|
||||||
|
|
||||||
.stat-icon {
|
&:hover {
|
||||||
width: 64px;
|
transform: translateY(-2px);
|
||||||
height: 64px;
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||||
border-radius: 16px;
|
}
|
||||||
display: flex;
|
}
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.stat-content {
|
// 筛选区域 - 参考错题分析现代风格
|
||||||
|
.filter-section {
|
||||||
|
padding: 16px 20px;
|
||||||
|
|
||||||
|
.filter-toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
flex: 0 0 280px;
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
:deep(.el-input__wrapper) {
|
||||||
|
border-radius: 20px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
box-shadow: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
padding: 4px 16px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
&:hover, &:focus-within {
|
||||||
|
background: #fff;
|
||||||
|
border-color: #409eff;
|
||||||
|
box-shadow: 0 2px 12px rgba(64, 158, 255, 0.15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-items {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
.stat-value {
|
.filter-select {
|
||||||
font-size: 32px;
|
width: 130px;
|
||||||
font-weight: 700;
|
|
||||||
color: #333;
|
:deep(.el-select__wrapper) {
|
||||||
line-height: 1;
|
border-radius: 8px;
|
||||||
margin-bottom: 8px;
|
background: #f5f7fa;
|
||||||
|
box-shadow: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
min-height: 36px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #fff;
|
||||||
|
border-color: #dcdfe6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stat-label {
|
&.is-focused {
|
||||||
|
background: #fff;
|
||||||
|
border-color: #409eff;
|
||||||
|
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-prefix-icon {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #666;
|
margin-right: 4px;
|
||||||
margin-bottom: 8px;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.stat-trend {
|
.date-picker {
|
||||||
display: flex;
|
:deep(.el-input__wrapper) {
|
||||||
align-items: center;
|
border-radius: 8px;
|
||||||
gap: 4px;
|
background: #f5f7fa;
|
||||||
font-size: 12px;
|
box-shadow: none;
|
||||||
font-weight: 500;
|
border: 1px solid transparent;
|
||||||
|
|
||||||
&.up {
|
&:hover {
|
||||||
color: #67c23a;
|
background: #fff;
|
||||||
}
|
border-color: #dcdfe6;
|
||||||
|
|
||||||
&.down {
|
|
||||||
color: #f56c6c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-section {
|
.reset-btn {
|
||||||
padding: 20px;
|
border-radius: 8px;
|
||||||
margin-bottom: 20px;
|
padding: 8px 16px;
|
||||||
|
font-size: 13px;
|
||||||
|
|
||||||
.filter-form {
|
.el-icon {
|
||||||
.el-form-item {
|
margin-right: 4px;
|
||||||
margin-bottom: 0;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-tags {
|
.filter-tags {
|
||||||
margin-top: 16px;
|
margin-top: 14px;
|
||||||
padding-top: 16px;
|
padding-top: 14px;
|
||||||
border-top: 1px solid #f0f0f0;
|
border-top: 1px solid #f0f0f0;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -834,34 +941,54 @@ const loadRecords = async () => {
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
||||||
.filter-label {
|
.filter-label {
|
||||||
color: #666;
|
color: #606266;
|
||||||
font-size: 14px;
|
font-size: 13px;
|
||||||
margin-right: 8px;
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tag {
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 0 12px;
|
||||||
|
height: 28px;
|
||||||
|
line-height: 26px;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clear-all-btn {
|
.clear-all-btn {
|
||||||
margin-left: 8px;
|
margin-left: auto;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-result-info {
|
.search-result-info {
|
||||||
margin-top: 12px;
|
margin-top: 14px;
|
||||||
padding-top: 12px;
|
padding-top: 14px;
|
||||||
border-top: 1px solid #f0f0f0;
|
border-top: 1px solid #f0f0f0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
.result-count {
|
.result-count {
|
||||||
color: #666;
|
color: #606266;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
strong {
|
strong {
|
||||||
color: #409eff;
|
color: #409eff;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-hint {
|
.filter-hint {
|
||||||
color: #e6a23c;
|
color: #e6a23c;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
background: #fdf6ec;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -891,6 +1018,26 @@ const loadRecords = async () => {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-top: 24px;
|
margin-top: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 表格行悬浮效果
|
||||||
|
:deep(.el-table__row) {
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.2s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 操作按钮样式优化
|
||||||
|
:deep(.el-button--link) {
|
||||||
|
padding: 4px 8px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(64, 158, 255, 0.1);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.replay-content {
|
.replay-content {
|
||||||
@@ -1001,25 +1148,33 @@ const loadRecords = async () => {
|
|||||||
// 响应式设计
|
// 响应式设计
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.practice-records-container {
|
.practice-records-container {
|
||||||
.page-header {
|
.stats-section {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-section {
|
||||||
|
.filter-toolbar {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: stretch;
|
||||||
gap: 16px;
|
|
||||||
|
|
||||||
.header-actions {
|
.search-box {
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.search-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-overview {
|
.filter-items {
|
||||||
grid-template-columns: 1fr;
|
width: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.filter-form {
|
.filter-select {
|
||||||
.el-form-item {
|
flex: 1;
|
||||||
display: block;
|
min-width: 100px;
|
||||||
margin-bottom: 16px !important;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1032,4 +1187,12 @@ const loadRecords = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.practice-records-container {
|
||||||
|
.stats-section {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user