增加第一次进入插件校验

This commit is contained in:
fofolee 2020-07-21 18:37:34 +08:00
parent 94e8f5752e
commit b3a5594e2d

View File

@ -8,7 +8,11 @@
} }
utools.onPluginEnter(async ({ code, type, payload }) => { utools.onPluginEnter(async ({ code, type, payload }) => {
// oldVersionFix() if (fofoCommon.isRunningAtFirstTime()) {
fofoCommon.showChangeLog()
importDefaultCommands()
oldVersionFix()
}
var handleEnter var handleEnter
utools.onPluginOut(() => { utools.onPluginOut(() => {
// 暂存 codeRunner 的内容 // 暂存 codeRunner 的内容
@ -23,7 +27,7 @@
customext: $('#customext').val(), customext: $('#customext').val(),
customcodec: $('#customcodec').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() $("#options, #out").empty()
@ -208,7 +212,8 @@
// 替换上个版本弃用的功能 // 替换上个版本弃用的功能
let oldVersionFix = () => { let oldVersionFix = () => {
var customFts = getDB('customFts'); utools.showNotification('第一次更新会对老版本命令做兼容处理,如插件显示空白请稍候', 'warning')
var customFts = fofoCommon.getDB('customFts');
Object.keys(customFts).forEach((x, i) => { Object.keys(customFts).forEach((x, i) => {
// 旧版的 program // 旧版的 program
if (customFts[x].program == 'simulation') customFts[x].program = 'quickcommand'; if (customFts[x].program == 'simulation') customFts[x].program = 'quickcommand';
@ -228,7 +233,16 @@
delete customFts[x] delete customFts[x]
customFts[newCode] = newFts 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])
}) })
} }
}() }()