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
3e57e0f6
Commit
3e57e0f6
authored
Sep 06, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf:优化请求次数,修复一些小问题
parent
32693b81
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
30 deletions
+100
-30
CollapseTable.vue
frontend/src/components/protocol/CollapseTable.vue
+39
-26
protocol.ts
frontend/src/dao/protocol.ts
+11
-2
allProtocolVersion.ts
frontend/src/stores/allProtocolVersion.ts
+24
-0
protocol.vue
frontend/src/views/protocol/protocol.vue
+16
-2
urls.py
protocol_version_manage/urls.py
+5
-0
views.py
protocol_version_manage/views.py
+5
-0
xdc.sqlite
xdc.sqlite
+0
-0
No files found.
frontend/src/components/protocol/CollapseTable.vue
View file @
3e57e0f6
...
...
@@ -3,7 +3,7 @@
<div
class=
"container"
>
<div
class=
"left"
>
<div
class=
"mr-4"
>
协议版本
</div>
<el-select
v-model=
"
value
"
>
<el-select
v-model=
"
currentVersion
"
>
<!-- TODO: 选择协议版本 -->
<el-option
v-for=
"option in options"
...
...
@@ -77,14 +77,18 @@
<
script
setup
lang=
"ts"
>
import
{
ref
,
onMounted
}
from
'vue'
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
{
GetProtocolVersion
,
ProtocolInit
}
from
"@/dao/protocol"
import
{
ProtocolInit
}
from
"@/dao/protocol"
import
ProtocolTable
from
"./ProtocolTable.vue"
;
import
type
{
DeviceProtocolResponse
,
ProtocolCmdResponse
}
from
'./types'
;
import
{
useProtocolVersionStore
}
from
'@/stores/allProtocolVersion'
;
const
addCmd
=
ref
<
boolean
>
(
false
)
const
value
=
ref
(
''
)
const
options
=
ref
<
Array
>
([])
const
protocol_names
=
ref
<
Array
>
([])
const
currentVersion
=
ref
(
''
)
type
OptionType
=
{
value
:
string
label
:
string
}
const
options
=
ref
<
OptionType
[]
>
([])
const
formLabelWidth
=
'140px'
type
propsType
=
{
...
...
@@ -118,37 +122,46 @@ const open = () => {
})
}
async
function
getVersion
(){
await
GetProtocolVersion
()
.
then
((
res
)
=>
{
for
(
const
item
of
res
){
protocol_names
.
value
.
push
(
item
.
protocol_name
)
if
(
item
.
protocol_name
===
props
.
name
){
let
version_paths
=
JSON
.
parse
(
item
.
version_paths
)
for
(
const
item2
of
version_paths
){
options
.
value
.
push
({
value
:
item2
.
version
,
label
:
item2
.
version
})
}
}
}
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
})
}
function
Init
(){
ProtocolInit
({
protocol_name
:
props
.
name
})
.
then
((
res
)
=>
{
.
then
((
_
)
=>
{
options
.
value
.
push
({
value
:
"init"
,
label
:
"init"
})
currentVersion
.
value
=
"init"
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
})
}
onMounted
(
async
()
=>
{
await
getVersion
()
if
(
protocol_names
.
value
.
indexOf
(
props
.
name
)
===
-
1
){
const
store
=
useProtocolVersionStore
()
onMounted
(()
=>
{
// 判断是否需要初始化
let
flag
=
true
for
(
let
protocolVersion
of
store
.
protocolVersions
){
if
(
protocolVersion
.
protocol_name
===
props
.
name
)
{
let
version_paths
=
JSON
.
parse
(
protocolVersion
.
version_paths
)
for
(
let
version_path
of
version_paths
){
options
.
value
.
push
({
value
:
version_path
.
version
,
label
:
version_path
.
version
})
}
flag
=
false
break
}
}
if
(
!
flag
)
{
for
(
let
item
of
store
.
currentVersions
){
if
(
item
.
protocol_name
===
props
.
name
)
{
currentVersion
.
value
=
item
.
version
}
}
}
// 如果需要初始化
if
(
flag
){
Init
()
}
})
...
...
frontend/src/dao/protocol.ts
View file @
3e57e0f6
import
axios
from
"axios"
const
baseURL
=
'http://192.168.0.214:8000/op'
//
const baseURL = 'http://192.168.0.214:8000/op'
export
function
GetProtocolVersion
(){
return
axios
.
get
(
'/api/all_protocol_version/'
).
then
(
...
...
@@ -11,9 +11,18 @@ export function GetProtocolVersion(){
}
export
function
ProtocolInit
(
protocol_name
:
any
){
return
axios
.
post
(
'api/protocol_version_manage/init/'
,
protocol_name
).
then
(
return
axios
.
post
(
'
/
api/protocol_version_manage/init/'
,
protocol_name
).
then
(
function
(
response
){
return
response
.
data
}
)
}
export
function
GetCurrentVersion
()
{
return
axios
.
get
(
'/api/current_versions/'
).
then
(
function
(
response
)
{
return
response
.
data
}
)
}
frontend/src/stores/allProtocolVersion.ts
0 → 100644
View file @
3e57e0f6
import
{
defineStore
}
from
'pinia'
import
{
ref
}
from
'vue'
type
ProtocolVersion
=
{
protocol_name
:
string
version_paths
:
string
}
type
CurrentVersion
=
{
protocol_name
:
string
version
:
string
}
export
const
useProtocolVersionStore
=
defineStore
(
'protocolVersion'
,
()
=>
{
const
protocolVersions
=
ref
<
ProtocolVersion
[]
>
([])
const
currentVersions
=
ref
<
CurrentVersion
[]
>
([])
return
{
protocolVersions
,
currentVersions
}
})
\ No newline at end of file
frontend/src/views/protocol/protocol.vue
View file @
3e57e0f6
...
...
@@ -27,16 +27,30 @@
</template>
<
script
setup
lang=
"ts"
>
import
{
ref
}
from
'vue'
;
import
{
ref
,
onMounted
}
from
'vue'
;
import
KitCollapse
from
"@/components/protocol/KitCollapse"
;
import
{
GetProtocolVersion
,
GetCurrentVersion
}
from
'@/dao/protocol'
;
import
{
useProtocolVersionStore
}
from
'@/stores/allProtocolVersion'
;
const
isShow
=
ref
<
boolean
>
(
false
)
const
formLabelWidth
=
'140px'
const
store
=
useProtocolVersionStore
()
onMounted
(()
=>
{
GetProtocolVersion
()
.
then
(
res
=>
{
store
.
protocolVersions
.
push
(...
res
)
})
GetCurrentVersion
()
.
then
(
res
=>
{
store
.
currentVersions
=
res
})
})
// TODO:添加协议
const
addProtocol
=
()
=>
{
isShow
.
value
=
false
console
.
log
(
'addProtocol'
)
}
</
script
>
...
...
protocol_version_manage/urls.py
View file @
3e57e0f6
from
django.urls
import
re_path
from
rest_framework.routers
import
DefaultRouter
from
.
import
views
router
=
DefaultRouter
()
router
.
register
(
r'current_versions'
,
views
.
CurrentDevVersionViewSet
)
urlpatterns
=
[
re_path
(
r'^protocol_version_manage/init/$'
,
views
.
init
),
...
...
@@ -13,3 +16,5 @@ urlpatterns = [
views
.
raw_file_download
),
re_path
(
r'^all_protocol_version/$'
,
views
.
AllProtocolVersionViewSet
.
as_view
({
'get'
:
'list'
})),
]
urlpatterns
+=
router
.
urls
protocol_version_manage/views.py
View file @
3e57e0f6
...
...
@@ -193,3 +193,8 @@ def raw_file_download(request, protocol_name, version):
response
[
'Content-Type'
]
=
'multipart/form-data'
response
[
'filename'
]
=
file_name
return
response
class
CurrentDevVersionViewSet
(
GenericViewSet
,
ListModelMixin
):
queryset
=
CurrentDevVersion
.
objects
.
all
()
serializer_class
=
CurrentDevVersionSerializer
xdc.sqlite
View file @
3e57e0f6
No preview for this file type
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