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
25 changes: 15 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,21 @@ function getSiteID() {
BAD_REQUEST: "获取出现问题,请检查权限和站点URL,站点URL示例:https://demo.sharepoint.com/site/demo",
DEFAULT: "请求发生错误"
};

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

// 使用服务器提供的uid和key获取站点ID
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 +114,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 +173,4 @@ function getSiteID() {
idElement.value = ERROR_MESSAGES.BAD_REQUEST;
console.error("URL解析失败:", error);
}
}
}