实现快传,完善快传和网盘的功能,实现文件的互传等一系列功能

This commit is contained in:
yoyuzh
2026-03-20 14:16:18 +08:00
parent 944ab6dbf8
commit 43358e29d7
109 changed files with 5237 additions and 2465 deletions

View File

@@ -0,0 +1,34 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
buildTransferArchiveFileName,
createTransferZipArchive,
} from './transfer-archive';
test('buildTransferArchiveFileName always returns a zip filename', () => {
assert.equal(buildTransferArchiveFileName('课堂资料'), '课堂资料.zip');
assert.equal(buildTransferArchiveFileName('课堂资料.zip'), '课堂资料.zip');
});
test('createTransferZipArchive creates a zip payload that keeps nested file paths', async () => {
const archive = await createTransferZipArchive([
{
name: 'report.pdf',
relativePath: '课程资料/report.pdf',
data: new TextEncoder().encode('report'),
},
{
name: 'notes.txt',
relativePath: '课程资料/notes.txt',
data: new TextEncoder().encode('notes'),
},
]);
const bytes = new Uint8Array(await archive.arrayBuffer());
const text = new TextDecoder().decode(bytes);
assert.equal(String.fromCharCode(...bytes.slice(0, 4)), 'PK\u0003\u0004');
assert.match(text, /课程资料\/report\.pdf/);
assert.match(text, /课程资料\/notes\.txt/);
});