Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 66959f50
authored
Sep 27, 2024
by
yixinjj
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
解决发送消息BUG
1 parent
3ab5a6dd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
utils/logger/LogCat.js
ws/Ws.js
ws/workers/LogsWorker.js
utils/logger/LogCat.js
View file @
66959f5
...
@@ -26,7 +26,7 @@ class LogCat {
...
@@ -26,7 +26,7 @@ class LogCat {
//文件名
//文件名
let
fileName
=
this
.
LogPath
+
'/'
+
date
+
'.txt'
let
fileName
=
this
.
LogPath
+
'/'
+
date
+
'.txt'
//写入的内容
//写入的内容
let
content
=
`
${
datetime
}
[
${
tag
}
] :
${
serializeIfObject
(
msg
)
}
\n`
let
content
=
`
${
datetime
}
[
${
tag
}
] :
${
msg
}
\n`
console
.
log
(
content
.
replace
(
/
\n
/g
,
''
))
console
.
log
(
content
.
replace
(
/
\n
/g
,
''
))
let
path
=
new
this
.
File
(
this
.
LogPath
)
let
path
=
new
this
.
File
(
this
.
LogPath
)
if
(
!
path
.
exists
())
{
if
(
!
path
.
exists
())
{
...
...
ws/Ws.js
View file @
66959f5
...
@@ -33,11 +33,10 @@ export class Ws {
...
@@ -33,11 +33,10 @@ export class Ws {
}
}
async
login
()
{
async
login
()
{
const
userInfo
=
uni
.
$storage
.
get
(
'userInfo'
)
const
userInfo
=
uni
.
$storage
.
get
(
'userInfo'
)
userInfo
.
name
=
'庞丽丽'
,
;(
userInfo
.
name
=
'胡悦'
),
(
userInfo
.
phone
=
'18754575574'
)
userInfo
.
phone
=
'15598191116'
if
(
!
userInfo
)
return
uni
.
$logger
.
local
.
error
(
'未获取到系统登录信息'
)
if
(
!
userInfo
)
return
uni
.
$logger
.
local
.
error
(
'未获取到系统登录信息'
)
uni
.
$logger
.
local
.
info
(
`========WS,用户登录
${
JSON
.
stringify
(
userInfo
)}
========`
)
const
{
name
:
user
,
phone
:
mobile
,
merchantName
}
=
userInfo
const
{
name
:
user
,
phone
:
mobile
}
=
userInfo
uni
.
$logger
.
local
.
info
(
`========WS,用户登录
${
JSON
.
stringify
({
user
,
mobile
,
merchantName
})}
========`
)
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
request
({
uni
.
request
({
url
:
this
.
loginAddress
,
url
:
this
.
loginAddress
,
...
@@ -63,7 +62,7 @@ export class Ws {
...
@@ -63,7 +62,7 @@ export class Ws {
uni
.
$logger
.
local
.
info
(
`WebSocket 收到消息 ->
${
JSON
.
stringify
(
data
)}
`
)
uni
.
$logger
.
local
.
info
(
`WebSocket 收到消息 ->
${
JSON
.
stringify
(
data
)}
`
)
if
(
data
.
errorCode
&&
data
.
errorCode
==
907
)
return
this
.
connect
()
if
(
data
.
errorCode
&&
data
.
errorCode
==
907
)
return
this
.
connect
()
const
worker
=
CommandFactory
.
getInstance
().
dispatch
(
data
.
command
)
const
worker
=
CommandFactory
.
getInstance
().
dispatch
(
data
.
command
)
worker
.
work
(
this
.
deviceId
,
data
,
this
.
ws
)
worker
.
work
(
this
.
deviceId
,
data
,
this
)
this
.
onMessage
&&
this
.
onMessage
(
data
)
this
.
onMessage
&&
this
.
onMessage
(
data
)
}.
bind
(
this
)
}.
bind
(
this
)
)
)
...
@@ -80,6 +79,6 @@ export class Ws {
...
@@ -80,6 +79,6 @@ export class Ws {
})
})
}
}
send
(
data
,
type
=
WsTyps
.
MessageTypes
.
Private
)
{
send
(
data
,
type
=
WsTyps
.
MessageTypes
.
Private
)
{
//
this.ws.emit(type, { device_id: this.deviceId, ...data })
this
.
ws
.
emit
(
type
,
{
device_id
:
this
.
deviceId
,
...
data
})
}
}
}
}
ws/workers/LogsWorker.js
View file @
66959f5
...
@@ -35,7 +35,8 @@ export default class LogsWorker {
...
@@ -35,7 +35,8 @@ export default class LogsWorker {
}
}
})
})
}
}
work
(
deviceId
,
data
)
{
work
(
deviceId
,
data
,
ws
)
{
this
.
ws
=
ws
this
.
upload
(
deviceId
,
data
)
this
.
upload
(
deviceId
,
data
)
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment