mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2026-10-07 21:34:49 -04:00
feat: add confirmBrowserExtensionAsync function and integrate it into DataSetting and SyncSetting components
This commit is contained in:
1 parent
6413b022b3
commit
5e1cb49cdc
3 files changed
+31
-14
No files matched your search
@@ -3,6 +3,7 @@ import { SettingInfoProps, SettingInfoState } from "./interface";
|
||||
import { Trans } from "react-i18next";
|
||||
import {
|
||||
clearAllData,
|
||||
confirmBrowserExtensionAsync,
|
||||
generateSyncRecord,
|
||||
getStorageLocation,
|
||||
getWebsiteUrl,
|
||||
@@ -98,6 +99,12 @@ class DataSetting extends React.Component<SettingInfoProps, SettingInfoState> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isElectron) {
|
||||
if (!(await confirmBrowserExtensionAsync())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const savedConfig =
|
||||
ConfigService.getObjectConfig(
|
||||
"koReaderSyncConfig",
|
||||
@@ -207,6 +214,12 @@ class DataSetting extends React.Component<SettingInfoProps, SettingInfoState> {
|
||||
const currentlyEnabled = this.state[item.propName];
|
||||
|
||||
if (!currentlyEnabled && item.requiresAuth) {
|
||||
if (!isElectron) {
|
||||
if (!(await confirmBrowserExtensionAsync())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Special case: Markdown sync uses a folder picker in Electron
|
||||
if (item.propName === "isEnableMarkdownSync" && isElectron) {
|
||||
const { ipcRenderer } = window.require("electron");
|
||||
|
||||
@@ -9,6 +9,7 @@ import { syncSettingList } from "../../../constants/settingList";
|
||||
|
||||
import toast from "react-hot-toast";
|
||||
import {
|
||||
confirmBrowserExtensionAsync,
|
||||
generateSyncRecord,
|
||||
getICloudDrivePath,
|
||||
getServerRegion,
|
||||
@@ -99,20 +100,7 @@ class SyncSetting extends React.Component<SettingInfoProps, SettingInfoState> {
|
||||
!isElectron &&
|
||||
driveList.find((item) => item.value === targetDrive)?.needExtension
|
||||
) {
|
||||
let result = await vexComfirmAsync(
|
||||
"Due to browser security restrictions, you may not be able to use this data source properly. If you encounter any issues, you can resolve them by installing our browser extension.",
|
||||
"Confirm",
|
||||
"Install extension"
|
||||
);
|
||||
if (!result) {
|
||||
if (
|
||||
ConfigService.getReaderConfig("lang") &&
|
||||
ConfigService.getReaderConfig("lang").startsWith("zh")
|
||||
) {
|
||||
openExternalUrl(getWebsiteUrl() + "/zh/use-extension");
|
||||
} else {
|
||||
openExternalUrl(getWebsiteUrl() + "/en/use-extension");
|
||||
}
|
||||
if (!(await confirmBrowserExtensionAsync())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,22 @@ export const vexComfirmAsync = (
|
||||
});
|
||||
});
|
||||
};
|
||||
export const confirmBrowserExtensionAsync = async (): Promise<boolean> => {
|
||||
const result = await vexComfirmAsync(
|
||||
"Due to browser security restrictions, you may not be able to use this data source properly. If you encounter any issues, you can resolve them by installing our browser extension.",
|
||||
"Confirm",
|
||||
"Install extension"
|
||||
);
|
||||
if (!result) {
|
||||
const lang = ConfigService.getReaderConfig("lang");
|
||||
openExternalUrl(
|
||||
getWebsiteUrl() +
|
||||
(lang?.startsWith("zh") ? "/zh/use-extension" : "/en/use-extension")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
export const vexOpenAsync = (
|
||||
config: Record<string, any>,
|
||||
message: string,
|
||||
|
||||
Reference in new issue
Block a user