- 修改模型模块的字段名称,从 `keyword` 更改为 `modelName`,以提高一致性。 - 添加模型类型和访问类型的选择功能,增强用户交互体验。 - 移除不必要的调试日志,优化代码整洁性。 - 更新订阅页面的错误处理逻辑,确保用户在加载失败时获得清晰反馈。
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
// 开通页面地址(public/web/subscribe.html)
|
||
const SUBSCRIBE_PAGE_URL = '/web/subscribe.html';
|
||
|
||
// 路由路径与 assetId 的映射关系
|
||
const ROUTE_ASSET_MAP: Record<string, { assetId: string; serviceName: string }> = {
|
||
// CID广告业务(聚合广告)
|
||
'/cidService': { assetId: '696f423705e496ba4ccbe665', serviceName: '聚合广告' },
|
||
|
||
// AI客服业务
|
||
'/customerService': { assetId: '696f421205e496ba4ccbe662', serviceName: 'AI客服' },
|
||
|
||
// 聚合电商业务(资产管理)
|
||
'/assets': { assetId: '696b4acd1be1c8b76c4b4c15', serviceName: '资产管理' },
|
||
};
|
||
|
||
/**
|
||
* 根据路由路径获取对应的 assetId 和服务名称
|
||
*/
|
||
export function getAssetInfoByRoute(routePath: string): { assetId: string; serviceName: string } | null {
|
||
// 精确匹配
|
||
if (ROUTE_ASSET_MAP[routePath]) {
|
||
return ROUTE_ASSET_MAP[routePath];
|
||
}
|
||
|
||
// 前缀匹配
|
||
for (const [prefix, info] of Object.entries(ROUTE_ASSET_MAP)) {
|
||
if (routePath.startsWith(prefix)) {
|
||
return info;
|
||
}
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* 跳转到外部开通页面
|
||
* @param assetId 资产ID
|
||
*/
|
||
export function redirectToSubscribePage(assetId: string) {
|
||
// 当前页面地址作为返回地址
|
||
const returnUrl = encodeURIComponent(window.location.href);
|
||
// 构建跳转URL
|
||
const url = `${SUBSCRIBE_PAGE_URL}?assetId=${assetId}&returnUrl=${returnUrl}`;
|
||
window.location.href = url;
|
||
}
|
||
|
||
/**
|
||
* 处理 402 错误码(模块未开通)
|
||
*/
|
||
export function handleModuleNotEnabled(routePath: string): boolean {
|
||
const assetInfo = getAssetInfoByRoute(routePath);
|
||
|
||
if (assetInfo) {
|
||
redirectToSubscribePage(assetInfo.assetId);
|
||
return true;
|
||
}
|
||
|
||
redirectToSubscribePage('696b4acd1be1c8b76c4b4c15');
|
||
return true;
|
||
}
|