feat(storage): 添加对阿里云OSS的支持,更新相关文档和界面文本

This commit is contained in:
bingxiang.cheng
2026-04-13 15:09:24 +08:00
parent 12001f23bf
commit 847660e4fc
7 changed files with 46 additions and 10 deletions
+1
View File
@@ -708,6 +708,7 @@ export default {
requestFailed: 'Request failed',
cos: 'Tencent Cloud COS',
tos: 'Volcengine TOS',
oss: 'Alibaba Cloud OSS',
},
},
webSearchSettings: {
+1
View File
@@ -562,6 +562,7 @@ export default {
requestFailed: "请求失败",
cos: "腾讯云 COS",
tos: "火山引擎 TOS",
oss: "阿里云 OSS",
},
},
webSearchSettings: {
+5 -5
View File
@@ -41,7 +41,7 @@ const DOMPurifyConfig = {
'display', 'pointer-events', 'cursor', 'data-emit', 'direction'
],
// 允许的协议
ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|(?:local|minio|cos|tos|s3):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|(?:local|minio|cos|tos|s3|oss):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
// 禁止的标签和属性
FORBID_TAGS: ['script', 'object', 'embed', 'form', 'input', 'button'],
FORBID_ATTR: ['onerror', 'onload', 'onclick', 'onmouseover', 'onfocus', 'onblur'],
@@ -119,7 +119,7 @@ function protectProviderImageSrcInHTML(html: string): string {
.replace(/&/g, '&')
.replace(/"/g, '"');
return html.replace(
/<img\b([^>]*?)\ssrc=(["'])(local|minio|cos|tos|s3):(?:\/\/|&#x2f;&#x2f;|&#47;&#47;)([^"']+)\2([^>]*)>/gi,
/<img\b([^>]*?)\ssrc=(["'])(local|minio|cos|tos|s3|oss):(?:\/\/|&#x2f;&#x2f;|&#47;&#47;)([^"']+)\2([^>]*)>/gi,
(_m, before, quote, provider, restPathRaw, after) => {
const restPath = decodeProviderURL(restPathRaw);
const protectedSrc = `${provider}://${restPath}`;
@@ -173,7 +173,7 @@ export function isValidURL(url: string): boolean {
}
// 允许 provider:// 形式,由前端后续鉴权拉取并替换为 blob URL
if (/^(local|minio|cos|tos|s3):\/\/\S+$/i.test(trimmed)) {
if (/^(local|minio|cos|tos|s3|oss):\/\/\S+$/i.test(trimmed)) {
return true;
}
@@ -299,7 +299,7 @@ export async function hydrateProtectedFileImages(root: ParentNode | null | undef
}
const images = root.querySelectorAll<HTMLImageElement>(
'img[data-protected-src], img[src^="local://"], img[src^="minio://"], img[src^="cos://"], img[src^="tos://"], img[src^="s3://"]',
'img[data-protected-src], img[src^="local://"], img[src^="minio://"], img[src^="cos://"], img[src^="tos://"], img[src^="s3://"], img[src^="oss://"]',
);
if (!images.length) {
return;
@@ -319,7 +319,7 @@ export async function hydrateProtectedFileImages(root: ParentNode | null | undef
}
img.dataset.authHydrated = '1';
const isProviderScheme = /^(local|minio|cos|tos|s3):\/\//.test(sourceURL);
const isProviderScheme = /^(local|minio|cos|tos|s3|oss):\/\//.test(sourceURL);
const requestURL = isProviderScheme
? `/files?${new URLSearchParams({ file_path: sourceURL }).toString()}`
: sourceURL;
@@ -1266,6 +1266,7 @@ const imageStorageOptions = computed(() => {
{ value: 'cos', label: t('settings.storage.engineCos'), disabled: statusMap.cos === false },
{ value: 'tos', label: t('settings.storage.engineTos'), disabled: statusMap.tos === false },
{ value: 's3', label: 'Amazon S3', disabled: statusMap.s3 === false },
{ value: 'oss', label: t('settings.storage.engineOss'), disabled: statusMap.oss === false },
];
});
@@ -114,6 +114,13 @@ const engineOptions = computed(() => {
available: statusMap.s3,
disabled: statusMap.s3 === false,
},
{
value: 'oss',
label: t('kbSettings.storage.engineOss'),
desc: t('kbSettings.storage.engineOssDesc'),
available: statusMap.oss,
disabled: statusMap.oss === false,
},
]
})
+1
View File
@@ -201,6 +201,7 @@ const navItems = computed(() => [
{ key: 'cos', label: t('settings.storage.cos') },
{ key: 'tos', label: t('settings.storage.tos') },
{ key: 's3', label: 'AWS S3' },
{ key: 'oss', label: t('settings.storage.oss') },
]
},
{ key: 'mcp', icon: 'tools', label: t('settings.mcpService') },