Skip to content

Commit 5f5d920

Browse files
committed
mod(driver): googleui_oa.ts
1 parent 4508021 commit 5f5d920

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"deploy-cf": "wrangler deploy --minify --config wrangler.encrypt.jsonc",
99
"dev-eo": "edgeone pages dev",
1010
"build-eo": "edgeone pages build",
11-
"deploy-eo": "rm -rf ./node_modules && edgeone pages deploy ./ -n edgeone-hono-app -t ",
11+
"deploy-eo": "edgeone pages deploy ./ -n edgeone-hono-app -t ",
1212
"cf-typegen": "wrangler types --env-interface CloudflareBindings"
1313
},
1414
"dependencies": {

src/driver/googleui_oa.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Context} from "hono";
33
import {showErr} from "../shares/message";
44
import * as configs from "../shares/configs";
55
import * as refresh from "../shares/refresh";
6-
import {encodeCallbackData,Secrets} from "../shares/secrets";
6+
import {encodeCallbackData, Secrets} from "../shares/secrets";
77

88
const driver_map: string[] = [
99
"https://accounts.google.com/o/oauth2/v2/auth",
@@ -51,8 +51,9 @@ export async function oneLogin(c: Context) {
5151
// 令牌申请 ##############################################################################
5252
export async function oneToken(c: Context) {
5353
let login_data, client_uid, client_key, random_key, server_use;
54-
let driver_txt, params_all, random_uid;
54+
let driver_txt, params_all, random_uid, server_url: string = driver_map[1];
5555
try { // 请求参数 ====================================================================
56+
if (c.env.PROXY_API.length > 0) server_url = "https://" + c.env.PROXY_API + "/token";
5657
login_data = <string>c.req.query('code');
5758
random_uid = <string>c.req.query('state');
5859
server_use = local.getCookie(c, 'server_use')
@@ -87,7 +88,7 @@ export async function oneToken(c: Context) {
8788
// 执行请求 ===========================================================================
8889
try {
8990
const paramsString = new URLSearchParams(params_all).toString();
90-
const response: Response = await fetch(driver_map[1], {
91+
const response: Response = await fetch(server_url, {
9192
method: 'POST', body: paramsString,
9293
headers: {'Content-Type': 'application/x-www-form-urlencoded',},
9394
});
@@ -139,5 +140,5 @@ export async function genToken(c: Context) {
139140
grant_type: 'refresh_token',
140141
refresh_token: refresh_text
141142
};
142-
return await refresh.pubRenew(c, driver_map[1], params, "POST","access_token","copy","none");
143+
return await refresh.pubRenew(c, driver_map[1], params, "POST", "access_token", "copy", "none");
143144
}

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import * as drops from './driver/dropboxs_oa';
1111
import * as quark from './driver/quarkpan_oa';
1212

1313
export type Bindings = {
14-
MAIN_URLS: string, baiduyun_ext: string,
14+
// 基本配置 ================================
15+
MAIN_URLS: string, PROXY_API: string | null,
16+
// 密钥参数 ================================
17+
baiduyun_ext: string,
1518
onedrive_uid: string, onedrive_key: string,
1619
alicloud_uid: string, alicloud_key: string,
1720
baiduyun_uid: string, baiduyun_key: string,

wrangler.example.jsonc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"$schema": "node_modules/wrangler/config-schema.json",
3-
"name": "cf-worker-api",
3+
"name": "openlist-apis-page",
44
"main": "src/cfapp.ts",
55
"compatibility_date": "2025-05-25",
66
"compatibility_flags": [
77
"nodejs_compat"
88
],
99
"vars": {
1010
"MAIN_URLS": "api.example.com",
11+
"PROXY_API": "",
1112
"onedrive_uid": "*****************************",
1213
"onedrive_key": "*****************************",
1314
"alicloud_uid": "*****************************",

wrangler.jsonc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"$schema": "node_modules/wrangler/config-schema.json",
3-
"name": "cf-worker-api",
3+
"name": "openlist-apis-page",
44
"main": "src/cfapp.ts",
55
"compatibility_date": "2025-05-25",
66
"compatibility_flags": [
77
"nodejs_compat"
88
],
99
"vars": {
1010
"MAIN_URLS": "api.example.com",
11+
"PROXY_API": "",
1112
"onedrive_uid": "*****************************",
1213
"onedrive_key": "*****************************",
1314
"alicloud_uid": "*****************************",
@@ -24,7 +25,7 @@
2425
"dropboxs_uid": "*****************************",
2526
"dropboxs_key": "*****************************",
2627
"quarkpan_uid": "*****************************",
27-
"quarkpan_key": "*****************************"
28+
"quarkpan_key": "*****************************",
2829
},
2930
"site": {
3031
"bucket": "./public"

0 commit comments

Comments
 (0)