Skip to content
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

refactor(messageBox): finish messagebox component #526

Closed
wants to merge 65 commits into from

Conversation

JerryWu1234
Copy link
Contributor

请提交 PR 之前确认一下已通过

  1. 看过这个贡献者说明 中文
  2. 测试通过
  3. 如果有相关的 issue,记得关联上
    refactor messagebox components #479

JerryWu1234 and others added 25 commits December 13, 2020 16:25
Refactor(messagebox):finish refactor messagebox component hug-sun#479
# Conflicts:
#	packages/element3/packages/message-box/src/MessageBox.vue
@zqy1151215064
Copy link

zqy1151215064 commented Dec 29, 2020

1、代码中请删除console,以及不必要的注释
2、文件名跟目录名请规范命名
3、组件demo => 自定义、使用HTML片段会报错

Copy link
Contributor

@cuixiaorui cuixiaorui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 测试文件里面需要使用 jest-vtu 已经存在的方法代替掉

})
describe('proprety', () => {
it('proprety title', () => {
const warpper = mount(MessageBox, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是 wrapper

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

title: 'chushihua'
}
})
expect(warpper.find('.el-message-box__title').text()).toBe('chushihua')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find 和 get 的使用区别

当你保证这个元素肯定存在的时候用 get

当你不确定这个元素是否存在的时候用 find ,一般 find 用于验证元素是否存在

title: 'chushihua'
}
})
expect(warpper.find('.el-message-box__title').text()).toBe('chushihua')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以使用 jest-vtu 里面的方法代替

expect(wrapper.find('.el-message-box__title')).toHaveTextContent('chushihua')

}
})
await warpper.findComponent({ ref: 'input' }).setValue('2323')
await nextTick()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setValue 已经是异步的了

这里是否还需要一个 nextTick() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要。。不需要会报错

@@ -7,9 +7,9 @@ import {
watch,
toRefs
} from 'vue'
import _ from 'lodash'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要使用 lodash-es

不然的话会增加打包代码的体积

@@ -13,7 +13,7 @@ export interface MessageBoxInputValidator {
(value: string): boolean | string
}

export const useMsgbox: () => ElMessageBox
export const MessageBox: () => ElMessageBox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该是

export const MessageBox: ElMessageBox

export default {
setup() {
let msgbox = useMsgbox()
let msgbox = MessageBox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里去掉 msgbox 这个变量吧

直接用 MessageBox

让用户看起来更清晰一点

export default {
setup() {
let msgbox = useMsgbox()
let msgbox = MessageBox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里去掉 msgbox 这个变量吧

直接用 MessageBox

让用户看起来更清晰一点

export default {
setup() {
let msgbox = useMsgbox()
let msgbox = MessageBox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里去掉 msgbox 这个变量吧

直接用 MessageBox

让用户看起来更清晰一点

app.config.globalProperties.$msgbox = ElMessageBox.service
app.config.globalProperties.$alert = ElMessageBox.service.alert
app.config.globalProperties.$confirm = ElMessageBox.service.confirm
app.config.globalProperties.$prompt = ElMessageBox.service.prompt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$msgbox 这个方法缺失了!

})
expect(warpper.find('.el-message-box__message > p').text()).toBe('333')
})
it('meesage is VNode', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message is VNode

@@ -3,7 +3,7 @@
模拟系统的消息提示框而实现的一套模态对话框组件,用于消息提示、确认消息和提交内容。

:::tip
从场景上说,MessageBox 的作用是美化系统自带的 `alert`、`confirm` 和 `prompt`,因此适合展示较为简单的内容。如果需要弹出较为复杂的内容,请使用 Dialog。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这句话为什么删除呢

@@ -171,9 +171,6 @@ export interface ElMessageBox {

declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
/** Show a message box */
$msgbox: ElMessageBox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为什么删除?

handleAction(unref(distinguishCancelAndClose) ? 'close' : 'cancel')
}
}
onMounted(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onMounted 和 onUnmounted 着两个生命周期内的功能 是否可以按照功能来封装一下

现在不具备可读性

handleAction,
handleInputEnter,
handleWrapperClick
} = handleList(state, instance, validate)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleList 可以从 setup 中抽离出现

可以让 setup 更清晰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants