-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(drawer): [drawer] modify icon and demo problem #2460
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
</template> | ||
|
||
<script lang="tsx"> | ||
import { TinyDrawer, TinyButton } from '@opentiny/vue' | ||
import { TinyDrawer, TinyButton, Notify } from '@opentiny/vue' | ||
import { iconHelp } from '@opentiny/vue-icon' | ||
|
||
export default { | ||
|
@@ -18,6 +18,9 @@ export default { | |
} | ||
}, | ||
methods: { | ||
closeDrawer() { | ||
this.drawerInstance.close() | ||
}, | ||
showDrawer() { | ||
const IconHelp = iconHelp() | ||
const config = { | ||
|
@@ -27,27 +30,35 @@ export default { | |
showFooter: true, | ||
// 通过 events 监听事件 | ||
events: { | ||
open: (instance) => console.log('open 事件', instance), | ||
close: () => console.log('close 事件') | ||
open: (instance) => | ||
Notify({ | ||
type: 'info', | ||
title: 'open 事件', | ||
message: `${instance.title}`, | ||
position: 'top-right' | ||
}), | ||
close: () => | ||
Notify({ | ||
type: 'info', | ||
title: 'close 事件', | ||
position: 'top-right' | ||
}) | ||
Comment on lines
+33
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider internationalizing notification messages The notification implementation provides better user feedback compared to console logs. However, consider extracting the message strings for internationalization support. events: {
open: (instance) =>
Notify({
type: 'info',
- title: 'open 事件',
+ title: this.$t('drawer.events.open'),
message: `${instance.title}`,
position: 'top-right'
}),
close: () =>
Notify({
type: 'info',
- title: 'close 事件',
+ title: this.$t('drawer.events.close'),
position: 'top-right'
})
}
|
||
}, | ||
// 通过属性 customSlots 设置插槽, 插槽内容可以是 string | VNode | ({h, $drawer}) => VNode | ||
customSlots: { | ||
// 使用 h 函数 | ||
default: (h) => h('p', { class: '' }, '抽屉主体内容。'), | ||
// 返回 VNode 节点的方法, 可通过参数中 $drawer 访问到组件实例 | ||
headerRight: () => <IconHelp></IconHelp>, | ||
headerRight: () => <IconHelp style="width:20px;height:20px"></IconHelp>, | ||
// 直接赋值 VNode | ||
footer: ( | ||
<Button type="primary" onClick={this.closeDrawer}> | ||
<TinyButton type="primary" onClick={this.closeDrawer}> | ||
点击关闭 | ||
</Button> | ||
</TinyButton> | ||
) | ||
} | ||
} | ||
this.drawerInstance = TinyDrawer.service(config) | ||
}, | ||
closeDrawer() { | ||
this.drawerInstance.close() | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider differentiating notification types and enhancing message consistency
While the notifications are an improvement over console logs, consider these enhancements:
📝 Committable suggestion
💡 Codebase verification
Tests and documentation updates needed for notification behavior
The changes require:
Action items:
examples/sites/demos/pc/app/drawer/webdoc/drawer.en.md
to include notification event details🔗 Analysis chain
Verify test coverage and documentation updates
The changes introduce new behavior with notifications and UI modifications. Please ensure:
Also applies to: 46-46
Let me check the content of the documentation files to verify if they cover the notification behavior.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 475
Script:
Length of output: 546