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 30e98e59
authored
Sep 23, 2024
by
yixinjj
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增文件处理worker
1 parent
8c35b037
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
28 deletions
App.vue
components/HomeFrame/index.vue
utils/logger/LocalLog.js
ws/WorkerFactory.js
ws/Ws.js
ws/constants.js
ws/workers/FileWorker.js
ws/workers/LogsWorker.js
ws/workers/StorageWorker.js
App.vue
View file @
30e98e5
...
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-07 17:09:53
* @LastEditors: limin
* @LastEditTime: 2024-09-
19 11:46:49
* @LastEditTime: 2024-09-
23 18:40:54
* @FilePath: \gl_tape\App.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
...
...
@@ -26,7 +26,7 @@ export default {
uni
.
setKeepScreenOn
({
keepScreenOn
:
true
})
const
ws
=
new
Ws
({
url
:
config
.
SOCKET_ADDRESS
,
token
:
123456
,
deviceId
:
1
,
onMessage
:
()
=>
{}
})
const
ws
=
new
Ws
({
url
:
config
.
SOCKET_ADDRESS
,
token
:
123456
,
deviceId
:
1
000000
,
onMessage
:
()
=>
{}
})
},
methods
:
{
setAPPVersion
()
{
...
...
components/HomeFrame/index.vue
View file @
30e98e5
...
...
@@ -84,7 +84,6 @@ export default {
mounted
()
{
const
userInfo
=
uni
.
$storage
.
get
(
'userInfo'
)
||
{}
this
.
userInfo
=
userInfo
this
.
wsConnet
()
},
computed
:
{
...
...
@@ -101,9 +100,6 @@ export default {
}
},
methods
:
{
wsConnet
()
{
const
ws
=
new
Ws
({
url
:
config
.
SOCKET_ADDRESS
,
token
:
123456
,
deviceId
:
1
,
onMessage
:
()
=>
{}
})
}
}
}
</
script
>
...
...
utils/logger/LocalLog.js
View file @
30e98e5
...
...
@@ -32,7 +32,7 @@ class LocalLog {
return
list
},[]);
// console.log('fileList', fileList)
this
.
logger
.
zip
(
fileList
)
//
this.logger.zip(fileList)
return
fileList
}
removeOverDays
(
day
=
7
)
{
...
...
ws/WorkerFactory.js
View file @
30e98e5
...
...
@@ -2,12 +2,15 @@ import LogsWorker from './workers/LogsWorker'
import
CommonWorker
from
'./workers/CommonWorker'
import
MessageWorker
from
'./workers/MessageWorker'
import
StorageWorker
from
'./workers/StorageWorker'
import
FileWorker
from
'./workers/FileWorker'
import
{
Command
}
from
'./constants'
const
Workers
=
{
[
Command
.
GetLog
]:
LogsWorker
,
[
Command
.
Message
]:
MessageWorker
,
[
Command
.
GetStorage
]:
StorageWorker
,
[
Command
.
File
]:
FileWorker
}
const
WorkerFactory
=
{
create
:
cmd
=>
Workers
[
cmd
]
||
CommonWorker
...
...
ws/Ws.js
View file @
30e98e5
...
...
@@ -11,7 +11,7 @@ export class Ws {
constructor
({
url
,
token
,
deviceId
,
onMessage
})
{
this
.
url
=
url
this
.
token
=
token
this
.
deviceId
=
deviceId
this
.
deviceId
=
deviceId
this
.
onMessage
=
onMessage
this
.
connect
()
}
...
...
@@ -26,13 +26,13 @@ export class Ws {
}
subscribe
()
{
this
.
ws
.
on
(
WsTyps
.
Connected
,
()
=>
{
console
.
log
(
'WebSocket 已连接'
)
console
.
log
(
'WebSocket 已连接'
)
})
this
.
ws
.
on
(
WsTyps
.
MessageTypes
.
Private
,
function
(
data
)
{
const
worker
=
CommandFactory
.
getInstance
().
dispatch
(
data
.
command
)
worker
.
work
(
this
.
deviceId
,
data
,
this
)
worker
.
work
(
this
.
deviceId
,
data
,
this
)
this
.
onMessage
&&
this
.
onMessage
(
data
)
}.
bind
(
this
)
)
...
...
@@ -46,7 +46,7 @@ export class Ws {
console
.
log
(
'ws error'
,
msg
)
})
}
send
(
data
,
type
=
WsTyps
.
MessageTypes
.
Private
)
{
this
.
ws
.
emit
(
type
,
data
)
send
(
data
,
type
=
WsTyps
.
MessageTypes
.
Private
)
{
this
.
ws
.
emit
(
type
,
{
device_id
:
this
.
deviceId
,...
data
}
)
}
}
ws/constants.js
View file @
30e98e5
const
Command
=
{
GetLog
:
'getLog'
,
GetStorage
:
'getStorage'
,
Message
:
'message'
GetLog
:
'getLog'
,
GetStorage
:
'getStorage'
,
Message
:
'message'
,
File
:
'file'
}
export
{
Command
}
const
FileCommand
=
{
Remove
:
'remove'
,
GetLogList
:
'getLogList'
}
export
{
Command
,
FileCommand
}
ws/workers/FileWorker.js
0 → 100644
View file @
30e98e5
import
{
FileCommand
}
from
'../constants'
export
default
class
FileWorker
{
data
=
null
constructor
()
{}
work
(
deviceId
,
data
,
ws
)
{
this
.
data
=
data
const
payload
=
data
.
payload
this
[
payload
?.
command
]
&&
this
[
payload
.
command
](
payload
,
ws
)
}
[
FileCommand
.
GetLogList
](
payload
,
ws
)
{
const
LogList
=
uni
.
$logger
.
local
.
getFiles
(
payload
.
beginDate
,
payload
.
endDate
)
ws
.
send
({
LogList
})
}
[
FileCommand
.
Remove
](
payload
,
ws
)
{
uni
.
$logger
.
local
.
removeOverDays
(
payload
.
days
)
ws
.
send
({
code
:
200
,
message
:
'success!'
,
data
:
this
.
data
})
}
}
ws/workers/LogsWorker.js
View file @
30e98e5
...
...
@@ -23,18 +23,18 @@ export default class LogsWorker {
},
formData
:
{
deviceId
,
type
:
'log'
type
:
'log'
},
success
:
res
=>
{
console
.
log
(
res
)
},
fail
:
res
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
},
complete
:
res
=>
{
// console.log(res)
// console.log(res)
}
})
})
}
work
(
deviceId
,
data
)
{
this
.
upload
(
deviceId
,
data
)
...
...
ws/workers/StorageWorker.js
View file @
30e98e5
import
{
constData
}
from
'../../utils/cache'
export
default
class
StorageWorker
{
constructor
()
{}
work
(
deviceId
,
data
,
ws
)
{
let
key
=
data
work
(
deviceId
,
data
,
ws
)
{
let
key
=
data
const
payload
=
data
.
payload
if
(
payload
&&
payload
.
key
)
{
if
(
payload
&&
payload
.
key
)
{
key
=
payload
.
key
}
if
(
!
constData
.
STORAGE_OBJECTKEY
[
key
])
{
uni
.
$logger
.
local
.
error
(
`不存在的 Storage Key->
${
key
}
. data->
${
typeof
data
===
'object'
?
JSON
.
stringify
(
data
):
data
}
`
)
console
.
log
(
`不存在的 Storage Key->
${
key
}
.`
)
if
(
!
constData
.
STORAGE_OBJECTKEY
[
key
])
{
uni
.
$logger
.
local
.
error
(
`不存在的 Storage Key->
${
key
}
. data->
${
typeof
data
===
'object'
?
JSON
.
stringify
(
data
)
:
data
}
`
)
console
.
log
(
`不存在的 Storage Key->
${
key
}
.`
)
return
}
const
value
=
uni
.
$storage
.
get
(
key
)
ws
.
send
({
value
:
123
})
const
value
=
uni
.
$storage
.
get
(
key
)
ws
.
send
({
[
key
]:
value
})
}
}
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