feat(workspace): 完成图片资产存储与引用

This commit is contained in:
2026-09-13 21:52:14 +08:00
parent c87b56a13f
commit 9c35f54560
16 changed files with 655 additions and 10 deletions
@@ -0,0 +1,14 @@
import { describe, expect, it } from 'vitest'
import { resolveWorkspaceAssetPath, workspaceAssetReference } from './workspaceService'
describe('workspace asset paths', () => {
it('creates portable references relative to the note', () => {
expect(workspaceAssetReference('/课程/系统/调度.md', 'attachments/ab/hash.png')).toBe('../../attachments/ab/hash.png')
expect(resolveWorkspaceAssetPath('/课程/系统/调度.md', '../../attachments/ab/hash.png')).toBe('attachments/ab/hash.png')
})
it('does not resolve remote URLs or paths escaping the vault', () => {
expect(resolveWorkspaceAssetPath('/a.md', 'https://example.com/image.png')).toBeNull()
expect(resolveWorkspaceAssetPath('/a.md', '../attachments/ab/hash.png')).toBeNull()
})
})