feat:历史记录分享功能实现

This commit is contained in:
liailing1026
2026-03-12 13:35:04 +08:00
parent 26c42697e8
commit 130f78108f
9 changed files with 1500 additions and 80 deletions

View File

@@ -26,6 +26,7 @@
</div>
<div class="plan-actions">
<el-popover
:ref="(el: any) => setPopoverRef(plan.id, el)"
placement="bottom-end"
:show-arrow="false"
trigger="click"
@@ -37,15 +38,15 @@
</button>
</template>
<div class="action-menu">
<div class="action-item" @click="pinPlan(plan)">
<div class="action-item" @click="handleAction(plan, 'pin')">
<SvgIcon icon-class="ZhiDing" size="14px" />
<span>{{ plan.is_pinned ? '取消置顶' : '置顶' }}</span>
</div>
<div class="action-item">
<div class="action-item" @click="handleAction(plan, 'share')">
<SvgIcon icon-class="FenXiang" size="14px" />
<span>分享</span>
</div>
<div class="action-item" @click="deletePlan(plan)">
<div class="action-item" @click="handleAction(plan, 'delete')">
<SvgIcon icon-class="ShanChu" size="14px" />
<span>删除</span>
</div>
@@ -62,6 +63,12 @@
content="删除后,该任务无法恢复 !"
@confirm="confirmDelete"
/>
<!-- 分享对话框 -->
<SharePlanDialog
v-model="shareDialogVisible"
:plan-id="sharePlanId"
/>
</div>
</template>
@@ -71,6 +78,7 @@ import { ElMessage } from 'element-plus'
import { Loading } from '@element-plus/icons-vue'
import SvgIcon from '@/components/SvgIcon/index.vue'
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog/index.vue'
import SharePlanDialog from '@/components/SharePlanDialog/index.vue'
import websocket from '@/utils/websocket'
// 事件定义
@@ -101,6 +109,44 @@ const dialogVisible = ref(false)
const planToDelete = ref<PlanInfo | null>(null)
const deleting = ref(false)
// 分享对话框相关
const shareDialogVisible = ref(false)
const sharePlanId = ref<string>('')
// Popover 引用管理
const popoverRefs = new Map<string, any>()
const setPopoverRef = (planId: string, el: any) => {
if (el) {
popoverRefs.set(planId, el)
}
}
// 统一处理操作点击
const handleAction = (plan: PlanInfo, action: 'pin' | 'share' | 'delete') => {
// 关闭 popover
const popover = popoverRefs.get(plan.id)
if (popover) {
popover.hide()
}
// 延迟执行操作,让 popover 有时间关闭
setTimeout(() => {
if (action === 'pin') {
pinPlan(plan)
} else if (action === 'share') {
openShareDialog(plan)
} else if (action === 'delete') {
deletePlan(plan)
}
}, 100)
}
// 打开分享弹窗
const openShareDialog = (plan: PlanInfo) => {
sharePlanId.value = plan.id
shareDialogVisible.value = true
}
// 生成唯一请求ID
let requestIdCounter = 0
const generateRequestId = () => `ws_req_${Date.now()}_${++requestIdCounter}`