From e6db211a16ab94a53c89de015a29223697358afb Mon Sep 17 00:00:00 2001 From: mxd <838425805@qq.com> Date: Sun, 2 Aug 2020 09:17:18 +0800 Subject: [PATCH] =?UTF-8?q?UI=E7=BC=96=E8=BE=91=E5=99=A8=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E7=BC=96=E8=BE=91=E4=BF=A1=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E5=BD=93=E6=84=8F=E5=A4=96=E5=85=B3=E9=97=AD=E6=97=B6=E5=8F=AF?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/magicapi-support/js/index.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/resources/magicapi-support/js/index.js b/src/main/resources/magicapi-support/js/index.js index 1cdf568a..93c444ad 100644 --- a/src/main/resources/magicapi-support/js/index.js +++ b/src/main/resources/magicapi-support/js/index.js @@ -21,6 +21,7 @@ var MagicEditor = { this.initScriptEditor(); this.resetEditor(); this.checkUpdate(); + this.backupInterval(); var _this = this; $.getJSON('config.json',function(data){ _this.config = data; @@ -819,6 +820,38 @@ var MagicEditor = { } }])]; }, + backupInterval : function(){ + var _this = this; + var info = _this.getValue('api_info'); + if(info){ + info = JSON.parse(info); + _this.apiId = info.id; + $('input[name=name]').val(info.name || ''); + $('input[name=path]').val(info.path || ''); + $('input[name=method]').val(info.method || ''); + $('input[name=group]').val(info.groupName || ''); + $('input[name=prefix]').val(info.groupPrefix || ''); + _this.scriptEditor&&_this.scriptEditor.setValue(info.script || 'return message;'); + _this.requestEditor&&_this.requestEditor.setValue(info.parameters || _this.defaultRequestValue); + _this.options&&_this.options.setValue(info.options || '{\r\n}'); + _this.output&&_this.output.setValue(info.options || ''); + + } + setInterval(function(){ + _this.setValue('api_info',{ + id : _this.apiId, + name : $('input[name=name]').val(), + path : $('input[name=path]').val(), + method : $('input[name=method]').val(), + groupName : $('input[name=group]').val(), + groupPrefix : $('input[name=prefix]').val(), + script : _this.scriptEditor&&_this.scriptEditor.getValue(), + parameters : _this.requestEditor&&_this.requestEditor.getValue(), + options : _this.optionsEditor&&_this.optionsEditor.getValue(), + output: _this.outputEditor&&_this.outputEditor.getValue() + }) + },5000) + }, // 初始化快捷键 initShortKey : function(){ var _this = this; @@ -1102,6 +1135,9 @@ var MagicEditor = { } localStorage&&localStorage.setItem(key,value) || ''; }, + removeValue : function(key){ + localStorage&&localStorage.removeItem(key); + }, bindEditorShortKey : function(editor){ // Alt + / 代码提示 editor.addCommand(monaco.KeyMod.Alt | monaco.KeyCode.US_SLASH,function(){