From b3a5594e2d2bb27645ad3a3406f57a6ed7c03441 Mon Sep 17 00:00:00 2001 From: fofolee Date: Tue, 21 Jul 2020 18:37:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AC=AC=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E6=8F=92=E4=BB=B6=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/index.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/assets/index.js b/src/assets/index.js index cc35d56..e6b14db 100644 --- a/src/assets/index.js +++ b/src/assets/index.js @@ -6,9 +6,13 @@ } else { $('#darkmode').length && $('#darkmode, #darkswal').remove() } - + utools.onPluginEnter(async ({ code, type, payload }) => { - // oldVersionFix() + if (fofoCommon.isRunningAtFirstTime()) { + fofoCommon.showChangeLog() + importDefaultCommands() + oldVersionFix() + } var handleEnter utools.onPluginOut(() => { // 暂存 codeRunner 的内容 @@ -23,7 +27,7 @@ customext: $('#customext').val(), customcodec: $('#customcodec').val() } - putDB('history', { cmd: cmd, program: program, scptarg: scptarg, customoptions: customoptions }, 'codeHistory') + fofoCommon.putDB('history', { cmd: cmd, program: program, scptarg: scptarg, customoptions: customoptions }, 'codeHistory') } // 初始化 $("#options, #out").empty() @@ -208,7 +212,8 @@ // 替换上个版本弃用的功能 let oldVersionFix = () => { - var customFts = getDB('customFts'); + utools.showNotification('第一次更新会对老版本命令做兼容处理,如插件显示空白请稍候', 'warning') + var customFts = fofoCommon.getDB('customFts'); Object.keys(customFts).forEach((x, i) => { // 旧版的 program if (customFts[x].program == 'simulation') customFts[x].program = 'quickcommand'; @@ -228,7 +233,16 @@ delete customFts[x] customFts[newCode] = newFts } - putDB(x, customFts[x], 'customFts'); + fofoCommon.putDB(x, customFts[x], 'customFts'); + }) + } + + importDefaultCommands = () => { + let customFts = fofoCommon.getDB('customFts') + let qc = Object.keys(customFts) + let defaultCommands = getDefaultCommands() + Object.keys(defaultCommands).forEach(d => { + if (!qc.includes(d)) importCommand(defaultCommands[d]) }) } }()