refactor(confirm): remove default text on confirm to avoid locale problem

This commit is contained in:
07akioni 2020-02-05 23:49:59 +08:00
parent 04d9a6a2a1
commit 9619b3b4ed
12 changed files with 81 additions and 47 deletions

View File

@ -20,6 +20,7 @@ export default {
title: 'Async',
content:
'Click and count down 3 second',
positiveText: 'Confirm',
onPositiveClick: hide => {
confirmInstance.loading = true
this.$NMessage.success('Count down 3 second')

View File

@ -23,6 +23,8 @@ export default {
const confirmInstance = this.$NConfirm.warning({
title: 'Confirm',
content: 'Are you sure?',
positiveText: 'Sure',
negativeText: 'Not Sure',
onPositiveClick: (hide) => {
this.$NMessage.success('Sure')
hide()
@ -38,6 +40,7 @@ export default {
title: 'Success',
content:
'Cool',
positiveText: 'Wow!',
onPositiveClick: (hide) => {
this.$NMessage.success('Great!')
hide()
@ -48,6 +51,7 @@ export default {
const confirmInstance = this.$NConfirm.error({
title: 'Error',
content: 'A mistake.',
positiveText: 'Ahhh!',
onPositiveClick: (hide) => {
this.$NMessage.success('I knew it...')
hide()

View File

@ -20,12 +20,12 @@ use-component
|Name|Type|Default|Description|
|-|-|-|-|
|type|`'error \| 'success' \| 'warning'`|`'warning'`||
|title|`string`|`'Confirm'`||
|title|`string \| function`|`null`|Can be a render function.|
|closable|`boolean`|`boolean`||
|icon|`function`|`null`|Should be a render function|
|negative-text|`string \| function`|`'Cancel'`|Can be a render function|
|positive-text|`string \| function`|`'Confirm'`|Can be a render function|
|content|`string`|`null`||
|icon|`function`|`null`|Should be a render function.|
|negative-text|`string`|`'Cancel'`||
|positive-text|`string`|`'Confirm'`||
|content|`string \| function`|`null`|Can be a render function.|
|show-icon|`boolean`|`true`||
|loading|`boolean`|`false`||
|bordered|`boolean`|`false`||
@ -40,12 +40,12 @@ Properties of ConfirmEnvironment can be modified
|Name|Type|Description|
|-|-|-|
|type|`'error \| 'success' \| 'warning'`||
|title|`string`||
|title|`string \| function`|Can be a render function.|
|closable|`boolean`||
|icon|`function`|Should be a render function|
|negative-text|`string \| function`|Can be a render function|
|positive-text|`string \| function`|Can be a render function|
|content|`string`||
|negative-text|`string`||
|positive-text|`string`||
|content|`string \| function`|Can be a render function.|
|show-icon|`boolean`||
|loading|`boolean`||
|bordered|`boolean`||
@ -63,12 +63,12 @@ Properties of ConfirmEnvironment can be modified
|Name|Type|Default|Description|
|-|-|-|-|
|type|`'error \| 'success' \| 'warning'`|`'warning'`||
|title|`string`|`'Confirm'`||
|title|`string \| function`|`null`|Can be a render function.|
|closable|`boolean`|`boolean`||
|icon|`function`|`null`|Should be a render function|
|negative-text|`string \| function`|`'Cancel'`|Can be a render function|
|positive-text|`string \| function`|`'Confirm'`|Can be a render function|
|content|`string`|`null`||
|negative-text|`string`|`null`||
|positive-text|`string`|`null`||
|content|`string \| function`|`null`|Can be a render function.|
|show-icon|`boolean`|`true`||
|loading|`boolean`|`false`||
|bordered|`boolean`|`false`||

View File

@ -5,21 +5,21 @@ Sometimes you may want to use a component.
title="Confirm"
content="Are you sure?"
:closable="false"
negative-text="Cancel"
positive-text="Submit"
@positive-click="submitCallback"
@negative-click="cancelCallback"
negative-text="Cancel">
</n-confirm>
@positive-click="handlePositiveClick"
@negative-click="handleNegativeClick"
/>
```
```js
export default {
methods: {
cancelCallback () {
handleNegativeClick () {
this.$NMessage.waning('Cancel')
this.isActive = false
},
submitCallback () {
this.$NMessage.success('Submit')
handlePositiveClick () {
this.$NMessage.success('Confirm')
this.isActive = false
}
}

View File

@ -20,6 +20,7 @@ export default {
title: '异步',
content:
'点击,倒计时 3 秒',
positiveText: '确认',
onPositiveClick: hide => {
confirmInstance.loading = true
this.$NMessage.success('倒计时 3 秒')

View File

@ -23,6 +23,8 @@ export default {
const confirmInstance = this.$NConfirm.warning({
title: '警告',
content: '你确定?',
positiveText: '确定',
negativeText: '不确定',
onPositiveClick: (hide) => {
this.$NMessage.success('确定')
hide()
@ -38,6 +40,7 @@ export default {
title: '成功',
content:
'厉害',
positiveText: '哇',
onPositiveClick: (hide) => {
this.$NMessage.success('耶!')
hide()
@ -48,6 +51,7 @@ export default {
const confirmInstance = this.$NConfirm.error({
title: '错误',
content: '错了',
positiveText: '啊',
onPositiveClick: (hide) => {
this.$NMessage.success('我就知道')
hide()

View File

@ -20,12 +20,12 @@ use-component
|名称|类型|默认值|介绍|
|-|-|-|-|
|type|`'error \| 'success' \| 'warning'`|`'warning'`||
|title|`string`|`'Confirm'`||
|title|`string \| function`|`null`|可以是 render 函数|
|closable|`boolean`|`boolean`||
|icon|`function`|`null`|需要是 render 函数|
|negative-text|`string \| function`|`'Cancel'`|可以是 render 函数|
|positive-text|`string \| function`|`'Confirm'`|可以是 render 函数|
|content|`string`|`null`||
|negative-text|`string`|`null`||
|positive-text|`string`|`null`||
|content|`string \| function`|`null`|可以是 render 函数|
|show-icon|`boolean`|`true`||
|loading|`boolean`|`false`||
|bordered|`boolean`|`false`||
@ -40,12 +40,12 @@ use-component
|名称|类型|介绍|
|-|-|-|
|type|`'error \| 'success' \| 'warning'`||
|title|`string`||
|title|`string \| function`|可以是 render 函数|
|closable|`boolean`||
|icon|`function`|需要是 render 函数|
|negative-text|`string \| function`|可以是 render 函数|
|positive-text|`string \| function`|可以是 render 函数|
|content|`string`||
|negative-text|`string`||
|positive-text|`string`||
|content|`string \| function`|可以是 render 函数|
|show-icon|`boolean`||
|loading|`boolean`||
|bordered|`boolean`||
@ -63,12 +63,12 @@ use-component
|名称|类型|默认值|介绍|
|-|-|-|-|
|type|`'error \| 'success' \| 'warning'`|`'warning'`||
|title|`string`|`'Confirm'`||
|title|`string \| function`|`null`|可以是 render 函数|
|closable|`boolean`|`boolean`||
|icon|`function`|`null`|需要是 render 函数|
|negative-text|`string \| function`|`'Cancel'`|可以是 render 函数|
|positive-text|`string \| function`|`'Confirm'`|可以是 render 函数|
|content|`string`|`null`||
|negative-text|`string`|`null`||
|positive-text|`string`|`null`||
|content|`string \| function`|`null`|可以是 render 函数|
|show-icon|`boolean`|`true`||
|loading|`boolean`|`false`||
|bordered|`boolean`|`false`||

View File

@ -5,20 +5,20 @@
title="确认"
content="你确定"
:closable="false"
negative-text="不确认"
positive-text="确认"
@positive-click="submitCallback"
@negative-click="cancelCallback"
negative-text="不确认">
</n-confirm>
@positive-click="handlePositiveClick"
@negative-click="handleNegativeClick"
/>
```
```js
export default {
methods: {
cancelCallback () {
handleNegativeClick () {
this.$NMessage.warning('取消')
this.isActive = false
},
submitCallback () {
handlePositiveClick () {
this.$NMessage.success('确认')
this.isActive = false
}

View File

@ -78,8 +78,8 @@ import iosHelpCircle from '../../../icons/ios-help-circle'
import iosCloseCircle from '../../../icons/ios-close-circle'
import withapp from '../../../mixins/withapp'
import themeable from '../../../mixins/themeable'
import asthemecontext from '../../../mixins/asthemecontext'
import render from '../../../utils/render'
export default {
name: 'NConfirm',
components: {
@ -91,7 +91,7 @@ export default {
iosCloseCircle,
render
},
mixins: [withapp, themeable, asthemecontext],
mixins: [withapp, themeable],
props: {
icon: {
type: Function,
@ -102,8 +102,8 @@ export default {
default: 'warning'
},
title: {
type: String,
default: 'Confirm'
type: [String, Function],
default: null
},
closable: {
type: Boolean,
@ -111,14 +111,14 @@ export default {
},
negativeText: {
type: String,
default: 'Cancel'
default: null
},
positiveText: {
type: String,
default: 'Confirm'
default: null
},
content: {
type: String,
type: [String, Function],
default: null
},
showIcon: {

View File

@ -38,8 +38,8 @@ export default {
active: false,
content: null,
icon: null,
positiveText: 'Confirm',
negativeText: 'Cancel',
positiveText: null,
negativeText: null,
type: 'warning',
title: null,
loading: false,

View File

@ -41,5 +41,17 @@ export default {
},
Empty: {
description: 'No Data'
},
Select: {
placeholder: 'Please Select'
},
TimePicker: {
placeholder: 'Select Time',
positiveText: 'Confirm',
negativeText: 'Cancel'
},
Pagination: {
goto: 'Goto',
selectionSuffix: 'page'
}
}

View File

@ -41,5 +41,17 @@ export default {
},
Empty: {
description: '无数据'
},
Select: {
placeholder: '请选择'
},
TimePicker: {
placeholder: '请选择时间',
positiveText: '确认',
negativeText: '取消'
},
Pagination: {
goto: '跳至',
selectionSuffix: '页'
}
}