liveh5-nuxt/app/components/x-message/useMessage.js
xingyy 36793c5c5a feat(live): 实现直播间竞拍功能并优化相关页面
- 新增 artworkBuy API 实现艺术品购买功能
- 重构 WebSocket连接逻辑,优化消息处理- 更新直播间页面,支持实时竞拍和消息提示
-调整艺术详情和用户中心页面样式
- 优化消息组件样式和展示逻辑
2025-02-08 15:21:00 +08:00

65 lines
1.5 KiB
JavaScript

import { createApp, nextTick } from 'vue'
import MessagePopup from './index.vue'
const message = {
success(options, duration = 2000) {
if (process.client) {
if (typeof options === 'string') {
this.show({ type: 'success', message: options, duration })
} else {
this.show({
type: 'success',
...options,
duration
})
}
}
},
error(options, duration = 2000) {
if (process.client) {
if (typeof options === 'string') {
this.show({ type: 'error', message: options, duration })
} else {
this.show({
type: 'error',
...options,
duration
})
}
}
},
warning(options, duration = 2000) {
if (process.client) {
if (typeof options === 'string') {
this.show({ type: 'warning', message: options, duration })
} else {
console.log('options',options)
this.show({
type: 'warning',
...options,
duration
})
}
}
},
show(options) {
if (!process.client) return
const container = document.createElement('div')
document.body.appendChild(container)
const app = createApp(MessagePopup, {
onAfterLeave: () => {
app.unmount()
document.body.removeChild(container)
}
})
const instance = app.mount(container)
nextTick(() => {
instance.showMessage?.(options)
})
}
}
export { message }