Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h2 class="text-center mb-4">🔐 OpenList Token 获取工具</h2>
<label for="sharepoint-url"></label><input type="text" id="sharepoint-url" class="form-control">
</div>
<div class="d-grid gap-2 mb-3" id="sharepoint-btn-view">
<button class="btn btn-primary" onclick="getSiteID()">获取 SharePoint 站点ID</button>
<button class="btn btn-primary" onclick="getSiteID(server_use_input.checked)">获取 SharePoint 站点ID</button>
</div>
<div class="mb-3" id="sharepoint-uid-view">
<label for="sharepoint-id" class="form-label">SharePoint Site ID</label>
Expand Down
28 changes: 18 additions & 10 deletions public/static/spoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function getWebdav() {


// 获取站点ID
function getSiteID() {
function getSiteID(server_use_input = false) {
const siteUrl = document.getElementById("sharepoint-url").value.trim();
const access_token = document.getElementById("access-token").value.trim();
const refresh_token = document.getElementById("refresh-token").value.trim();
Expand All @@ -91,12 +91,24 @@ function getSiteID() {
BAD_REQUEST: "获取出现问题,请检查权限和站点URL,站点URL示例:https://demo.sharepoint.com/site/demo",
DEFAULT: "请求发生错误"
};

// 验证
if (!client_uid || !client_key) {
idElement.value = ERROR_MESSAGES.MISSING_CREDENTIALS;

// OneDrive 参数校验:
// 默认要求填写客户端 ID(client_uid)和应用机密(client_key);
// 当 server_use_input 为 true(例如勾选“使用 OpenList 提供的参数”)时,
// 跳过本地必填校验,由服务器 / OpenList 提供这些参数
if (site_type.includes("onedrive")){
if (!client_uid || !client_key){
if (!server_use_input) {
idElement.value = ERROR_MESSAGES.MISSING_CREDENTIALS;
return;
}
}
}else{
idElement.value = ERROR_MESSAGES.NOT_SUPPORTED;
return;
}

// 验证
if (!access_token || !refresh_token) {
idElement.value = ERROR_MESSAGES.MISSING_TOKENS;
return;
Expand All @@ -105,10 +117,6 @@ function getSiteID() {
idElement.value = ERROR_MESSAGES.MISSING_URL;
return;
}
if (!site_type.includes("onedrive")) {
idElement.value = ERROR_MESSAGES.NOT_SUPPORTED;
return;
}
if (!GATEWAYS[site_type]) {
idElement.value = ERROR_MESSAGES.DEFAULT;
return;
Expand Down Expand Up @@ -168,4 +176,4 @@ function getSiteID() {
idElement.value = ERROR_MESSAGES.BAD_REQUEST;
console.error("URL解析失败:", error);
}
}
}