处理第一次打开online报错问题
This commit is contained in:
parent
ed69f0ff60
commit
8b97e5d91e
@ -1,4 +1,4 @@
|
|||||||
NODE_ENV='development'
|
NODE_ENV='development'
|
||||||
VITE_APP_TITLE='开发环境'
|
VITE_APP_TITLE='开发环境'
|
||||||
VITE_APP_BASE_API='http://127.0.0.1:8099'
|
VITE_APP_BASE_API='https://admin.cdtrucktralier.com'
|
||||||
VITE_APP_SCOKET='ws://1.92.99.15:8099/ws/asset/'
|
VITE_APP_SCOKET='wss://admin.cdtrucktralier.com/ws/asset/'
|
||||||
@ -95,15 +95,21 @@ export const useScoketMsg = defineStore('scoketMsg', () => {
|
|||||||
const chatMain = ref({})
|
const chatMain = ref({})
|
||||||
|
|
||||||
const scoketInit = () => {
|
const scoketInit = () => {
|
||||||
|
return new Promise((reslove,reject) => {
|
||||||
scoket.value = uni.connectSocket({
|
scoket.value = uni.connectSocket({
|
||||||
url: `${import.meta.env.VITE_APP_SCOKET}${onlyId.value}`,
|
url: `${import.meta.env.VITE_APP_SCOKET}${onlyId.value}`,
|
||||||
success: () => {
|
success: () => {
|
||||||
console.log('创建链接成功')
|
console.log('创建链接成功')
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
reject(err)
|
||||||
console.log('创建失败',err)
|
console.log('创建失败',err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
scoket.value.onOpen((e) => {
|
||||||
|
reslove()
|
||||||
|
console.log('链接打开')
|
||||||
|
})
|
||||||
scoket.value.onMessage((e) => {
|
scoket.value.onMessage((e) => {
|
||||||
if (e.data === '连接成功') {
|
if (e.data === '连接成功') {
|
||||||
return
|
return
|
||||||
@ -123,8 +129,10 @@ export const useScoketMsg = defineStore('scoketMsg', () => {
|
|||||||
scoket.value.onError((err) => {
|
scoket.value.onError((err) => {
|
||||||
console.log('链接错误',err)
|
console.log('链接错误',err)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
const send = (text) => {
|
const send = (text) => {
|
||||||
|
console.log(text)
|
||||||
return new Promise((reslove,reject) => {
|
return new Promise((reslove,reject) => {
|
||||||
scoket.value.send({
|
scoket.value.send({
|
||||||
data: text,
|
data: text,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user