|
|
@@ -85,14 +85,14 @@ export const useClassroom = ({ user }:{ user : User }) => {
|
|
|
// 状态管理
|
|
|
// const [userId, setUserId] = useState<string>(''); // 保持string类型
|
|
|
|
|
|
- const [searchParams] = useSearchParams();
|
|
|
+ const pathParams = useParams()
|
|
|
const userId = user.id.toString();
|
|
|
const [isCameraOn, setIsCameraOn] = useState<boolean>(false);
|
|
|
const [isAudioOn, setIsAudioOn] = useState<boolean>(false);
|
|
|
const [isScreenSharing, setIsScreenSharing] = useState<boolean>(false);
|
|
|
const [className, setClassName] = useState<string>('');
|
|
|
- const [role, setRole] = useState<Role>(searchParams.get('role') === Role.Teacher ? Role.Teacher : Role.Student);
|
|
|
- const [classId, setClassId] = useState<string>('');
|
|
|
+ const [role, setRole] = useState<Role>(pathParams['role'] === Role.Teacher ? Role.Teacher : Role.Student);
|
|
|
+ const [classId, setClassId] = useState<string>(pathParams['classId'] || '');
|
|
|
const [isLoggedIn, setIsLoggedIn] = useState<boolean>(false);
|
|
|
const [isJoinedClass, setIsJoinedClass] = useState<boolean>(false);
|
|
|
const [msgText, setMsgText] = useState<string>('');
|