liveh5-nuxt/app/stores/live/index.js
xingyy ff053a5a8c feat(image): 添加 webp 图片格式支持
- 在 x-image组件中添加 webp 格式支持
- 在 nuxt.config.js 中配置 ipx 图片处理- 添加 sharp 库以支持图片格式转换
- 修改 live store 中的 show1 变量初始值
- 调整 PaymentResults 组件中 price 的默认值
2025-01-23 20:02:20 +08:00

43 lines
1.2 KiB
JavaScript

import { createGlobalState } from '@vueuse/core'
import {ref} from "vue";
import {goodStore} from "@/stores/goods/index.js";
import {authStore} from "@/stores/auth/index.js";
export const liveStore = createGlobalState(() => {
const {auctionDetail,getAuctionDetail} = goodStore();
const { token } = authStore()
const quoteStatus = ref(false)
const show = ref(false)
const show1=ref(true)
const playerId=ref('J_prismPlayer')
const auctionData=ref({})
const getSocketData=async ()=>{
if (!auctionDetail.value.uuid){
await getAuctionDetail()
}
const { ws, messages, onMessage } = useWebSocket()
// 连接
ws.connect('/api/v1/m/auction/live',{auctionUuid: auctionDetail.value.uuid,token:token.value})
/*// 发送消息
ws.send({ type: 'chat', content: 'Hello!' })*/
// 监听消息
onMessage((data) => {
console.log('收到消息:', data)
auctionData.value = data
})
}
const changeStatus = () => {
quoteStatus.value = !quoteStatus.value
}
return{
auctionData,
getSocketData,
show1,
playerId,
show,
quoteStatus,
changeStatus
}
})