more hints for webdav

This commit is contained in:
fyears 2022-03-23 22:54:44 +08:00
parent 4edd8caaea
commit 99926adbbd
3 changed files with 30 additions and 18 deletions

@ -1 +1 @@
Subproject commit 28730585f8cef9625b2b5a2296318c1c071ff7ba Subproject commit 475d524994493a53bfffabbad6bfa25259197a2d

View File

@ -1,5 +1,11 @@
import { Buffer } from "buffer"; import { Buffer } from "buffer";
import { Vault, request, requestUrl, requireApiVersion } from "obsidian"; import {
Vault,
request,
requestUrl,
requireApiVersion,
Platform,
} from "obsidian";
import { Queue } from "@fyears/tsqueue"; import { Queue } from "@fyears/tsqueue";
import chunk from "lodash/chunk"; import chunk from "lodash/chunk";
@ -20,7 +26,7 @@ import type {
ResponseDataDetailed, ResponseDataDetailed,
} from "webdav/web"; } from "webdav/web";
import { getPatcher } from "webdav/web"; import { getPatcher } from "webdav/web";
if (requireApiVersion(API_VER_REQURL)) { if (requireApiVersion(API_VER_REQURL) && !Platform.isAndroidApp) {
getPatcher().patch( getPatcher().patch(
"request", "request",
async ( async (
@ -110,6 +116,7 @@ if (requireApiVersion(API_VER_REQURL)) {
// return r; // return r;
// }); // });
import { AuthType, BufferLike, createClient } from "webdav/web"; import { AuthType, BufferLike, createClient } from "webdav/web";
import { Plane } from "lucide";
export type { WebDAVClient } from "webdav/web"; export type { WebDAVClient } from "webdav/web";
export const DEFAULT_WEBDAV_CONFIG = { export const DEFAULT_WEBDAV_CONFIG = {

View File

@ -1105,6 +1105,9 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
this.plugin.settings.serviceType !== "webdav" this.plugin.settings.serviceType !== "webdav"
); );
const webdavReq =
requireApiVersion(API_VER_REQURL) && !Platform.isAndroidApp;
webdavDiv.createEl("h2", { text: t("settings_webdav") }); webdavDiv.createEl("h2", { text: t("settings_webdav") });
webdavDiv.createEl("p", { webdavDiv.createEl("p", {
@ -1112,7 +1115,17 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
cls: "webdav-disclaimer", cls: "webdav-disclaimer",
}); });
if (!requireApiVersion(API_VER_REQURL)) { if (!webdavReq) {
if (Platform.isAndroidApp) {
webdavDiv.createEl("p", {
text: t("settings_webdav_cors_android"),
});
} else {
webdavDiv.createEl("p", {
text: t("settings_webdav_cors_otheros"),
});
}
webdavDiv.createEl("p", { webdavDiv.createEl("p", {
text: t("settings_webdav_cors"), text: t("settings_webdav_cors"),
}); });
@ -1168,15 +1181,12 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
.setDesc(t("settings_webdav_auth_desc")) .setDesc(t("settings_webdav_auth_desc"))
.addDropdown(async (dropdown) => { .addDropdown(async (dropdown) => {
dropdown.addOption("basic", "basic"); dropdown.addOption("basic", "basic");
if (requireApiVersion(API_VER_REQURL)) { if (webdavReq) {
dropdown.addOption("digest", "digest"); dropdown.addOption("digest", "digest");
} }
// new version config, copied to old version, we need to reset it // new version config, copied to old version, we need to reset it
if ( if (!webdavReq && this.plugin.settings.webdav.authType !== "basic") {
!requireApiVersion(API_VER_REQURL) &&
this.plugin.settings.webdav.authType !== "basic"
) {
this.plugin.settings.webdav.authType = "basic"; this.plugin.settings.webdav.authType = "basic";
await this.plugin.saveSettings(); await this.plugin.saveSettings();
} }
@ -1249,16 +1259,11 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
if (res) { if (res) {
new Notice(t("settings_webdav_connect_succ")); new Notice(t("settings_webdav_connect_succ"));
} else { } else {
let corsErrMsg = "/CORS"; if (webdavReq) {
if (requireApiVersion(API_VER_REQURL)) { new Notice(t("settings_webdav_connect_fail"));
corsErrMsg = ""; } else {
new Notice(t("settings_webdav_connect_fail_withcors"));
} }
new Notice(
t("settings_webdav_connect_fail", {
corsErrMsg: corsErrMsg,
})
);
new Notice(errors.msg); new Notice(errors.msg);
} }
}); });