Explorar o código

新增日志保留最多条数配置

mxd %!s(int64=3) %!d(string=hai) anos
pai
achega
16869452c7

+ 4 - 0
magic-editor/src/console/src/components/layout/magic-log.vue

@@ -14,6 +14,7 @@
 <script>
 import bus from "@/scripts/bus";
 import * as utils from "@/scripts/utils";
+import contants from "@/scripts/contants";
 
 export default {
   name: "MagicLog",
@@ -43,6 +44,9 @@ export default {
         row.throwable = true
       }
       row.newline = row.message.indexOf('<br>') > -1
+      if(this.logs.length >= contants.LOG_MAX_ROWS){
+        this.logs.shift()
+      }
       this.logs.push(row)
       let container = this.$refs.container;
       this.$nextTick(() => container.scrollTop = container.scrollHeight)

+ 3 - 0
magic-editor/src/console/src/components/magic-editor.vue

@@ -127,6 +127,9 @@ export default {
     if(this.config.editorFontSize !== undefined){
       contants.EDITOR_FONT_SIZE = this.config.editorFontSize
     }
+    if(this.config.logMaxRows !== undefined){
+      contants.LOG_MAX_ROWS = Math.max(this.config.logMaxRows, 10)
+    }
     this.config.version = contants.MAGIC_API_VERSION_TEXT
     this.config.title = this.config.title || 'magic-api'
     this.config.themes = this.config.themes || {}

+ 1 - 0
magic-editor/src/console/src/scripts/contants.js

@@ -23,6 +23,7 @@ const contants = {
   RESPONSE_CODE_DEBUG: 1000,
   RESPONSE_CODE_SCRIPT_ERROR: -1000,
   RESPONSE_NO_PERMISSION: -10,
+  LOG_MAX_ROWS: Infinity,
   DEFAULT_EXPAND: true,
   JDBC_DRIVERS: [],
   DATASOURCE_TYPES: [],