fix(training): 修复安全培训状态问题!
This commit is contained in:
1 parent
11cef575b4
commit
375e4e371d
6 files changed
+192
-73
No files matched your search
@@ -41,6 +41,7 @@ const props = defineProps<{
|
||||
currentIndex?: number;
|
||||
agentId?: number | null;
|
||||
authHeaders?: Record<string, string>;
|
||||
requiredDuration?: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -49,6 +50,35 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const countdownSeconds = ref(0);
|
||||
let countdownTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
const startCountdown = () => {
|
||||
if (countdownTimer) {
|
||||
clearInterval(countdownTimer);
|
||||
countdownTimer = null;
|
||||
}
|
||||
if (props.requiredDuration && props.requiredDuration > 0) {
|
||||
countdownSeconds.value = props.requiredDuration * 60;
|
||||
countdownTimer = setInterval(() => {
|
||||
if (countdownSeconds.value > 0) {
|
||||
countdownSeconds.value--;
|
||||
} else {
|
||||
if (countdownTimer) clearInterval(countdownTimer);
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
countdownSeconds.value = 0;
|
||||
}
|
||||
};
|
||||
|
||||
const stopCountdown = () => {
|
||||
if (countdownTimer) {
|
||||
clearInterval(countdownTimer);
|
||||
countdownTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
const isLoading = ref(false);
|
||||
const error = ref('');
|
||||
const markdownHtml = ref('');
|
||||
@@ -647,6 +677,9 @@ const loadContent = async () => {
|
||||
watch(
|
||||
() => [props.modelValue, activeFile.value?.url, activeFile.value?.name, activeIndex.value, activeFiles.value.length],
|
||||
() => {
|
||||
if (props.modelValue) {
|
||||
startCountdown();
|
||||
}
|
||||
loadContent();
|
||||
},
|
||||
{ immediate: true }
|
||||
@@ -657,6 +690,7 @@ watch(
|
||||
(v) => {
|
||||
if (!v) {
|
||||
clearOfficeObjectUrl();
|
||||
stopCountdown();
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -674,6 +708,9 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<div v-if="countdownSeconds > 0" class="flex items-center justify-center h-8 w-8 rounded-full border border-red-200 bg-red-50 text-red-500 font-semibold text-xs shadow-sm">
|
||||
{{ countdownSeconds }}s
|
||||
</div>
|
||||
<div v-if="isExcelPreviewFile" class="flex items-center gap-2 rounded-full border border-default bg-surface px-2 py-1">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user