|
|
@@ -111,9 +111,9 @@
|
|
|
|
|
|
<div class="workspace-section">
|
|
|
<div class="controls">
|
|
|
- <button id="runCode" @click="runCode">运行代码</button>
|
|
|
+ <button id="runCode" @click="runCode" v-if="!isRunning">运行代码</button>
|
|
|
+ <button @click="resetPlayer" v-if="isRunning">重置玩家</button>
|
|
|
<button @click="clearWorkspace">清空工作区</button>
|
|
|
- <button @click="resetPlayer">重置玩家</button>
|
|
|
</div>
|
|
|
|
|
|
<div id="blocklyDiv"></div>
|
|
|
@@ -259,6 +259,8 @@ let currentExecutionPromise = null;
|
|
|
let executionAbortController = null;
|
|
|
// 添加响应式的容器尺寸
|
|
|
const mapContainerDimensions = ref({ width: 0, height: 0 });
|
|
|
+// 用于控制运行/重置按钮状态
|
|
|
+const isRunning = ref(false);
|
|
|
|
|
|
// 暂停模块-倒计时相关状态
|
|
|
const showCountdown = ref(false);
|
|
|
@@ -1564,8 +1566,8 @@ window.isFinish = async function() {
|
|
|
|
|
|
// 运行代码
|
|
|
const runCode = async () => {
|
|
|
+ isRunning.value = true;
|
|
|
try {
|
|
|
- await resetPlayer();
|
|
|
await new Promise(resolve => setTimeout(resolve, CONFIG.DELAY.RESET_DELAY));
|
|
|
// 重置执行标志,允许新的执行
|
|
|
shouldStopExecution = false;
|
|
|
@@ -1636,14 +1638,9 @@ const runCode = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-// 清空工作区
|
|
|
-const clearWorkspace = () => {
|
|
|
- workspace.clear();
|
|
|
- showGameMessage('工作区已清空', 'info');
|
|
|
-};
|
|
|
-
|
|
|
// 重置玩家位置和状态
|
|
|
-const resetPlayer = () => {
|
|
|
+const resetPlayer = async () => {
|
|
|
+ isRunning.value = false;
|
|
|
// 设置标志强制停止所有执行
|
|
|
shouldStopExecution = true;
|
|
|
|
|
|
@@ -1673,6 +1670,12 @@ const resetPlayer = () => {
|
|
|
gameState.player.isSliding = false; // 重置滑行状态
|
|
|
};
|
|
|
|
|
|
+// 清空工作区
|
|
|
+const clearWorkspace = () => {
|
|
|
+ workspace.clear();
|
|
|
+ showGameMessage('工作区已清空', 'info');
|
|
|
+};
|
|
|
+
|
|
|
// 更新地图容器尺寸的函数
|
|
|
function updateMapContainerDimensions() {
|
|
|
const mapContainer = document.querySelector('.map-container');
|