refactor(app): 优化代码结构和功能

- 移除多处 console.log 语句,清理无用代码
- 在消息组件中添加 info 类型配置并实现 info 消息显示功能
- 优化 WebSocket 消息处理逻辑,提高代码可读性
This commit is contained in:
xingyy 2025-02-08 16:24:26 +08:00
parent c86e449d52
commit a791248752
8 changed files with 25 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

View File

@ -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',

View File

@ -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,

View File

@ -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()

View File

@ -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++

View File

@ -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)

View File

@ -24,7 +24,7 @@ export const liveStore = createGlobalState(() => {
ws.send({ type: 'chat', content: 'Hello!' })*/
// 监听消息
onMessage((data) => {
console.log('收到消息:', data)
auctionData.value = data
})
}

View File

@ -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)