chore: remove download releated code

Signed-off-by: zu1k <i@zu1k.com>
master
zu1k 2022-12-06 10:16:48 +08:00
parent 451627917f
commit bfc9216931
No known key found for this signature in database
GPG Key ID: AE381A8FB1EF2CC8
3 changed files with 0 additions and 64 deletions

View File

@ -17,10 +17,6 @@ use tokio::sync::Mutex;
struct AppConfig {
/// Index files of z-library
pub index_dir: PathBuf,
/// IPFS daemon RPC address
pub ipfs_api_url: String,
/// Where to store downloaded files
pub download_path: PathBuf,
}
fn get_dir(name: &str) -> Option<PathBuf> {
@ -33,11 +29,8 @@ fn get_dir(name: &str) -> Option<PathBuf> {
impl Default for AppConfig {
fn default() -> Self {
let index_dir = get_dir("index").unwrap_or_else(|| PathBuf::from("index"));
let download_path = get_dir("download").unwrap_or_else(|| PathBuf::from("download"));
Self {
index_dir,
ipfs_api_url: "http://localhost:5001".to_string(),
download_path,
}
}
}

View File

@ -31,8 +31,6 @@ import { useTranslation } from 'react-i18next';
interface Config {
index_dir: string;
ipfs_api_url: string;
download_path: string;
}
interface SettingsItemProps extends InputProps {
@ -87,8 +85,6 @@ const Settings: React.FC = () => {
invoke('get_config').then((conf) => {
const config = conf as Config;
setValue('index_dir', config.index_dir, { shouldValidate: true });
setValue('ipfs_api_url', config.ipfs_api_url, { shouldValidate: true });
setValue('download_path', config.download_path, { shouldValidate: true });
});
}, [isOpen]);
@ -145,45 +141,6 @@ const Settings: React.FC = () => {
</InputRightElement>
}
/>
<SettingsItem
label={t('settings.ipfs_api_url')}
help={t('settings.ipfs_api_url_help') ?? undefined}
{...register('ipfs_api_url', {
required: t('settings.ipfs_api_url_required') ?? true
})}
aria-invalid={errors.ipfs_api_url ? 'true' : 'false'}
error={errors.ipfs_api_url?.message}
/>
<SettingsItem
label={t('settings.download_path')}
help={t('settings.download_path_help') ?? undefined}
{...register('download_path', {
required: t('settings.download_path_required') ?? true
})}
aria-invalid={errors.download_path ? 'true' : 'false'}
error={errors.download_path?.message}
rightElement={
<InputRightElement>
<IconButton
aria-label={t('settings.download_path_browse')}
title={t('settings.download_path_browse') ?? ''}
tabIndex={-1}
icon={<Icon as={TbFolder} />}
variant="unstyled"
pt={1}
onClick={async () => {
const selected = (await open({
defaultPath: watch('download_path'),
directory: true,
multiple: false
})) as string | null;
if (selected)
setValue('download_path', selected, { shouldValidate: true });
}}
/>
</InputRightElement>
}
/>
</Stack>
</form>
</DrawerBody>

View File

@ -7,13 +7,6 @@
"index_dir_help": "The directory where the index is stored.",
"index_dir_required": "The index directory is required",
"index_dir_browse": "Browse",
"ipfs_api_url": "IPFS API URL",
"ipfs_api_url_help": "The URL of the IPFS API.",
"ipfs_api_url_required": "The IPFS API URL is required",
"download_path": "Download path",
"download_path_help": "The path where the books will be downloaded.",
"download_path_required": "The download path is required",
"download_path_browse": "Browse",
"cancel": "Cancel",
"save": "Save"
}
@ -27,13 +20,6 @@
"index_dir_help": "存储索引的目录。",
"index_dir_required": "索引目录不能为空",
"index_dir_browse": "浏览",
"ipfs_api_url": "IPFS API 地址",
"ipfs_api_url_help": "IPFS API 地址。",
"ipfs_api_url_required": "IPFS API 地址不能为空",
"download_path": "下载路径",
"download_path_help": "下载书籍的保存路径。",
"download_path_required": "下载路径不能为空",
"download_path_browse": "浏览",
"cancel": "取消",
"save": "保存"
}