diff --git a/docs/markdown/en/i18n.md b/docs/markdown/en/i18n.md
index 06fba03..107de55 100644
--- a/docs/markdown/en/i18n.md
+++ b/docs/markdown/en/i18n.md
@@ -41,5 +41,6 @@ new Vue({ i18n }).$mount('#app')
| Korean (South Korea) | ko-KR |
| Portuguese (Brazil) | pt-BR |
| Persian (Iran) | fa-IR |
+| Hungarian | hu |
If your target language is not included, you are more than welcome to contribute: just add another language config to [here](https://github.com/AT-UI/at-ui/blob/master/src/locale/lang/) and create a pull request.
diff --git a/docs/markdown/zh/i18n.md b/docs/markdown/zh/i18n.md
index 8db69dd..826c3ed 100644
--- a/docs/markdown/zh/i18n.md
+++ b/docs/markdown/zh/i18n.md
@@ -41,5 +41,6 @@ new Vue({ i18n }).$mount('#app')
| 韩语(韩国) | ko-KR |
| 葡萄牙语(巴西) | pt-BR |
| 波斯语(伊朗) | fa-IR |
+| 匈牙利 | hu |
如果您需要使用其他的语言,欢迎贡献 PR:只需要在 [这里](https://github.com/AT-UI/at-ui/blob/master/src/locale/lang/) 添加一个语言配置文件即可
diff --git a/docs/markdown/zh/modal.md b/docs/markdown/zh/modal.md
index 9e8359c..f5f7505 100644
--- a/docs/markdown/zh/modal.md
+++ b/docs/markdown/zh/modal.md
@@ -230,6 +230,19 @@
```
:::
+## 关闭前
+
+- 通过属性 `before-close` 监听 `Modal` 关闭前的事件,会暂停 `Modal` 的关闭
+- 参数为event事件和回调函数,调用函数将关闭 `Modal` ,传递 `false` 参数可以阻止 `Modal`的关闭
+- 点击按钮、icon、遮罩、esc均会触发该钩子,手动修改value的值不触发
+
+:::demo
+```html
+打开modal
+这里是文本
+```
+:::
+
## Modal 参数
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
@@ -247,6 +260,7 @@
| width | 模态框的宽度 | Number / String | - | `520` |
| closeOnPressEsc | 点击 `ESC` 是否可以关闭模态框 | Boolean | - | true |
| styles | 模态框的自定义样式 | Object | - | - |
+| before-close | 关闭前的回调,会暂停 `Modal` 的关闭,手动修改 `value` 的值不会触发 | Function(event, done),`done` 用于关闭 `Modal`,传递 `false` 参数可以阻止 `Modal` 关闭 | - | - |
## Modal 事件
@@ -272,7 +286,8 @@
modal3: false,
modal4: false,
modal5: false,
- modal6: false
+ modal6: false,
+ modal7: false
}
},
methods: {
@@ -332,6 +347,16 @@
},
closeModal2 () {
this.modal2 = false
+ },
+ handleBeforeClose (evt, done) {
+ this.$Modal.confirm({
+ content: '确定关闭吗?',
+ styles: {
+ top: '300px'
+ }
+ }).then(done).catch(() => {
+ done(false)
+ })
}
}
}
diff --git a/src/components/modal/src/modal.vue b/src/components/modal/src/modal.vue
index 957a266..4ee7c81 100644
--- a/src/components/modal/src/modal.vue
+++ b/src/components/modal/src/modal.vue
@@ -25,18 +25,18 @@
{{ content }}
-
+
@@ -96,7 +96,8 @@
return {}
}
},
- type: String
+ type: String,
+ beforeClose: Function
},
data () {
return {
@@ -159,7 +160,13 @@
}
},
methods: {
- doClose () {
+ doBeforeClose (evt) {
+ this.beforeClose ? this.beforeClose(evt, this.doClose) : this.doClose()
+ },
+ doClose (result) {
+ if (result === false) {
+ return
+ }
this.visible = false
this.$emit('input', false)
this.$emit('on-cancel')
@@ -170,28 +177,26 @@
},
handleMaskClick (evt) {
if (this.maskClosable) {
- this.doClose()
+ this.doBeforeClose(evt)
}
},
handleWrapperClick (evt) {
if (this.maskClosable) {
- this.doClose()
+ this.doBeforeClose(evt)
}
},
- handleAction (action) {
+ handleAction (action, evt) {
this.action = action
+ this.doBeforeClose(evt)
if (action === 'confirm') {
- this.$emit('input', false)
this.$emit('on-confirm')
}
-
- this.doClose()
},
handleKeyCode (evt) {
if (this.visible && this.showClose) {
if (evt.keyCode === 27) { // Escape
- this.doClose()
+ this.doBeforeClose()
}
}
}
diff --git a/src/locale/lang/hu.js b/src/locale/lang/hu.js
new file mode 100644
index 0000000..6306228
--- /dev/null
+++ b/src/locale/lang/hu.js
@@ -0,0 +1,28 @@
+export default {
+ at: {
+ select: {
+ placeholder: 'Kiválasztás',
+ notFoundText: 'Nincs ilyen adat'
+ },
+ modal: {
+ okText: 'OK',
+ cancelText: 'Mégsem'
+ },
+ pagination: {
+ prevText: 'Előző oldal',
+ nextText: 'Következő oldal',
+ total: 'Összesen',
+ item: 'tétel',
+ items: 'tétel',
+ pageSize: '/ oldal',
+ goto: 'Ugrás',
+ pageText: '',
+ prev5Text: 'Előző 5 oldal',
+ next5Text: 'Következő 5 oldal'
+ },
+ table: {
+ emptyText: 'Nincs adat'
+ }
+ }
+ }
+
\ No newline at end of file