修改HTTP LIBRARY,增加OPTIONS支持
修改GATEWAY,修复转发 修改dnfs,暂时不编译(找不到模板) 修改static,能够获取节点
This commit is contained in:
1 parent
d60fe533bd
commit
419ae82858
8 files changed
+310
-23
No files matched your search
@@ -98,5 +98,6 @@
|
||||
<li><a href="https://www.baidu.com">百度推荐</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<script src="/js/dnfs.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -0,0 +1,46 @@
|
||||
async function getNode(token, id) {
|
||||
try {
|
||||
obj = { "pid": String(id) }
|
||||
jsonBody = JSON.stringify(obj)
|
||||
alert(jsonBody)
|
||||
const res = await fetch('/get_notes', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // 告诉服务器内容为json
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Target-Url': 'http://127.0.0.1:8006'
|
||||
},
|
||||
body: jsonBody
|
||||
});
|
||||
|
||||
const responseText = await res.text();
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = JSON.parse(responseText);
|
||||
} catch {
|
||||
console.error(`登录接口返回非 JSON 内容(HTTP ${res.status}):`, responseText);
|
||||
throw new Error('服务器响应格式异常,请稍后重试');
|
||||
}
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(result.message || `获取节点失败(HTTP ${res.status})`);
|
||||
}
|
||||
|
||||
//if (result.success) {
|
||||
alert(`获取节点成功`);
|
||||
//...
|
||||
|
||||
//} else {
|
||||
// alert(result.message || '获取节点失败');
|
||||
//}
|
||||
|
||||
} catch (err) {
|
||||
alert(err.message || '接口请求失败,请检查后端服务是否启动');
|
||||
console.error('登录请求异常:', err);
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
var token = sessionStorage.getItem('q4_token')
|
||||
var main_node = getNode(token, 0)
|
||||
@@ -148,7 +148,7 @@ form.addEventListener('submit', async function(e) {
|
||||
|
||||
if (result.success) {
|
||||
alert(`登陆成功`);
|
||||
sessionStorage.setItem('token', result.data.token);
|
||||
sessionStorage.setItem('q4_token', result.data.token);
|
||||
location.href = 'dnfs.html';
|
||||
} else {
|
||||
alert(result.message || '登录失败');
|
||||
|
||||
Reference in new issue
Block a user