extends Node class_name SceneLoader var ConfigParams = preload("res://config_params.gd") func _ready(): # 监听JavaScript发送的场景名称 var training_name = JavaScriptBridge.eval(""" var urlParams = new URLSearchParams(window.location.search); urlParams.get('name'); """) var token = JavaScriptBridge.eval(""" var urlParams = new URLSearchParams(window.location.search); urlParams.get('token'); """) print(training_name, ", token=", token) ConfigParams.Token = token if not training_name: $ErrMsg.text = "未指定实训" else: _on_scene_name_received(training_name) func _on_scene_name_received(training_name): print("load training: ", training_name) var scene = load("res://trainings/" + training_name + ".tscn") if not scene: $ErrMsg.text = "未找到实训: %s" % training_name if scene: get_tree().change_scene_to_packed(scene)