
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@dimples/todo-list
Advanced tools
基于全新utils-headless架构的Todo列表组件,完全按照ui-editor的最新架构模式实现。
createHeadless(workspace)创建workspace实例getHeadless(workspace).getFeature(name)获取功能特性createData、createEvent创建数据和事件每个功能特性包含:
const FeatureOptions = { data, event, api }
headless.createFeature(FeatureName, FeatureOptions)
declare module '../headless' {
interface Features {
[FeatureName]: typeof FeatureOptions
}
}
import React from 'react'
import { WebTodoApp } from '@anker-fe/ui-todo-list-v2'
function App() {
return (
<div>
<WebTodoApp />
</div>
)
}
import React from 'react'
import { MobileTodoApp } from '@anker-fe/ui-todo-list-v2'
function App() {
return <MobileTodoApp />
}
import { getHeadless } from '@anker-fe/ui-todo-list-v2'
// 获取功能特性
const addTodoFeature = getHeadless('todo-list').getFeature('add-todo')
const todosFeature = getHeadless('todo-list').getFeature('todos')
// 使用API
addTodoFeature.api.addTodo('新的待办事项')
// 获取数据
const items = todosFeature.data.value.items
// 监听事件
addTodoFeature.event.on('afterAdd', (data) => {
console.log('添加了todo:', data)
})
// 1. 创建数据
import { createData } from '@dimples/utils-headless'
export const data = createData({
customValue: 'initial'
})
// 2. 创建事件
import { createEvent } from '@dimples/utils-headless'
export const event = createEvent<{
customEvent: [string]
}>()
// 3. 创建API
import { getHeadless } from '@dimples/utils-headless'
export const customAction = (value: string) => {
const feature = getHeadless('todo-list').getFeature('custom-feature')
feature.data.value.customValue = value
feature.event.emit('customEvent', value)
}
// 4. 注册功能特性
import { data } from './data'
import { event } from './event'
import * as api from './api'
import { headless } from '../headless'
const FeatureName = 'custom-feature' as const
const FeatureOptions = { data, event, api }
headless.createFeature(FeatureName, FeatureOptions)
declare module '../headless' {
interface Features {
[FeatureName]: typeof FeatureOptions
}
}
items, filter, loading, errorgetTodos(), getFilteredTodos()itemsChange, filterChangeinputValue, isAddingaddTodo(text), setInputValue(value)beforeAdd, afterAdd, addFailedremoveTodo(id)beforeRemove, afterRemovetoggleTodo(id)beforeToggle, afterToggleimport { getHeadless } from '@anker-fe/ui-todo-list-v2'
const addTodoFeature = getHeadless('todo-list').getFeature('add-todo')
// 监听添加成功事件
addTodoFeature.event.on('afterAdd', (data) => {
console.log('添加了新的todo:', data)
// 可以在这里添加自定义逻辑,如统计、通知等
})
// 监听添加失败事件
addTodoFeature.event.on('addFailed', (data) => {
if (data.reason === 'empty') {
alert('请输入待办事项内容')
}
})
这个架构完全基于ui-editor的最新实现模式,与anker-fe项目保持完全一致!🎉
FAQs
todo-list demo
We found that @dimples/todo-list demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.