design
attribute configuration.'
+ },
+ codeFiles: ['merge.vue']
+ },
{
demoId: 'text-direct',
name: {
diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts
index c6fb921347..f017d50931 100644
--- a/packages/utils/src/index.ts
+++ b/packages/utils/src/index.ts
@@ -110,7 +110,19 @@ export {
} from './string'
export { roundFixed, Decimal, toFixed as toFixedDecimal, formatNumber, recoverNumber } from './decimal'
-export { each, getObj, setObj, copyField, copyArray, isEqual, isEachEqual, extend, toJsonStr, merge } from './object'
+export {
+ each,
+ getObj,
+ setObj,
+ copyField,
+ copyArray,
+ isEqual,
+ isEachEqual,
+ extend,
+ toJsonStr,
+ merge,
+ deepMerge
+} from './object'
export {
supportBigInt,
diff --git a/packages/utils/src/object/index.ts b/packages/utils/src/object/index.ts
index 7dbfabf25c..ea9607dcb5 100644
--- a/packages/utils/src/object/index.ts
+++ b/packages/utils/src/object/index.ts
@@ -434,3 +434,43 @@ export const merge = function (target: object, ...rest: object[]) {
return target
}
+
+/**
+ * 深度合并普通对象:递归合并所有普通对象的属性,嵌套对象也会被合并。
+ * 覆盖非对象值:数组、日期、函数等非普通对象值会被直接覆盖。
+ * 不修改原对象:所有合并操作都在新对象上进行,原对象保持不变。
+ * 处理null和undefined源:忽略null和undefined类型的源对象。
+ */
+export function deepMerge(...sources) {
+ function merge(target, source) {
+ if (!isObject(source)) {
+ return
+ }
+ Object.keys(source).forEach((key) => {
+ const sourceValue = source[key]
+ const targetValue = target[key]
+
+ if (isObject(sourceValue)) {
+ if (isObject(targetValue)) {
+ // 递归合并对象
+ merge(targetValue, sourceValue)
+ } else {
+ // 目标属性不是对象,创建新对象并递归合并
+ target[key] = {}
+ merge(target[key], sourceValue)
+ }
+ } else {
+ // 直接赋值非对象或数组等类型的值
+ target[key] = sourceValue
+ }
+ })
+ }
+
+ const target = {}
+ for (const source of sources) {
+ if (source !== null && source !== undefined) {
+ merge(target, source)
+ }
+ }
+ return target
+}
diff --git a/packages/vue/src/config-provider/package.json b/packages/vue/src/config-provider/package.json
index 1032b24292..3dd47c4966 100644
--- a/packages/vue/src/config-provider/package.json
+++ b/packages/vue/src/config-provider/package.json
@@ -1,21 +1,22 @@
{
"name": "@opentiny/vue-config-provider",
+ "type": "module",
"version": "3.22.0",
+ "license": "MIT",
+ "sideEffects": false,
"main": "lib/index.js",
"module": "index.ts",
- "sideEffects": false,
- "type": "module",
- "devDependencies": {
- "@opentiny-internal/vue-test-utils": "workspace:*",
- "vitest": "catalog:"
- },
"scripts": {
"build": "pnpm -w build:ui $npm_package_name",
"//postversion": "pnpm build"
},
"dependencies": {
+ "@opentiny/utils": "workspace:~",
"@opentiny/vue-common": "workspace:~",
"@opentiny/vue-theme": "workspace:~"
},
- "license": "MIT"
+ "devDependencies": {
+ "@opentiny-internal/vue-test-utils": "workspace:*",
+ "vitest": "catalog:"
+ }
}
diff --git a/packages/vue/src/config-provider/src/index.vue b/packages/vue/src/config-provider/src/index.vue
index 5747f84118..cdda7b2c5d 100644
--- a/packages/vue/src/config-provider/src/index.vue
+++ b/packages/vue/src/config-provider/src/index.vue
@@ -1,8 +1,17 @@