MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / processGroupsData

Function processGroupsData

web/src/helpers/api.js:153–176  ·  view source on GitHub ↗
(data, userGroup)

Source from the content-addressed store, hash-verified

151
152// 处理分组数据
153export const processGroupsData = (data, userGroup) => {
154 let groupOptions = Object.entries(data).map(([group, info]) => ({
155 label: info.desc.length > 20 ? info.desc.substring(0, 20) + '...' : info.desc,
156 value: group,
157 ratio: info.ratio,
158 fullLabel: info.desc,
159 }));
160
161 if (groupOptions.length === 0) {
162 groupOptions = [{
163 label: '用户分组',
164 value: '',
165 ratio: 1,
166 }];
167 } else if (userGroup) {
168 const userGroupIndex = groupOptions.findIndex(g => g.value === userGroup);
169 if (userGroupIndex > -1) {
170 const userGroupOption = groupOptions.splice(userGroupIndex, 1)[0];
171 groupOptions.unshift(userGroupOption);
172 }
173 }
174
175 return groupOptions;
176};
177
178// 原来components中的utils.js
179

Callers 1

useDataLoaderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected