feat:【mall 商城】商品发布 - 库存价格【antd】100%: 迁移完成

This commit is contained in:
puhui999
2025-10-21 16:39:54 +08:00
parent 93149876e5
commit 6bbf878171
3 changed files with 36 additions and 25 deletions

View File

@@ -68,3 +68,22 @@ export const getUrlValue = (
const url = new URL(decodeURIComponent(urlStr));
return url.searchParams.get(key) ?? '';
};
/**
* 将值复制到目标对象且以目标对象属性为准target: {a:1} source:{a:2,b:3} 结果为:{a:2}
* @param target 目标对象
* @param source 源对象
*/
export const copyValueToTarget = (target: any, source: any) => {
const newObj = Object.assign({}, target, source);
// 删除多余属性
Object.keys(newObj).forEach((key) => {
// 如果不是target中的属性则删除
if (!Object.keys(target).includes(key)) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete newObj[key];
}
});
// 更新目标对象值
Object.assign(target, newObj);
};