提问 发文

easyv如何做常用接口

库米

| 2023-06-08 18:14 113 1 0
收藏 0
分享
分享方式
微信

回答

游客

全部1条回答

微微菌 微微菌 2023-06-08 18:30

注:所有接口调用都需要先登录easyv,也只允许通过接口修改该账号下的大屏。

1. 修改组件显隐:

url :https://workspace.easyv.cloud/api/easyv/v3/screen/layers/change

method: POST,

headers: 'Content-Type': 'application/json',

body: JSON.stringify({

id:大屏id,

configs:[

{

id:组件id,

key:关键字段,控制显隐时为 show,

value:字段值, false为隐藏,true为显示

}

]

})

实例:

//在控制台中调用该请求,可控制827642大屏下的28082261组件隐藏
fetch("https://workspace.easyv.cloud/api/easyv/v3/screen/layers/change",{
method:"POST",
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify({
id:827642,
configs:[
{id:28082261,key:"show",value:false}
]
})
})
.then(res=>res.json())
.then(data=>console.log(data));

2. 批量删除大屏中的过滤器

注:使用此接口记得先把大屏中和组件绑定的的过滤器先删掉,否则会触发平台bug(如果已经触发Bug了,就把大屏复制一下,使用复制后的大屏即可解决)。

url:https://workspace.easyv.cloud/api/easyv/v3/filter/delete

method:POST,

headers: 'Content-Type': 'application/json',

body:JSON.stringify({

components:[],

ids:[xxx,xxx,xxx] //每一个过滤器的id

})

实例:

//要获取下列ids数组,可以打开大屏以及chrome浏览器控制台,选择network(网络)标签,刷新页面
//将list?id=作为筛选内容,筛选所有请求,即可获取所有数据过滤器的内容
let ids=[
358114,
358115,
358116,
358117,
358118,
358119,
358120,
358121,
358122,
358123,
358124,
358125,
358170,
358194,
358296,
358297,
358299,
358301
];
//在控制台中调用该请求,可删除所有ids中的数据过滤器
fetch("https://workspace.easyv.cloud/api/easyv/v3/filter/delete",{
method:"POST",
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify({
components:[],
ids:ids
})
})
.then(res=>res.json())
.then(data=>console.log(data));
/*
fetch("https://workspace.easyv.cloud/api/easyv/v3/filter/delete",{
method:"POST",
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify({
components:[],
ids:[].map(d=>{return d.id})
})
})
.then(res=>res.json())
.then(data=>console.log(data));
*/
/*在控制台调用下面这个函数可以删除大屏内所有数据过滤器,注意先解绑组件和过滤器*/
//screenId = 大屏ID
function deletAllFilter(screenId){
fetch(`https://workspace.easyv.cloud/api/easyv/v3/filter/list?id=${screenId}&type=screen`)
.then(res=>res.json())
.then(res=>{
if(res.success==true){
fetch("https://workspace.easyv.cloud/api/easyv/v3/filter/delete",{
method:"POST",
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify({
components:[],
ids:res.data.map(d=>{return d.id})
})
})
.then(res=>res.json())
.then(data=>console.log(data));
}else{
console.log("获取大屏数据过滤器失败");
}
});
};
deletAllFilter(xxxxxx);

3. 修改“组”的缩放,使其产生水平/垂直镜像效果

url:https://workspace.easyv.cloud/api/easyv/v3/screen/layers/change,

method:"POST",

headers: {

'Content-Type': 'application/json'

},

body:JSON.stringify({

id:679470, //大屏id

configs:[

{

"id": group_xxx, //组的id

"key": "transform", //变形

"value": { //水平镜像的效果配置如下

"open":true,

"scale":{

"lock":false,

"y":-1,

"x":1

}

}

}

]

})

fetch("https://workspace.easyv.cloud/api/easyv/v3/screen/layers/change",{
method:"POST",
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify({
id:679470,
configs:[
{
"id": "group_xxx", //组的id,获取组的id可以通过设置一次缩放,然后从控制台中查看network来获取
"key": "transform",
"value": {
"open":true,
"scale":{
"lock":false,
"y":-1,
"x":1
}
}
}
]
})
})
.then(res=>res.json())
.then(data=>console.log(data));

4. 获取大屏列表

fetch("https://workspace.easyv.cloud/api/easyv/v3/screen/list",{
method:"GET"
})
.then(res=>res.json())
.then(data=>console.log(data));

5. 更新引用面板绑定关系

具体案例:https://dtstack.yuque.com/docs/share/97b3ce4f-0cc9-4ab7-a113-1a0f38a55d2f?# 《如何快速绑定引用面板》

fetch("https://workspace.easyv.cloud/api/easyv/v3/panel/update",{
method:"POST",
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify({
configs:[
{
"config": "{\"left\":0,\"top\":0,\"width\":1080,\"height\":1920,\"hideDefault\":false}",
"id": "1384", //引用面板的id
"states":[大屏id1,大屏id2] //大屏id数组,可以通过接口4根据名称来反查id
}
]
})
})
.then(res=>res.json())
.then(data=>console.log(data));

6.获取大屏中所有的组件

fetch("https://workspace.easyv.cloud/api/easyv/v5/screens/大屏id")
.then(res=>res.json())
.then(res=>console.log(res.data.components))

7. 更新组件的某个配置项

改接口配合第六个接口,可以完成批量修改某一类组件,详细方法见:

https://dtstack.yuque.com/docs/share/557f7f47-6045-423f-a6e1-8dc421d23468?# 《easyv常用接口》

fetch("https://workspace.easyv.cloud/api/easyv/v3/component/update",{
method:"POST",
headers:{
"content-type":"application/json"
},
body:JSON.stringify({
configs:[{
config:[],//组件完整配置项
id:xxxx, //组件id
parent:null //这个我也不知道干嘛的,反正写上就完事了
}],
screenId:大屏ID
})
})
.then(res=>res.json())
.then(res=>console.log(res))

8. 关闭某个组件的过滤器

fetch("https://workspace.easyv.cloud/api/easyv/v3/component/data/update",{
method:"POST",
headers:{
"content-type":"application/json"
},
body:JSON.stringify({
"id": 组件id,
"type": "static",
"useFilter": false
})
})
.then(res=>res.json())
.then(res=>console.log(res))

回复 0
0

文章

1.15K

人气

0

粉丝

0

关注

官方媒体

轻松设计高效搭建,减少3倍设计改稿与开发运维工作量

开始免费试用 预约演示

扫一扫关注公众号 扫一扫联系客服

©Copyrights 2016-2022 杭州易知微科技有限公司 浙ICP备2021017017号-3 浙公网安备33011002011932号

互联网信息服务业务 合字B2-20220090

400-8505-905 复制
免费试用
微信社区
易知微-数据可视化
微信扫一扫入群