-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.0-alpha.7
- Loading branch information
Showing
26 changed files
with
557 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React, { Suspense } from "react"; | ||
import Loading from "~/components/loading"; | ||
|
||
export const suspense = (component: React.ReactNode) => ( | ||
<Suspense fallback={<Loading />}>{component}</Suspense> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { HomeOutlined, ClearOutlined } from "@ant-design/icons"; | ||
import { FloatButton } from "antd"; | ||
|
||
interface HomeButtonProps { | ||
onClick: () => void; | ||
clear?: () => void; | ||
} | ||
|
||
const HomeButton = ({ onClick, clear }: HomeButtonProps) => { | ||
const homeBtn = ( | ||
<FloatButton tooltip="回到首页" icon={<HomeOutlined />} onClick={onClick} /> | ||
); | ||
|
||
if (!clear) return homeBtn; | ||
|
||
return ( | ||
<FloatButton.Group> | ||
<FloatButton | ||
icon={<ClearOutlined />} | ||
tooltip="清空文件列表" | ||
onClick={clear} | ||
/> | ||
|
||
{homeBtn} | ||
</FloatButton.Group> | ||
); | ||
}; | ||
|
||
export default HomeButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Spin } from "antd"; | ||
|
||
const Loading = () => { | ||
return ( | ||
<div | ||
style={{ | ||
position: "absolute", | ||
width: "100%", | ||
height: "100%", | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
}} | ||
> | ||
<Spin /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Loading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { lazy } from "react"; | ||
|
||
export const LazyFloatButtons = lazy(() => import("~/components/floatButtons")); | ||
|
||
export const LazySend = lazy(() => import("~/pages/send")); | ||
export const LazySendFileList = lazy(() => import("~/pages/send/list")); | ||
|
||
export const LazyReceive = lazy(() => import("~/pages/receive")); | ||
export const LazyReceiveHeader = lazy(() => import("~/pages/receive/header")); | ||
export const LazyReceiveQrCode = lazy(() => import("~/pages/receive/qrcode")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Col, Progress, Row } from "antd"; | ||
|
||
interface FileListItemProps { | ||
name: string; | ||
percent: number; | ||
speed?: number; | ||
size: string; | ||
} | ||
|
||
const FileListItem = ({ name, percent, speed, size }: FileListItemProps) => ( | ||
<li className="receive-file-list-item"> | ||
<div | ||
style={{ | ||
textAlign: "left", | ||
fontSize: "0.8rem", | ||
color: percent < 100 ? "#959595" : "var(--ant-color-text-base)", | ||
}} | ||
> | ||
<Row gutter={10}> | ||
<Col span={speed ? 12 : 18}> | ||
<h4 className="filename">{name}</h4> | ||
</Col> | ||
|
||
{speed ? ( | ||
<Col span={6} className="speed">{`${speed.toFixed(1)} MB/s`}</Col> | ||
) : null} | ||
|
||
<Col span={6} className="filesize"> | ||
{size} | ||
</Col> | ||
</Row> | ||
</div> | ||
<Progress percent={percent} /> | ||
</li> | ||
); | ||
|
||
export default FileListItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { useState, useEffect } from "react"; | ||
import { Row, Col, Dropdown, Button } from "antd"; | ||
import type { MenuProps } from "antd"; | ||
import { open as pick } from "@tauri-apps/api/dialog"; | ||
import { open } from "@tauri-apps/api/shell"; | ||
import { changeDownloadsDir, getDownloadsDir } from "~/api"; | ||
import Loading from "~/components/loading"; | ||
|
||
const Header = () => { | ||
const [downloadDir, setDownloadDir] = useState<string | undefined>(undefined); | ||
const [openDropDown, setOpenDropDown] = useState(false); | ||
|
||
useEffect(() => { | ||
if (downloadDir) return; | ||
|
||
getDownloadsDir().then((d) => setDownloadDir(d)); | ||
}, []); | ||
|
||
const pickDirectory = async () => { | ||
const dir = (await pick({ | ||
directory: true, | ||
defaultPath: downloadDir, | ||
multiple: false, | ||
})) as string | null; | ||
|
||
if (!dir) return; | ||
|
||
await changeDownloadsDir(dir); | ||
|
||
setDownloadDir(dir); | ||
}; | ||
|
||
const DirectoryDropdownItems: MenuProps["items"] = [ | ||
{ | ||
key: "1", | ||
label: <a>打开</a>, | ||
onClick: () => open(downloadDir!), | ||
}, | ||
{ | ||
key: "2", | ||
label: <a>修改</a>, | ||
onClick: () => pickDirectory(), | ||
}, | ||
]; | ||
|
||
if (!downloadDir) return <Loading />; | ||
|
||
return ( | ||
<Row className="header"> | ||
<Col span={6} className="directory-button-label"> | ||
<span style={{ fontSize: "0.8rem" }}>保存目录:</span> | ||
</Col> | ||
|
||
<Col span={18}> | ||
<Dropdown | ||
open={openDropDown} | ||
onOpenChange={() => setOpenDropDown((pre) => !pre)} | ||
menu={{ items: DirectoryDropdownItems }} | ||
placement="bottomRight" | ||
arrow | ||
overlayStyle={{ minWidth: 0 }} | ||
> | ||
<Button | ||
className="directory-button" | ||
type="link" | ||
onClick={async () => { | ||
setOpenDropDown(false); | ||
open(downloadDir); | ||
}} | ||
style={{ textOverflow: "ellipsis" }} | ||
> | ||
{downloadDir} | ||
</Button> | ||
</Dropdown> | ||
</Col> | ||
</Row> | ||
); | ||
}; | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.