mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
feat: 重构胶囊缓存逻辑,增加设置和移除缓存的方法
This commit is contained in:
parent
b445af932c
commit
1c8b73a381
@ -322,18 +322,7 @@ export default {
|
|||||||
capsule: config,
|
capsule: config,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
;(async () => {
|
this.setCapsuleCache(name, config)
|
||||||
const cache = await $A.IDBJson("microAppsCapsuleCache");
|
|
||||||
if ($A.isTrue(config.no_cache)) {
|
|
||||||
if (typeof cache[name] === "undefined") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
delete cache[name];
|
|
||||||
} else {
|
|
||||||
cache[name] = config;
|
|
||||||
}
|
|
||||||
await $A.IDBSet("microAppsCapsuleCache", cache);
|
|
||||||
})()
|
|
||||||
},
|
},
|
||||||
nextZIndex: () => {
|
nextZIndex: () => {
|
||||||
if (typeof window.modalTransferIndex === 'number') {
|
if (typeof window.modalTransferIndex === 'number') {
|
||||||
@ -366,6 +355,37 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置胶囊缓存
|
||||||
|
* @param name
|
||||||
|
* @param config
|
||||||
|
*/
|
||||||
|
async setCapsuleCache(name, config) {
|
||||||
|
const cache = await $A.IDBJson("microAppsCapsuleCache");
|
||||||
|
if ($A.isTrue(config.no_cache)) {
|
||||||
|
if (typeof cache[name] === "undefined") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete cache[name];
|
||||||
|
} else {
|
||||||
|
cache[name] = config;
|
||||||
|
}
|
||||||
|
await $A.IDBSet("microAppsCapsuleCache", cache);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除胶囊缓存
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
async removeCapsuleCache(name) {
|
||||||
|
const cache = await $A.IDBJson("microAppsCapsuleCache");
|
||||||
|
if (typeof cache[name] === "undefined") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete cache[name];
|
||||||
|
await $A.IDBSet("microAppsCapsuleCache", cache);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 观察打开微应用
|
* 观察打开微应用
|
||||||
* @param config
|
* @param config
|
||||||
@ -374,10 +394,12 @@ export default {
|
|||||||
// 备份配置
|
// 备份配置
|
||||||
this.backupConfigs[config.name] = $A.cloneJSON(config);
|
this.backupConfigs[config.name] = $A.cloneJSON(config);
|
||||||
|
|
||||||
// 如果没有胶囊配置,则从缓存中恢复
|
// 从缓存读取胶囊配置
|
||||||
if (!$A.isHave(config.capsule, true)) {
|
const capsuleCache = await $A.IDBJson("microAppsCapsuleCache");
|
||||||
const capsuleCache = await $A.IDBJson("microAppsCapsuleCache");
|
if ($A.isJson(capsuleCache[config.name])) {
|
||||||
if ($A.isJson(capsuleCache[config.name])) {
|
if ($A.isHave(config.capsule, true)) {
|
||||||
|
Object.assign(config.capsule, capsuleCache[config.name]);
|
||||||
|
} else {
|
||||||
config.capsule = capsuleCache[config.name];
|
config.capsule = capsuleCache[config.name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,10 +670,12 @@ export default {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "restart":
|
case "restart":
|
||||||
|
this.removeCapsuleCache(name)
|
||||||
this.onRestartApp(name)
|
this.onRestartApp(name)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "destroy":
|
case "destroy":
|
||||||
|
this.removeCapsuleCache(name)
|
||||||
this.closeMicroApp(name, true)
|
this.closeMicroApp(name, true)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user