gomtm 0.0.334 → 0.0.335
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/site/SiteSwitchDlg.d.ts +0 -0
- package/dist/esm/components/site/SiteSwitchDlg.js +0 -0
- package/dist/esm/curd/list-item/ListViewLayoutRender.js +4 -3
- package/dist/esm/ly/UserAvatorMenus.js +3 -2
- package/dist/esm/providers/AuthProvider.d.ts +1 -0
- package/dist/esm/providers/AuthProvider.js +9 -0
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
File without changes
|
|
File without changes
|
|
@@ -11,6 +11,7 @@ import { useState } from "react";
|
|
|
11
11
|
import { MtDateView } from "../../components/MtDate";
|
|
12
12
|
import Tag from "../../components/Tag";
|
|
13
13
|
import { ListViewLayout } from "../../gomtmpb/mtm/sppb/mtm_pb";
|
|
14
|
+
import { useIsLogined } from "../../providers/AuthProvider";
|
|
14
15
|
import { useListview } from "../listview/list-store";
|
|
15
16
|
const CommontListResView = (props) => {
|
|
16
17
|
var _a;
|
|
@@ -78,6 +79,7 @@ const PostCardListItem = (props) => {
|
|
|
78
79
|
const slugPath = useListview((x) => x.slugPath);
|
|
79
80
|
const activateItem = useListview((x) => x.activateItem);
|
|
80
81
|
const setActivateItem = useListview((x) => x.setActivateItem);
|
|
82
|
+
const isLogined = useIsLogined();
|
|
81
83
|
if (item.layoutVariant == "list") {
|
|
82
84
|
return /* @__PURE__ */ jsx(
|
|
83
85
|
"li",
|
|
@@ -121,7 +123,7 @@ const PostCardListItem = (props) => {
|
|
|
121
123
|
) })
|
|
122
124
|
] })
|
|
123
125
|
] }),
|
|
124
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-0", children: /* @__PURE__ */ jsx(PostCardItemActions, { id: item.id }) })
|
|
126
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-0", children: isLogined && /* @__PURE__ */ jsx(PostCardItemActions, { id: item.id }) })
|
|
125
127
|
] })
|
|
126
128
|
}
|
|
127
129
|
);
|
|
@@ -160,7 +162,7 @@ const PostCardListItem = (props) => {
|
|
|
160
162
|
] }) }),
|
|
161
163
|
/* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
|
|
162
164
|
/* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `${slugPath}/${item.id}`, children: "Show" }),
|
|
163
|
-
/* @__PURE__ */ jsx(PostCardItemActions, { id: item.id })
|
|
165
|
+
isLogined && /* @__PURE__ */ jsx(PostCardItemActions, { id: item.id })
|
|
164
166
|
] })
|
|
165
167
|
]
|
|
166
168
|
}
|
|
@@ -173,7 +175,6 @@ const PostCardItemActions = (props) => {
|
|
|
173
175
|
const slugPath = useListview((x) => x.slugPath);
|
|
174
176
|
const [open, setOpen] = useState(false);
|
|
175
177
|
const setOpenEdit = useListview((x) => x.setOpenEdit);
|
|
176
|
-
const setActivateItem = useListview((x) => x.setActivateItem);
|
|
177
178
|
return /* @__PURE__ */ jsxs(DropdownMenu, { open, onOpenChange: setOpen, children: [
|
|
178
179
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
179
180
|
MtLink,
|
|
@@ -6,12 +6,13 @@ import { Avatar, AvatarFallback, AvatarImage } from "mtxuilib/ui/avatar";
|
|
|
6
6
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
7
7
|
import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
|
|
8
8
|
import { usePathname } from "next/navigation";
|
|
9
|
-
import { useAuth, useLogout } from "../providers/AuthProvider";
|
|
9
|
+
import { useAuth, useIsLogined, useLogout } from "../providers/AuthProvider";
|
|
10
10
|
function UserAvatorMenus() {
|
|
11
11
|
const pathName = usePathname();
|
|
12
12
|
const auth = useAuth();
|
|
13
13
|
const logout = useLogout();
|
|
14
|
-
|
|
14
|
+
const isLogined = useIsLogined();
|
|
15
|
+
return /* @__PURE__ */ jsx(Fragment, { children: !isLogined ? /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `/login?next=${pathName}`, children: " login" }) : /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
15
16
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Avatar, { children: [
|
|
16
17
|
/* @__PURE__ */ jsx(AvatarImage, { src: "/mtm_images/placeholder-user.jpg", alt: "@siteCook" }),
|
|
17
18
|
/* @__PURE__ */ jsx(AvatarFallback, { children: "You" })
|
|
@@ -42,8 +42,17 @@ function useLogout() {
|
|
|
42
42
|
router.push("/");
|
|
43
43
|
}, [router]);
|
|
44
44
|
}
|
|
45
|
+
function useIsLogined() {
|
|
46
|
+
const userInfoQuery = useGomtmSuspenseQuery(userinfo.service.typeName, userinfo.name);
|
|
47
|
+
const userId = useMemo(() => {
|
|
48
|
+
var _a;
|
|
49
|
+
return (_a = userInfoQuery.data.userInfo) == null ? void 0 : _a.ID;
|
|
50
|
+
}, [userInfoQuery.data]);
|
|
51
|
+
return !!userId;
|
|
52
|
+
}
|
|
45
53
|
export {
|
|
46
54
|
isRoleMatch,
|
|
47
55
|
useAuth,
|
|
56
|
+
useIsLogined,
|
|
48
57
|
useLogout
|
|
49
58
|
};
|