From 5eebcc886f9e4790f552ee215449ac8b9ad80a63 Mon Sep 17 00:00:00 2001 From: wood Date: Sun, 3 Sep 2023 20:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E4=BA=86=E6=94=AF=E6=8C=81=E5=8D=95?= =?UTF-8?q?=E8=A1=8C=E5=A4=9A=E4=BF=A1=E6=81=AF=E5=8C=B9=E9=85=8D=EF=BC=8C?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=8F=91=E7=8E=B0=E5=8F=AA=E8=BE=93=E5=85=A5?= =?UTF-8?q?sess=E6=88=96=E8=80=85key=E7=9A=84=E6=97=B6=E5=80=99=E6=9F=A5?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E4=BA=86=20Fixes=20#24?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/static/js.js b/static/js.js index 95d557e..ce8fbdb 100644 --- a/static/js.js +++ b/static/js.js @@ -289,30 +289,35 @@ function sendRequest() { apiUrl = apiUrlSelect.value; } + let apiKeys = parseKeys(apiKeyInput.value); - + if (apiKeys.length === 0) { alert("未匹配到 API-KEY,请检查输入内容"); return; } - alert("成功匹配到 API Key,确认后开始查询:" + apiKeys); - + function parseKeys(input) { let lines = input.split(/\n/); let result = []; for (let line of lines) { - if (line.includes("sk-") && line.includes("sess-")) { - let sessKey = line.match(/sess-[^\-]+/)[0]; - result.push(sessKey); + let sessKeyMatch = line.match(/sess-[^-]+/); + let skKeyMatch = line.match(/sk-[^-]+/); + + if (sessKeyMatch !== null && skKeyMatch !== null) { + result.push(sessKeyMatch[0]); } - else if (line.includes("sk-")) { - let skKey = line.match(/sk-[^\-]+/)[0]; - result.push(skKey); + else if (skKeyMatch !== null) { + result.push(skKeyMatch[0]); + } + else if (sessKeyMatch !== null) { + result.push(sessKeyMatch[0]); } } return result; } + let lastQueryPromise = null;