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

@@ -6,8 +6,6 @@ import hljs from 'highlight.js';
import 'highlight.js/styles/github.css'; // 亮色主题
// 导入主题存储
import { useThemeStore } from '@/stores/theme';
// 导入ExamClient用于获取图片资源
import { ExamClient } from '@/APIClient';
import { AuthManager } from '@/utils/AuthManager';
const props = defineProps({
@@ -36,8 +34,8 @@ const imageResourceCache = ref<Map<string, string>>(new Map());
// 获取图片资源ID的函数
async function getImageResourceId(examId: string, imagePath: string): Promise<string | null> {
try {
const client = AuthManager.createAuthenticatedExamClient();
const resources = await client.getExamResourceList(examId, 'images');
const client = AuthManager.createAuthenticatedResourceClient();
const resources = await client.getResourceList(examId, 'images', 'template');
// 查找匹配的图片资源
const imageResource = resources.find(r => r.name === imagePath || r.name.endsWith(imagePath));
@@ -52,8 +50,8 @@ async function getImageResourceId(examId: string, imagePath: string): Promise<st
// 通过资源ID获取图片数据URL
async function getImageDataUrl(resourceId: string): Promise<string | null> {
try {
const client = AuthManager.createAuthenticatedExamClient();
const response = await client.getExamResourceById(parseInt(resourceId));
const client = AuthManager.createAuthenticatedResourceClient();
const response = await client.getResourceById(parseInt(resourceId));
if (response && response.data) {
return URL.createObjectURL(response.data);