feat: 统一资源管理

This commit is contained in:
alivender
2025-08-02 13:14:01 +08:00
parent e5f2be616c
commit 9904fecbee
15 changed files with 1178 additions and 838 deletions

View File

@@ -679,15 +679,15 @@ const downloadResources = async () => {
downloadingResources.value = true
try {
const client = AuthManager.createAuthenticatedExamClient()
const resourceClient = AuthManager.createAuthenticatedResourceClient()
// 获取资源包列表
const resourceList = await client.getExamResourceList(selectedExam.value.id, 'resource')
// 获取资源包列表(模板资源)
const resourceList = await resourceClient.getResourceList(selectedExam.value.id, 'resource', 'template')
if (resourceList && resourceList.length > 0) {
// 使用动态API获取第一个资源包
// 使用新的ResourceClient API获取第一个资源包
const resourceId = resourceList[0].id
const fileResponse = await client.getExamResourceById(resourceId)
const fileResponse = await resourceClient.getResourceById(resourceId)
// 创建Blob URL
const blobUrl = URL.createObjectURL(fileResponse.data)
@@ -925,7 +925,7 @@ const submitCreateExam = async () => {
// 上传实验资源
const uploadExamResources = async (examId: string) => {
const client = AuthManager.createAuthenticatedExamClient()
const client = AuthManager.createAuthenticatedResourceClient()
try {
// 上传MD文档
@@ -934,7 +934,7 @@ const uploadExamResources = async (examId: string) => {
data: uploadFiles.value.mdFile,
fileName: uploadFiles.value.mdFile.name
}
await client.addExamResource(examId, 'doc', mdFileParam)
await client.addResource('doc', 'template', examId, mdFileParam)
console.log('MD文档上传成功')
}
@@ -944,7 +944,7 @@ const uploadExamResources = async (examId: string) => {
data: imageFile,
fileName: imageFile.name
}
await client.addExamResource(examId, 'image', imageFileParam)
await client.addResource('image', 'template', examId, imageFileParam)
console.log('图片上传成功:', imageFile.name)
}
@@ -954,7 +954,7 @@ const uploadExamResources = async (examId: string) => {
data: bitstreamFile,
fileName: bitstreamFile.name
}
await client.addExamResource(examId, 'bitstream', bitstreamFileParam)
await client.addResource('bitstream', 'template', examId, bitstreamFileParam)
console.log('比特流文件上传成功:', bitstreamFile.name)
}
@@ -964,7 +964,7 @@ const uploadExamResources = async (examId: string) => {
data: canvasFile,
fileName: canvasFile.name
}
await client.addExamResource(examId, 'canvas', canvasFileParam)
await client.addResource('canvas', 'template', examId, canvasFileParam)
console.log('画布模板上传成功:', canvasFile.name)
}
@@ -974,7 +974,7 @@ const uploadExamResources = async (examId: string) => {
data: uploadFiles.value.resourceFile,
fileName: uploadFiles.value.resourceFile.name
}
await client.addExamResource(examId, 'resource', resourceFileParam)
await client.addResource('resource', 'template', examId, resourceFileParam)
console.log('资源包上传成功')
}

View File

@@ -37,7 +37,7 @@
<!-- 拖拽分割线 -->
<SplitterResizeHandle
id="splitter-group-h-resize-handle"
class="w-2 bg-base-100 hover:bg-primary hover:opacity-70 transition-colors"
class="w-1 bg-base-300"
/>
<!-- 右侧编辑区域 -->
<SplitterPanel
@@ -74,7 +74,7 @@
<SplitterResizeHandle
v-show="!isBottomBarFullscreen"
id="splitter-group-v-resize-handle"
class="h-2 bg-base-100 hover:bg-primary hover:opacity-70 transition-colors"
class="h-1 bg-base-300"
/>
<!-- 功能底栏 -->
@@ -217,17 +217,17 @@ async function loadDocumentContent() {
if (examId) {
// 如果有实验ID从API加载实验文档
console.log('加载实验文档:', examId);
const client = AuthManager.createAuthenticatedExamClient();
const client = AuthManager.createAuthenticatedResourceClient();
// 获取markdown类型的资源列表
const resources = await client.getExamResourceList(examId, 'doc');
// 获取markdown类型的模板资源列表
const resources = await client.getResourceList(examId, 'doc', 'template');
if (resources && resources.length > 0) {
// 获取第一个markdown资源
const markdownResource = resources[0];
// 使用动态API获取资源文件内容
const response = await client.getExamResourceById(markdownResource.id);
// 使用新的ResourceClient API获取资源文件内容
const response = await client.getResourceById(markdownResource.id);
if (!response || !response.data) {
throw new Error('获取markdown文件失败');