@alitajs/keep-alive
Version:
@alitajs/keep-alive
12 lines (9 loc) • 1.36 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = function _default() {
return "\n// @ts-nocheck\n\nimport pathToRegexp from '@umijs/deps/compiled/path-to-regexp';\n\ninterface LayoutInstanceProps {\n alivePathnames: string[],\n keepAliveViewMap: {}\n}\nlet LayoutInstance: LayoutInstanceProps;\nfunction dropByCacheKey(pathname: string) {\n if (LayoutInstance) {\n const { alivePathnames, keepAliveViewMap } = LayoutInstance;\n const index = alivePathnames.findIndex(item => item === pathname?.toLowerCase());\n if (index !== -1) {\n alivePathnames.splice(index, 1);\n // \u7528\u6765\u5F53\u4F5Ckey\uFF0C\u53EA\u6709key\u53D1\u751F\u53D8\u5316\u624D\u4F1Aremout\u7EC4\u4EF6\n for (const key in keepAliveViewMap) {\n if (pathToRegexp(key).test(pathname?.toLowerCase())) {\n keepAliveViewMap[key].recreateTimes += 1;\n break;\n }\n }\n }\n }\n}\nfunction patchKeepAlive(fn: (config: any[]) => any[]) {\n if (LayoutInstance) {\n LayoutInstance.patchKeepAlive(fn);\n }\n}\nconst setLayoutInstance = (value: any) => {\n LayoutInstance = value\n}\nconst getLayoutInstance = () => LayoutInstance;\n\nexport {\n setLayoutInstance, getLayoutInstance, dropByCacheKey, patchKeepAlive\n}\n";
};
exports.default = _default;