fix: question guide prompt save & sub route image (#5672)

* fix: question guide prompt save & sub route image

* fix markdown
This commit is contained in:
heheer
2025-09-18 18:13:57 +08:00
committed by GitHub
parent 3099b33343
commit 206fd7e4a8
5 changed files with 24 additions and 24 deletions

View File

@@ -35,10 +35,14 @@ export const getImageBase64 = async (url: string) => {
export const addEndpointToImageUrl = (text: string) => {
const baseURL = process.env.FE_DOMAIN;
const subRoute = process.env.NEXT_PUBLIC_BASE_URL || '';
if (!baseURL) return text;
// 匹配 /api/system/img/xxx.xx 的图片链接,并追加 baseURL
return text.replace(
/(?<!https?:\/\/[^\s]*)(?:\/api\/system\/img\/[^\s.]*\.[^\s]*)/g,
(match) => `${baseURL}${match}`
const regex = new RegExp(
`(?<!https?:\\/\\/[^\\s]*)(?:${subRoute}\\/api\\/system\\/img\\/[^\\s.]*\\.[^\\s]*)`,
'g'
);
// 匹配 ${subRoute}/api/system/img/xxx.xx 的图片链接,并追加 baseURL
return text.replace(regex, (match) => {
return `${baseURL}${match}`;
});
};