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 5d22652c
authored
Nov 07, 2024
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改数字的判断
1 parent
b2777ea1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
13 deletions
mixin/uploader.js
utils/utils.js
ws/CommandFactory.js
ws/Ws.js
ws/workers/RemoveLogWorker.js
ws/workers/SetPollingIntervalWorker.js
mixin/uploader.js
View file @
5d22652
import
{
getOssToken
}
from
'@/utils/ossUploadFile/uploadFile.js'
import
{
getOssToken
}
from
'@/utils/ossUploadFile/uploadFile.js'
import
Queue
from
'@/utils/Queue.js'
import
Queue
from
'@/utils/Queue.js'
import
{
Command
}
from
'../ws/constants'
import
{
Command
}
from
'../ws/constants'
import
{
isInteger
}
from
'@/utils/utils.js'
export
default
{
export
default
{
onLoad
()
{},
onLoad
()
{},
data
()
{
data
()
{
...
@@ -361,7 +362,7 @@ export default {
...
@@ -361,7 +362,7 @@ export default {
uni
.
$logger
.
local
.
info
(
`停止文件上传轮询并清除队列`
)
uni
.
$logger
.
local
.
info
(
`停止文件上传轮询并清除队列`
)
},
},
setInterval
(
interval
,
isForce
=
false
)
{
setInterval
(
interval
,
isForce
=
false
)
{
if
(
!
i
nterval
||
(
interval
&&
isNaN
(
interval
)
))
{
if
(
!
i
sInteger
(
interval
))
{
const
error
=
`参数错误!interval 必需为数字! interval ->
${
interval
}
`
const
error
=
`参数错误!interval 必需为数字! interval ->
${
interval
}
`
uni
.
$logger
.
local
.
error
(
error
)
uni
.
$logger
.
local
.
error
(
error
)
return
return
...
...
utils/utils.js
View file @
5d22652
...
@@ -177,6 +177,14 @@ async function getAudioFilePath(path = '') {
...
@@ -177,6 +177,14 @@ async function getAudioFilePath(path = '') {
export
function
serializeIfObject
(
msg
)
{
export
function
serializeIfObject
(
msg
)
{
return
typeof
msg
===
'object'
?
JSON
.
stringify
(
msg
)
:
msg
.
toString
()
return
typeof
msg
===
'object'
?
JSON
.
stringify
(
msg
)
:
msg
.
toString
()
}
}
export
function
isInteger
(
value
)
{
if
(
typeof
value
===
'number'
)
{
return
Number
.
isInteger
(
value
);
}
else
if
(
typeof
value
===
'string'
)
{
return
/^-
?\d
+$/
.
test
(
value
);
}
return
false
;
}
export
default
{
export
default
{
compareVersions
,
compareVersions
,
convertDateTimeFormat
,
convertDateTimeFormat
,
...
...
ws/CommandFactory.js
View file @
5d22652
...
@@ -19,10 +19,11 @@ export default class CommandFactory {
...
@@ -19,10 +19,11 @@ export default class CommandFactory {
if
(
!
Worker
)
{
if
(
!
Worker
)
{
throw
new
Error
(
'未找到对应的Worker'
)
throw
new
Error
(
'未找到对应的Worker'
)
}
}
if
(
!
this
.
store
.
has
(
Worker
.
name
))
{
// if (!this.store.has(Worker.name)) {
this
.
store
.
set
(
Worker
.
name
,
new
Worker
())
// this.store.set(Worker.name, new Worker())
}
// }
return
this
.
store
.
get
(
Worker
.
name
)
// return this.store.get(Worker.name)
return
new
Worker
()
}
}
clear
()
{
clear
()
{
this
.
store
.
clear
()
this
.
store
.
clear
()
...
...
ws/Ws.js
View file @
5d22652
...
@@ -2,7 +2,7 @@ import io from '@/uni_modules/hyoga-uni-socket_io/uni-socket.io.js'
...
@@ -2,7 +2,7 @@ import io from '@/uni_modules/hyoga-uni-socket_io/uni-socket.io.js'
import
{
WsTyps
}
from
'../utils/common'
import
{
WsTyps
}
from
'../utils/common'
import
CommandFactory
from
'./CommandFactory'
import
CommandFactory
from
'./CommandFactory'
import
config
from
'@/config.js'
import
config
from
'@/config.js'
import
{
serializeIfObject
}
from
'@/utils/utils.js'
import
{
serializeIfObject
,
deepClone
}
from
'@/utils/utils.js'
// const WsTyps = common.constants.WsTyps
// const WsTyps = common.constants.WsTyps
export
class
Ws
{
export
class
Ws
{
...
@@ -37,7 +37,7 @@ export class Ws {
...
@@ -37,7 +37,7 @@ export class Ws {
// const userInfo = uni.$storage.get('userInfo')
// const userInfo = uni.$storage.get('userInfo')
// ;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574')
// ;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574')
if
(
!
sysInfo
?.
deviceId
)
return
uni
.
$logger
.
local
.
error
(
'未获取到系统设备信息'
)
if
(
!
sysInfo
?.
deviceId
)
return
uni
.
$logger
.
local
.
error
(
'未获取到系统设备信息'
)
//
sysInfo.deviceId='4DF8801064461802495A2452CCD04EE4'
sysInfo
.
deviceId
=
'4DF8801064461802495A2452CCD04EE4'
// const { name: user, phone: mobile, merchantName } = userInfo
// const { name: user, phone: mobile, merchantName } = userInfo
uni
.
$logger
.
local
.
info
(
`========WS,用户登录
${
JSON
.
stringify
({
deviceId
:
sysInfo
.
deviceId
})}
========`
)
uni
.
$logger
.
local
.
info
(
`========WS,用户登录
${
JSON
.
stringify
({
deviceId
:
sysInfo
.
deviceId
})}
========`
)
console
.
log
(
this
.
loginAddress
)
console
.
log
(
this
.
loginAddress
)
...
@@ -66,9 +66,10 @@ export class Ws {
...
@@ -66,9 +66,10 @@ export class Ws {
function
(
data
)
{
function
(
data
)
{
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
_data
=
deepClone
(
data
)
worker
.
work
(
this
.
deviceId
,
data
,
this
)
const
worker
=
CommandFactory
.
getInstance
().
dispatch
(
_data
.
command
)
this
.
onMessage
&&
this
.
onMessage
(
data
)
worker
.
work
(
this
.
deviceId
,
_data
,
this
)
this
.
onMessage
&&
this
.
onMessage
(
_data
)
}.
bind
(
this
)
}.
bind
(
this
)
)
)
this
.
ws
.
on
(
WsTyps
.
MessageTypes
.
System
,
function
(
data
)
{
this
.
ws
.
on
(
WsTyps
.
MessageTypes
.
System
,
function
(
data
)
{
...
@@ -84,7 +85,6 @@ export class Ws {
...
@@ -84,7 +85,6 @@ export class Ws {
})
})
}
}
send
(
data
,
type
=
WsTyps
.
MessageTypes
.
Private
)
{
send
(
data
,
type
=
WsTyps
.
MessageTypes
.
Private
)
{
console
.
log
(
data
)
this
.
ws
.
emit
(
type
,
{
device_id
:
this
.
deviceId
,
...
data
})
this
.
ws
.
emit
(
type
,
{
device_id
:
this
.
deviceId
,
...
data
})
}
}
}
}
ws/workers/RemoveLogWorker.js
View file @
5d22652
import
{
isInteger
}
from
'@/utils/utils.js'
export
default
class
RemoveLogWorker
{
export
default
class
RemoveLogWorker
{
constructor
()
{}
constructor
()
{}
work
(
deviceId
,
data
,
ws
)
{
work
(
deviceId
,
data
,
ws
)
{
//参数可以不传,默认7天
//参数可以不传,默认7天
const
days
=
data
.
days
const
days
=
data
.
days
if
(
!
days
||
isNaN
(
days
)
)
{
if
(
!
isInteger
(
days
)
||
days
==
0
)
{
const
error
=
`RemoveLogWorker -> 删除日志: 参数错误!days 必需为数字! days ->
${
days
}
`
const
error
=
`RemoveLogWorker -> 删除日志: 参数错误!days 必需为数字! days ->
${
days
}
`
ws
.
send
({
error
,
data
})
ws
.
send
({
error
,
data
})
uni
.
$logger
.
local
.
error
(
error
)
uni
.
$logger
.
local
.
error
(
error
)
...
...
ws/workers/SetPollingIntervalWorker.js
View file @
5d22652
import
{
isInteger
}
from
'@/utils/utils.js'
export
default
class
SetPollingIntervalWorker
{
export
default
class
SetPollingIntervalWorker
{
constructor
()
{}
constructor
()
{}
work
(
deviceId
,
data
,
ws
)
{
work
(
deviceId
,
data
,
ws
)
{
const
interval
=
data
.
interval
const
interval
=
data
.
interval
const
isForce
=
!!
data
.
force
const
isForce
=
!!
data
.
force
if
(
!
i
nterval
||
(
interval
&&
isNaN
(
interval
)
))
{
if
(
!
i
sInteger
(
interval
))
{
const
error
=
`SetPollingIntervalWorker -> 设置轮询时间间隔: 参数错误!interval 必需为数字! interval ->
${
interval
}
`
const
error
=
`SetPollingIntervalWorker -> 设置轮询时间间隔: 参数错误!interval 必需为数字! interval ->
${
interval
}
`
ws
.
send
({
error
,
data
})
ws
.
send
({
error
,
data
})
uni
.
$logger
.
local
.
error
(
error
)
uni
.
$logger
.
local
.
error
(
error
)
...
...
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