refactor(app): 优化代码结构和功能
- 移除多处 console.log 语句,清理无用代码 - 在消息组件中添加 info 类型配置并实现 info 消息显示功能 - 优化 WebSocket 消息处理逻辑,提高代码可读性
This commit is contained in:
parent
c86e449d52
commit
a791248752
BIN
app/components/x-message/images/info.png
Normal file
BIN
app/components/x-message/images/info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 932 B |
@ -3,6 +3,7 @@
|
||||
import error from '../images/error.png'
|
||||
import success from '../images/success.png'
|
||||
import warning from '../images/warning.png'
|
||||
import info from '../images/info.png'
|
||||
|
||||
const props = defineProps({
|
||||
type: {
|
||||
@ -40,6 +41,11 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const typeConfig = {
|
||||
info: {
|
||||
imgSrc: info,
|
||||
borderColor: '#C6DFFB',
|
||||
bgColor: '#ECF5FE',
|
||||
},
|
||||
success: {
|
||||
imgSrc: success,
|
||||
borderColor: '#C5E7D5',
|
||||
|
@ -28,12 +28,25 @@ const message = {
|
||||
}
|
||||
}
|
||||
},
|
||||
info(options, duration = 2000) {
|
||||
if (process.client) {
|
||||
if (typeof options === 'string') {
|
||||
this.show({ type: 'info', 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,
|
||||
|
@ -8,7 +8,7 @@ const initData=async ()=>{
|
||||
const res=await userArtwork({uuid})
|
||||
if (res.status===0){
|
||||
detail.value=res.data
|
||||
console.log('detail.value',detail.value)
|
||||
|
||||
}
|
||||
}
|
||||
initData()
|
||||
|
@ -37,7 +37,6 @@ const close = () => emit('update:show', false);
|
||||
const openShow=(item)=>{
|
||||
showDetailInfo.value=item
|
||||
showDetail.value=true
|
||||
|
||||
}
|
||||
const loadMore = async () => {
|
||||
pageRef.value.page++
|
||||
|
@ -85,7 +85,7 @@ watch(()=>{
|
||||
}
|
||||
})
|
||||
const goBuy=async ()=>{
|
||||
console.log('auctionData',auctionData.value)
|
||||
|
||||
const res= await artworkBuy({
|
||||
auctionArtworkUuid:auctionData.value?.artwork?.uuid,
|
||||
buyMoney:String(auctionData.value?.nowAuctionPrice?.nextPrice??0)
|
||||
|
@ -24,7 +24,7 @@ export const liveStore = createGlobalState(() => {
|
||||
ws.send({ type: 'chat', content: 'Hello!' })*/
|
||||
// 监听消息
|
||||
onMessage((data) => {
|
||||
console.log('收到消息:', data)
|
||||
|
||||
auctionData.value = data
|
||||
})
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ export class WebSocketClient {
|
||||
},
|
||||
onMessage: (callback: (data: any) => void) => {
|
||||
this.socket!.onmessage = (event) => {
|
||||
console.log('event',event)
|
||||
|
||||
try {
|
||||
const data = JSON.parse(event.data)
|
||||
console.log('data',data)
|
||||
|
||||
callback(data)
|
||||
} catch (error) {
|
||||
console.error('解析消息失败:', error)
|
||||
|
Loading…
Reference in New Issue
Block a user