旧版本兼容处理

This commit is contained in:
fofolee 2020-07-19 01:12:55 +08:00
parent b0ff86fd47
commit e771a34fb3

View File

@ -91,7 +91,7 @@
if (db.hasSubInput) {
// 启动子命令输入
// 清空输出
$("#out").empty();
// $("#out").empty();
var subinput = '';
var setSubInput = () => {
utools.setSubInput(({text}) => {
@ -202,9 +202,25 @@
// 替换上个版本弃用的功能
let oldVersionFix = () => {
var customFts = getDB('customFts');
Object.keys(customFts).forEach(x => {
Object.keys(customFts).forEach((x, i) => {
// 旧版的 program
if (customFts[x].program == 'simulation') customFts[x].program = 'quickcommand';
// 旧版的 sleep
if (customFts[x].cmd.includes('await sleep')) customFts[x].cmd = customFts[x].cmd.replace(/await sleep/g, 'quickcommand.sleep')
// 不规范的 code
let code = customFts[x].features.code
if (!/^(window|key|regex|files|default)_/.test(code)) {
console.log(code);
utools.removeFeature(code)
let uid = Number(Math.random().toString().substr(3, 3) + (Date.now() + i * 10000)).toString(36)
let type = customFts[x].features.cmds[0].type
type || (type = 'key')
let newCode = type + '_' + uid
let newFts = customFts[x]
newFts.features.code = newCode
delete customFts[x]
customFts[newCode] = newFts
}
putDB(x, customFts[x], 'customFts');
})
}