新增: OSS 资产库与桌面本地文件读取,交互与云同步增强

This commit is contained in:
lxy
2026-08-27 22:22:04 +08:00
parent e839c62bba
commit daaccb8ad7
21 changed files with 1388 additions and 38 deletions
+17
View File
@@ -7,6 +7,7 @@ import { store } from '../../core/store'
import { elementTypes } from '../../core/sample'
import { generateImage, isImageConfigured, checkImageQuota } from '../../core/ai'
import { readAsDataURL } from '../../core/importer'
import { putAsset, isOssEnabled } from '../../core/assets'
import { appAlert, appConfirm, appPrompt } from '../../core/dialog'
import { markdownToSegments, segmentsToPlain, hasFormatting } from '../../core/richtext'
import AddGrid from './AddGrid.vue'
@@ -271,6 +272,12 @@ function onLocalImage() {
const file = input.files?.[0]
if (!file) return
try {
// OSS 启用:走资产库(上云或离线暂存),content 存引用/URL,绕过 5MB 墙
if (isOssEnabled()) {
const ref = await putAsset(file)
store.updateElement(el.id, { content: ref })
return
}
const dataUrl = await readAsDataURL(file)
const quotaErr = checkImageQuota(dataUrl)
if (quotaErr) { appAlert('图片受限', quotaErr); return }
@@ -292,6 +299,16 @@ function onLocalVideo() {
input.onchange = async () => {
const f = input.files?.[0]
if (!f) return
// OSS 启用:视频走资产库(大文件尤其受益,避免撑爆本地存储)
if (isOssEnabled()) {
try {
const ref = await putAsset(f)
store.updateElement(el.id, { content: ref })
} catch (e: any) {
appAlert('读取视频失败', e?.message || String(e))
}
return
}
// 注意:大视频会整体读入内存(dataURL),本地工具首版接受
const dataUrl = await readAsDataURL(f)
store.updateElement(el.id, { content: dataUrl })