UNPKG

@wener/console

Version:

Base console UI toolkit

68 lines (67 loc) 2.79 kB
import React from "react"; import { BiError } from "react-icons/bi"; import { GrDocumentMissing } from "react-icons/gr"; import { HiMiniArrowLeft, HiMiniArrowPath, HiMiniHome } from "react-icons/hi2"; import { useInRouterContext, useNavigate } from "react-router-dom"; import { Button, NonIdealState } from "../daisy/index.js"; export const NonIdealPage = ({ title, icon, description }) => { const inRouterContext = useInRouterContext(); let navigate = (v) => { typeof v === "string" ? window.location.href = v : window.history.back(); }; if (inRouterContext) { navigate = useNavigate(); } return /*#__PURE__*/ React.createElement("div", { className: "flex h-full flex-1 items-center justify-center" }, /*#__PURE__*/ React.createElement(NonIdealState, { icon: icon, title: title, description: description, action: /*#__PURE__*/ React.createElement("div", { className: "flex gap-2 opacity-95" }, /*#__PURE__*/ React.createElement(Button, { className: "btn-outline btn-sm", onClick: () => { navigate("/"); } }, /*#__PURE__*/ React.createElement(HiMiniHome, { className: "h-4 w-4" }), "\u9996\u9875"), /*#__PURE__*/ React.createElement(Button, { className: "btn-outline btn-sm", onClick: () => { navigate(-1); } }, /*#__PURE__*/ React.createElement(HiMiniArrowLeft, { className: "h-4 w-4" }), "\u8FD4\u56DE"), /*#__PURE__*/ React.createElement(Button, { className: "btn-outline btn-sm", onClick: () => { window.location.reload(); } }, /*#__PURE__*/ React.createElement(HiMiniArrowPath, { className: "h-4 w-4" }), "\u5237\u65B0")) })); }; export const NotFoundPage = () => { return /*#__PURE__*/ React.createElement(NonIdealPage, { icon: /*#__PURE__*/ React.createElement(GrDocumentMissing, { className: "h-12 w-12" }), title: "\u9875\u9762\u4E0D\u5B58\u5728", description: /*#__PURE__*/ React.createElement("small", { suppressHydrationWarning: true }, "\u5F53\u524D\u9875\u9762\u5730\u5740: ", globalThis.location?.href) }); }; export const ServerErrorPage = ({ statusCode }) => { return /*#__PURE__*/ React.createElement(NonIdealPage, { icon: /*#__PURE__*/ React.createElement(BiError, { className: "h-12 w-12" }), title: `服务器处理错误`, description: /*#__PURE__*/ React.createElement("small", null, "\u9519\u8BEF\u7801\uFF1A", statusCode || "\u672A\u77E5") }); }; //# sourceMappingURL=NonIdealPage.js.map