feat: 统一资源管理
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user