数据引擎-快手平台数据抽取bug修复

This commit is contained in:
2026-06-16 10:44:10 +08:00
parent e5133eea34
commit b4fc6f54af
22 changed files with 1324 additions and 487 deletions

View File

@@ -254,28 +254,32 @@ async function openPlatformModal(id) {
const title = document.getElementById('modalTitle');
const body = document.getElementById('modalBody');
const footer = document.getElementById('modalFooter');
if (id) {
const data = await api('GET', P.platform + '/getDatasourcePlatform?id=' + id);
title.textContent = '编辑平台';
body.innerHTML = pfHTML(data);
footer.innerHTML = '<button class="btn btn-outline" onclick="closeModal()">取消</button><button class="btn btn-primary" onclick="saveP(' + id + ')">保存</button>';
} else {
title.textContent = '新建平台';
body.innerHTML = pfHTML(null);
footer.innerHTML = '<button class="btn btn-outline" onclick="closeModal()">取消</button><button class="btn btn-primary" onclick="saveP(0)">创建</button>';
}
document.getElementById('modalOverlay').classList.add('open');
document.getElementById('modal').classList.add('open');
try {
if (id) {
const data = await api('GET', P.platform + '/getDatasourcePlatform?id=' + id);
title.textContent = '编辑平台';
body.innerHTML = pfHTML(data);
footer.innerHTML = '<button class="btn btn-outline" onclick="closeModal()">取消</button><button class="btn btn-primary" onclick="saveP(' + id + ')">保存</button>';
} else {
title.textContent = '新建平台';
body.innerHTML = pfHTML(null);
footer.innerHTML = '<button class="btn btn-outline" onclick="closeModal()">取消</button><button class="btn btn-primary" onclick="saveP(0)">创建</button>';
}
document.getElementById('modalOverlay').classList.add('open');
document.getElementById('modal').classList.add('open');
} catch (e) { toast('加载平台详情失败: ' + e.message, 'error'); }
}
function pfHTML(d) {
d = d || {};
const authCfg = d.authConfig ? JSON.stringify(d.authConfig, null, 2) : '{}';
return '<div class="form-row"><div class="form-group"><label>编码 *</label><input id="f-pcode" value="' + esc(d.platformCode||'') + '"></div>' +
'<div class="form-group"><label>名称 *</label><input id="f-pname" value="' + esc(d.platformName||'') + '"></div></div>' +
'<div class="form-group"><label>描述</label><input id="f-pdesc" value="' + esc(d.description||'') + '"></div>' +
'<div class="form-group"><label>API地址</label><input id="f-apiurl" value="' + esc(d.apiBaseUrl||'') + '"></div>' +
'<div class="form-row"><div class="form-group"><label>认证类型 *</label><select id="f-auth"><option value="OAUTH2"' + (d.authType==='OAUTH2'?' selected':'') + '>OAuth2</option><option value="TOKEN"' + (d.authType==='TOKEN'?' selected':'') + '>Token</option><option value="API_KEY"' + (d.authType==='API_KEY'?' selected':'') + '>API Key</option><option value="SIGN"' + (d.authType==='SIGN'?' selected':'') + '>签名</option></select></div>' +
'<div class="form-group"><label>状态</label><select id="f-ps"><option value="ACTIVE"' + ((d.status||'ACTIVE')==='ACTIVE'?' selected':'') + '>启用</option><option value="INACTIVE"' + (d.status==='INACTIVE'?' selected':'') + '>停用</option></select></div></div>' +
'<div class="form-group"><label>Token / access_token</label><input id="f-tk" value="' + esc(d.token||'') + '"></div>' +
'<div class="form-group"><label>API Key</label><input id="f-apik" value="' + esc(d.apiKey||'') + '"></div>' +
'<div class="form-row"><div class="form-group"><label>Client ID</label><input id="f-cid" value="' + esc(d.clientId||'') + '"></div>' +
'<div class="form-group"><label>Client Secret</label><input id="f-cs" value="' + esc(d.clientSecret||'') + '"></div></div>' +
'<div class="form-group"><label>认证配置 JSON</label><textarea id="f-ac" rows="4">' + esc(authCfg) + '</textarea></div>' +
@@ -284,9 +288,9 @@ function pfHTML(d) {
}
async function saveP(id) {
const body = {
platformCode: v('f-pcode'), platformName: v('f-pname'), apiBaseUrl: v('f-apiurl'),
authType: v('f-auth'), status: v('f-ps'), token: v('f-tk'),
clientId: v('f-cid'), clientSecret: v('f-cs'),
platformCode: v('f-pcode'), platformName: v('f-pname'), description: v('f-pdesc'),
apiBaseUrl: v('f-apiurl'), authType: v('f-auth'), status: v('f-ps'),
token: v('f-tk'), apiKey: v('f-apik'), clientId: v('f-cid'), clientSecret: v('f-cs'),
rateLimitPerMinute: parseInt(v('f-rpm'))||60, requestTimeoutMs: parseInt(v('f-to'))||30000,
};
try { body.authConfig = JSON.parse(v('f-ac')); } catch(e) { toast('auth_config JSON 格式错误', 'error'); return; }
@@ -299,27 +303,30 @@ async function saveP(id) {
// ========== 接口表单 ==========
async function openInterfaceModal(id) {
const pl = await api('GET', P.platform + '/listDatasourcePlatforms?page=1&pageSize=100');
const opts = (pl.list||[]).map(p => '<option value="' + p.id + '">' + esc(p.platformName) + '</option>').join('');
const title = document.getElementById('modalTitle');
const body = document.getElementById('modalBody');
const footer = document.getElementById('modalFooter');
if (id) {
const data = await api('GET', P.iface + '/getApiInterface?id=' + id);
title.textContent = '编辑接口';
body.innerHTML = iFormHTML(data, opts);
footer.innerHTML = '<button class="btn btn-outline" onclick="closeModal()">取消</button><button class="btn btn-primary" onclick="saveI(' + id + ')">保存</button>';
} else {
title.textContent = '新建接口';
body.innerHTML = iFormHTML(null, opts);
footer.innerHTML = '<button class="btn btn-outline" onclick="closeModal()">取消</button><button class="btn btn-primary" onclick="saveI(0)">创建</button>';
}
document.getElementById('modalOverlay').classList.add('open');
document.getElementById('modal').classList.add('open');
try {
const pl = await api('GET', P.platform + '/listDatasourcePlatforms?page=1&pageSize=100');
const opts = (pl.list||[]).map(p => '<option value="' + p.id + '">' + esc(p.platformName) + '</option>').join('');
const title = document.getElementById('modalTitle');
const body = document.getElementById('modalBody');
const footer = document.getElementById('modalFooter');
if (id) {
const data = await api('GET', P.iface + '/getApiInterface?id=' + id);
title.textContent = '编辑接口';
body.innerHTML = iFormHTML(data, opts);
footer.innerHTML = '<button class="btn btn-outline" onclick="closeModal()">取消</button><button class="btn btn-primary" onclick="saveI(' + id + ')">保存</button>';
} else {
title.textContent = '新建接口';
body.innerHTML = iFormHTML(null, opts);
footer.innerHTML = '<button class="btn btn-outline" onclick="closeModal()">取消</button><button class="btn btn-primary" onclick="saveI(0)">创建</button>';
}
document.getElementById('modalOverlay').classList.add('open');
document.getElementById('modal').classList.add('open');
} catch (e) { toast('加载接口详情失败: ' + e.message, 'error'); }
}
function iFormHTML(d, opts) {
d = d || {};
const sel = opts.replace('value="' + (d.platformId||'') + '"', 'value="' + (d.platformId||'') + '" selected');
const pid = (d.platformId != null) ? d.platformId : '';
const sel = opts.replace('value="' + pid + '"', 'value="' + pid + '" selected');
return '<div class="form-group"><label>所属平台</label><select id="f-pid">' + sel + '</select></div>' +
'<div class="form-row"><div class="form-group"><label>编码 *</label><input id="f-ic" value="' + esc(d.code||'') + '"></div>' +
'<div class="form-group"><label>名称 *</label><input id="f-in" value="' + esc(d.name||'') + '"></div></div>' +