sync: 同步 monkey-ai@weiyuan(ddc5b9443) 的 web/ 到 ui-optimization
- 合入 weiyuan 新功能前端:分佣 V2 / 伙伴工作台、智能路由、企业资金与分析、官网设置与预约演示等, semi-ui 已全部迁移到 antd 6 / @/components/ui,不重新引入 Semi - 分佣二级菜单与页头去重、伙伴入口探测(企业伙伴走企业中心「企业分佣」)、超管侧栏入口恢复 - 适配层 DatePicker / TimePicker 统一 onChange(Date|Date[]|null, 文本) 契约;生产构建剔除调试日志 - 图片链接刷新:同任务请求复用、后台刷新不弹全局错误、离页停止批量请求 - 恢复 bun.lock(与 package-lock.json 共存);docs 规范与 CHANGELOG 更新 - 停止跟踪 .env.playwright.local(本地登录凭据,已加入 .gitignore)
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
export function latestTierURL(filters = {}, page = 1, snapshot = {}) {
|
||||
const params = new URLSearchParams({
|
||||
view: 'latest',
|
||||
p: String(page),
|
||||
page_size: '100',
|
||||
});
|
||||
if (filters.query?.trim()) params.set('q', filters.query.trim());
|
||||
if (filters.type) params.set('source_type', filters.type);
|
||||
const status =
|
||||
{ enabled: 'active', scheduled: 'pending' }[filters.status] ||
|
||||
filters.status;
|
||||
if (status && status !== 'all') params.set('status', status);
|
||||
if (snapshot.as_of) params.set('as_of', String(snapshot.as_of));
|
||||
if (snapshot.revision != null)
|
||||
params.set('revision', String(snapshot.revision));
|
||||
return `/api/commission/v2/tiers?${params}`;
|
||||
}
|
||||
|
||||
export async function fetchAllLatestTiers(fetchJSON, filters = {}) {
|
||||
const rows = [];
|
||||
let snapshot;
|
||||
let total;
|
||||
for (let page = 1; ; page++) {
|
||||
const result = await fetchJSON(latestTierURL(filters, page, snapshot));
|
||||
if (!snapshot) {
|
||||
snapshot = { as_of: result.as_of, revision: result.revision };
|
||||
total = result.total;
|
||||
}
|
||||
if (
|
||||
result.as_of !== snapshot.as_of ||
|
||||
result.revision !== snapshot.revision ||
|
||||
result.total !== total
|
||||
)
|
||||
throw new Error('档位配置已变化,请重新加载或重新导出');
|
||||
if (
|
||||
!Array.isArray(result.items) ||
|
||||
(rows.length < total && !result.items.length)
|
||||
)
|
||||
throw new Error('无法取得完整档位列表,请重试');
|
||||
rows.push(...result.items);
|
||||
if (rows.length === total) return rows;
|
||||
if (rows.length > total) throw new Error('档位配置已变化,请重新导出');
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeIdentityOptions(previous, next, selected) {
|
||||
return [
|
||||
...new Map(
|
||||
[...(selected ? [selected] : []), ...previous, ...next].map((item) => [
|
||||
Number(item.id),
|
||||
item,
|
||||
]),
|
||||
).values(),
|
||||
];
|
||||
}
|
||||
|
||||
export function createRequestGeneration() {
|
||||
let generation = 0;
|
||||
return { next: () => ++generation, current: (value) => generation === value };
|
||||
}
|
||||
|
||||
export function identityOptionLabel(item) {
|
||||
const name =
|
||||
item.name || item.display_name || item.username || item.code || '';
|
||||
const identifier = item.name ? item.code : item.username;
|
||||
return `${name}${identifier && identifier !== name ? ` · ${identifier}` : ''} (#${item.id})${item.disabled_reason ? ` · ${item.disabled_reason}` : ''}`;
|
||||
}
|
||||
Reference in New Issue
Block a user