Skip to content

Commit

Permalink
🚸 将部分router.push替换为<Link />
Browse files Browse the repository at this point in the history
  • Loading branch information
neila-a committed Apr 28, 2024
1 parent 9d3f6c0 commit 8e01973
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@verkfi/core",
"version": "1.7.0",
"devVersion": "905",
"devVersion": "913",
"dev": true,
"description": "Platform for Neila's something useless tools.",
"private": true,
Expand Down
19 changes: 10 additions & 9 deletions packages/core/src/app/components/window/Window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import MouseOverPopover from "../Popover";
import {
Route
} from "next";
import Link from "next/link";
export interface WindowOptions {
to: string;
name: string;
Expand All @@ -48,7 +49,6 @@ export default function Window(props: WindowOptions): JSX.Element {
id
} = props,
realSx: CSSProperties = props?.sx === undefined ? {} : props?.sx,
router = useRouter(),
[open, setOpen] = useState<boolean>(true),
nodeRef = useRef<HTMLDivElement>(null),
[size, setSize] = useState<[number, number]>([50, 50]), /* height, width */
Expand Down Expand Up @@ -122,14 +122,15 @@ export default function Window(props: WindowOptions): JSX.Element {
{type === "min" ? <KeyboardArrowDownIcon /> : <KeyboardArrowUpIcon />}
</IconButton>
</MouseOverPopover>
<MouseOverPopover text={get("window.maxmize")}>
<IconButton aria-label={get("window.maxmize")} edge="end" onClick={event => {
router.push(props.to as Route);
setOpen(false);
}}>
<CropDinIcon />
</IconButton>
</MouseOverPopover>
<Link href={props.to as Route}>
<MouseOverPopover text={get("window.maxmize")}>
<IconButton aria-label={get("window.maxmize")} edge="end" onClick={event => {
setOpen(false);
}}>
<CropDinIcon />
</IconButton>
</MouseOverPopover>
</Link>
<MouseOverPopover text={get("close")}>
<IconButton aria-label={get("close")} edge="end" onClick={event => setOpen(false)}>
<CloseIcon />
Expand Down
22 changes: 10 additions & 12 deletions packages/core/src/app/layout/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ import {
import getParamTools from "index/getParamTools";
import VerkfiIcon from "components/verkfiIcon/verkfiIcon";
import convertExtensionTools from "index/convertExtensionTools";
import {
Route
} from "next";
import Link from "next/link";
export default function Menu() {
const control = useContext(showSidebar),
theme = useTheme(),
Expand Down Expand Up @@ -294,15 +292,15 @@ export default function Menu() {
<Box sx={{
display: "flex"
}}>
<MouseOverPopover text={get("主页")}>
<IconButton color="primary" sx={{
p: 1
}} aria-label={get("主页")} onClick={_event => {
router.push("/" satisfies Route);
}}>
<HomeIcon />
</IconButton>
</MouseOverPopover>
<Link href="/">
<MouseOverPopover text={get("主页")}>
<IconButton color="primary" sx={{
p: 1
}} aria-label={get("主页")}>
<HomeIcon />
</IconButton>
</MouseOverPopover>
</Link>
<SwitchViewMode viewMode={viewMode} setViewMode={setViewMode} />
{(editing && sortingFor !== "__extension__") && (
<SwitchEditMode editMode={editMode} setEditMode={setEditMode} />
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/app/setting/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default function Settings(props: {
setValue(newValue);
}}>
{sets.map(Set => (
<Tab icon={<Set.Icon />} iconPosition="start" label={Set.name} key={Set.id} onClick={event => {
<Tab icon={<Set.Icon />} title={`/setting/${Set.id}`} iconPosition="start" label={Set.name} key={Set.id} onClick={event => {
router.push(`/setting/${Set.id}` satisfies Route);
}} />
))}
Expand Down

0 comments on commit 8e01973

Please sign in to comment.