@mega-apps/test-cli-demo
Version:
Mom builder for all mega modules apps. The recommended basic operation dependency package is attached, and users can check and repair defects in actual applications.
145 lines (143 loc) • 4.93 kB
JavaScript
// 针对KeepAlive的补丁
const commonKeepAliveRules = [
{
search: `
this._leaving = true;
mergeVNodeHook(oldData, 'afterLeave', function () {
this$1._leaving = false;
this$1.$forceUpdate();
});
return placeholder(h, rawChild)
`,
replace: `
this._leaving = true;
mergeVNodeHook(oldData, 'afterLeave', function () {
this$1._leaving = false;
this$1.$forceUpdate();
});
if (!/\\d-keep-alive$/.test(rawChild.tag)) {
return placeholder(h, rawChild);
}
`,
},
];
const patchKeepAliveRules = {
/**
* 原理: 修改Vue源码,增加判断rawChild.tag 代码。
*
* 源代码片段:
* ``` js
// handle transition mode
if (mode === 'out-in') {
// return placeholder node and queue update when leave finishes
this._leaving = true
mergeVNodeHook(oldData, 'afterLeave', () => {
this._leaving = false
this.$forceUpdate()
})
return placeholder(h, rawChild)
}
* ```
* 修改成:
* ``` js
// handle transition mode
if (mode === 'out-in') {
// return placeholder node and queue update when leave finishes
this._leaving = true
mergeVNodeHook(oldData, 'afterLeave', () => {
this._leaving = false
this.$forceUpdate()
})
if (!/\d-keep-alive$/.test(rawChild.tag)) {
return placeholder(h, rawChild);
}
}
* ```
*
* 文件位置:src/platforms/web/runtime/components/transition.js
*/
"2.6.12": [
{
search: `
if("out-in"===r)return this._leaving=!0,it(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),ro(e,o);if("in-out"===r)
`,
replace: `
if("out-in"===r){if(this._leaving=!0,it(p,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),!/\\d-keep-alive$/.test(o.tag))return ro(e,o)}else if("in-out"===r)
`,
},
{
search: `
if("out-in"===n)return this._leaving=!0,Qt(e,"afterLeave",()=>{this._leaving=!1,this.$forceUpdate()}),Yr(t,o);if("in-out"===n)
`,
replace: `
if("out-in"===n){if(this._leaving=!0,Qt(e,"afterLeave",()=>{this._leaving=!1,this.$forceUpdate()}),!/\\d-keep-alive$/.test(o.tag))return Yr(t,o)}else if("in-out"===n)
`,
},
{
search: `
if("out-in"===r)return this._leaving=!0,ne(f,"afterLeave",function(){e._leaving=!1,e.$forceUpdate()}),xo(t,i);if("in-out"===r)
`,
replace: `
if("out-in"===r){if(this._leaving=!0,ne(d,"afterLeave",function(){e._leaving=!1,e.$forceUpdate()}),!/\\d-keep-alive$/.test(i.tag))return xo(t,i)}else if("in-out"===r)
`,
},
...commonKeepAliveRules,
],
"2.6.13": [
{
search: `
if("out-in"===r)return this._leaving=!0,ot(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),io(e,o);if("in-out"===r)
`,
replace: `
if("out-in"===r){if(this._leaving=!0,ot(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),!/\\d-keep-alive$/.test(o.tag))return io(e,o)}else if("in-out"===r)
`,
},
{
search: `
if("out-in"===n)return this._leaving=!0,te(e,"afterLeave",()=>{this._leaving=!1,this.$forceUpdate()}),Qr(t,o);if("in-out"===n)
`,
replace: `
if("out-in"===n){if(this._leaving=!0,te(e,"afterLeave",()=>{this._leaving=!1,this.$forceUpdate()}),!/\\d-keep-alive$/.test(o.tag))return Qr(t,o)}else if("in-out"===n)
`,
},
{
search: `
if("out-in"===r)return this._leaving=!0,re(f,"afterLeave",function(){e._leaving=!1,e.$forceUpdate()}),ko(t,i);if("in-out"===r)
`,
replace: `
if("out-in"===r){if(this._leaving=!0,re(f,"afterLeave",function(){e._leaving=!1,e.$forceUpdate()}),!/\\d-keep-alive$/.test(i.tag))return ko(t,i)}else if("in-out"===r)
`,
},
...commonKeepAliveRules,
],
"2.6.14": [
{
search: `
if("out-in"===r)return this._leaving=!0,ot(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),io(e,o);if("in-out"===r)
`,
replace: `
if("out-in"===r){if(this._leaving=!0,ot(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),!/\\d-keep-alive$/.test(o.tag))return io(e,o)}else if("in-out"===r)
`,
},
{
search: `
if("out-in"===n)return this._leaving=!0,te(e,"afterLeave",()=>{this._leaving=!1,this.$forceUpdate()}),Qr(t,o);if("in-out"===n)
`,
replace: `
if("out-in"===n){if(this._leaving=!0,te(e,"afterLeave",()=>{this._leaving=!1,this.$forceUpdate()}),!/\\d-keep-alive$/.test(o.tag))return Qr(t,o)}else if("in-out"===n)
`,
},
{
search: `
if("out-in"===r)return this._leaving=!0,re(f,"afterLeave",function(){e._leaving=!1,e.$forceUpdate()}),ko(t,i);if("in-out"===r)
`,
replace: `
if("out-in"===r){if(this._leaving=!0,re(f,"afterLeave",function(){e._leaving=!1,e.$forceUpdate()}),!/\\d-keep-alive$/.test(i.tag))return ko(t,i)}else if("in-out"===r)
`,
},
...commonKeepAliveRules,
],
};
module.exports = {
...patchKeepAliveRules,
};