一键导入
zhin-component-rendering
Covers Zhin component rendering, defineComponent usage, and message template composition. Use when creating reusable message UI components.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Covers Zhin component rendering, defineComponent usage, and message template composition. Use when creating reusable message UI components.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | zhin-component-rendering |
| description | Covers Zhin component rendering, defineComponent usage, and message template composition. Use when creating reusable message UI components. |
| license | MIT |
| metadata | {"author":"zhinjs","version":"1.0","framework":"zhin"} |
Use this skill when developers need to create reusable message components with Zhin's component system.
import { defineComponent, usePlugin } from '@zhin.js/core'
const plugin = usePlugin()
const StatusCard = defineComponent((props: { title: string, value: string }, context) => {
return `<text>${props.title}: ${props.value}</text>`
}, 'status-card')
plugin.addComponent(StatusCard)
Components render within message templates:
await message.$reply('<status-card title="CPU" value="40%"/>')
You can nest components:
await message.$reply('<Fragment><status-card title="Memory" value="512MB"/></Fragment>')
Props support inline expressions with {} and template interpolation via ${} when rendering:
const Card = defineComponent((props: { title: string, count: number }) => {
return `<text>${props.title}: ${props.count}</text>`
}, 'card')
await message.$reply('<card title="Jobs" count="{1 + 2}"/>')
The component service attaches a before.sendMessage listener to render templates before messages send.
If you need to pre-render a template manually, use renderComponents:
import { renderComponents } from '@zhin.js/core'
const options = await renderComponents(componentService.byName, {
context: 'process',
bot: 'dev',
type: 'private',
id: '123',
content: '<status-card title="CPU" value="40%"/>'
})
Zhin includes:
Fragment for grouping/children renderingfetch for loading remote content (use carefully and validate URLs)fetch component.Explains Zhin command registration, middleware flow, and permission checks. Use when building commands or message middleware in Zhin plugins.
Guides creation and management of Zhin tools using ZhinTool, defineTool, and ToolService. Covers the unified tool system that bridges AI agent tool-calling and message commands, including Tool↔Command conversion, permission levels, platform/scope filtering, and tool collection. Use when registering tools, converting between tools and commands, or integrating tools with AI agents.
Guides integration of AI/LLM capabilities in Zhin plugins using @zhin.js/ai. Covers multi-model providers, Agent tool calling, session management, streaming responses, unified tool services, and rich media output. Use when adding AI chat, agents, or tool-calling features to a Zhin bot.
Guides development of custom platform adapters in Zhin. Covers extending the Adapter abstract class, creating Bot instances, handling message events, registering tools, and lifecycle management. Use when building adapters for new chat platforms.
Guides database usage in Zhin including model definitions, CRUD queries, transactions, migrations, and lifecycle hooks. Covers the built-in ORM based on @zhin.js/database with SQLite support. Use when working with data persistence in Zhin plugins.
Guides error handling in Zhin using the built-in error hierarchy, ErrorManager, RetryManager, and CircuitBreaker. Use when implementing resilient error handling, retry logic, or circuit breaker patterns in Zhin plugins.