×
-
阿里云盘扫码登录v2
+
扫码登录
@@ -170,13 +169,10 @@
隐私政策和使用条款
const shared_btn_views = document.getElementById('sharepoint-btn-view');
const shared_uid_views = document.getElementById('sharepoint-uid-view');
const url_hash = window.location.hash.substring(1); // 去掉地址栏上的#号
+ const current_host = window.location.protocol + "//" + window.location.host;
if(window.location.host==="api.oplist.org.cn")
document.getElementById('eo-show').hidden = false;
getToken();
- // 阿里云盘扫码v2相关变量
- let alicloud2SessionId = null;
- let alicloud2CheckInterval = null;
- let alicloud2StartTime = null;
let clientFingerprint = null;
// 点击模态框外部关闭
window.onclick = function (event) {
diff --git a/public/static/alitv.js b/public/static/alitv.js
index 0f4d1f6..63ec90c 100644
--- a/public/static/alitv.js
+++ b/public/static/alitv.js
@@ -4,11 +4,11 @@ class AliTVQRLogin {
// 创建QR登录管理器实例
this.qrManager = new QRLoginManager({
onSuccess: this.handleLoginSuccess.bind(this),
- maxCheckTime: 300000 // 5分钟过期时间
+ maxCheckTime: 30000 // 30秒过期时间
});
this.sidValue = null; // 存储二维码的sid
this.checkAttempts = 0; // 检查尝试次数
- this.maxCheckAttempts = 120; // 最大检查次数(5分钟内,每2.5秒检查一次)
+ this.maxCheckAttempts = 12; // 最大检查次数(30秒内,每2.5秒检查一次)
}
// 启动阿里云盘TV版扫码登录
diff --git a/public/static/aliv2.js b/public/static/aliv2.js
index d1c3c9b..c6531b9 100644
--- a/public/static/aliv2.js
+++ b/public/static/aliv2.js
@@ -3,7 +3,8 @@ class AlicloudQRLogin {
constructor() {
// 创建QR登录管理器实例
this.qrManager = new QRLoginManager({
- onSuccess: this.handleLoginSuccess.bind(this)
+ onSuccess: this.handleLoginSuccess.bind(this),
+ maxCheckTime: 30000 // 30秒过期时间
});
}
diff --git a/public/static/event.js b/public/static/event.js
index 894c537..a842a8d 100644
--- a/public/static/event.js
+++ b/public/static/event.js
@@ -23,7 +23,11 @@ function onSelect() {
client_uid_input.disabled = false;
client_uid_views.hidden = false;
secret_key_views.hidden = true;
- const driver_pre = driver_txt_input.value.split("_")[0];
+ let driver_pre = driver_txt_input.value.split("_")[0];
+ if (driver_txt_input.value === "alicloud_tv") {
+ driver_pre = "alitv"
+ }
+
direct_url_input.value = `${current_host}/${driver_pre}/callback`;
// 修改一些样式 ========================================================
@@ -39,7 +43,6 @@ function onSelect() {
clientIdContainer.style.display = 'none';
appSecretContainer.style.display = 'none';
serverUseContainer.style.display = 'none';
- callbackContainer.style.display = 'none';
server_use_input.checked = true;
} else {
clientIdContainer.style.display = 'block';
@@ -81,6 +84,7 @@ function onSelect() {
driver_txt_input.value === "onedrive_us" ||
driver_txt_input.value === "onedrive_de" ||
driver_txt_input.value === "alicloud_cs" ||
+ driver_txt_input.value === "alicloud_tv" ||
driver_txt_input.value === "dropboxs_go"
) {
server_use_input.checked = false;
diff --git a/public/static/login.js b/public/static/login.js
index 1feaf31..d9877db 100644
--- a/public/static/login.js
+++ b/public/static/login.js
@@ -31,6 +31,13 @@ async function getLogin(refresh = false) {
await startAlicloud2Login();
return;
}
+
+ // 阿里云盘TV版扫码登录,使用新的专用函数
+ if (driver_txt === "alicloud_tv" && !refresh) {
+ await startAliTVLogin();
+ return;
+ }
+
// 刷新秘钥情况 =================================================
let base_urls = "/requests?client_uid="
if (refresh) {
diff --git a/public/static/qrlogin.js b/public/static/qrlogin.js
index 20d10dc..bf24394 100644
--- a/public/static/qrlogin.js
+++ b/public/static/qrlogin.js
@@ -49,9 +49,24 @@ class QRLoginManager {
// 显示二维码
showQRCode(qrUrl, size = 200) {
- const qrApiUrl = `https://api.qrserver.com/v1/create-qr-code/?size=${size}x${size}&data=${encodeURIComponent(qrUrl)}`;
- document.getElementById(this.codeDisplayId).innerHTML = `

`;
- document.getElementById(this.codeContainerId).style.display = 'block';
+ try {
+ const codeDisplayElement = document.getElementById(this.codeDisplayId);
+ codeDisplayElement.innerHTML = ''; // 清除之前的内容
+ // 创建canvas元素
+ const canvas = document.createElement('canvas');
+ codeDisplayElement.appendChild(canvas);
+ // 使用新创建的canvas元素
+ QRCode.toCanvas(canvas, qrUrl, {
+ width: size,
+ margin: 1,
+ }, function(error) {
+ if (error) console.error('QR码生成错误:', error);
+ });
+
+ document.getElementById(this.codeContainerId).style.display = 'block';
+ } catch (error) {
+ console.error('生成QR码失败:', error);
+ }
}
// 设置状态
diff --git a/public/static/token.js b/public/static/token.js
index 25c4d80..86e1674 100644
--- a/public/static/token.js
+++ b/public/static/token.js
@@ -4,7 +4,6 @@ async function getToken() {
const json_byte = Uint8Array.from(atob(url_hash), c => c.charCodeAt(0));
const json_text = new TextDecoder().decode(json_byte);
const json_data = JSON.parse(json_text);
- console.log(json_data);
const server_use = json_data.server_use;
const client_uid = json_data.client_uid;
const secret_key = json_data.secret_key;
diff --git a/src/driver/alicloud_oa.ts b/src/driver/alicloud_oa.ts
index 3904b7b..7e654de 100644
--- a/src/driver/alicloud_oa.ts
+++ b/src/driver/alicloud_oa.ts
@@ -64,7 +64,6 @@ export async function alyLogin(c: Context) {
const result = await pubLogin(c, JSON.stringify(params_info), request_urls,
false, "POST", "json",
{'Content-Type': 'application/json'});
- console.log(result);
if (!result.qrCodeUrl) return c.json({"text": result.message}, 500);
return c.json({"text": result.qrCodeUrl, "sid": result.sid}, 200);
}
@@ -73,7 +72,6 @@ export async function alyLogin(c: Context) {
// 令牌申请 ##############################################################################
export async function alyToken(c: Context) {
const clients_info: configs.Clients = getCookie(c);
- if (clients_info.drivers == "alicloud_tv") return await checkStatus(c, clients_info);
let oauth_type: string | undefined = c.req.query('grant_type')
if (!clients_info.servers) clients_info.servers = c.req.query('server_use') == "true"
if (!clients_info.drivers) return c.json({text: 'No Cookies',}, 401);
@@ -138,7 +136,6 @@ export async function genToken(c: Context) {
const refresh_text: string | undefined = c.req.query('refresh_ui');
if (!clients_info) return c.json({text: "传入参数缺少"}, 500);
if (!refresh_text) return c.json({text: "缺少刷新令牌"}, 500);
- if (clients_info.drivers == "alicloud_tv") return await refreshToken(c, refresh_text);
// 请求参数 ==========================================================================
const params: Record
= {
client_id: clients_info.servers ? c.env.alicloud_uid : clients_info.app_uid,
diff --git a/src/driver/alicloud_tv.ts b/src/driver/alicloud_tv.ts
index db37c9a..c3eda86 100644
--- a/src/driver/alicloud_tv.ts
+++ b/src/driver/alicloud_tv.ts
@@ -1,5 +1,6 @@
import {Context} from "hono";
import {pubLogin} from "../shares/oauthv2";
+import {Requests} from "../shares/request";
// 定义API响应的接口
interface AliCloudTVApiResponse {
@@ -402,13 +403,20 @@ function getClient(): AliyunPanTvToken {
// checkQrcodeStatus 检查二维码状态
async function checkQrcodeStatus(c: Context, sid: string): Promise<{ auth_code: string } | null> {
+ let headersBase ;
try {
- const response = await pubLogin(
+ headersBase = {
+ "User-Agent": "Mozilla/5.0 (Linux; U; Android 15; zh-cn; SM-S908E Build/UKQ1.231108.001) AppleWebKit/533.1 (KHTML, like Gecko) Mobile Safari/533.1",
+ "Host": "openapi.alipan.com",
+ "Content-Type": "text/plain;charset=UTF-8",
+ };
+ const response = await Requests(
c,
"",
`https://openapi.alipan.com/oauth/qrcode/${sid}/status`,
- false,
"GET",
+ false,
+ headersBase,
"json"
);