Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
M
mmc-stl-vue2
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
mmc-stl-vue2
Commits
9f7cf985
提交
9f7cf985
authored
7月 04, 2023
作者:
翁进城
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修正地面站链路
上级
730345e1
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
216 行增加
和
112 行删除
+216
-112
store.js
src/plugins/MMCGroundStation/store.js
+2
-4
demo.js
vue2/src/views/groundStation/demo.js
+102
-54
demo.vue
vue2/src/views/groundStation/demo.vue
+102
-54
vue.config.js
vue2/vue.config.js
+10
-0
没有找到文件。
src/plugins/MMCGroundStation/store.js
浏览文件 @
9f7cf985
...
...
@@ -14,7 +14,7 @@ export default {
},
orders
,
//所有指令
callbackList
:
[],
//ws消息callback队列
userInfo
:
""
,
//用户名
userInfo
:
{},
//用户信息
},
mutations
:
{
setWs
(
state
,
data
)
{
...
...
@@ -98,9 +98,7 @@ export default {
type
:
100
,
systemCode
:
"mmc"
,
state
:
1
,
username
:
state
.
userInfo
.
username
,
token
:
state
.
userInfo
.
token
,
appId
:
state
.
userInfo
.
appId
,
...
userInfo
,
};
ws
.
send
(
JSON
.
stringify
(
wsData
));
resolve
();
...
...
vue2/src/views/groundStation/demo.js
浏览文件 @
9f7cf985
...
...
@@ -2,10 +2,20 @@ export default `
<template>
<div>
<el-form>
<el-form-item label="账号">
<el-input v-model="account"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="password"></el-input>
</el-form-item>
<el-button @click="login">登录</el-button>
<el-form-item label="个人信息">{{ userInfo }}</el-form-item>
<el-form-item label="无人机id">
<el-input v-model="deviceHardId"></el-input>
</el-form-item>
<el-form-item label="操作">
<el-button @click="connect">连接地面站ws</el-button>
<el-button @click="subscribe">订阅</el-button>
<el-button @click="unsubscribe">取消订阅</el-button>
<el-button @click="publish()">通过原始type发送指令</el-button>
...
...
@@ -13,90 +23,127 @@ export default `
<el-button @click="addCallback">添加事件回调</el-button>
<el-button @click="removeCallback">移除事件回调</el-button>
</el-form-item>
<el-form-item label="支持的指令">
{{ orders }}
</el-form-item>
<el-form-item label="支持的指令">{{ orders }}</el-form-item>
</el-form>
<div>
{{ text }}
</div>
<div>
{{ callbackText }}
</div>
<div>{{ text }}</div>
<div>{{ callbackText }}</div>
</div>
</template>
<script>
export default {
name:
'GroundStation'
,
data(){
name:
"GroundStation"
,
data()
{
return {
deviceHardId: '',
account: "juchut",
password: "dG1qMDQwNyNuZXcuMQ==",
deviceHardId: "",
userInfo: {
username: 'admin',
token: 'cbe85bcd114cfb00a8547c86cac5460ad7942a1ab531094cd53e55a1e67617d9',
appId: 87878
username: "",
// token: "5e93559e5d00ed4dda7d75f9502ea9d83b8c15cb54672b4262dc85d0669ee53d",
appId: "40003",
// 'task-id': 1448
},
callbackText:
''
}
callbackText:
"",
}
;
},
computed: {
text(){
text()
{
return this.$store.state.MMCGroundStation.dataSet;
},
orders(){
orders()
{
return this.$store.state.MMCGroundStation.orders;
},
},
async created(){
try{
await this.$store.dispatch('MMCGroundStation/init', {
url: 'ws://116.62.122.225:30103',
userInfo: this.userInfo
})
}catch(e){
console.log('地面站连接失败', e)
}
console.log('地面站连接成功');
},
async created() {},
methods: {
subscribe(){
this.$store.dispatch('MMCGroundStation/subscribe', this.deviceHardId)
async login() {
let formData = new FormData();
formData.append("userAccount", this.account);
formData.append("password", this.password);
let res1 = await fetch("/crm/account/login", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username: this.account,
password: this.password,
}),
});
let data1 = await res1.json();
if (data1.code == 200) {
this.userInfo.username = data1.data.username;
}
let res2 = await fetch("/crm/account/loginInfo", {
method: "post",
headers: {
token: data1.data.token,
"Content-Type": "application/json",
},
body: JSON.stringify({
loginInfo: {
appId: "40004",
token: data1.data.token,
},
}),
});
let data2 = await res2.json();
if (data2.code == 200) {
this.userInfo.token = data2.data.token + data2.data.flyingSessionId;
}
},
async connect() {
try {
await this.$store.dispatch("MMCGroundStation/init", {
url: "ws://121.43.58.140:30105",
userInfo: this.userInfo,
});
} catch (e) {
console.log("地面站连接失败", e);
}
console.log("地面站连接成功");
},
subscribe() {
this.$store.dispatch("MMCGroundStation/subscribe", this.deviceHardId);
},
unsubscribe(){
this.$store.dispatch(
'MMCGroundStation/unsubscribe', this.deviceHardId)
unsubscribe()
{
this.$store.dispatch(
"MMCGroundStation/unsubscribe", this.deviceHardId);
},
publish(){
this.$store.dispatch(
'MMCGroundStation/publish'
, {
publish()
{
this.$store.dispatch(
"MMCGroundStation/publish"
, {
type: 200,
cmdFunction: 9001,
data: {
cmdControlType: 900,
},
deviceHardId: this.deviceHardId
})
deviceHardId: this.deviceHardId
,
})
;
},
order(
{ order } )
{
this.$store.dispatch(
'MMCGroundStation/order'
, {
order(
{ order })
{
this.$store.dispatch(
"MMCGroundStation/order"
, {
order,
data: {
cmdControlType: 900,
},
deviceHardId: this.deviceHardId
})
},
deviceHardId: this.deviceHardId,
});
},
callback(data) {
console.log("callback data", data);
this.callbackText += "收到事件,调试窗口查看 ";
},
callback(data){
console.log('callback data', data)
this.callbackText += '收到事件,调试窗口查看 ';
addCallback() {
this.$store.dispatch("MMCGroundStation/addCallback", this.callback);
},
addCallback(){
this.$store.dispatch('MMCGroundStation/addCallback', this.callback)
removeCallback() {
this.callbackText = "";
this.$store.dispatch("MMCGroundStation/removeCallback", this.callback);
},
removeCallback(){
this.callbackText = '';
this.$store.dispatch('MMCGroundStation/removeCallback', this.callback)
}
}
}
},
};
</script>
`
;
\ No newline at end of file
vue2/src/views/groundStation/demo.vue
浏览文件 @
9f7cf985
<
template
>
<div>
<el-form>
<el-form-item
label=
"账号"
>
<el-input
v-model=
"account"
></el-input>
</el-form-item>
<el-form-item
label=
"密码"
>
<el-input
v-model=
"password"
></el-input>
</el-form-item>
<el-button
@
click=
"login"
>
登录
</el-button>
<el-form-item
label=
"个人信息"
>
{{
userInfo
}}
</el-form-item>
<el-form-item
label=
"无人机id"
>
<el-input
v-model=
"deviceHardId"
></el-input>
</el-form-item>
<el-form-item
label=
"操作"
>
<el-button
@
click=
"connect"
>
连接地面站ws
</el-button>
<el-button
@
click=
"subscribe"
>
订阅
</el-button>
<el-button
@
click=
"unsubscribe"
>
取消订阅
</el-button>
<el-button
@
click=
"publish()"
>
通过原始type发送指令
</el-button>
...
...
@@ -12,89 +22,126 @@
<el-button
@
click=
"addCallback"
>
添加事件回调
</el-button>
<el-button
@
click=
"removeCallback"
>
移除事件回调
</el-button>
</el-form-item>
<el-form-item
label=
"支持的指令"
>
{{
orders
}}
</el-form-item>
<el-form-item
label=
"支持的指令"
>
{{
orders
}}
</el-form-item>
</el-form>
<div>
{{
text
}}
</div>
<div>
{{
callbackText
}}
</div>
<div>
{{
text
}}
</div>
<div>
{{
callbackText
}}
</div>
</div>
</
template
>
<
script
>
export
default
{
name
:
'GroundStation'
,
data
(){
name
:
"GroundStation"
,
data
()
{
return
{
deviceHardId
:
''
,
account
:
"juchut"
,
password
:
"dG1qMDQwNyNuZXcuMQ=="
,
deviceHardId
:
""
,
userInfo
:
{
username
:
'admin'
,
token
:
'cbe85bcd114cfb00a8547c86cac5460ad7942a1ab531094cd53e55a1e67617d9'
,
appId
:
87878
username
:
""
,
// token: "5e93559e5d00ed4dda7d75f9502ea9d83b8c15cb54672b4262dc85d0669ee53d",
appId
:
"40003"
,
// 'task-id': 1448
},
callbackText
:
''
}
callbackText
:
""
,
}
;
},
computed
:
{
text
(){
text
()
{
return
this
.
$store
.
state
.
MMCGroundStation
.
dataSet
;
},
orders
(){
orders
()
{
return
this
.
$store
.
state
.
MMCGroundStation
.
orders
;
},
},
async
created
(){
try
{
await
this
.
$store
.
dispatch
(
'MMCGroundStation/init'
,
{
url
:
'ws://116.62.122.225:30103'
,
userInfo
:
this
.
userInfo
})
}
catch
(
e
){
console
.
log
(
'地面站连接失败'
,
e
)
}
console
.
log
(
'地面站连接成功'
);
},
async
created
()
{},
methods
:
{
subscribe
(){
this
.
$store
.
dispatch
(
'MMCGroundStation/subscribe'
,
this
.
deviceHardId
)
async
login
()
{
let
formData
=
new
FormData
();
formData
.
append
(
"userAccount"
,
this
.
account
);
formData
.
append
(
"password"
,
this
.
password
);
let
res1
=
await
fetch
(
"/crm/account/login"
,
{
method
:
"post"
,
headers
:
{
"Content-Type"
:
"application/json"
,
},
body
:
JSON
.
stringify
({
username
:
this
.
account
,
password
:
this
.
password
,
}),
});
let
data1
=
await
res1
.
json
();
if
(
data1
.
code
==
200
)
{
this
.
userInfo
.
username
=
data1
.
data
.
username
;
}
let
res2
=
await
fetch
(
"/crm/account/loginInfo"
,
{
method
:
"post"
,
headers
:
{
token
:
data1
.
data
.
token
,
"Content-Type"
:
"application/json"
,
},
body
:
JSON
.
stringify
({
loginInfo
:
{
appId
:
"40004"
,
token
:
data1
.
data
.
token
,
},
}),
});
let
data2
=
await
res2
.
json
();
if
(
data2
.
code
==
200
)
{
this
.
userInfo
.
token
=
data2
.
data
.
token
+
data2
.
data
.
flyingSessionId
;
}
},
async
connect
()
{
try
{
await
this
.
$store
.
dispatch
(
"MMCGroundStation/init"
,
{
url
:
"ws://121.43.58.140:30105"
,
userInfo
:
this
.
userInfo
,
});
}
catch
(
e
)
{
console
.
log
(
"地面站连接失败"
,
e
);
}
console
.
log
(
"地面站连接成功"
);
},
subscribe
()
{
this
.
$store
.
dispatch
(
"MMCGroundStation/subscribe"
,
this
.
deviceHardId
);
},
unsubscribe
(){
this
.
$store
.
dispatch
(
'MMCGroundStation/unsubscribe'
,
this
.
deviceHardId
)
unsubscribe
()
{
this
.
$store
.
dispatch
(
"MMCGroundStation/unsubscribe"
,
this
.
deviceHardId
);
},
publish
(){
this
.
$store
.
dispatch
(
'MMCGroundStation/publish'
,
{
publish
()
{
this
.
$store
.
dispatch
(
"MMCGroundStation/publish"
,
{
type
:
200
,
cmdFunction
:
9001
,
data
:
{
cmdControlType
:
900
,
},
deviceHardId
:
this
.
deviceHardId
})
deviceHardId
:
this
.
deviceHardId
,
})
;
},
order
(
{
order
}
)
{
this
.
$store
.
dispatch
(
'MMCGroundStation/order'
,
{
order
(
{
order
})
{
this
.
$store
.
dispatch
(
"MMCGroundStation/order"
,
{
order
,
data
:
{
cmdControlType
:
900
,
},
deviceHardId
:
this
.
deviceHardId
})
},
deviceHardId
:
this
.
deviceHardId
,
});
},
callback
(
data
)
{
console
.
log
(
"callback data"
,
data
);
this
.
callbackText
+=
"收到事件,调试窗口查看 "
;
},
callback
(
data
){
console
.
log
(
'callback data'
,
data
)
this
.
callbackText
+=
'收到事件,调试窗口查看 '
;
addCallback
()
{
this
.
$store
.
dispatch
(
"MMCGroundStation/addCallback"
,
this
.
callback
);
},
addCallback
(){
this
.
$store
.
dispatch
(
'MMCGroundStation/addCallback'
,
this
.
callback
)
removeCallback
()
{
this
.
callbackText
=
""
;
this
.
$store
.
dispatch
(
"MMCGroundStation/removeCallback"
,
this
.
callback
);
},
removeCallback
(){
this
.
callbackText
=
''
;
this
.
$store
.
dispatch
(
'MMCGroundStation/removeCallback'
,
this
.
callback
)
}
}
}
},
};
</
script
>
\ No newline at end of file
vue2/vue.config.js
浏览文件 @
9f7cf985
...
...
@@ -17,6 +17,16 @@ module.exports = defineConfig({
"Cross-Origin-Embedder-Policy"
:
"require-corp"
,
},
proxy
:
{
"/crm"
:
{
target
:
"http://infra.mmcuav.cn/"
,
// target: "http://47.106.147.192/", //测试
// target: "http://120.79.102.66",
// target: "http://120.77.219.153:80", //v3正式
// target: "http://39.108.188.237:10009", //推广平台
ws
:
false
,
changeOrigin
:
true
,
pathRewrite
:
{},
},
},
},
});
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论