deal merge issue
This commit is contained in:
parent
8f4ffc649c
commit
f5da610bc3
53
.idea/workspace.xml
generated
53
.idea/workspace.xml
generated
@ -4,16 +4,10 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="987ac7e2-ceaa-49a2-b5c9-aed65a7c598d" name="更改" comment="fin onedrive official token">
|
<list default="true" id="987ac7e2-ceaa-49a2-b5c9-aed65a7c598d" name="更改" comment="deal merge issue">
|
||||||
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/cf-worker-api.iml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/public/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/public/index.html" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/public/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/public/index.html" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/public/static/style-all.css" beforeDir="false" afterPath="$PROJECT_DIR$/public/static/style-all.css" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/wrangler.jsonc.example" beforeDir="false" afterPath="$PROJECT_DIR$/wrangler.jsonc" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -23,6 +17,9 @@
|
|||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="ProblemsViewState">
|
||||||
|
<option name="selectedTabId" value="CurrentFile" />
|
||||||
|
</component>
|
||||||
<component name="ProjectColorInfo">{
|
<component name="ProjectColorInfo">{
|
||||||
"associatedIndex": 4
|
"associatedIndex": 4
|
||||||
}</component>
|
}</component>
|
||||||
@ -69,8 +66,41 @@
|
|||||||
<updated>1749696640494</updated>
|
<updated>1749696640494</updated>
|
||||||
<workItem from="1749696641557" duration="119000" />
|
<workItem from="1749696641557" duration="119000" />
|
||||||
<workItem from="1749696773818" duration="18000" />
|
<workItem from="1749696773818" duration="18000" />
|
||||||
<workItem from="1749696801474" duration="7490000" />
|
<workItem from="1749696801474" duration="15061000" />
|
||||||
</task>
|
</task>
|
||||||
|
<task id="LOCAL-00001" summary="fin onedrive official token">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1749704488857</created>
|
||||||
|
<option name="number" value="00001" />
|
||||||
|
<option name="presentableId" value="LOCAL-00001" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1749704488857</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00002" summary="add readme">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1749705341327</created>
|
||||||
|
<option name="number" value="00002" />
|
||||||
|
<option name="presentableId" value="LOCAL-00002" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1749705341327</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00003" summary="add onedrive area: cn us de">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1749712084921</created>
|
||||||
|
<option name="number" value="00003" />
|
||||||
|
<option name="presentableId" value="LOCAL-00003" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1749712084921</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00004" summary="deal merge issue">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1749712420228</created>
|
||||||
|
<option name="number" value="00004" />
|
||||||
|
<option name="presentableId" value="LOCAL-00004" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1749712420228</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="5" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@ -78,6 +108,9 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="fin onedrive official token" />
|
<MESSAGE value="fin onedrive official token" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="fin onedrive official token" />
|
<MESSAGE value="add readme" />
|
||||||
|
<MESSAGE value="add onedrive area: cn us de" />
|
||||||
|
<MESSAGE value="deal merge issue" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="deal merge issue" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -105,8 +105,9 @@
|
|||||||
<div class="text-muted text-center">
|
<div class="text-muted text-center">
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
本工具所有信息只以Cookie形式存储于浏览器本地<br>
|
本工具所有信息只以Cookie形式存储于浏览器本地<br>
|
||||||
开源于 <a href=" " target="_blank">GitHub</a> | by <a href="https://github.com/OpenListTeam"
|
开源于 <a href="https://github.com/OpenListTeam/cf-worker-api" target="_blank">GitHub</a> | by <a
|
||||||
target="_blank">OpenListTeam</a>
|
href="https://github.com/OpenListTeam"
|
||||||
|
target="_blank">OpenListTeam</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -139,7 +140,6 @@
|
|||||||
// 解析响应内容 ===============================================
|
// 解析响应内容 ===============================================
|
||||||
const response_data = await response.json();
|
const response_data = await response.json();
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// window.open(response_data.text)
|
|
||||||
window.location.href = response_data.text;
|
window.location.href = response_data.text;
|
||||||
} else Swal.fire({
|
} else Swal.fire({
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
@ -189,6 +189,17 @@
|
|||||||
const client_key = urlParams.get("client_key");
|
const client_key = urlParams.get("client_key");
|
||||||
const access_token = urlParams.get("access_token");
|
const access_token = urlParams.get("access_token");
|
||||||
const refresh_token = urlParams.get("refresh_token");
|
const refresh_token = urlParams.get("refresh_token");
|
||||||
|
const message_err = urlParams.get("message_err");
|
||||||
|
console.log(message_err);
|
||||||
|
if (message_err && client_uid) {
|
||||||
|
Swal.fire({
|
||||||
|
position: 'top',
|
||||||
|
icon: 'error',
|
||||||
|
title: '授权失败',
|
||||||
|
html: message_err,
|
||||||
|
showConfirmButton: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
document.getElementById("client-id").value = client_uid;
|
document.getElementById("client-id").value = client_uid;
|
||||||
document.getElementById("app-secret").value = client_key;
|
document.getElementById("app-secret").value = client_key;
|
||||||
document.getElementById("access-token").value = access_token;
|
document.getElementById("access-token").value = access_token;
|
||||||
|
65
src/index.ts
65
src/index.ts
@ -60,20 +60,33 @@ app.get('/onedrive/requests', async (c) => {
|
|||||||
})
|
})
|
||||||
// 令牌申请 ##############################################################################
|
// 令牌申请 ##############################################################################
|
||||||
app.get('/onedrive/callback', async (c) => {
|
app.get('/onedrive/callback', async (c) => {
|
||||||
const login_data = <string>c.req.query('code');
|
let login_data, client_uid, client_key, driver_txt, client_url, params_all;
|
||||||
const client_uid: string = <string>local.getCookie(c, 'client_uid')
|
try { // 请求参数 ====================================================================
|
||||||
const client_key: string = <string>local.getCookie(c, 'client_key')
|
login_data = <string>c.req.query('code');
|
||||||
const driver_txt: string = <string>local.getCookie(c, 'apps_types')
|
client_uid = <string>local.getCookie(c, 'client_uid')
|
||||||
const client_url: string = driver_map[driver_txt][1];
|
client_key = <string>local.getCookie(c, 'client_key')
|
||||||
console.log(login_data);
|
driver_txt = <string>local.getCookie(c, 'apps_types')
|
||||||
// 请求参数 ==========================================================================
|
client_url = driver_map[driver_txt][1];
|
||||||
const params_all = {
|
params_all = {
|
||||||
client_id: client_uid,
|
client_id: client_uid,
|
||||||
client_secret: client_key,
|
client_secret: client_key,
|
||||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback',
|
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback',
|
||||||
code: login_data,
|
code: login_data,
|
||||||
grant_type: 'authorization_code'
|
grant_type: 'authorization_code'
|
||||||
};
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return c.redirect(
|
||||||
|
`/?message_err=${"授权失败,请检查: <br>" +
|
||||||
|
"1、应用ID和应用机密是否正确<br>" +
|
||||||
|
"2、登录账号是否具有应用权限<br>" +
|
||||||
|
"3、回调地址是否包括上面地址<br>" +
|
||||||
|
"4、登录可能过期,请重新登录<br>" +
|
||||||
|
"错误信息: <br> " + error}`
|
||||||
|
+ `&client_uid=NULL`
|
||||||
|
+ `&client_key=`);
|
||||||
|
}
|
||||||
|
// console.log(login_data);
|
||||||
|
|
||||||
// 执行请求 ===========================================================================
|
// 执行请求 ===========================================================================
|
||||||
try {
|
try {
|
||||||
const paramsString = new URLSearchParams(params_all).toString();
|
const paramsString = new URLSearchParams(params_all).toString();
|
||||||
@ -84,9 +97,19 @@ app.get('/onedrive/callback', async (c) => {
|
|||||||
},
|
},
|
||||||
body: paramsString,
|
body: paramsString,
|
||||||
});
|
});
|
||||||
console.log(response);
|
// console.log(response);
|
||||||
|
local.deleteCookie(c, 'client_uid');
|
||||||
|
local.deleteCookie(c, 'client_key');
|
||||||
|
local.deleteCookie(c, 'apps_types');
|
||||||
if (!response.ok)
|
if (!response.ok)
|
||||||
return c.json({text: response.text()}, 403);
|
return c.redirect(
|
||||||
|
`/?message_err=${"授权失败,请检查: <br>" +
|
||||||
|
"1、应用ID和应用机密是否正确<br>" +
|
||||||
|
"2、登录账号是否具有应用权限<br>" +
|
||||||
|
"3、回调地址是否包括上面地址<br>" +
|
||||||
|
"错误信息: <br>" + response.text()}`
|
||||||
|
+ `&client_uid=${client_uid}`
|
||||||
|
+ `&client_key=${client_key}`);
|
||||||
const json: Record<string, any> = await response.json();
|
const json: Record<string, any> = await response.json();
|
||||||
if (json.token_type === 'Bearer') {
|
if (json.token_type === 'Bearer') {
|
||||||
return c.redirect(
|
return c.redirect(
|
||||||
@ -96,8 +119,14 @@ app.get('/onedrive/callback', async (c) => {
|
|||||||
+ `&client_key=${client_key}`);
|
+ `&client_key=${client_key}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
return c.redirect(
|
||||||
return c.json({text: error}, 500);
|
`/?message_err=${"授权失败,请检查: <br>" +
|
||||||
|
"1、应用ID和应用机密是否正确<br>" +
|
||||||
|
"2、登录账号是否具有应用权限<br>" +
|
||||||
|
"3、回调地址是否包括上面地址<br>" +
|
||||||
|
"错误信息: <br>" + error}`
|
||||||
|
+ `&client_uid=${client_uid}`
|
||||||
|
+ `&client_key=${client_key}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user