Upload index.vue
Browse files
frontend/src/views/Editor/Thumbnails/index.vue
CHANGED
@@ -453,6 +453,11 @@ const shareLinks = ref({
|
|
453 |
screenshotUrl: '',
|
454 |
})
|
455 |
|
|
|
|
|
|
|
|
|
|
|
456 |
// 处理分享幻灯片
|
457 |
const handleShareSlide = async (index: number) => {
|
458 |
if (!authStore.isLoggedIn) {
|
@@ -460,8 +465,17 @@ const handleShareSlide = async (index: number) => {
|
|
460 |
return
|
461 |
}
|
462 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
shareSlideIndex.value = index
|
464 |
shareModalVisible.value = true
|
|
|
|
|
465 |
|
466 |
// 重置链接
|
467 |
shareLinks.value = {
|
@@ -483,6 +497,12 @@ const handleShareSlide = async (index: number) => {
|
|
483 |
message.error('生成分享链接失败')
|
484 |
// console.error('分享链接生成失败:', error)
|
485 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
}
|
487 |
|
488 |
// 复制到剪贴板
|
|
|
453 |
screenshotUrl: '',
|
454 |
})
|
455 |
|
456 |
+
// 防抖控制
|
457 |
+
const isGeneratingLinks = ref(false)
|
458 |
+
const lastGenerateTime = ref(0)
|
459 |
+
const generateDebounceTime = 2000 // 2秒防抖
|
460 |
+
|
461 |
// 处理分享幻灯片
|
462 |
const handleShareSlide = async (index: number) => {
|
463 |
if (!authStore.isLoggedIn) {
|
|
|
465 |
return
|
466 |
}
|
467 |
|
468 |
+
// 防抖检查
|
469 |
+
const now = Date.now()
|
470 |
+
if (isGeneratingLinks.value || (now - lastGenerateTime.value < generateDebounceTime)) {
|
471 |
+
message.warning('请稍后再试,避免频繁请求')
|
472 |
+
return
|
473 |
+
}
|
474 |
+
|
475 |
shareSlideIndex.value = index
|
476 |
shareModalVisible.value = true
|
477 |
+
isGeneratingLinks.value = true
|
478 |
+
lastGenerateTime.value = now
|
479 |
|
480 |
// 重置链接
|
481 |
shareLinks.value = {
|
|
|
497 |
message.error('生成分享链接失败')
|
498 |
// console.error('分享链接生成失败:', error)
|
499 |
}
|
500 |
+
finally {
|
501 |
+
// 延迟重置生成状态,确保防抖生效
|
502 |
+
setTimeout(() => {
|
503 |
+
isGeneratingLinks.value = false
|
504 |
+
}, 1000)
|
505 |
+
}
|
506 |
}
|
507 |
|
508 |
// 复制到剪贴板
|