Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue_django_test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
vue_django_test
Commits
1bfdeecf
Commit
1bfdeecf
authored
Sep 04, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mod:修改样式
parent
4201aedc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
41 deletions
+70
-41
App.vue
frontend/src/App.vue
+4
-4
DevicePerformanceTabel.vue
frontend/src/components/DevicePerformanceTabel.vue
+25
-5
Chat.vue
frontend/src/views/Chat.vue
+26
-17
mqtt.py
mqtt/mqtt.py
+15
-15
No files found.
frontend/src/App.vue
View file @
1bfdeecf
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
//
import Chat from '@/views/Chat'
import
Chat
from
'@/views/Chat'
// import FileDown from './views/FileDown.vue';
// import FileDown from './views/FileDown.vue';
// import Upload from './views/Upload.vue';
// import Upload from './views/Upload.vue';
// import Tabs from './views/Tabs.vue';
// import Tabs from './views/Tabs.vue';
import
DeviceCommunication
from
'@/views/DeviceCommunication'
;
//
import DeviceCommunication from '@/views/DeviceCommunication';
</
script
>
</
script
>
<
template
>
<
template
>
<
!--
<chat
/>
--
>
<
chat
/
>
<!--
<FileDown
/>
-->
<!--
<FileDown
/>
-->
<!--
<Upload
/>
-->
<!--
<Upload
/>
-->
<!--
<Tabs
/>
-->
<!--
<Tabs
/>
-->
<
device-communication
/
>
<
!--
<device-communication
/>
--
>
</
template
>
</
template
>
frontend/src/components/DevicePerformanceTabel.vue
View file @
1bfdeecf
<
template
>
<
template
>
<el-table
:data=
"tableData"
class=
"w-full"
>
<div>
<el-table-column
v-for=
"(_, key) in tableData[0]"
:label=
"key"
:prop=
"key"
width=
"150"
/>
<div
class=
"text-right"
>
</el-table>
<el-button
type=
"danger"
@
click=
"del"
:icon=
"Delete"
circle
/>
</div>
<el-table
:data=
"tableData"
class=
"w-full"
>
<el-table-column
v-for=
"(_, key) in tableData[0]"
:label=
"key"
:prop=
"key"
width=
"150"
/>
</el-table>
</div>
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
onMounted
}
from
'vue'
import
{
ref
,
onMounted
,
onBeforeUnmount
}
from
'vue'
import
{
Delete
}
from
'@element-plus/icons-vue'
type
propsType
=
{
type
propsType
=
{
groupName
:
string
groupName
:
string
...
@@ -17,8 +23,9 @@ type tableDataType = Record<string, string>[]
...
@@ -17,8 +23,9 @@ type tableDataType = Record<string, string>[]
// const tableData = ref
<
tableDataType
>
([{}]);
// const tableData = ref
<
tableDataType
>
([{}]);
const
tableData
=
ref
<
tableDataType
>
([{}])
const
tableData
=
ref
<
tableDataType
>
([{}])
let
table_websocket
:
WebSocket
|
null
=
null
onMounted
(()
=>
{
onMounted
(()
=>
{
let
table_websocket
=
new
WebSocket
(
table_websocket
=
new
WebSocket
(
'ws://'
+
window
.
location
.
host
+
'/ws/chat/'
+
props
.
groupName
!
+
'/'
'ws://'
+
window
.
location
.
host
+
'/ws/chat/'
+
props
.
groupName
!
+
'/'
)
)
...
@@ -35,4 +42,17 @@ onMounted(() => {
...
@@ -35,4 +42,17 @@ onMounted(() => {
console
.
error
(
'Table socket closed unexpectedly'
,
e
);
console
.
error
(
'Table socket closed unexpectedly'
,
e
);
}
}
})
})
const
emits
=
defineEmits
([
'deleteTable'
])
const
del
=
()
=>
{
emits
(
'deleteTable'
)
}
onBeforeUnmount
(()
=>
{
if
(
table_websocket
!
.
OPEN
)
{
table_websocket
!
.
close
()
}
})
</
script
>
</
script
>
frontend/src/views/Chat.vue
View file @
1bfdeecf
<
template
>
<el-scrollbar
ref=
"scrollbarRef"
style=
"height: 25rem;"
class=
"mb-10"
always
>
<div
ref=
"innerRef"
>
<p
v-for=
"item in items"
:key=
"item"
class=
"scrollbar-demo-item text-sm"
>
<div>
{{
JSON
.
parse
(
item
)?.
ts
}}
</div>
{{
item
}}
</p>
</div>
</el-scrollbar>
<el-input
v-model=
"input"
placeholder=
"Please input"
@
keyup
.
enter=
"send"
></el-input>
<el-button
@
click=
"send"
>
Send
</el-button>
<device-performance-table
v-for=
"param in deviceTableParams"
mt-5
:group-name=
"param"
:key=
"param"
@
delete-table=
"deleteDeviceInfo(param)"
/>
<el-button
@
click=
"addDeviceTable"
class=
"mt-5"
>
Add table
</el-button>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
onMounted
,
watch
}
from
'vue'
;
import
{
ref
,
onMounted
,
watch
}
from
'vue'
;
import
{
ElScrollbar
,
ElInput
,
ElButton
}
from
'element-plus'
;
import
{
ElScrollbar
,
ElInput
,
ElButton
}
from
'element-plus'
;
...
@@ -80,24 +102,11 @@ const addDeviceTable = () => {
...
@@ -80,24 +102,11 @@ const addDeviceTable = () => {
})
})
}
}
</
script
>
const
deleteDeviceInfo
=
(
param
:
string
)
=>
{
deviceTableParams
.
value
.
splice
(
deviceTableParams
.
value
.
indexOf
(
param
),
1
);
<
template
>
}
<el-scrollbar
ref=
"scrollbarRef"
mb-10
height=
"400px"
always
>
<div
ref=
"innerRef"
>
<p
v-for=
"item in items"
:key=
"item"
class=
"scrollbar-demo-item text-sm"
>
<div>
{{
JSON
.
parse
(
item
)?.
ts
}}
</div>
{{
item
}}
</p>
</div>
</el-scrollbar>
<el-input
v-model=
"input"
placeholder=
"Please input"
@
keyup
.
enter=
"send"
></el-input>
<el-button
@
click=
"send"
>
Send
</el-button>
<device-performance-table
v-for=
"param in deviceTableParams"
mt-5
:group-name=
"param"
:key=
"param"
/>
</
script
>
<el-button
@
click=
"addDeviceTable"
class=
"mt-5"
>
Add table
</el-button>
</
template
>
<
style
scoped
>
<
style
scoped
>
.scrollbar-demo-item
{
.scrollbar-demo-item
{
...
...
mqtt/mqtt.py
View file @
1bfdeecf
...
@@ -33,21 +33,21 @@ def send_message(data: dict, device_name: str):
...
@@ -33,21 +33,21 @@ def send_message(data: dict, device_name: str):
"""
"""
send_websocket_message
(
data
)
send_websocket_message
(
data
)
dev_info
=
TableXproAllDevinfo
.
objects
.
filter
(
dev_name
=
device_name
)
.
first
()
#
dev_info = TableXproAllDevinfo.objects.filter(dev_name=device_name).first()
if
"TCP"
in
dev_info
.
comunitate_mode
.
upper
():
#
if "TCP" in dev_info.comunitate_mode.upper():
name
=
dev_info
.
tcp_port
#
name = dev_info.tcp_port
elif
"UDP"
in
dev_info
.
comunitate_mode
.
upper
():
#
elif "UDP" in dev_info.comunitate_mode.upper():
name
=
dev_info
.
udp_port_src
#
name = dev_info.udp_port_src
print
(
name
)
#
print(name)
send_websocket_message
(
data
,
group_name
=
f
'chat_{name}'
)
#
send_websocket_message(data, group_name=f'chat_{name}')
#
cmds = data.get('CMDS')
cmds
=
data
.
get
(
'CMDS'
)
#
if cmds is None:
if
cmds
is
None
:
#
return
return
#
if cmds[0] == '$':
if
cmds
[
0
]
==
'$'
:
#
send_websocket_message(data, group_name="chat_acu7m5")
send_websocket_message
(
data
,
group_name
=
"chat_acu7m5"
)
#
else:
else
:
#
send_websocket_message(data, group_name="chat_hwf")
send_websocket_message
(
data
,
group_name
=
"chat_hwf"
)
client
=
mqtt
.
Client
()
client
=
mqtt
.
Client
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment