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 { ...@@ -14,17 +14,25 @@ class ScriptController extends Controller {
const { ctx, service } = this; const { ctx, service } = this;
const { appKey } = ctx.query; const { appKey } = ctx.query;
let limitScriptsList = false; let limitScriptsList = false;
let excludeTab = true;
if (appKey) { if (appKey) {
const ret = await service.partner.fetchInfo(appKey); const ret = await service.partner.fetchInfo(appKey);
if (ret) { if (ret) {
limitScriptsList = ret.hfExcludeScripts; limitScriptsList = ret.hfExcludeScripts;
excludeTab = ret.excludeTab;
} }
} }
let data = await service.scripts.fetchScripts(); let data = await service.scripts.fetchScripts();
if (limitScriptsList) { if (limitScriptsList) {
data = data.filter(item => { if (excludeTab) {
return !(limitScriptsList.includes(item.id)); data = data.filter(item => {
}); return !(limitScriptsList.includes(item.id));
});
} else {
data = data.filter(item => {
return (limitScriptsList.includes(item.id));
});
}
} }
data = data.filter(item => { data = data.filter(item => {
return !(item.state === 'none'); return !(item.state === 'none');
...@@ -103,10 +111,31 @@ class ScriptController extends Controller { ...@@ -103,10 +111,31 @@ class ScriptController extends Controller {
async fetchHubSeripts() { async fetchHubSeripts() {
const { ctx, service } = this; const { ctx, service } = this;
let { hubId } = ctx.params; let { hubId } = ctx.params;
const { appKey } = ctx.query;
if (hubId === 'auto') { if (hubId === 'auto') {
const ret = await service.scripts.fetchScriptIdByIp(); const ret = await service.scripts.fetchScriptIdByIp();
hubId = ret.hubId; 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 data = await service.scripts.fetchHubSeripts(hubId);
const array = []; const array = [];
data.forEach(element => { 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