diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d299e1a..ea9507a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,7 +6,14 @@
-
+
+
+
+
+
+
+
+
@@ -77,7 +84,7 @@
1749696640494
-
+
@@ -151,7 +158,15 @@
1749817021359
-
+
+
+ 1749817071777
+
+
+
+ 1749817071777
+
+
diff --git a/public/index.html b/public/index.html
index 6b23b9d..bac7375 100644
--- a/public/index.html
+++ b/public/index.html
@@ -172,13 +172,13 @@
// 获取登录秘钥 #######################################################
async function getLogin() {
- let server_use = document.getElementById("server_use").value;
+ let server_use = document.getElementById("server_use").checked;
let apps_uuid = document.getElementById("client-id").value;
let apps_keys = document.getElementById("app-secret").value;
let apps_type = document.getElementById("site-select").value;
let secret_key = document.getElementById("secret-key").value;
- console.log(server_use);
- if (server_use === "off" && (apps_uuid === "" || apps_keys === "")) {
+ console.log( server_use);
+ if (!server_use && (apps_uuid === "" || apps_keys === "")) {
Swal.fire({
position: 'top',
icon: 'info',
diff --git a/src/115ui.ts b/src/115ui.ts
index 563d55f..944f809 100644
--- a/src/115ui.ts
+++ b/src/115ui.ts
@@ -14,12 +14,13 @@ export async function oneLogin(c: Context) {
const client_key: string = c.req.query('client_key');
const driver_txt: string = c.req.query('apps_types');
const server_use: string = c.req.query('server_use');
- if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
+ if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
return c.json({text: "参数缺少"}, 500);
const random_key = getRandomString(64);
+ console.log(server_use);
// 请求参数 ==========================================================================
const params_all: Record = {
- client_id: server_use == "on" ? c.env.cloud115_uid : client_uid,
+ client_id: server_use == "true" ? c.env.cloud115_uid : client_uid,
state: random_key,
response_type: 'code',
redirect_uri: 'https://' + c.env.MAIN_URLS + '/115cloud/callback'
@@ -31,7 +32,7 @@ export async function oneLogin(c: Context) {
// 执行请求 ===========================================================================
try {
const response = await fetch(urlWithParams.href, {method: 'GET',});
- if (server_use !== "on") {
+ if (server_use == "false") {
local.setCookie(c, 'client_uid', client_uid);
local.setCookie(c, 'client_key', client_key);
}
@@ -55,19 +56,18 @@ export async function oneToken(c: Context) {
server_use = local.getCookie(c, 'server_use')
random_key = local.getCookie(c, 'random_key')
driver_txt = local.getCookie(c, 'driver_txt')
- if (server_use !== "on") {
+ if (server_use == "false") {
client_uid = local.getCookie(c, 'client_uid')
client_key = local.getCookie(c, 'client_key')
+ if (!random_uid || !random_key || random_uid !== random_key
+ || !driver_txt || !login_data || !client_uid || !client_key)
+ return c.redirect(showErr("Cookie无效", "", ""));
}
-
- if (!random_uid || !random_key || random_uid !== random_key
- || !driver_txt || !login_data || !client_uid || !client_key)
- return c.redirect(showErr("Cookie无效", "", ""));
client_url = driver_map[1];
params_all = {
- client_id: server_use == "on" ? c.env.cloud115_uid : client_uid,
- client_secret: server_use == "on" ? c.env.cloud115_uid : client_key,
+ client_id: server_use == "true" ? c.env.cloud115_uid : client_uid,
+ client_secret: server_use == "true" ? c.env.cloud115_key : client_key,
redirect_uri: 'https://' + c.env.MAIN_URLS + '/115cloud/callback',
code: login_data,
grant_type: 'authorization_code'
@@ -86,7 +86,7 @@ export async function oneToken(c: Context) {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
- if (server_use !== "on") {
+ if (server_use == "false") {
local.deleteCookie(c, 'client_uid');
local.deleteCookie(c, 'client_key');
}
@@ -98,8 +98,8 @@ export async function oneToken(c: Context) {
return c.redirect(
`/?access_token=${json.data.access_token}`
+ `&refresh_token=${json.data.refresh_token}`
- + `&client_uid=${server_use == "on" ? "" : client_uid}`
- + `&client_key=${server_use == "on" ? "" : client_key}`
+ + `&client_uid=${server_use == "true" ? "" : client_uid}`
+ + `&client_key=${server_use == "true" ? "" : client_key}`
+ `&driver_txt=${driver_txt}`
);
}
diff --git a/src/123ui.ts b/src/123ui.ts
index b105614..9598a96 100644
--- a/src/123ui.ts
+++ b/src/123ui.ts
@@ -15,7 +15,7 @@ export async function oneLogin(c: Context) {
const driver_txt: string = c.req.query('apps_types');
const server_use: string = c.req.query('server_use');
console.log(server_use);
- if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
+ if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
return c.json({text: "参数缺少"}, 500);
// 请求参数 ==========================================================================
const params_all: Record = {
diff --git a/src/aliui.ts b/src/aliui.ts
index f0be125..60fc283 100644
--- a/src/aliui.ts
+++ b/src/aliui.ts
@@ -34,11 +34,11 @@ export async function alyLogin(c: Context) {
const client_key: string = c.req.query('client_key');
const driver_txt: string = c.req.query('apps_types');
const server_use: string = c.req.query('server_use');
- if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
+ if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
return c.json({text: "参数缺少"}, 500);
const req: AliQrcodeReq = {
- client_id: server_use == "on" ? c.env.alicloud_uid : client_uid,
- client_secret: server_use == "on" ? c.env.alicloud_key : client_key,
+ client_id: server_use == "true" ? c.env.alicloud_uid : client_uid,
+ client_secret: server_use == "true" ? c.env.alicloud_key : client_key,
scopes: ['user:base', 'file:all:read', 'file:all:write']
}
const response = await fetch(driver_map[0], {
@@ -68,8 +68,8 @@ export async function alyLogin(c: Context) {
export async function alyToken(c: Context) {
let server_use: string = local.getCookie(c, 'server_use')
const req: AliAccessTokenReq = {
- client_id: server_use == "on" ? c.env.alicloud_uid : c.req.query('client_id'),
- client_secret: server_use == "on" ? c.env.alicloud_key : c.req.query('client_secret'),
+ client_id: server_use == "true" ? c.env.alicloud_uid : c.req.query('client_id'),
+ client_secret: server_use == "true" ? c.env.alicloud_key : c.req.query('client_secret'),
grant_type: c.req.query('grant_type'),
code: c.req.query('code'),
refresh_token: c.req.query('refresh_token')
diff --git a/src/baidu.ts b/src/baidu.ts
index 8918649..b2e31a3 100644
--- a/src/baidu.ts
+++ b/src/baidu.ts
@@ -15,12 +15,12 @@ export async function oneLogin(c: Context) {
const secret_key: string = c.req.query('secret_key');
const driver_txt: string = c.req.query('apps_types');
const server_use: string = c.req.query('server_use');
- if (server_use == "off" && (!driver_txt || !client_uid || !client_key || !secret_key))
+ if (server_use == "false" && (!driver_txt || !client_uid || !client_key || !secret_key))
return c.json({text: "参数缺少"}, 500);
// 请求参数 ==========================================================================
const params_all: Record = {
- client_id: server_use == "on" ? c.env.baiduyun_key : client_key,
- device_id: server_use == "on" ? c.env.baiduyun_uid : client_uid,
+ 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'
@@ -34,7 +34,7 @@ export async function oneLogin(c: Context) {
const response = await fetch(urlWithParams.href, {
method: 'GET',
});
- if (server_use !== "on") {
+ 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);
@@ -57,17 +57,18 @@ export async function oneToken(c: Context) {
server_use = local.getCookie(c, 'server_use')
driver_txt = local.getCookie(c, 'driver_txt')
client_uid = client_key = secret_key = ""
- if (server_use !== "on") {
+ 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)
+ return c.redirect(showErr("Cookie缺少", "", ""));
}
- if (!login_data || !client_uid || !client_key || !secret_key)
- return c.redirect(showErr("Cookie缺少", "", ""));
+
client_url = driver_map[1];
params_all = {
- client_id: server_use == "on" ? c.env.baiduyun_key : client_key,
- client_secret: server_use == "on" ? c.env.baiduyun_ext : secret_key,
+ client_id: server_use == "true" ? c.env.baiduyun_key : client_key,
+ client_secret: server_use == "true" ? c.env.baiduyun_ext : secret_key,
code: login_data,
grant_type: 'authorization_code',
redirect_uri: 'https://' + c.env.MAIN_URLS + '/baiduyun/callback'
@@ -85,7 +86,7 @@ export async function oneToken(c: Context) {
urlWithParams.searchParams.append(key, params_all[key]);
});
const response: Response = await fetch(urlWithParams, {method: 'GET'});
- if (server_use !== "on") {
+ if (server_use == "false") {
local.deleteCookie(c, 'client_uid');
local.deleteCookie(c, 'client_key');
local.deleteCookie(c, 'secret_key');
@@ -93,14 +94,14 @@ export async function oneToken(c: Context) {
local.deleteCookie(c, 'driver_txt');
local.deleteCookie(c, 'server_use');
const json: Record = await response.json();
- // console.log(response, json);
+ console.log(response, json);
if (response.ok) {
return c.redirect(
`/?access_token=${json.access_token}`
+ `&refresh_token=${json.refresh_token}`
+ `&client_uid=${client_uid}`
- + `&client_key=${server_use == "on" ? "" : client_key}`
- + `&secret_key=${server_use == "on" ? "" : secret_key}`
+ + `&client_key=${server_use == "true" ? "" : client_key}`
+ + `&secret_key=${server_use == "true" ? "" : secret_key}`
+ `&driver_txt=${driver_txt}`
);
}
diff --git a/src/goapi.ts b/src/goapi.ts
index 665f08e..b0227a0 100644
--- a/src/goapi.ts
+++ b/src/goapi.ts
@@ -14,12 +14,12 @@ export async function oneLogin(c: Context) {
const client_key: string = c.req.query('client_key');
const driver_txt: string = c.req.query('apps_types');
const server_use: string = c.req.query('server_use');
- if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
+ if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
return c.json({text: "参数缺少"}, 500);
const random_key = getRandomString(32);
// 请求参数 ==========================================================================
const params_all: Record = {
- 'client_id': server_use == "on" ? c.env.onedrive_uid : client_uid,
+ 'client_id': server_use == "true" ? c.env.googleui_uid : client_uid,
'redirect_uri': 'https://' + c.env.MAIN_URLS + '/googleui/callback',
'scope': "https://www.googleapis.com/auth/drive",
'response_type': 'code',
@@ -27,7 +27,7 @@ export async function oneLogin(c: Context) {
'access_type': 'offline',
'prompt': 'consent'
};
- if (server_use !== "on") {
+ if (server_use == "false") {
local.setCookie(c, 'client_uid', client_uid);
local.setCookie(c, 'client_key', client_key);
}
@@ -56,18 +56,19 @@ export async function oneToken(c: Context) {
server_use = local.getCookie(c, 'server_use')
driver_txt = local.getCookie(c, 'driver_txt')
client_uid = client_key = ""
- if (server_use !== "on") {
+ if (server_use == "false") {
client_uid = local.getCookie(c, 'client_uid')
client_key = local.getCookie(c, 'client_key')
+ if (!client_uid || !client_key || random_uid !== random_key || !client_uid || !client_key)
+ return c.redirect(showErr("Cookie无效", "", ""));
}
random_key = local.getCookie(c, 'random_key')
driver_txt = local.getCookie(c, 'driver_txt')
// console.log(login_data, random_uid, client_uid, client_key, random_key, driver_txt)
- if (!client_uid || !client_key || random_uid !== random_key || !client_uid || !client_key)
- return c.redirect(showErr("Cookie无效", "", ""));
+
params_all = {
- 'client_id': server_use == "on" ? c.env.googleui_uid : client_uid,
- 'client_secret': server_use == "on" ? c.env.googleui_key : client_key,
+ 'client_id': server_use == "true" ? c.env.googleui_uid : client_uid,
+ 'client_secret': server_use == "true" ? c.env.googleui_key : client_key,
'code': login_data,
'grant_type': 'authorization_code',
'redirect_uri': 'https://' + c.env.MAIN_URLS + '/googleui/callback',
@@ -83,7 +84,7 @@ export async function oneToken(c: Context) {
method: 'POST', body: paramsString,
headers: {'Content-Type': 'application/x-www-form-urlencoded',},
});
- if (server_use !== "on") {
+ if (server_use == "false") {
local.deleteCookie(c, 'client_uid');
local.deleteCookie(c, 'client_key');
}
@@ -96,8 +97,8 @@ export async function oneToken(c: Context) {
return c.redirect(
`/?access_token=${json.access_token}`
+ `&refresh_token=${json.refresh_token}`
- + `&client_uid=${server_use == "on" ? "" : client_uid}`
- + `&client_key=${server_use == "on" ? "" : client_key}`
+ + `&client_uid=${server_use == "true" ? "" : client_uid}`
+ + `&client_key=${server_use == "true" ? "" : client_key}`
+ `&driver_txt=${driver_txt}`
);
}
diff --git a/src/oneui.ts b/src/oneui.ts
index 6884985..c835263 100644
--- a/src/oneui.ts
+++ b/src/oneui.ts
@@ -28,13 +28,13 @@ export async function oneLogin(c: Context) {
const client_key: string = c.req.query('client_key');
const driver_txt: string = c.req.query('apps_types');
const server_use: string = c.req.query('server_use');
- if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
+ if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
return c.json({text: "参数缺少"}, 500);
const scopes_all = 'offline_access Files.ReadWrite.All';
const client_url: string = driver_map[driver_txt][0];
// 请求参数 ==========================================================================
const params_all: Record = {
- client_id: server_use == "on" ? c.env.onedrive_uid : client_uid,
+ client_id: server_use == "true" ? c.env.onedrive_uid : client_uid,
scope: scopes_all,
response_type: 'code',
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback'
@@ -48,7 +48,7 @@ export async function oneLogin(c: Context) {
const response = await fetch(urlWithParams.href, {
method: 'GET',
});
- if (server_use !== "on") {
+ if (server_use == "false") {
local.setCookie(c, 'client_uid', client_uid);
local.setCookie(c, 'client_key', client_key);
}
@@ -68,14 +68,14 @@ export async function oneToken(c: Context) {
server_use = local.getCookie(c, 'server_use')
driver_txt = local.getCookie(c, 'driver_txt')
client_uid = client_key = ""
- if (server_use !== "on") {
+ if (server_use == "false") {
client_uid = local.getCookie(c, 'client_uid')
client_key = local.getCookie(c, 'client_key')
}
client_url = driver_map[driver_txt][1];
params_all = {
- client_id: server_use == "on" ? c.env.onedrive_uid : client_uid,
- client_secret: server_use == "on" ? c.env.onedrive_key : client_key,
+ client_id: server_use == "true" ? c.env.onedrive_uid : client_uid,
+ client_secret: server_use == "true" ? c.env.onedrive_key : client_key,
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback',
code: login_data,
grant_type: 'authorization_code'
@@ -96,7 +96,7 @@ export async function oneToken(c: Context) {
body: paramsString,
});
// console.log(response);
- if (server_use !== "on") {
+ if (server_use == "false") {
local.deleteCookie(c, 'client_uid');
local.deleteCookie(c, 'client_key');
}
@@ -110,8 +110,8 @@ export async function oneToken(c: Context) {
return c.redirect(
`/?access_token=${json.access_token}`
+ `&refresh_token=${json.refresh_token}`
- + `&client_uid=${server_use == "on" ? "" : client_uid}`
- + `&client_key=${server_use == "on" ? "" : client_key}`
+ + `&client_uid=${server_use == "true" ? "" : client_uid}`
+ + `&client_key=${server_use == "true" ? "" : client_key}`
+ `&driver_txt=${driver_txt}`
);
}
diff --git a/wrangler.jsonc.example b/wrangler.jsonc.example
index 505bc7a..f203df8 100644
--- a/wrangler.jsonc.example
+++ b/wrangler.jsonc.example
@@ -16,8 +16,6 @@
"baiduyun_key": "",
"115cloud_uid": "",
"115cloud_key": "",
- "123cloud_uid": "",
- "123cloud_key": "",
"googleui_uid": "",
"googleui_key": ""
},