Quellcode durchsuchen

更新积木图标

liyanbo vor 4 Monaten
Ursprung
Commit
4285eb6bfa

+ 44 - 37
src/api/blockly/blockly.js

@@ -3,7 +3,14 @@ import 'blockly/msg/zh-hans';
 import { javascriptGenerator } from "blockly/javascript";
 import { pythonGenerator } from "blockly/python";
 // 导入图片资源
-import xianqianImage from '@/assets/images/blockly/component/xianqian.png';
+import about_turnImage from '@/assets/images/blockly/component/about_turn.png';
+import move_backwardImage from '@/assets/images/blockly/component/move_backward.png';
+import move_forwardImage from '@/assets/images/blockly/component/move_forward.png';
+import pick_upImage from '@/assets/images/blockly/component/pick_up.png';
+import turn_leftImage from '@/assets/images/blockly/component/turn_left.png';
+import turn_rightImage from '@/assets/images/blockly/component/turn_right.png';
+import useImage from '@/assets/images/blockly/component/use.png';
+
 
 /**
  * 定义所有可用的自定义积木配置
@@ -17,9 +24,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": move_forwardImage,
+          "width": 20,
+          "height": 20,
           "alt": "向前移动"
         }
       ],
@@ -38,9 +45,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": move_forwardImage,
+          "width": 20,
+          "height": 20,
           "alt": "向前移动多次"
         },
         {
@@ -67,9 +74,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": move_backwardImage,
+          "width": 20,
+          "height": 20,
           "alt": "向后移动"
         }
       ],
@@ -88,9 +95,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": move_backwardImage,
+          "width": 20,
+          "height": 20,
           "alt": "向后移动多次"
         },
         {
@@ -117,9 +124,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": turn_leftImage,
+          "width": 20,
+          "height": 20,
           "alt": "向左转"
         }
       ],
@@ -138,9 +145,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": turn_rightImage,
+          "width": 20,
+          "height": 20,
           "alt": "向右转"
         }
       ],
@@ -159,9 +166,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": about_turnImage,
+          "width": 20,
+          "height": 20,
           "alt": "向后转"
         }
       ],
@@ -181,9 +188,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": pick_upImage,
+          "width": 20,
+          "height": 20,
           "alt": "拾取物品"
         }
       ],
@@ -202,9 +209,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": useImage,
+          "width": 20,
+          "height": 20,
           "alt": "使用物品"
         }
       ],
@@ -224,9 +231,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": useImage,
+          "width": 20,
+          "height": 20,
           "alt": "暂停"
         },
         {
@@ -253,9 +260,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": useImage,
+          "width": 20,
+          "height": 20,
           "alt": "声音"
         }
       ],
@@ -274,9 +281,9 @@ const availableBlocks = {
       "args0": [
         {
           "type": "field_image",
-          "src": xianqianImage,
-          "width": 16,
-          "height": 16,
+          "src": useImage,
+          "width": 20,
+          "height": 20,
           "alt": "修建"
         }
       ],

BIN
src/assets/images/blockly/component/about_turn.png


BIN
src/assets/images/blockly/component/move_backward.png


BIN
src/assets/images/blockly/component/move_forward.png


BIN
src/assets/images/blockly/component/pick_up.png


BIN
src/assets/images/blockly/component/turn_left.png


BIN
src/assets/images/blockly/component/turn_right.png


BIN
src/assets/images/blockly/component/use.png


BIN
src/assets/images/blockly/component/xianqian.png


+ 23 - 14
vite.config.js

@@ -1,55 +1,57 @@
 import { defineConfig, loadEnv } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import path from 'path'
-
-// 引入@vitejs/plugin-legacy
 import legacy from '@vitejs/plugin-legacy'
 
-// https://vite.dev/config/
 export default defineConfig(({ mode }) => {
-  // 加载对应模式的环境变量
   const env = loadEnv(mode, process.cwd())
   return {
     plugins: [
+      // 关键调整:适配5+App的WebView(安卓5.0+/iOS 10+)
       legacy({
-        targets: ['defaults', 'not IE 11']
+        targets: ['Android >= 5.0', 'iOS >= 10'], // 精准适配移动端WebView
+        additionalLegacyPolyfills: ['regenerator-runtime/runtime'], // 补充ES6+兼容
+        renderLegacyChunks: true, // 生成兼容包
+        polyfills: [
+          'es.symbol',
+          'es.promise',
+          'es.array.iterator',
+          'es.object.assign' // 解决低版本WebView的对象赋值兼容
+        ]
       }),
       vue({
         template: {
           compilerOptions: {
-            // 告诉Vue这些是原生自定义元素,不需要解析为Vue组件
             isCustomElement: (tag) => {
-              // Blockly工具箱中使用的标签
               return ['block', 'category', 'field', 'shadow', 'value', 'sep', 'label'].includes(tag)
             }
           }
         }
       }),
     ],
-    base: './',
+    base: './', // 保留相对路径(核心,不能改)
     resolve: {
-      // 路径别名配置
       alias: {
-        '@': path.resolve(__dirname, './src')
+        '@': path.resolve(__dirname, './src') // 保留别名
       }
     },
     server: {
       host: '0.0.0.0',
       proxy: {
         '/admin-api': {
-          // 使用加载的环境变量
           target: env.VITE_BASE_URL,
           changeOrigin: true
         }
       }
     },
     build: {
-      outDir: 'aiWeb',
+      outDir: 'aiWeb', // 保留原有输出目录(打包后生成aiWeb文件夹)
+      target: 'es2015', // 关键:降低编译目标,适配旧WebView
+      assetsDir: 'assets', // 明确静态资源目录
       rollupOptions: {
         output: {
           entryFileNames: `assets/[name]-[hash].js`,
           chunkFileNames: `assets/[name]-[hash].js`,
-          // 保留原始目录结构
           assetFileNames: ({ name }) => {
             const extType = name.split('.').pop();
             if (/png|jpe?g|gif|svg|webp/i.test(extType)) {
@@ -64,7 +66,14 @@ export default defineConfig(({ mode }) => {
             return `assets/[name]-[hash].[ext]`;
           }
         }
+      },
+      // 可选:关闭压缩(避免低版本WebView解析压缩代码失败)
+      minify: mode === 'production' ? 'terser' : false,
+      terserOptions: {
+        compress: {
+          drop_console: false // 保留控制台日志,方便调试
+        }
       }
     }
   }
-})
+})