Jelajahi Sumber

feat_monaco-format

ananzhusen 1 tahun lalu
induk
melakukan
545ca0fdfe

+ 9 - 10
src/services/echarts.ts

@@ -72,17 +72,16 @@ export const charts = [
               label: '二月数据',
               type: 'object',
             },
-            {
-              key: 'echarts.option',
-              label: 'echarts',
-              type: 'object',
-            },
-            {
-              key: 'echarts.max',
-              label: '最大数量',
-              type: 'number',
-            },
           ],
+          props: {
+            custom: [
+              {
+                key: 'echarts',
+                label: 'echarts',
+                type: 'code',
+              },
+            ],
+          },
         },
       },
       {

+ 6 - 0
src/views/components/PenProps.vue

@@ -1014,6 +1014,7 @@
             <div class="py-8">
               <CodeEditor
                 :json="true"
+                :language="'json'"
                 v-model="propsDialog.value"
                 style="height: 300px"
               />
@@ -1055,6 +1056,7 @@ import { getCookie } from '@/services/cookie';
 import { useSelection } from '@/services/selections';
 import { autoSave, fonts, inTreePanel } from '@/services/common';
 import { updatePen } from './pen';
+import { MessagePlugin } from 'tdesign-vue-next';
 
 const headers = {
   Authorization: 'Bearer ' + (localStorage.token || getCookie('token') || ''),
@@ -1261,6 +1263,10 @@ const showPropsEdit = (item: any) => {
 };
 
 const onOkPropsEdit = () => {
+  if (!propsDialog.value) {
+    MessagePlugin.error('数据不满足json格式');
+    return;
+  }
   data.pen[propsDialog.key] = propsDialog.value;
   updatePen(data.pen, propsDialog.key);
   propsDialog.show = false;

+ 4 - 0
src/views/components/common/CodeEditor.vue

@@ -112,6 +112,10 @@ onMounted(() => {
       emit('change', currenValue);
     }
   });
+
+  setTimeout(() => {
+    editor.getAction('editor.action.formatDocument').run();
+  }, 300);
 });
 
 watch(