Browse Source

✨ feat(client): 默认路由切换为移动端

- 注释掉原移动端路由判断
- 将默认路由从home/index改为mobile/index

🐛 fix(mobile): 修复教室状态判断错误

- 移除classroomData.status的Number转换
- 直接与ClassroomStatus.OPEN枚举值比较

♻️ refactor(server): 调整alivc-im脚本加载条件

- 将脚本加载条件从/mobile路径改为非/admin路径

🔧 chore(entity): 清理classroom-data实体定义

- 移除status字段定义中的length属性,enum类型不需要指定长度
yourname 5 months ago
parent
commit
9a7bdd8258

+ 3 - 3
src/client/index.tsx

@@ -1,8 +1,8 @@
 // 如果当前是在 /big 下
 if (window.location.pathname.startsWith('/admin')) {
   import('./admin/index')
-} else if (window.location.pathname.startsWith('/mobile')) {
-  import('./mobile/index')
+// } else if (window.location.pathname.startsWith('/mobile')) {
+//   import('./mobile/index')
 } else {
-  import('./home/index')
+  import('./mobile/index')
 }

+ 2 - 2
src/client/mobile/components/Exam/ExamCard.tsx

@@ -5,10 +5,10 @@ import dayjs from 'dayjs';
 import { message } from 'antd';
 import { useSocketClient } from './hooks/useSocketClient';
 import { classroomDataClient } from '@/client/api';
-import { ClassroomStatus } from '@/share/types_stock';
 import type { QuizState } from './types';
 import type { AnswerRecord, Answer } from './types';
 import { useAuth } from '@/client/mobile/hooks/AuthProvider';
+import { ClassroomStatus } from '@/server/modules/classroom/classroom-data.entity';
 
 
 
@@ -56,7 +56,7 @@ export default function ExamCard() {
       return;
     }
     
-    if (classroomData && Number(classroomData.status) !== ClassroomStatus.OPEN) {
+    if (classroomData && classroomData.status !== ClassroomStatus.OPEN) {
       message.error('该教室已关闭');
       // globalThis.location.href = '/exam';
       navigate('/mobile')

+ 1 - 1
src/server/index.tsx

@@ -83,7 +83,7 @@ app.get('/*', (c) => {
   
   return c.render(
     <>
-      {c.req.path.startsWith('/mobile') && <script src="https://g.alicdn.com/apsara-media-box/imp-interaction/1.6.1/alivc-im.iife.js"></script>}
+      {!c.req.path.startsWith('/admin') && <script src="https://g.alicdn.com/apsara-media-box/imp-interaction/1.6.1/alivc-im.iife.js"></script>}
       <div id="root"></div>
     </>
   )

+ 1 - 1
src/server/modules/classroom/classroom-data.entity.ts

@@ -36,7 +36,7 @@ export class ClassroomData {
   @Column({ name: 'code', type: 'varchar', length: 255, nullable: true, comment: '代码' })
   code!: string | null;
 
-  @Column({ name: 'status', type: 'enum', enum:ClassroomStatus, length: 255, nullable: true, comment: '状态' })
+  @Column({ name: 'status', type: 'enum', enum:ClassroomStatus, nullable: true, comment: '状态' })
   status!: ClassroomStatus | null;
 
   @Column({ name: 'spare', type: 'varchar', length: 255, nullable: true, comment: '备用' })