|
|
@@ -137,6 +137,16 @@ async function generateImToken(userId: string, role: string): Promise<string> {
|
|
|
}
|
|
|
|
|
|
export const ClassroomPage = () => {
|
|
|
+ // 解析URL参数
|
|
|
+ useEffect(() => {
|
|
|
+ const queryParams = new URLSearchParams(window.location.search);
|
|
|
+ const urlClassId = queryParams.get('classId');
|
|
|
+ if (urlClassId) {
|
|
|
+ setClassId(urlClassId);
|
|
|
+ showMessage(`从分享链接获取课堂ID: ${urlClassId}`);
|
|
|
+ }
|
|
|
+ }, []);
|
|
|
+
|
|
|
// 状态管理
|
|
|
const [userId, setUserId] = useState<string>('');
|
|
|
const [className, setClassName] = useState<string>('');
|
|
|
@@ -365,8 +375,7 @@ export const ClassroomPage = () => {
|
|
|
setErrorMessage('');
|
|
|
showToast('success', '登录成功');
|
|
|
|
|
|
- // 登录后获取分享链接占位符
|
|
|
- setShareLink(`${window.location.href.split('?')[0]}?classId=${classId || '12345'}`);
|
|
|
+ // 登录成功,不生成分享链接(将在课堂创建成功后生成)
|
|
|
} catch (err: any) {
|
|
|
setErrorMessage(`登录失败: ${err.message}`);
|
|
|
showToast('error', '登录失败');
|
|
|
@@ -376,6 +385,12 @@ export const ClassroomPage = () => {
|
|
|
// 加入课堂
|
|
|
const joinClass = async (classId: string): Promise<void> => {
|
|
|
if (!imEngine.current || !aliRtcEngine.current) return;
|
|
|
+
|
|
|
+ if (!classId) {
|
|
|
+ setErrorMessage('课堂ID不能为空');
|
|
|
+ showToast('error', '请输入有效的课堂ID');
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
// 加入IM群组
|