feat: 实现 PinnedProject 组件与父组件的双向交互

添加 PinnedProject 组件引用和 pin-changed 事件处理
在 Dashboard 和 Dashboard-AI 中同步 pin 状态
暴露 loadPinnedBids 方法供父组件调用
This commit is contained in:
dmy
2026-01-13 21:16:23 +08:00
parent feb18c01bb
commit f050d38140
3 changed files with 72 additions and 3 deletions

View File

@@ -52,6 +52,10 @@ import axios from 'axios'
import { ElMessage } from 'element-plus'
import { Loading, InfoFilled, Paperclip } from '@element-plus/icons-vue'
const emit = defineEmits<{
pinChanged: [title: string]
}>()
const pinnedBids = ref<any[]>([])
const pinnedLoading = ref(false)
@@ -77,6 +81,8 @@ const togglePin = async (item: any) => {
pinnedBids.value.splice(index, 1)
}
ElMessage.success('已取消置顶')
// 通知父组件 pin 状态已改变,传递 title
emit('pinChanged', item.title)
} catch (error) {
ElMessage.error('操作失败')
}
@@ -96,6 +102,11 @@ const formatDate = (dateStr: string) => {
onMounted(() => {
loadPinnedBids()
})
// 暴露方法给父组件调用
defineExpose({
loadPinnedBids
})
</script>
<style scoped>