fix: 修复子路径部署静态资源引用
- 修复 admin 与 usercenter 登录验证码资源在 /flow 子路径下的加载路径 - 统一 logo、空状态图、兜底头像与模型服务商图标的 BASE_URL 处理 - 补齐 usercenter 公共布局与 loading 注入的子路径兼容
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import providerList from './providerList.json';
|
||||
|
||||
const assetBase = import.meta.env.BASE_URL || '/';
|
||||
|
||||
export interface ProviderModelPreset {
|
||||
description: string;
|
||||
label: string;
|
||||
@@ -28,8 +30,25 @@ export interface ProviderPreset {
|
||||
|
||||
const providerOptions = providerList as ProviderPreset[];
|
||||
|
||||
export const getProviderPresetByValue = (targetValue?: string) =>
|
||||
providerOptions.find((item) => item.value === targetValue);
|
||||
const normalizeAssetUrl = (url?: string) => {
|
||||
if (!url || !url.startsWith('/')) {
|
||||
return url || '';
|
||||
}
|
||||
return `${assetBase}${url.slice(1)}`;
|
||||
};
|
||||
|
||||
export const getProviderPresetByValue = (targetValue?: string) => {
|
||||
const preset = providerOptions.find((item) => item.value === targetValue);
|
||||
|
||||
if (!preset) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
...preset,
|
||||
icon: normalizeAssetUrl(preset.icon),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据传入的value,返回对应的icon属性
|
||||
@@ -63,4 +82,7 @@ export const getProviderBadgeText = (
|
||||
return source.replaceAll(/\s+/g, '').slice(0, 2).toUpperCase();
|
||||
};
|
||||
|
||||
export const providerPresets = providerOptions;
|
||||
export const providerPresets = providerOptions.map((item) => ({
|
||||
...item,
|
||||
icon: normalizeAssetUrl(item.icon),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user