Skip to content

Commit

Permalink
优化文件浏览
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtualHotBar committed May 17, 2024
1 parent a3b9cc1 commit c9e15e4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 25 deletions.
4 changes: 3 additions & 1 deletion src/controller/language/pack/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Webdav": "WebDAV是一组基于超文本传输协议的技术集合,有利于用户间协同编辑和管理存储在万维网服务器文档。",
"url": "地址",
"vendor": "提供商",
"execute": "执行",
"user": "用户",
"pass": "密码",
"save": "保存",
Expand Down Expand Up @@ -254,7 +255,8 @@
"runtime_error": "运行错误",
"view_log": "查看日志",
"version": "版本",
"filelist_load_Fail": "文件列表加载失败,请检查网络或存储配置",
"filelist_load_fail": "文件列表加载失败,请检查网络或存储配置",
"filelist_loading": "文件列表加载中",
"devtools": "开发者工具",
"not_add_storage": "未添加存储",
"about_to_restart_self": "即将重启程序",
Expand Down
14 changes: 10 additions & 4 deletions src/controller/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { rclone_api_post } from "../utils/rclone/request";
import { createStorage } from "./storage/create";
import { getFileList, reupStorage } from "./storage/storage";
import { convertStoragePath, getFileList, reupStorage } from "./storage/storage";
import { invoke } from '@tauri-apps/api';

