Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pages/manage/metas/AddOrEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const AddOrEdit = () => {
}

const t = useT()
const { params, back } = useRouter()
const { params, to } = useRouter()
const { id } = params
const [meta, setMeta] = createStore<Meta>({
id: 0,
Expand Down Expand Up @@ -238,7 +238,7 @@ const AddOrEdit = () => {
// TODO maybe can use handleRrespWithNotifySuccess
handleResp(resp, () => {
notify.success(t("global.save_success"))
back()
to("/@manage/metas")
})
}}
>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/manage/shares/AddOrEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { me } from "~/store"

const AddOrEdit = () => {
const t = useT()
const { params, back, to } = useRouter()
const { params, to } = useRouter()
const { id } = params
const [shareLoading, loadShare] = useFetch(
(): PResp<ShareInfo> => r.get(`/share/get?id=${id}`),
Expand Down Expand Up @@ -192,7 +192,7 @@ const AddOrEdit = () => {
resp,
() => {
notify.success(t("global.save_success"))
back()
to("/@manage/shares")
},
(_msg, _code) => {
if (resp.data.id) {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/manage/storages/AddOrEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Drivers = Record<string, DriverInfo>

const AddOrEdit = () => {
const t = useT()
const { params, back, to } = useRouter()
const { params, to } = useRouter()
const { id } = params
const [driversLoading, loadDrivers] = useFetch(
(): PResp<Drivers> => r.get("/admin/driver/list"),
Expand Down Expand Up @@ -209,7 +209,7 @@ const AddOrEdit = () => {
resp,
() => {
notify.success(t("global.save_success"))
back()
to("/@manage/storages")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Replace the edit entry instead of pushing the list

When a user follows the normal list → edit → save flow, to() calls navigate(path, options) without replace, so this leaves the editor in history and creates list → edit → list; pressing Back after saving now reopens the just-saved editor, whereas the previous back() returned to the original list entry. Pass { replace: true } through the third argument to to() so navigation is deterministic without retaining the stale edit page.

Useful? React with 👍 / 👎.

},
(msg, code) => {
if (resp.data.id) {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/manage/users/AddOrEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Permission = (props: {

const AddOrEdit = () => {
const t = useT()
const { params, back } = useRouter()
const { params, to } = useRouter()
const { id } = params
const [user, setUser] = createStore<User>({
id: 0,
Expand Down Expand Up @@ -169,7 +169,7 @@ const AddOrEdit = () => {
notify.success(t("global.save_success"))
if (user.username === me().username)
handleResp(await (r.get("/me") as PResp<Me>), setMe)
back()
to("/@manage/users")
})
}}
>
Expand Down