refactor: 移除README.md中模拟待办事项同步的示例代码
This commit is contained in:
27
README.md
27
README.md
@@ -142,33 +142,6 @@ cordova.plugins.ShutoApi.addEventListener('uploadLog', function(_, callback) {
|
|||||||
// 监听待办事项同步事件(需要回调)
|
// 监听待办事项同步事件(需要回调)
|
||||||
cordova.plugins.ShutoApi.addEventListener('syncTodo', function(userInfo) {
|
cordova.plugins.ShutoApi.addEventListener('syncTodo', function(userInfo) {
|
||||||
console.log('触发待办事项同步:', userInfo);
|
console.log('触发待办事项同步:', userInfo);
|
||||||
|
|
||||||
// 模拟异步同步待办事项(使用 setTimeout 模拟网络延迟)
|
|
||||||
setTimeout(function() {
|
|
||||||
try {
|
|
||||||
// 模拟从服务器获取待办事项数据
|
|
||||||
var todoList = [
|
|
||||||
{ id: 1, title: '完成项目文档', completed: false, priority: 'high' },
|
|
||||||
{ id: 2, title: '参加团队会议', completed: true, priority: 'medium' },
|
|
||||||
{ id: 3, title: '代码审查', completed: false, priority: 'high' }
|
|
||||||
];
|
|
||||||
|
|
||||||
var syncResult = {
|
|
||||||
success: true,
|
|
||||||
syncedAt: new Date().toISOString(),
|
|
||||||
userId: userInfo.userId,
|
|
||||||
todoList: todoList,
|
|
||||||
totalCount: todoList.length,
|
|
||||||
completedCount: todoList.filter(function(todo) { return todo.completed; }).length
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log('待办事项同步成功:', syncResult);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('待办事项同步失败:', error.message);
|
|
||||||
// 返回错误信息
|
|
||||||
callback(null, error.message);
|
|
||||||
}
|
|
||||||
}, 1000); // 模拟 1 秒的网络延迟
|
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user