Last Sync: 2025-06-14 21:23:30 (Mobile)

This commit is contained in:
Yizelove 2025-06-14 21:23:30 +08:00
parent aa386512c2
commit c5389d163e
7 changed files with 18 additions and 93 deletions

View File

@ -4,8 +4,8 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenList Token 获取工具</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link href="https://jsd.tencent.to/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://jsd.tencent.to/npm/sweetalert2@11.22.0/dist/sweetalert2.all.min.js"></script>
<style>
:root {
--bg-color-light: #ffffff;
@ -117,21 +117,21 @@
<div class="mb-3" style="margin-top: 15px">
<input type="checkbox" id="server_use" class="form-check-input">
<label for="server_use" class="form-check-label">使用 OpenList 提供的API</label>
<label for="server_use" class="form-check-label">使用 OpenList 提供的参数</label>
</div>
<div class="mb-3">
<label for="client-id" class="form-label">客户端ID</label>
<div class="mb-3" id="client-id-view">
<label for="client-id" class="form-label">Client ID客户端ID</label>
<input type="text" id="client-id" class="form-control">
</div>
<div class="mb-3">
<label for="app-secret" class="form-label">应用机密</label>
<label for="app-secret" class="form-label">AppKey应用秘钥</label>
<input type="text" id="app-secret" class="form-control">
</div>
<div class="mb-3" id="secret-key-view">
<label for="secret-key" class="form-label">访问密钥(SecretKey</label>
<label for="secret-key" class="form-label">SecretKey(访问秘钥</label>
<input type="text" id="secret-key" class="form-control">
</div>
@ -183,7 +183,7 @@
position: 'top',
icon: 'info',
title: '获取失败',
text: '请先填写客户端ID和应用机密',
text: '请先填写AppID和AppKey',
showConfirmButton: true,
});
return;
@ -305,6 +305,9 @@
document.getElementById('secret-key-view').hidden = true;
if (siteSelect.value === "baiduyun_go") {
document.getElementById('secret-key-view').hidden = false;
document.getElementById('client-id-view').hidden = true;
}else{
document.getElementById('client-id-view').hidden = false;
}
});
@ -324,7 +327,7 @@
position: 'top',
icon: 'error',
title: '暂不支持',
html: "阿里云、123云盘、OneDrive非官方区域暂不支持使用官方密钥",
html: "阿里云、123云盘、OneDrive非美国区域暂不支持使用官方密钥",
showConfirmButton: true,
});
return;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

View File

@ -1,58 +0,0 @@
/* 手动设置字体链接 */
@font-face {
font-family: 'MapleMonoNL';
src: url('/static/maple-min.ttf');
}
* {
font-family: MapleMonoNL, sans-serif;
}
body {
margin: 0;
padding: 0;
font-family: MapleMonoNL, sans-serif;
background: url('/static/cdn-image.jpg') no-repeat center center fixed;
background-size: cover;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-container {
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
max-width: 400px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
.input-group {
margin-bottom: 20px;
}
.input-group label {
display: block;
margin-bottom: 5px;
color: #555;
}
.input-group input, .input-group select,.input-group textarea{
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 10px; /* 修改圆角为10px */
box-sizing: border-box;
}

View File

@ -10,17 +10,15 @@ const driver_map: string[] = [
// 登录申请 ##############################################################################
export async function oneLogin(c: Context) {
const client_uid: string = <string>c.req.query('client_uid');
const client_key: string = <string>c.req.query('client_key');
const secret_key: string = <string>c.req.query('secret_key');
const driver_txt: string = <string>c.req.query('apps_types');
const server_use: string = <string>c.req.query('server_use');
if (server_use == "false" && (!driver_txt || !client_uid || !client_key || !secret_key))
if (server_use == "false" && (!driver_txt || !client_key || !secret_key))
return c.json({text: "参数缺少"}, 500);
// 请求参数 ==========================================================================
const params_all: Record<string, any> = {
client_id: server_use == "true" ? c.env.baiduyun_key : client_key,
device_id: server_use == "true" ? c.env.baiduyun_uid : client_uid,
scope: "basic,netdisk",
response_type: 'code',
redirect_uri: 'https://' + c.env.MAIN_URLS + '/baiduyun/callback'
@ -35,7 +33,6 @@ export async function oneLogin(c: Context) {
method: 'GET',
});
if (server_use == "false") {
local.setCookie(c, 'client_uid', client_uid);
local.setCookie(c, 'client_key', client_key);
local.setCookie(c, 'secret_key', secret_key);
}
@ -50,18 +47,17 @@ export async function oneLogin(c: Context) {
// 令牌申请 ##############################################################################
export async function oneToken(c: Context) {
let login_data, client_uid, client_key, secret_key, client_url;
let login_data, client_key, secret_key, client_url;
let driver_txt, server_use, params_all: Record<string, any>;
try { // 请求参数 ====================================================================
login_data = c.req.query('code');
server_use = local.getCookie(c, 'server_use')
driver_txt = local.getCookie(c, 'driver_txt')
client_uid = client_key = secret_key = ""
client_key = secret_key = ""
if (server_use == "false") {
client_uid = local.getCookie(c, 'client_uid')
client_key = local.getCookie(c, 'client_key')
secret_key = local.getCookie(c, 'secret_key')
if (!login_data || !client_uid || !client_key || !secret_key)
if (!login_data || !client_key || !secret_key)
return c.redirect(showErr("Cookie缺少", "", ""));
}
@ -87,7 +83,6 @@ export async function oneToken(c: Context) {
});
const response: Response = await fetch(urlWithParams, {method: 'GET'});
if (server_use == "false") {
local.deleteCookie(c, 'client_uid');
local.deleteCookie(c, 'client_key');
local.deleteCookie(c, 'secret_key');
}
@ -99,15 +94,14 @@ export async function oneToken(c: Context) {
return c.redirect(
`/?access_token=${json.access_token}`
+ `&refresh_token=${json.refresh_token}`
+ `&client_uid=${client_uid}`
+ `&client_key=${server_use == "true" ? "" : client_key}`
+ `&secret_key=${server_use == "true" ? "" : secret_key}`
+ `&driver_txt=${driver_txt}`
);
}
return c.redirect(showErr(json.error_description, client_uid, client_key));
return c.redirect(showErr(json.error_description, client_key));
} catch (error) {
return c.redirect(showErr(<string>error, client_uid, client_key));
return c.redirect(showErr(<string>error, client_key));
}
}