giime-components
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGiime 组件库使用规范
Giime Component Library Usage Specification
Giime 是基于 Element Plus 扩展和增强的内部组件库,所有 组件都有对应的 版本。未列出的 组件与 行为一致,可直接替换使用。
el-gm-gm-*el-*Giime is an internal component library extended and enhanced based on Element Plus. All components have corresponding versions. Unlisted components have the same behavior as components and can be directly replaced for use.
el-gm-gm-*el-*使用原则
Usage Principles
- 优先 Giime:→
el-button,gm-button→el-table,以此类推。Giime 在 Element Plus 基础上统一了默认行为(如自动 loading、默认 filterable),直接使用可以减少重复配置。gm-table - 特殊需求:Giime 无法满足时可用 Element Plus 原生组件。
- 旧代码兼容:旧代码保持原样,新代码按本规范编写。
- 二次确认用 :删除等危险操作使用
GmConfirmBox,它会自动处理确认按钮的 loading 和禁用状态,避免重复提交。GmConfirmBox - 复制用 :
GmCopy自动处理剪切板 API 兼容性并提示成功/失败,无需手写 try-catch。GmCopy - 消息提示用 :
GmMessage默认合并相同消息(GmMessage),避免短时间内弹出大量重复提示,体验优于grouping: true。ElMessage
- Prioritize Giime: →
el-button,gm-button→el-table, and so on. Giime unifies default behaviors on the basis of Element Plus (such as automatic loading, default filterable), which can reduce repeated configuration when used directly.gm-table - Special Requirements: You can use native Element Plus components when Giime cannot meet your needs.
- Legacy Code Compatibility: Keep old code as it is, and write new code in accordance with this specification.
- Use for secondary confirmation: Use
GmConfirmBoxfor dangerous operations such as deletion, which automatically handles the loading and disabled state of the confirmation button to avoid duplicate submissions.GmConfirmBox - Use for copy functions:
GmCopyautomatically handles clipboard API compatibility and prompts success/failure, no need to write try-catch manually.GmCopy - Use for message prompts:
GmMessagemerges identical messages by default (GmMessage), which avoids a large number of repeated prompts popping up in a short time, and provides a better experience thangrouping: true.ElMessage
核心增强特性(gm-* vs el-*)
Core Enhancement Features (gm-* vs el-*)
以下组件相对于 Element Plus 有增强行为,使用时需了解差异:
| 组件 | 增强内容 |
|---|---|
| 异步 |
| 默认 |
| 默认 |
| 新增 |
| 支持 |
| 新增下载进度、默认工具栏(缩放/旋转/下载)、 |
| 同 |
| 新增 |
| 默认 |
| alert 默认禁止 Esc 和遮罩关闭;confirm/prompt 默认显示取消按钮 |
| 二次确认弹窗,自动处理确认按钮 loading 和禁用 |
| 复制到剪切板,自动提示成功/失败 |
注意:未默认开启gm-select-v2,与filterable不同。gm-select
The following components have enhanced behaviors compared to Element Plus, you need to understand the differences when using them:
| Component | Enhancement Content |
|---|---|
| Automatically handles loading for async |
| Default |
| Default |
| Added |
| Supports |
| Added download progress, default toolbar (zoom/rotate/download), |
| Same as |
| Added |
| Default |
| Alert disables Esc and mask closing by default; confirm/prompt shows cancel button by default |
| Secondary confirmation pop-up, automatically handles confirmation button loading and disabled state |
| Copy to clipboard, automatically prompts success/failure |
Note:does not enablegm-select-v2by default, which is different fromfilterable.gm-select
常用代码模式
Common Code Patterns
二次确认删除
Secondary Confirmation for Deletion
ts
const handleDelete = () => {
GmConfirmBox({ message: '是否确认删除?' }, async () => {
await deleteItem();
GmMessage.success('删除成功');
});
};ts
const handleDelete = () => {
GmConfirmBox({ message: '是否确认删除?' }, async () => {
await deleteItem();
GmMessage.success('删除成功');
});
};异步按钮(自动 loading)
Async Button (Automatic Loading)
绑定异步函数即可,无需手动管理 loading 状态。当按钮仅执行 而不返回 Promise 时,不会触发自动 loading:
emitvue
<gm-button @click="handleSubmit">提交</gm-button>ts
const handleSubmit = async () => {
await submitForm();
GmMessage.success('提交成功');
};Just bind an async function, no need to manually manage the loading state. When the button only executes and does not return a Promise, automatic loading will not be triggered:
emitvue
<gm-button @click="handleSubmit">提交</gm-button>ts
const handleSubmit = async () => {
await submitForm();
GmMessage.success('提交成功');
};选择器(:options 写法)
Selector (:options Syntax)
vue
<gm-select v-model="form.status" clearable :options="statusOptions" />vue
<gm-select v-model="form.status" clearable :options="statusOptions" />复制到剪切板
Copy to Clipboard
ts
GmCopy(text);ts
GmCopy(text);获取详细文档
Get Detailed Documentation
使用具体组件、Hook 或工具函数时,通过 MCP 获取详细用法:
giime-docs- 调用 获取完整目录(包含所有组件/Hook/工具函数的链接)
get-giime-docs-sidebar - 调用 获取对应的 Markdown 文档
get-giime-component-doc({ link })
如果 MCP 未配置,参考 mcp-setup.md 进行安装。
giime-docsWhen using specific components, Hooks or utility functions, get detailed usage through the MCP:
giime-docs- Call to get the complete directory (including links to all components/Hooks/utility functions)
get-giime-docs-sidebar - Call to get the corresponding Markdown documentation
get-giime-component-doc({ link })
If the MCP is not configured, refer to mcp-setup.md for installation.
giime-docs