mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
fix: CRUD组件使用非严格比较导致部分场景query无法更新问题
This commit is contained in:
parent
8af076ce0e
commit
7c951e3f75
@ -141,7 +141,32 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
||||
...values
|
||||
};
|
||||
|
||||
if (isObjectShallowModified(originQuery, query, false)) {
|
||||
/**
|
||||
* 非严格模式下也需要严格比较的CASE
|
||||
* @reference https://tc39.es/ecma262/#sec-islooselyequal
|
||||
*/
|
||||
const exceptedLooselyRules: [any, any][] = [
|
||||
[0, ''],
|
||||
[false, ''],
|
||||
[false, '0'],
|
||||
[false, 0],
|
||||
[true, 1],
|
||||
[true, '1']
|
||||
];
|
||||
|
||||
if (
|
||||
isObjectShallowModified(originQuery, query, (lhs: any, rhs: any) => {
|
||||
if (
|
||||
exceptedLooselyRules.some(
|
||||
rule => rule.includes(lhs) && rule.includes(rhs)
|
||||
)
|
||||
) {
|
||||
return lhs === rhs;
|
||||
}
|
||||
|
||||
return lhs == rhs;
|
||||
})
|
||||
) {
|
||||
if (query[pageField || 'page']) {
|
||||
self.page = parseInt(query[pageField || 'page'], 10);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ export function rmUndefined(obj: PlainObject) {
|
||||
export function isObjectShallowModified(
|
||||
prev: any,
|
||||
next: any,
|
||||
strictMode: boolean = true,
|
||||
strictModeOrFunc: boolean | ((lhs: any, rhs: any) => boolean) = true,
|
||||
ignoreUndefined: boolean = false,
|
||||
statck: Array<any> = []
|
||||
): boolean {
|
||||
@ -262,7 +262,7 @@ export function isObjectShallowModified(
|
||||
isObjectShallowModified(
|
||||
prev,
|
||||
next[index],
|
||||
strictMode,
|
||||
strictModeOrFunc,
|
||||
ignoreUndefined,
|
||||
statck
|
||||
)
|
||||
@ -281,7 +281,11 @@ export function isObjectShallowModified(
|
||||
isObservable(prev) ||
|
||||
isObservable(next)
|
||||
) {
|
||||
return strictMode ? prev !== next : prev != next;
|
||||
if (strictModeOrFunc && typeof strictModeOrFunc === 'function') {
|
||||
return strictModeOrFunc(prev, next);
|
||||
}
|
||||
|
||||
return strictModeOrFunc ? prev !== next : prev != next;
|
||||
}
|
||||
|
||||
if (ignoreUndefined) {
|
||||
@ -311,7 +315,7 @@ export function isObjectShallowModified(
|
||||
isObjectShallowModified(
|
||||
prev[key],
|
||||
next[key],
|
||||
strictMode,
|
||||
strictModeOrFunc,
|
||||
ignoreUndefined,
|
||||
statck
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user