Claw 项目完整结构提交

This commit is contained in:
zqm
2026-03-16 15:47:55 +08:00
parent ca4970bcbf
commit fb0aeb6ca2
118 changed files with 28648 additions and 281 deletions

View File

@@ -0,0 +1,143 @@
// 任务卡片组件逻辑
const { TASK_STATUS } = require('../../utils/constant.js')
Component({
properties: {
// 任务ID
taskId: {
type: String,
value: ''
},
// 任务标题
title: {
type: String,
value: ''
},
// 任务描述
description: {
type: String,
value: ''
},
// 任务类型
type: {
type: String,
value: ''
},
// 任务状态
status: {
type: String,
value: TASK_STATUS.PENDING
},
// 优先级
priority: {
type: String,
value: ''
},
// 创建时间
createdAt: {
type: String,
value: ''
},
// 更新时间
updatedAt: {
type: String,
value: ''
},
// 处理结果
result: {
type: String,
value: ''
},
// 进度0-100
progress: {
type: Number,
value: 0
}
},
data: {
statusText: ''
},
lifetimes: {
attached() {
this.updateStatusText()
}
},
observers: {
'status': function(status) {
this.updateStatusText()
}
},
methods: {
// 更新状态文本
updateStatusText() {
const statusMap = {
[TASK_STATUS.PENDING]: '待处理',
[TASK_STATUS.PROCESSING]: '处理中',
[TASK_STATUS.COMPLETED]: '已完成',
[TASK_STATUS.FAILED]: '处理失败',
[TASK_STATUS.CANCELLED]: '已取消'
}
this.setData({
statusText: statusMap[this.properties.status] || '未知状态'
})
},
// 开始处理任务
startTask() {
this.triggerEvent('start', {
taskId: this.properties.taskId,
title: this.properties.title
})
},
// 完成任务
completeTask() {
this.triggerEvent('complete', {
taskId: this.properties.taskId,
title: this.properties.title
})
},
// 重试任务
retryTask() {
this.triggerEvent('retry', {
taskId: this.properties.taskId,
title: this.properties.title
})
},
// 查看任务详情
viewDetails() {
this.triggerEvent('detail', {
taskId: this.properties.taskId,
title: this.properties.title,
description: this.properties.description,
status: this.properties.status,
result: this.properties.result,
createdAt: this.properties.createdAt,
updatedAt: this.properties.updatedAt
})
},
// 取消任务
cancelTask() {
wx.showModal({
title: '确认取消',
content: `确定要取消任务"${this.properties.title}"吗?`,
success: (res) => {
if (res.confirm) {
this.triggerEvent('cancel', {
taskId: this.properties.taskId,
title: this.properties.title
})
}
}
})
}
}
})

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View File

@@ -0,0 +1,39 @@
<!-- 任务卡片组件 -->
<view class="task-card {{status}}">
<view class="task-header">
<text class="task-title">{{title}}</text>
<text class="task-status {{status}}">{{statusText}}</text>
</view>
<view class="task-content">
<text class="task-description">{{description}}</text>
<view class="task-meta" wx:if="{{type}}">
<text class="task-type">类型:{{type}}</text>
<text class="task-priority" wx:if="{{priority}}">优先级:{{priority}}</text>
</view>
<view class="task-timeline" wx:if="{{createdAt}}">
<text class="task-time">创建时间:{{createdAt}}</text>
<text class="task-time" wx:if="{{updatedAt}}">更新时间:{{updatedAt}}</text>
</view>
</view>
<view class="task-actions">
<button class="action-btn primary" wx:if="{{status === 'pending'}}" bindtap="startTask">开始处理</button>
<button class="action-btn success" wx:if="{{status === 'processing'}}" bindtap="completeTask">标记完成</button>
<button class="action-btn warning" wx:if="{{status === 'failed'}}" bindtap="retryTask">重试</button>
<button class="action-btn info" bindtap="viewDetails">查看详情</button>
<button class="action-btn danger" wx:if="{{status !== 'completed'}}" bindtap="cancelTask">取消</button>
</view>
<view class="task-progress" wx:if="{{status === 'processing' && progress}}">
<progress percent="{{progress}}" stroke-width="6" activeColor="#07c160" backgroundColor="#f0f0f0"/>
<text class="progress-text">{{progress}}%</text>
</view>
<view class="task-result" wx:if="{{result}}">
<text class="result-label">处理结果:</text>
<text class="result-content">{{result}}</text>
</view>
</view>

View File

@@ -0,0 +1,195 @@
/* 任务卡片组件样式 */
.task-card {
background: white;
border-radius: 20rpx;
padding: 30rpx;
margin: 20rpx 0;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
border-left: 8rpx solid #e0e0e0;
}
.task-card.pending {
border-left-color: #f0ad4e;
}
.task-card.processing {
border-left-color: #10aeff;
}
.task-card.completed {
border-left-color: #07c160;
}
.task-card.failed {
border-left-color: #dd524d;
}
.task-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.task-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
flex: 1;
margin-right: 20rpx;
}
.task-status {
padding: 8rpx 20rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-weight: bold;
text-transform: uppercase;
}
.task-status.pending {
background-color: #fff3cd;
color: #856404;
}
.task-status.processing {
background-color: #cce5ff;
color: #004085;
}
.task-status.completed {
background-color: #d4edda;
color: #155724;
}
.task-status.failed {
background-color: #f8d7da;
color: #721c24;
}
.task-content {
margin-bottom: 20rpx;
}
.task-description {
font-size: 28rpx;
color: #666;
line-height: 1.5;
margin-bottom: 20rpx;
}
.task-meta {
display: flex;
flex-wrap: wrap;
gap: 20rpx;
margin-bottom: 20rpx;
}
.task-type,
.task-priority {
font-size: 24rpx;
color: #999;
background: #f8f8f8;
padding: 8rpx 16rpx;
border-radius: 10rpx;
}
.task-timeline {
display: flex;
flex-direction: column;
gap: 10rpx;
}
.task-time {
font-size: 24rpx;
color: #999;
}
.task-actions {
display: flex;
flex-wrap: wrap;
gap: 15rpx;
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f0f0f0;
}
.action-btn {
padding: 16rpx 32rpx;
border: none;
border-radius: 25rpx;
font-size: 26rpx;
font-weight: 500;
transition: all 0.3s ease;
min-width: 120rpx;
}
.action-btn.primary {
background: linear-gradient(135deg, #07c160 0%, #06a050 100%);
color: white;
}
.action-btn.success {
background: linear-gradient(135deg, #28a745 0%, #218838 100%);
color: white;
}
.action-btn.warning {
background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
color: #212529;
}
.action-btn.info {
background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
color: white;
}
.action-btn.danger {
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
color: white;
}
.action-btn:active {
transform: scale(0.95);
}
.task-progress {
margin: 20rpx 0;
display: flex;
align-items: center;
gap: 20rpx;
}
.progress-text {
font-size: 24rpx;
color: #666;
min-width: 60rpx;
text-align: right;
}
.task-result {
background: #f8f9fa;
border-radius: 10rpx;
padding: 20rpx;
margin-top: 20rpx;
}
.result-label {
font-size: 24rpx;
color: #666;
font-weight: bold;
margin-bottom: 10rpx;
display: block;
}
.result-content {
font-size: 26rpx;
color: #333;
line-height: 1.5;
background: white;
padding: 15rpx;
border-radius: 8rpx;
border: 1rpx solid #e9ecef;
}