adtec-core-package 3.1.4 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adtec-core-package",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -101,3 +101,31 @@ export function getRouteMetaParam(
101
101
  }
102
102
  return undefined
103
103
  }
104
+
105
+ /** 将 meta.params + query 归一为键值对象(替代 params.reduce / forEach 灌 taskVo) */
106
+ export function routeMetaParamsToRecord(
107
+ params: unknown,
108
+ query?: Record<string, unknown>,
109
+ ): Record<string, unknown> {
110
+ const record: Record<string, unknown> = {}
111
+ const paramList = extractParameterArray(params)
112
+ if (paramList) {
113
+ for (const item of paramList) {
114
+ if (item?.code != null) record[String(item.code)] = item.value
115
+ }
116
+ } else if (isPlainObject(params) && !isEmptyPlainObject(params)) {
117
+ Object.assign(record, params)
118
+ }
119
+ if (query) {
120
+ for (const [key, value] of Object.entries(query)) {
121
+ if (value !== undefined && value !== null && value !== '' && !(key in record)) {
122
+ record[key] = value
123
+ }
124
+ }
125
+ }
126
+ return record
127
+ }
128
+
129
+ export function hasRouteMetaParams(params: unknown, query?: Record<string, unknown>): boolean {
130
+ return Object.keys(routeMetaParamsToRecord(params, query)).length > 0
131
+ }