Просмотр исходного кода

✨ feat(admin): 添加语音转文字功能页面

- 在管理菜单中添加语音转文字功能入口
- 创建AgoraSTT页面组件并配置路由
- 添加语音转文字页面的导航和访问权限

✅ test(e2e): 优化Agora STT页面测试

- 为AgoraSTTPage添加goto方法,支持直接访问页面
- 简化测试前置步骤,直接导航到语音转文字页面
yourname 4 месяцев назад
Родитель
Сommit
f05f52fe57

+ 9 - 1
src/client/admin/menu.tsx

@@ -8,7 +8,8 @@ import {
   LogOut,
   LogOut,
   BarChart3,
   BarChart3,
   LayoutDashboard,
   LayoutDashboard,
-  File
+  File,
+  Mic
 } from 'lucide-react';
 } from 'lucide-react';
 
 
 export interface MenuItem {
 export interface MenuItem {
@@ -94,6 +95,13 @@ export const useMenu = () => {
       path: '/admin/files',
       path: '/admin/files',
       permission: 'file:manage'
       permission: 'file:manage'
     },
     },
+    {
+      key: 'agora-stt',
+      label: '语音转文字',
+      icon: <Mic className="h-4 w-4" />,
+      path: '/admin/agora-stt',
+      permission: 'agora-stt:use'
+    },
     {
     {
       key: 'analytics',
       key: 'analytics',
       label: '数据分析',
       label: '数据分析',

+ 20 - 0
src/client/admin/pages/AgoraSTT.tsx

@@ -0,0 +1,20 @@
+import React from 'react';
+import { AgoraSTTComponent } from '../components/agora-stt/AgoraSTTComponent';
+
+/**
+ * Agora语音转文字功能页面
+ */
+export const AgoraSTTPage: React.FC = () => {
+  return (
+    <div className="space-y-6">
+      <div>
+        <h1 className="text-3xl font-bold tracking-tight">语音转文字</h1>
+        <p className="text-muted-foreground">
+          实时语音识别和转录功能,支持多种语言和实时结果展示
+        </p>
+      </div>
+
+      <AgoraSTTComponent />
+    </div>
+  );
+};

+ 6 - 0
src/client/admin/routes.tsx

@@ -8,6 +8,7 @@ import { DashboardPage } from './pages/Dashboard';
 import { UsersPage } from './pages/Users';
 import { UsersPage } from './pages/Users';
 import { LoginPage } from './pages/Login';
 import { LoginPage } from './pages/Login';
 import { FilesPage } from './pages/Files';
 import { FilesPage } from './pages/Files';
+import { AgoraSTTPage } from './pages/AgoraSTT';
 
 
 export const router = createBrowserRouter([
 export const router = createBrowserRouter([
   {
   {
@@ -45,6 +46,11 @@ export const router = createBrowserRouter([
         element: <FilesPage />,
         element: <FilesPage />,
         errorElement: <ErrorPage />
         errorElement: <ErrorPage />
       },
       },
+      {
+        path: 'agora-stt',
+        element: <AgoraSTTPage />,
+        errorElement: <ErrorPage />
+      },
       {
       {
         path: '*',
         path: '*',
         element: <NotFoundPage />,
         element: <NotFoundPage />,

+ 7 - 0
tests/e2e/pages/admin/agora-stt.page.ts

@@ -64,6 +64,13 @@ export class AgoraSTTPage {
     await this.expectToBeVisible();
     await this.expectToBeVisible();
   }
   }
 
 
+  async goto() {
+    // 直接访问Agora STT页面URL
+    await this.page.goto('/admin/agora-stt');
+    await this.page.waitForLoadState('networkidle');
+    await this.expectToBeVisible();
+  }
+
   async joinChannel() {
   async joinChannel() {
     await this.joinChannelButton.click();
     await this.joinChannelButton.click();
     await expect(this.connectionStatusBadge).toHaveText('已连接');
     await expect(this.connectionStatusBadge).toHaveText('已连接');

+ 3 - 4
tests/e2e/specs/admin/agora-stt.spec.ts

@@ -2,14 +2,13 @@ import { test, expect } from '../../utils/test-setup';
 import testUsers from '../../fixtures/test-users.json' with { type: 'json' };
 import testUsers from '../../fixtures/test-users.json' with { type: 'json' };
 
 
 test.describe('Agora实时语音转录功能', () => {
 test.describe('Agora实时语音转录功能', () => {
-  test.beforeEach(async ({ adminLoginPage, dashboardPage, agoraSTTPage }) => {
+  test.beforeEach(async ({ adminLoginPage, agoraSTTPage }) => {
     // 以管理员身份登录
     // 以管理员身份登录
     await adminLoginPage.goto();
     await adminLoginPage.goto();
     await adminLoginPage.login(testUsers.admin.username, testUsers.admin.password);
     await adminLoginPage.login(testUsers.admin.username, testUsers.admin.password);
-    await dashboardPage.expectToBeVisible();
 
 
-    // 导航到Agora STT页面
-    await agoraSTTPage.navigateFromDashboard(dashboardPage);
+    // 直接访问Agora STT页面
+    await agoraSTTPage.goto();
   });
   });
 
 
   test('Agora STT页面加载', async ({ agoraSTTPage }) => {
   test('Agora STT页面加载', async ({ agoraSTTPage }) => {