web-component-gallery 2.2.1 → 2.2.3
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/dist/index.umd.js +1 -1
- package/dist/js.umd.js +1 -1
- package/extensions/BuildTheme.js +56 -46
- package/extensions/UpdateTheme.js +32 -12
- package/lib/browse/style/index.less +1 -2
- package/lib/form-comp/ASliderVerify.vue +283 -0
- package/lib/form-comp/index.js +4 -1
- package/lib/form-comp/style/ASliderVerify.less +94 -0
- package/lib/form-comp/style/index.less +2 -1
- package/lib/modal/index.jsx +2 -2
- package/package.json +1 -1
- package/utils/Filter.js +2 -2
- package/utils/Storage.js +2 -0
- package/utils/Utils.js +89 -3
package/utils/Utils.js
CHANGED
|
@@ -81,7 +81,7 @@ export function handleEnvURL(url, processType = 'url') {
|
|
|
81
81
|
|
|
82
82
|
// 环境变量解构
|
|
83
83
|
const { origin } = window.location
|
|
84
|
-
const { VUE_APP_ROUTE_PORT,
|
|
84
|
+
const { VUE_APP_ROUTE_PORT, VUE_APP_API_URL } = process.env
|
|
85
85
|
|
|
86
86
|
// URL处理策略
|
|
87
87
|
const urlStrategies = {
|
|
@@ -95,7 +95,7 @@ export function handleEnvURL(url, processType = 'url') {
|
|
|
95
95
|
image: {
|
|
96
96
|
dev: () =>
|
|
97
97
|
imagePattern.test(url)
|
|
98
|
-
? constructUrl(
|
|
98
|
+
? constructUrl(VUE_APP_API_URL, url)
|
|
99
99
|
: url,
|
|
100
100
|
prod: () =>
|
|
101
101
|
imagePattern.test(url)
|
|
@@ -103,7 +103,7 @@ export function handleEnvURL(url, processType = 'url') {
|
|
|
103
103
|
: url
|
|
104
104
|
},
|
|
105
105
|
file: {
|
|
106
|
-
dev: () => constructUrl(
|
|
106
|
+
dev: () => constructUrl(VUE_APP_API_URL, url),
|
|
107
107
|
prod: () => constructUrl(origin, url)
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -116,4 +116,90 @@ export function handleEnvURL(url, processType = 'url') {
|
|
|
116
116
|
const strategy = urlStrategies[processType]
|
|
117
117
|
|
|
118
118
|
return isDev ? strategy.dev() : strategy.prod()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 根据属性路径更新数组对象中的数据,支持条件匹配
|
|
123
|
+
* @param {Array} arr - 目标数组
|
|
124
|
+
* @param {string} key - 点分隔的属性路径(如"model: input.a.b")
|
|
125
|
+
* @param {*} data - 要设置的数据
|
|
126
|
+
* @returns {Array} 更新后的数组
|
|
127
|
+
*/
|
|
128
|
+
export function setOptionsData(arr, key, data) {
|
|
129
|
+
if (!key || !Array.isArray(arr)) return arr
|
|
130
|
+
|
|
131
|
+
// 解析条件匹配格式
|
|
132
|
+
const hasCondition = key.includes(':')
|
|
133
|
+
let conditionModel = null
|
|
134
|
+
let conditionValue = null
|
|
135
|
+
let actualPath = key
|
|
136
|
+
|
|
137
|
+
if (hasCondition) {
|
|
138
|
+
const [prefix, path] = key.split(':').map(s => s.trim())
|
|
139
|
+
conditionModel = prefix
|
|
140
|
+
conditionValue = path.split('.')[0]
|
|
141
|
+
actualPath = path.replace(`${conditionValue}.`, '')
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 分割属性路径
|
|
145
|
+
const pathParts = actualPath.split('.')
|
|
146
|
+
|
|
147
|
+
// 更新数组中的每个对象
|
|
148
|
+
return arr.map(item => {
|
|
149
|
+
// 检查条件匹配
|
|
150
|
+
if (hasCondition && conditionModel) {
|
|
151
|
+
if (item[conditionModel] !== conditionValue) {
|
|
152
|
+
return item
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 获取当前对象
|
|
157
|
+
let current = item
|
|
158
|
+
|
|
159
|
+
// 遍历路径(除最后一部分)
|
|
160
|
+
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
161
|
+
if (!current[pathParts[i]]) current[pathParts[i]] = {}
|
|
162
|
+
current = current[pathParts[i]]
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// 设置最终属性值
|
|
166
|
+
const lastPart = pathParts[pathParts.length - 1]
|
|
167
|
+
// 是对象则进行属性合并
|
|
168
|
+
const isObj = data instanceof Object && !Array.isArray(data)
|
|
169
|
+
|
|
170
|
+
pathParts.length > 1 ?
|
|
171
|
+
current[lastPart] = isObj ? { ...current[lastPart], ...data } : data :
|
|
172
|
+
current[pathParts[0]] = isObj ? { ...current[pathParts[0]], ...data } : data
|
|
173
|
+
|
|
174
|
+
return item
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 异步获取搜索数据并更新配置
|
|
180
|
+
* @param {Object} searchSetting - 需要更新的搜索配置对象
|
|
181
|
+
* @returns {Promise<Object>} 返回包含所有API调用结果的对象
|
|
182
|
+
*/
|
|
183
|
+
export const fetchSearchData = async (searchSetting, apiMap) => {
|
|
184
|
+
try {
|
|
185
|
+
// 并行调用所有API
|
|
186
|
+
const results = await Promise.allSettled(Object.values(apiMap))
|
|
187
|
+
|
|
188
|
+
let innerSetting = []
|
|
189
|
+
|
|
190
|
+
Object.keys(apiMap).forEach((key, index) => {
|
|
191
|
+
const result = results[index]
|
|
192
|
+
if (result.status === 'fulfilled' && result.value) {
|
|
193
|
+
innerSetting = setOptionsData(searchSetting, key, result.value)
|
|
194
|
+
} else {
|
|
195
|
+
console.error(`API调用失败: ${key}`, result.reason)
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
// 返回更新后的配置数据
|
|
200
|
+
return innerSetting
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error('apiMap配置格式不对导致API并发失败', error)
|
|
203
|
+
throw error
|
|
204
|
+
}
|
|
119
205
|
}
|