修复问题

This commit is contained in:
fengge 2026-04-18 22:52:38 +08:00
parent b1de3f9ba3
commit 5715981b53
1 changed files with 21 additions and 17 deletions

View File

@ -264,9 +264,9 @@
document.getElementById('current-time').innerText = new Date().toLocaleString();
function checkApp() {
const tag = document.getElementById('inject-status');
const versionSpan = document.getElementById('app-version');
const envSpan = document.getElementById('env-type');
var tag = document.getElementById('inject-status');
var versionSpan = document.getElementById('app-version');
var envSpan = document.getElementById('env-type');
if (window.android) {
tag.innerText = "已连接至 App 原生接口";
@ -539,29 +539,33 @@
container.insertBefore(item, container.firstChild);
}
async function pttRequest(path, method = 'GET', query = {}, body = null) {
let url = PTT_BASE + path;
const qParams = new URLSearchParams(query).toString();
function pttRequest(path, method, query, body) {
if (!method) method = 'GET';
if (!query) query = {};
var url = PTT_BASE + path;
var qParams = new URLSearchParams(query).toString();
if (qParams) url += "?" + qParams;
const options = {
var options = {
method: method,
headers: { 'Content-Type': 'application/json' }
};
if (body) options.body = JSON.stringify(body);
try {
const response = await fetch(url, options);
if (path === '/record/play') {
showPttResult("流式播放接口已调用,请查看网络请求或直接点击预览链接");
return;
}
const data = await response.json();
showPttResult(data);
return data;
fetch(url, options).then(function(response) {
if (path === '/record/play') {
showPttResult("流式播放接口已调用");
return;
}
return response.json();
}).then(function(data) {
if (data) showPttResult(data);
}).catch(function(e) {
showPttResult("请求失败: " + e.message);
});
} catch (e) {
showPttResult("请求失败: " + e.message);
console.error(e);
showPttResult("fetch异常: " + e.message);
}
}