refactor: replace Toast with Sonner
This commit is contained in:
@@ -7,7 +7,6 @@ import type { ActivePage, NavigationItem, SubPage } from "./platform.navigation"
|
||||
import { Collapsible } from "@base-ui/react/collapsible";
|
||||
|
||||
import type { Route } from "./+types/platform";
|
||||
import { Toast } from "../components/common/Toast";
|
||||
import { Topbar } from "../components/common/Topbar";
|
||||
import Icon from "../components/common/Icon";
|
||||
import {
|
||||
@@ -165,8 +164,6 @@ function AuthenticatedLayout() {
|
||||
const endEditing = useScriptWorkspaceStore((s) => s.endEditing);
|
||||
const selectScript = useScriptWorkspaceStore((s) => s.selectScript);
|
||||
|
||||
const toast = useUiStore((s) => s.toast);
|
||||
const dismissToast = useUiStore((s) => s.dismissToast);
|
||||
const workspaceMenuOpen = useUiStore((s) => s.workspaceMenuOpen);
|
||||
const setWorkspaceMenuOpen = useUiStore((s) => s.setWorkspaceMenuOpen);
|
||||
|
||||
@@ -199,13 +196,6 @@ function AuthenticatedLayout() {
|
||||
// 心跳 / cleanup / 切页结束编辑 / 卸载前释放
|
||||
useEditSessionLifecycle({ activePage });
|
||||
|
||||
// toast 自动消失
|
||||
useEffect(() => {
|
||||
if (!toast) return;
|
||||
const timer = window.setTimeout(dismissToast, 3200);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [toast, dismissToast]);
|
||||
|
||||
// 原 common/Sidebar 的编辑会话守卫上移到这里:切出 /scripts 时有活动编辑
|
||||
// 会话先 endEditing,回工作台时清空选中脚本;再按当前激活页导航。
|
||||
function guardedNavigate(page: ActivePage, sub?: SubPage) {
|
||||
@@ -279,7 +269,6 @@ function AuthenticatedLayout() {
|
||||
<Outlet />
|
||||
</SidebarInset>
|
||||
|
||||
<Toast toast={toast} />
|
||||
</SidebarProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useAuth } from "~/context/AuthContext";
|
||||
import { useScriptWorkspaceStore } from "~/features/platform/state/scriptWorkspaceStore";
|
||||
import { useUiStore } from "~/features/platform/state/uiStore";
|
||||
import { toast } from "sonner";
|
||||
import { ProjectManagementPage } from "~/features/admin/ProjectManagementPage";
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@ import { ProjectManagementPage } from "~/features/admin/ProjectManagementPage";
|
||||
export default function ProjectManagementRoute() {
|
||||
const { user, currentWorkspace } = useAuth();
|
||||
const setApiOnline = useScriptWorkspaceStore((s) => s.setApiOnline);
|
||||
const pushToast = useUiStore((s) => s.pushToast);
|
||||
const pushToast = (notice: { tone: "success" | "error" | "info"; message: string }) => {
|
||||
if (notice.tone === "error") toast.error(notice.message);
|
||||
else if (notice.tone === "info") toast.info(notice.message);
|
||||
else toast.success(notice.message);
|
||||
};
|
||||
|
||||
return (
|
||||
<ProjectManagementPage
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useAuth } from "~/context/AuthContext";
|
||||
import { useScriptWorkspaceStore } from "~/features/platform/state/scriptWorkspaceStore";
|
||||
import { useUiStore } from "~/features/platform/state/uiStore";
|
||||
import { toast } from "sonner";
|
||||
import { RoleManagementPage } from "~/features/admin/RoleManagementPage";
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@ import { RoleManagementPage } from "~/features/admin/RoleManagementPage";
|
||||
export default function RoleManagementRoute() {
|
||||
const { user, currentWorkspace } = useAuth();
|
||||
const setApiOnline = useScriptWorkspaceStore((s) => s.setApiOnline);
|
||||
const pushToast = useUiStore((s) => s.pushToast);
|
||||
const pushToast = (notice: { tone: "success" | "error" | "info"; message: string }) => {
|
||||
if (notice.tone === "error") toast.error(notice.message);
|
||||
else if (notice.tone === "info") toast.info(notice.message);
|
||||
else toast.success(notice.message);
|
||||
};
|
||||
|
||||
return (
|
||||
<RoleManagementPage
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useAuth } from "~/context/AuthContext";
|
||||
import { useScriptWorkspaceStore } from "~/features/platform/state/scriptWorkspaceStore";
|
||||
import { useUiStore } from "~/features/platform/state/uiStore";
|
||||
import { toast } from "sonner";
|
||||
import { UserManagementPage } from "~/features/admin/UserManagementPage";
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@ import { UserManagementPage } from "~/features/admin/UserManagementPage";
|
||||
export default function UserManagementRoute() {
|
||||
const { user, currentWorkspace } = useAuth();
|
||||
const setApiOnline = useScriptWorkspaceStore((s) => s.setApiOnline);
|
||||
const pushToast = useUiStore((s) => s.pushToast);
|
||||
const pushToast = (notice: { tone: "success" | "error" | "info"; message: string }) => {
|
||||
if (notice.tone === "error") toast.error(notice.message);
|
||||
else if (notice.tone === "info") toast.info(notice.message);
|
||||
else toast.success(notice.message);
|
||||
};
|
||||
|
||||
return (
|
||||
<UserManagementPage
|
||||
|
||||
Reference in New Issue
Block a user