|
|
@@ -14,6 +14,28 @@ import pauseImage from '@/assets/images/blockly/component/pause.png';
|
|
|
import play_soundImage from '@/assets/images/blockly/component/sound.png';
|
|
|
import constructImage from '@/assets/images/blockly/component/construct.png';
|
|
|
|
|
|
+// 积木形状字典
|
|
|
+const BLOCKLY_SHAPE_DICT = {
|
|
|
+ SQUARE_GEM: { value: 'square_gem', label: '正方形宝石' }, // 正方形宝石
|
|
|
+ TRIANGLE_GEM: { value: 'triangle_gem', label: '三角形宝石' }, // 三角形宝石
|
|
|
+ RED_MARK: { value: 'red_mark', label: '红色标记' }, // 红色标记
|
|
|
+ GREEN_MARK: { value: 'green_mark', label: '绿色标记' } // 绿色标记
|
|
|
+};
|
|
|
+
|
|
|
+// 地图元素类型字典
|
|
|
+const BLOCKLY_MAP_TYPE_DICT = {
|
|
|
+ ICE: 'ice', // 冰块
|
|
|
+ TASK: 'task', // 钥匙
|
|
|
+ ITEM: 'item', // 物品
|
|
|
+ TRAP: 'trap' // 陷阱
|
|
|
+};
|
|
|
+
|
|
|
+// 自定义积木字典
|
|
|
+const BLOCKLY_CUSTOMIZE_DICT = {
|
|
|
+ PAUSE: 'pause', // 暂停
|
|
|
+ PLAY_SOUND: 'play_sound', // 播放音效
|
|
|
+ CONSTRUCT: 'construct' // 修建
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
* 定义所有可用的自定义积木配置
|
|
|
@@ -235,12 +257,7 @@ const availableBlocks = {
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "SHAPE",
|
|
|
- "options": [
|
|
|
- ["正方形", "square"],
|
|
|
- ["长方形", "rectangle"],
|
|
|
- ["圆形", "circle"],
|
|
|
- ["三角形", "triangle"]
|
|
|
- ]
|
|
|
+ "options": Object.values(BLOCKLY_SHAPE_DICT).map(shape => [shape.label, shape.value])
|
|
|
}
|
|
|
],
|
|
|
"output": "Boolean",
|
|
|
@@ -652,6 +669,9 @@ export function getAllPythonGeneratorsConfig() {
|
|
|
return {...availablePythonGenerators};
|
|
|
}
|
|
|
|
|
|
+// 导出字典常量
|
|
|
+export { BLOCKLY_SHAPE_DICT, BLOCKLY_MAP_TYPE_DICT, BLOCKLY_CUSTOMIZE_DICT };
|
|
|
+
|
|
|
export default {
|
|
|
registerCustomBlocks,
|
|
|
registerJavaScriptGenerators,
|
|
|
@@ -659,5 +679,8 @@ export default {
|
|
|
setupBlocklyChineseLocale,
|
|
|
initBlockly,
|
|
|
getAllBlocksConfig,
|
|
|
- getAllGeneratorsConfig
|
|
|
+ getAllGeneratorsConfig,
|
|
|
+ BLOCKLY_SHAPE_DICT,
|
|
|
+ BLOCKLY_MAP_TYPE_DICT,
|
|
|
+ BLOCKLY_CUSTOMIZE_DICT
|
|
|
};
|