import { appWindow } from "@tauri-apps/api/window";
Expand All @@ -26,10 +26,16 @@ export async function Test() {

console.log(await rclone_api_post('/options/get'));
console.log(await rclone_api_post('/rc/list'),);
console.log(await alist_api_get('/api/me'));
console.log(roConfig.env.path.homeDir);

console.log(storageInfoList);
/* console.log(await rclone_api_post('/operations/publiclink',{
fs: convertStoragePath('S3_new',undefined,undefined,undefined,true),
remote :convertStoragePath('S3_new','Package/HotPE-V2.7.240201.7z',undefined,true,false),
})); */

//console.log(await alist_api_get('/api/me'));
//console.log(roConfig.env.path.homeDir);

//console.log(storageInfoList);

//await addAlistInRclone()

Expand Down
3 changes: 2 additions & 1 deletion src/page/mount/add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { homeDir } from '@tauri-apps/api/path';
import { InputForm_module, paramsType2FormItems } from '../other/InputForm';
import { filterHideStorage } from '../../controller/storage/storage';
import { MountOptions, VfsOptions } from '../../type/rclone/storage/mount/parameters';
import { searchStorageInfo } from '../../controller/storage/allList';

const FormItem = Form.Item;

Expand Down Expand Up @@ -134,7 +135,7 @@ export default function AddMount_page() {
{
storageList.map((item) => {
return (
<Select.Option key={item.name} value={item.name}>{item.name}({item.type})</Select.Option>
<Select.Option key={item.name} value={item.name}>{item.name}({t(searchStorageInfo(item.type).label)})</Select.Option>
)
})
}
Expand Down
31 changes: 19 additions & 12 deletions src/page/storage/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { rcloneInfo } from '../../services/rclone';
import { useTranslation } from 'react-i18next';
import { copyDir, copyFile, delDir, delFile, filterHideStorage, formatPathRclone, getFileList, mkDir, moveDir, moveFile, uploadFileRequest } from '../../controller/storage/storage';
import { FileInfo } from '../../type/rclone/rcloneInfo';
import { formatSize, getURLSearchParam } from '../../utils/utils';
import { formatSize, getURLSearchParam, sleep } from '../../utils/utils';
import { RequestOptions } from '@arco-design/web-react/es/Upload';
import { NoData_module } from '../other/noData';
import { clipListItem } from '../../type/page/storage/explorer';
Expand Down Expand Up @@ -73,7 +73,7 @@ function ExplorerItem() {

const [fileList, setFileInfo] = useState<Array<FileInfo>>()

const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState<boolean>()

const [clipList, setClipList] = useState<Array<clipListItem>>([])

Expand Down Expand Up @@ -110,9 +110,12 @@ function ExplorerItem() {
//刷新文件列表
async function fileInfo() {
setLoading(true)
const l = await getFileList(storageName!, path!)
setLoading(false)
setFileInfo(l)
try {
const l = await getFileList(storageName!, path!)
setFileInfo(l)
} finally {
setLoading(false)
}
}

// 创建一个自定义函数用于更新路径,确保路径始终符合规范
Expand Down Expand Up @@ -193,7 +196,7 @@ function ExplorerItem() {
title: t('upload_file'),
icon: null,
content: <>
<Upload drag customRequest={(option: RequestOptions)=>{uploadFileRequest(option,storageName,path)}} ></Upload></>,
<Upload drag customRequest={(option: RequestOptions) => { uploadFileRequest(option, storageName, path) }} ></Upload></>,
onOk: fileInfo,
onCancel: fileInfo
})
Expand All @@ -220,9 +223,9 @@ function ExplorerItem() {
})
}

const openFile=( path:string )=>{
console.log(path);
Message.info({ content:t('mount_the_storage_to_download_files'),id:'openfile' })
const openFile = (path: string) => {
console.log(path);
Message.info({ content: t('mount_the_storage_to_download_files'), id: 'openfile' })
}

return (
Expand Down Expand Up @@ -306,7 +309,7 @@ function ExplorerItem() {
data={
fileList.map((item) => {
return {
...item, fileName: <Link style={{ width: '100%' }} onClick={() => { item.isDir ?updatePath(item.path): openFile(item.path) }}><Typography.Ellipsis showTooltip>{item.name}</Typography.Ellipsis></Link>,
...item, fileName: <Link style={{ width: '100%' }} onClick={() => { item.isDir ? updatePath(item.path) : openFile(item.path) }}><Typography.Ellipsis showTooltip>{item.name}</Typography.Ellipsis></Link>,
fileSize: (item.size != -1 ? formatSize(item.size) : t('dir')),
fileModTime: (new Date(item.modTime)).toLocaleString(),
actions: <Space size={'mini'}>
Expand All @@ -332,10 +335,14 @@ function ExplorerItem() {
</Space>
}
})} />
: <div style={{ textAlign: 'center', marginTop: '10rem', width: '100%' }}><p>{t('filelist_load_Fail')}</p></div>
: <div style={{ textAlign: 'center', marginTop: '10rem', width: '100%' }}>
<p>{loading ? <Spin tip={t('filelist_loading')} /> : t('filelist_load_fail')}</p>
</div>
}
</> :
!storageName && <Typography.Paragraph style={tipsStyle}>{t('please_select_storage')}</Typography.Paragraph>
!storageName && <Typography.Paragraph style={tipsStyle}>
{t('please_select_storage')}
</Typography.Paragraph>
}
</div>
</div>
Expand Down
20 changes: 13 additions & 7 deletions src/page/task/task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, Grid, Link, Modal, Space, Table, TableColumnProps, Typography }
import { useTranslation } from 'react-i18next'
import { nmConfig, roConfig } from '../../services/config'
import { useNavigate } from 'react-router-dom'
import { delTask } from '../../controller/task/task'
import { delTask, taskScheduler } from '../../controller/task/task'
import { NoData_module } from '../other/noData'
import { IconQuestionCircle } from '@arco-design/web-react/icon'
import { openUrlInBrowser } from '../../utils/utils'
Expand All @@ -24,16 +24,16 @@ function Task_page() {
{
title: t('task_name'),
dataIndex: 'name',
width:'20%'
width: '20%'
},
{
title: t('state'),
dataIndex: 'state',
width:'5rem'
width: '5rem'
}, {
title: t('cycle'),
dataIndex: 'cycle',
width:'5rem'
width: '5rem'
}
, {
title: t('run_info'),
Expand All @@ -43,7 +43,7 @@ function Task_page() {
title: t('actions'),
dataIndex: 'actions',
align: 'right',
width:'6rem'
width: '6rem'
}
];
console.log(nmConfig.task);
Expand Down Expand Up @@ -72,9 +72,15 @@ function Task_page() {
onClick={() => { showLog(modal, taskItem.runInfo?.msg || t('none')) }}>
<Typography.Ellipsis>{(taskItem.runInfo?.msg || t('none')).split('\n').pop()}</Typography.Ellipsis>
</Link>,
actions: <>
actions: <Space>
<Button onClick={() => { delTask(taskItem.name); forceUpdate() }}>{t('delete')}</Button>
</>
<Button onClick={() => {
taskScheduler.executeTask(taskItem)
setTimeout(() => {
forceUpdate()
}, 200)
}}>{t('execute')}</Button>
</Space>
}
})} />
</div>
Expand Down

0 comments on commit c9e15e4

Please sign in to comment.