|
|
@@ -225,7 +225,14 @@
|
|
|
}
|
|
|
$skillNames = [];
|
|
|
foreach ($skills as $skill) {
|
|
|
- $skillNames[] = $skill['skill_name'] ?? ($skill['skill_code'] ?? 'N/A');
|
|
|
+ // 处理不同格式的技能数据
|
|
|
+ if (is_string($skill)) {
|
|
|
+ // 如果是字符串,直接显示
|
|
|
+ $skillNames[] = $skill;
|
|
|
+ } elseif (is_array($skill)) {
|
|
|
+ // 如果是对象,显示skill_name或skill_code
|
|
|
+ $skillNames[] = $skill['skill_name'] ?? $skill['skill_code'] ?? 'N/A';
|
|
|
+ }
|
|
|
}
|
|
|
$skillText = implode(', ', array_slice($skillNames, 0, 2));
|
|
|
if (count($skillNames) > 2) {
|
|
|
@@ -530,6 +537,86 @@
|
|
|
window.location.reload();
|
|
|
}, 500); // 延迟500ms刷新,给用户时间看到成功消息
|
|
|
});
|
|
|
+
|
|
|
+ // 监听实时回调通知
|
|
|
+ Livewire.on('task-failed', (event) => {
|
|
|
+ const { taskId, error, kpCode } = event[0];
|
|
|
+
|
|
|
+ // 显示详细错误通知
|
|
|
+ const notification = document.createElement('div');
|
|
|
+ notification.className = 'fixed top-4 right-4 bg-red-50 border border-red-200 rounded-lg shadow-lg p-4 max-w-md z-50';
|
|
|
+ notification.innerHTML = `
|
|
|
+ <div class="flex items-start">
|
|
|
+ <div class="flex-shrink-0">
|
|
|
+ <svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
|
|
|
+ <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"></path>
|
|
|
+ </svg>
|
|
|
+ </div>
|
|
|
+ <div class="ml-3">
|
|
|
+ <h3 class="text-sm font-medium text-red-800">题目生成失败</h3>
|
|
|
+ <div class="mt-2 text-sm text-red-700">
|
|
|
+ <p>任务ID: ${taskId}</p>
|
|
|
+ <p>知识点: ${kpCode}</p>
|
|
|
+ <p class="mt-1 font-mono text-xs">${error}</p>
|
|
|
+ </div>
|
|
|
+ <div class="mt-3 flex space-x-2">
|
|
|
+ <button onclick="this.closest('.fixed').remove()" class="text-sm text-red-600 hover:text-red-800 underline">
|
|
|
+ 关闭
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+
|
|
|
+ document.body.appendChild(notification);
|
|
|
+
|
|
|
+ // 5秒后自动移除
|
|
|
+ setTimeout(() => {
|
|
|
+ if (notification.parentNode) {
|
|
|
+ notification.parentNode.removeChild(notification);
|
|
|
+ }
|
|
|
+ }, 10000);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 监听任务成功回调
|
|
|
+ Livewire.on('task-completed', (event) => {
|
|
|
+ const { taskId, kpCode, total } = event[0];
|
|
|
+
|
|
|
+ // 显示成功通知
|
|
|
+ const notification = document.createElement('div');
|
|
|
+ notification.className = 'fixed top-4 right-4 bg-green-50 border border-green-200 rounded-lg shadow-lg p-4 max-w-md z-50';
|
|
|
+ notification.innerHTML = `
|
|
|
+ <div class="flex items-start">
|
|
|
+ <div class="flex-shrink-0">
|
|
|
+ <svg class="h-5 w-5 text-green-400" fill="currentColor" viewBox="0 0 20 20">
|
|
|
+ <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path>
|
|
|
+ </svg>
|
|
|
+ </div>
|
|
|
+ <div class="ml-3">
|
|
|
+ <h3 class="text-sm font-medium text-green-800">题目生成成功</h3>
|
|
|
+ <div class="mt-2 text-sm text-green-700">
|
|
|
+ <p>任务ID: ${taskId}</p>
|
|
|
+ <p>知识点: ${kpCode}</p>
|
|
|
+ <p>已成功生成 ${total} 道题目</p>
|
|
|
+ </div>
|
|
|
+ <div class="mt-3">
|
|
|
+ <button onclick="location.reload()" class="text-sm text-green-600 hover:text-green-800 underline">
|
|
|
+ 刷新页面
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+
|
|
|
+ document.body.appendChild(notification);
|
|
|
+
|
|
|
+ // 3秒后自动移除
|
|
|
+ setTimeout(() => {
|
|
|
+ if (notification.parentNode) {
|
|
|
+ notification.parentNode.removeChild(notification);
|
|
|
+ }
|
|
|
+ }, 5000);
|
|
|
+ });
|
|
|
});
|
|
|
</script>
|
|
|
</x-filament-panels::page>
|