Commit 110b73b3 authored by 姜登's avatar 姜登

limit

parent c79f0ff3
Pipeline #13996 passed with stage
in 22 seconds
......@@ -14,17 +14,25 @@ class ScriptController extends Controller {
const { ctx, service } = this;
const { appKey } = ctx.query;
let limitScriptsList = false;
let excludeTab = true;
if (appKey) {
const ret = await service.partner.fetchInfo(appKey);
if (ret) {
limitScriptsList = ret.hfExcludeScripts;
excludeTab = ret.excludeTab;
}
}
let data = await service.scripts.fetchScripts();
if (limitScriptsList) {
data = data.filter(item => {
return !(limitScriptsList.includes(item.id));
});
if (excludeTab) {
data = data.filter(item => {
return !(limitScriptsList.includes(item.id));
});
} else {
data = data.filter(item => {
return (limitScriptsList.includes(item.id));
});
}
}
data = data.filter(item => {
return !(item.state === 'none');
......@@ -103,10 +111,31 @@ class ScriptController extends Controller {
async fetchHubSeripts() {
const { ctx, service } = this;
let { hubId } = ctx.params;
const { appKey } = ctx.query;
if (hubId === 'auto') {
const ret = await service.scripts.fetchScriptIdByIp();
hubId = ret.hubId;
}
let limitScriptsList = false;
let excludeTab = true;
if (appKey) {
const ret = await service.partner.fetchInfo(appKey);
if (ret) {
limitScriptsList = ret.hfExcludeScripts;
excludeTab = ret.excludeTab;
}
}
if (limitScriptsList) {
if (!excludeTab) {
if (limitScriptsList.includes(Number(hubId))) {
hubId = 1;
}
} else {
if (!limitScriptsList.includes(Number(hubId))) {
hubId = limitScriptsList[0];
}
}
}
const data = await service.scripts.fetchHubSeripts(hubId);
const array = [];
data.forEach(element => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment