Skip to content

Commit

Permalink
进一步详细说明
Browse files Browse the repository at this point in the history
  • Loading branch information
Mapaler committed Jul 7, 2024
1 parent c91e8f3 commit 4a23839
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@ https://mapaler.github.io/GetOneDriveDirectLink/

# 如何自行搭建

## 文件选取器 v8 教程

我不想注册收费的 Azure,所以只提到在原有 v7.2 上的变化。注册 Azure 的流程区别请自己想办法了。

1. 身份验证不能用 Web ,得改成单页应用程序,不然会报错:[The provided request must include a 'client_secret' input parameter in the sample project](https://github.com/Azure-Samples/ms-identity-javascript-react-spa-dotnetcore-webapi-obo/issues/30)
![身份验证](document/authentication-v8.png)
2. 应用 ID,替换本程序 `scripts/auth.js` 内的 `msalParams.auth.clientId`

## JavaScript SDK v7.2 教程

2024年7月8日 目前时间点登录会显示以下警告,也就是需要迁移到收费的 Azure,我不想搞,所以以下自行搭建教程已不适用于目前的内容,就这样将就着用吧。

> 自 2020 年 6 月 30 日起,我们将不再向 Azure Active Directory 身份验证库(ADAL)和 Azure Active Directory Graph 添加任何新功能。我们将继续提供技术支持和安全更新程序,但将不再提供功能更新。应用程序将需要升级到 Microsoft 身份验证库(MSAL)和 Microsoft Graph。[了解更多信息](https://go.microsoft.com/fwlink/?linkid=2132805)
> 这些应用程序与帐户 [email protected] 关联,但不包含在任何目录中。在目录外部创建应用程序的功能已被弃用。你可通过加入 [M365 开发人员计划](https://aka.ms/joinM365DeveloperProgram)[注册 Azure](https://aka.ms/signUpForAzure) 来获取新目录。[了解详细信息](https://aka.ms/MsaDeprecateInfo)
原 JavaScript SDK v7.2 教程
### 原内容

>按照[OneDrive file picker SDK](https://docs.microsoft.com/onedrive/developer/controls/file-pickers/js-v72/)内的说明进行,由于旧有的*Microsoft 应用注册门户*已经迁移到*Azure门户*,特此做出更新,此版本更新于2020年2月6日。
Expand Down
Binary file added document/authentication-v8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
<link rel="icon" href="icon.png" type="image/x-png" />
<link rel="shortcut icon" href="icon.png" type="image/x-png" />
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="https://alcdn.msauth.net/browser/2.35.0/js/msal-browser.min.js"></script> <!-- 官方示例代码是 MSAL 2.x 的,切换到 MSAL 3.x 无法使用 -->
<script type="text/javascript" src="https://alcdn.msauth.net/browser/2.35.0/js/msal-browser.min.js"></script>
<!--
官方示例代码是 MSAL 2.x 的,切换到 MSAL 3.x 无法使用
想迁移 v3 的自己看 https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/v2-migration.md
找 v2 最新的自己看 https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/cdn-usage.md
-->
<script type="text/javascript" src="scripts/auth.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
Expand All @@ -22,8 +27,9 @@ <h3>隐私声明</h3>
<h3>使用方法</h3>
<ol class="howtouse">
<li>点击<span class="openbtn" title="不是点我,真的按钮在下面呢" onclick="document.getElementById('launchPicker').click();">从OneDrive选择文件</span>按钮,等待打开新窗口。</li>
<li>在新窗口中登陆OneDrive对应的账户并授予需要的权限。</li>
<li>进入OneDrive“公开”文件夹内选择需要获取直链的文件(同一文件夹内可多选),点击打开。</li>
<li>第一次可能被浏览器广告拦截阻断,需要手动允许浏览器打开新窗口。</li>
<li>在新窗口中登陆 OneDrive 对应的账户并授予需要的权限。</li>
<li>进入 OneDrive “公开”文件夹内选择需要获取直链的文件(同一文件夹内可多选),点击打开。<a href="#no-public">没有“公开”怎么办</a></li>
<li>选择需要输出的掩码格式,输出面板内会自动生成对应的格式。</li>
</ol>
<div class="splitContainer">
Expand Down Expand Up @@ -51,7 +57,7 @@ <h3>输出面板</h3>
<h3>F&amp;Q</h3>
<dl>
<dt>如何书写掩码?</dt>
<dd>使用 ES6 原生<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/template_strings">模板字符串</a> ${表达式} 书写方式。
<dd>使用 ES6 原生<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Template_literals">模板字符串</a> ${表达式} 书写方式。
“file”表示该文件信息,“index”表示在获取列表中的序号,具体的JSON对象会在获取数据后发送到控制台(或查看全局变量 redata ),需要更多信息的的自己去看吧。</dd>
<dt>为什么这个应用必须要在https下运行?</dt>
<dd>微软的规定,非https只返回错误,我也不想。</dd>
Expand All @@ -62,7 +68,7 @@ <h3>F&amp;Q</h3>
<dd>列表模式下:点左上角那个选中全部的复选框就行了。</dd>
<dt>如何收回我授予的权限?</dt>
<dd>访问微软账户<a href="https://account.live.com/consent/Manage" target="_blank">你已授予访问权限的应用和服务</a>删除即可。</dd>
<dt>没有“公开”文件夹怎么办?</dt>
<dt id="no-public">没有“公开”文件夹怎么办?</dt>
<dd>好像现在的新账号已经没有公开文件夹了。就需要麻烦点,添加访问通行证。<br>
选中需要共享的文件夹,点击嵌入<br>
<img src="images/Image 29.png" alt="点击嵌入"/><br>
Expand Down
2 changes: 1 addition & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function showMask(str,file,index) {
return newTxt;
}

let redata;//储存返回的数据
let redata = null;//储存返回的数据

window.onload = function() //网页加载初始化
{
Expand Down
7 changes: 5 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
@charset "utf-8";
/* CSS Document */
h1
{
h1 {
text-align: center;
}
dt {
font-weight: bold;
background-color: rgba(0,0,0,0.2);
}
.splitContainer {
display: grid;
grid-template-columns: 1fr 2fr;
Expand Down

0 comments on commit 4a23839

Please sign in to comment.