gomtm 0.0.162 → 0.0.164
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/ListItem.d.ts +6 -0
- package/dist/esm/components/ListItem.js +49 -0
- package/dist/esm/components/auth/AuthPage.d.ts +2 -0
- package/dist/esm/components/auth/AuthPage.js +36 -0
- package/dist/esm/components/auth/LoginScreen2.d.ts +2 -0
- package/dist/esm/components/auth/LoginScreen2.js +106 -0
- package/dist/esm/components/auth/UserAuthForm.d.ts +6 -0
- package/dist/esm/components/auth/UserAuthForm.js +76 -0
- package/dist/esm/components/blog/BlogPostActions.d.ts +4 -0
- package/dist/esm/components/blog/BlogPostActions.js +34 -0
- package/dist/esm/components/blog/BlogPostCreateForm.d.ts +2 -0
- package/dist/esm/components/blog/BlogPostCreateForm.js +27 -0
- package/dist/esm/components/blog/BlogPostImportDlgUrl.d.ts +6 -0
- package/dist/esm/components/blog/BlogPostImportDlgUrl.js +94 -0
- package/dist/esm/components/blog/PostCard.d.ts +5 -0
- package/dist/esm/components/blog/PostCard.js +38 -0
- package/dist/esm/components/blog/PostEditForm.d.ts +2 -0
- package/dist/esm/components/blog/PostEditForm.js +91 -0
- package/dist/esm/components/blog/post-content.d.ts +5 -0
- package/dist/esm/components/blog/post-content.js +15 -0
- package/dist/esm/components/blog/post.atoms.d.ts +11 -0
- package/dist/esm/components/blog/post.atoms.js +9 -0
- package/dist/esm/curd/CommonListViewV2.d.ts +4 -3
- package/dist/esm/curd/CommonListViewV2.js +6 -6
- package/dist/esm/curd/CreateFormV2.d.ts +2 -3
- package/dist/esm/curd/CreateFormV2.js +1 -1
- package/dist/esm/curd/CurdViewView.d.ts +2 -2
- package/dist/esm/curd/CurdViewView.js +3 -6
- package/dist/esm/gomtm-clients-ss.d.ts +6 -0
- package/dist/esm/gomtm-clients-ss.js +9 -3
- package/dist/esm/gomtmpb/mtm/sppb/mtm_pb.d.ts +5 -9
- package/dist/esm/gomtmpb/mtm/sppb/mtm_pb.js +20 -63
- package/dist/esm/hooks/useAuth.d.ts +5 -0
- package/dist/esm/hooks/useAuth.js +43 -0
- package/dist/esm/lib/auth/jwt.d.ts +7 -0
- package/dist/esm/lib/auth/jwt.js +43 -0
- package/dist/esm/ly/DashLayout.d.ts +2 -0
- package/dist/esm/ly/DashLayout.js +39 -0
- package/dist/esm/ly/UserAvatorMenus.d.ts +2 -0
- package/dist/esm/ly/UserAvatorMenus.js +63 -0
- package/dist/esm/ly/dash5/aside.d.ts +2 -0
- package/dist/esm/ly/dash5/aside.js +40 -0
- package/dist/esm/ly/dash5/components/PageCreate.d.ts +4 -0
- package/dist/esm/ly/dash5/components/PageCreate.js +8 -0
- package/dist/esm/ly/dash5/components/PageEdit.d.ts +4 -0
- package/dist/esm/ly/dash5/components/PageEdit.js +8 -0
- package/dist/esm/ly/dash5/components/PageList.d.ts +4 -0
- package/dist/esm/ly/dash5/components/PageList.js +9 -0
- package/dist/esm/ly/dash5/components/PageShow.d.ts +4 -0
- package/dist/esm/ly/dash5/components/PageShow.js +8 -0
- package/dist/esm/ly/dash5/header.d.ts +2 -0
- package/dist/esm/ly/dash5/header.js +123 -0
- package/dist/esm/ly/dash5/index.d.ts +2 -0
- package/dist/esm/ly/dash5/index.js +21 -0
- package/dist/esm/ly/front-layout/PageCmds.d.ts +2 -0
- package/dist/esm/ly/front-layout/PageCmds.js +25 -0
- package/dist/esm/ly/front-layout/PageSearchCmd.d.ts +2 -0
- package/dist/esm/ly/front-layout/PageSearchCmd.js +63 -0
- package/dist/esm/ly/front-layout/header.d.ts +2 -0
- package/dist/esm/ly/front-layout/header.js +18 -0
- package/dist/esm/ly/front-layout/index.d.ts +2 -0
- package/dist/esm/ly/front-layout/index.js +13 -0
- package/dist/esm/ly/front-layout/main-nav.d.ts +3 -0
- package/dist/esm/ly/front-layout/main-nav.js +116 -0
- package/dist/esm/mtmFetcher.d.ts +0 -13
- package/dist/esm/mtmFetcher.js +1 -148
- package/dist/esm/mtmcore.d.ts +0 -5
- package/dist/esm/mtmcore.js +0 -19
- package/dist/esm/mtmquery.d.ts +0 -6
- package/dist/esm/mtmquery.js +1 -64
- package/dist/esm/providers/GomtmAppSS.d.ts +1 -0
- package/dist/esm/providers/GomtmAppSS.js +23 -11
- package/dist/esm/providers/GomtmProvider.d.ts +1 -3
- package/dist/esm/providers/GomtmProvider.js +7 -30
- package/dist/esm/providers/MtConnectProvider.js +3 -8
- package/dist/esm/providers/logger.context.d.ts +4 -0
- package/dist/esm/sscore.d.ts +0 -3
- package/dist/esm/sscore.js +2 -34
- package/dist/esm/store/CurdListViewV3.d.ts +13 -0
- package/dist/esm/store/CurdListViewV3.js +78 -0
- package/dist/esm/store/ExampleStoreProvider.d.ts +6 -0
- package/dist/esm/store/ExampleStoreProvider.js +43 -0
- package/dist/esm/store/GomtmBackendProvider.d.ts +12 -0
- package/dist/esm/store/GomtmBackendProvider.js +49 -0
- package/dist/esm/validations/env.d.ts +2 -2
- package/dist/esm/validations/spContentModi.d.ts +8 -8
- package/dist/esm/validations/spRoute.d.ts +8 -8
- package/dist/gomtm +0 -0
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +119 -7
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Message, PlainMessage } from "@bufbuild/protobuf";
|
|
2
|
+
import { ConnectError } from "@connectrpc/connect";
|
|
1
3
|
import { InfiniteData, UseSuspenseInfiniteQueryResult } from "@tanstack/react-query";
|
|
2
|
-
import type { ConnectError, Message, PlainMessage } from "gomtm";
|
|
3
|
-
import { MethodUnaryDescriptor } from "gomtm/connectquery";
|
|
4
|
-
import { MtmError } from "gomtm/gomtmpb/mtm/sppb/mtm_pb";
|
|
5
4
|
import { PropsWithChildren } from "react";
|
|
5
|
+
import { MethodUnaryDescriptor } from "../connectquery";
|
|
6
|
+
import { MtmError } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
6
7
|
export declare function CommonListViewProvider<I extends Message<I>, O extends Message<O>>(props: {
|
|
7
8
|
methodList: MethodUnaryDescriptor<I, any>;
|
|
8
9
|
} & PropsWithChildren): import("react").JSX.Element;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useSuspenseInfiniteQuery } from "gomtm/connectquery";
|
|
4
|
-
import { ListViewLayout } from "gomtm/gomtmpb/mtm/sppb/mtm_pb";
|
|
5
3
|
import { atom, useAtom } from "jotai";
|
|
6
4
|
import { useHydrateAtoms } from "jotai/utils";
|
|
7
|
-
import { ListItemView } from "mtxuilib/components/ListItem";
|
|
8
|
-
import { MtUnaryCallErrorView } from "mtxuilib/components/MtUnaryCallErrorView";
|
|
9
5
|
import { cn } from "mtxuilib/lib/utils";
|
|
10
6
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
7
|
+
import { ListItemView } from "../components/ListItem";
|
|
8
|
+
import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
|
|
9
|
+
import { useSuspenseInfiniteQuery } from "../connectquery";
|
|
10
|
+
import { ListViewLayout } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
11
11
|
const listQueryAtom = atom(null);
|
|
12
12
|
function CommonListViewProvider(props) {
|
|
13
13
|
const { children, methodList } = props;
|
|
14
14
|
const listquery = useSuspenseInfiniteQuery(methodList, {
|
|
15
|
-
//@ts-
|
|
15
|
+
//@ts-expect-error
|
|
16
16
|
page: 1
|
|
17
17
|
}, {
|
|
18
18
|
pageParamKey: "pagination",
|
|
19
19
|
getNextPageParam: (res, b, c) => {
|
|
20
20
|
return {
|
|
21
|
-
//@ts-
|
|
21
|
+
//@ts-expect-error
|
|
22
22
|
page: ((c == null ? void 0 : c.page) || 0) + 1
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PartialMessage } from "gomtm";
|
|
3
|
-
import { MethodUnaryDescriptor } from "gomtm/connectquery";
|
|
1
|
+
import { Message, PartialMessage } from "@bufbuild/protobuf";
|
|
4
2
|
import { PropsWithChildren } from "react";
|
|
5
3
|
import { DefaultValues } from "react-hook-form";
|
|
4
|
+
import { MethodUnaryDescriptor } from "../connectquery";
|
|
6
5
|
export declare function useCreateForm<I extends Message<I>, O extends Message<O>>(props: {
|
|
7
6
|
defaultValues: DefaultValues<PartialMessage<I>>;
|
|
8
7
|
mutationSig: MethodUnaryDescriptor<I, any>;
|
|
@@ -31,12 +31,12 @@ var __objRest = (source, exclude) => {
|
|
|
31
31
|
return target;
|
|
32
32
|
};
|
|
33
33
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
34
|
-
import { useMutation } from "gomtm/connectquery";
|
|
35
34
|
import { EditFormToolbar } from "mtxuilib/form/EditFormToolbar";
|
|
36
35
|
import { useMtRouter } from "mtxuilib/hooks/use-router";
|
|
37
36
|
import { Dialog, DialogContent, DialogFooter } from "mtxuilib/ui/dialog";
|
|
38
37
|
import { useCallback } from "react";
|
|
39
38
|
import { FormProvider, useForm } from "react-hook-form";
|
|
39
|
+
import { useMutation } from "../connectquery";
|
|
40
40
|
function useCreateForm(props) {
|
|
41
41
|
const { defaultValues, mutationSig } = props;
|
|
42
42
|
const form = useForm({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PlainMessage } from "
|
|
2
|
-
import { CurdView } from "gomtm/gomtmpb/mtm/sppb/mtm_pb";
|
|
1
|
+
import { PlainMessage } from "@bufbuild/protobuf";
|
|
3
2
|
import { PropsWithChildren } from "react";
|
|
3
|
+
import { CurdView } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
4
4
|
export declare const activateIdAtom: import("jotai").PrimitiveAtom<string> & {
|
|
5
5
|
init: string;
|
|
6
6
|
};
|
|
@@ -21,14 +21,14 @@ var __async = (__this, __arguments, generator) => {
|
|
|
21
21
|
};
|
|
22
22
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
23
23
|
import { useQueryClient } from "@tanstack/react-query";
|
|
24
|
-
import { useSuspenseQuery } from "gomtm/connectquery";
|
|
25
|
-
import { curdViewGet } from "gomtm/gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
|
|
26
|
-
import { createInfiniteQueryKey, createQueryKey } from "gomtm/mtmquery";
|
|
27
24
|
import { atom, createStore, useAtom } from "jotai";
|
|
28
25
|
import { useMtRouter } from "mtxuilib/hooks/use-router";
|
|
29
26
|
import { usePathname } from "next/navigation";
|
|
30
27
|
import { compile, match } from "path-to-regexp";
|
|
31
28
|
import { useCallback, useMemo } from "react";
|
|
29
|
+
import { useSuspenseQuery } from "../connectquery";
|
|
30
|
+
import { curdViewGet } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
|
|
31
|
+
import { createInfiniteQueryKey, createQueryKey } from "../mtmquery";
|
|
32
32
|
const activateIdAtom = atom("0");
|
|
33
33
|
const curdViewAtom = atom(null);
|
|
34
34
|
const curdViewIdAtom = atom("");
|
|
@@ -105,9 +105,6 @@ function useCurdView() {
|
|
|
105
105
|
}, [curdView == null ? void 0 : curdView.routeEdit, curdView == null ? void 0 : curdView.routeShow, pathName, setActivateId]);
|
|
106
106
|
return {
|
|
107
107
|
curdView,
|
|
108
|
-
// canEdit,
|
|
109
|
-
// canCreate,
|
|
110
|
-
// canDelete,
|
|
111
108
|
openShow,
|
|
112
109
|
invalidateList,
|
|
113
110
|
invalidateGet,
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { ServiceType } from "@bufbuild/protobuf";
|
|
2
2
|
export declare function createMtmServiceClient<T extends ServiceType>(service: T, url?: string): import("@connectrpc/connect").PromiseClient<T>;
|
|
3
|
+
type CustomRequestInit = RequestInit & {
|
|
4
|
+
enableCache?: boolean;
|
|
5
|
+
enableLog?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const gomtmFetcher: (initGlobal?: CustomRequestInit) => (input: string | URL | globalThis.Request, init?: CustomRequestInit) => Promise<Response>;
|
|
8
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
var __async = (__this, __arguments, generator) => {
|
|
18
21
|
return new Promise((resolve, reject) => {
|
|
19
22
|
var fulfilled = (value) => {
|
|
@@ -43,6 +46,7 @@ function createMtmServiceClient(service, url) {
|
|
|
43
46
|
if (!baseUrl) {
|
|
44
47
|
throw new Error("missing mtm api url,\xB7MTM_BACKEND\xB7");
|
|
45
48
|
}
|
|
49
|
+
console.info("gomtm baseUrl:", baseUrl);
|
|
46
50
|
return createPromiseClient(
|
|
47
51
|
service,
|
|
48
52
|
createConnectTransport({
|
|
@@ -69,9 +73,10 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
69
73
|
init = {};
|
|
70
74
|
}
|
|
71
75
|
init = __spreadValues(__spreadValues({}, init), {
|
|
72
|
-
headers: __spreadValues(__spreadValues({}, init.headers),
|
|
76
|
+
headers: __spreadValues(__spreadProps(__spreadValues({}, init.headers), {
|
|
77
|
+
"Content-Type": "application/json"
|
|
78
|
+
}), headerCookie && { "Cookie": headerCookie })
|
|
73
79
|
});
|
|
74
|
-
console.log("mtm request init", init);
|
|
75
80
|
let fetcher = fetch;
|
|
76
81
|
if (req.enableCache) {
|
|
77
82
|
fetcher = fetchMiddleWithCache(fetch);
|
|
@@ -96,5 +101,6 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
96
101
|
});
|
|
97
102
|
};
|
|
98
103
|
export {
|
|
99
|
-
createMtmServiceClient
|
|
104
|
+
createMtmServiceClient,
|
|
105
|
+
gomtmFetcher
|
|
100
106
|
};
|
|
@@ -503,19 +503,15 @@ export declare class ItemAction extends Message<ItemAction> {
|
|
|
503
503
|
static equals(a: ItemAction | PlainMessage<ItemAction> | undefined, b: ItemAction | PlainMessage<ItemAction> | undefined): boolean;
|
|
504
504
|
}
|
|
505
505
|
export declare class ListParams extends Message<ListParams> {
|
|
506
|
-
slugs
|
|
506
|
+
slugs?: string;
|
|
507
507
|
params: {
|
|
508
508
|
[key: string]: string;
|
|
509
509
|
};
|
|
510
|
-
searchParams: {
|
|
511
|
-
[key: string]: string;
|
|
512
|
-
};
|
|
513
510
|
pagination?: Paging;
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
siteHost: string;
|
|
511
|
+
preTagLimit?: number;
|
|
512
|
+
cursor?: string;
|
|
513
|
+
rerefer?: string;
|
|
514
|
+
siteHost?: string;
|
|
519
515
|
constructor(data?: PartialMessage<ListParams>);
|
|
520
516
|
static readonly runtime: typeof proto3;
|
|
521
517
|
static readonly typeName = "sppb.ListParams";
|
|
@@ -1999,51 +1999,44 @@ const _ListParams = class _ListParams extends Message {
|
|
|
1999
1999
|
constructor(data) {
|
|
2000
2000
|
super();
|
|
2001
2001
|
/**
|
|
2002
|
-
* @generated from field: string slugs = 1;
|
|
2002
|
+
* @generated from field: optional string slugs = 1;
|
|
2003
2003
|
*/
|
|
2004
|
-
__publicField(this, "slugs"
|
|
2004
|
+
__publicField(this, "slugs");
|
|
2005
2005
|
/**
|
|
2006
2006
|
* @generated from field: map<string, string> params = 2;
|
|
2007
2007
|
*/
|
|
2008
2008
|
__publicField(this, "params", {});
|
|
2009
2009
|
/**
|
|
2010
|
-
*
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
/**
|
|
2014
|
-
* @generated from field: sppb.Paging pagination = 4;
|
|
2010
|
+
* optional map<string, string> search_params = 3;
|
|
2011
|
+
*
|
|
2012
|
+
* @generated from field: optional sppb.Paging pagination = 4;
|
|
2015
2013
|
*/
|
|
2016
2014
|
__publicField(this, "pagination");
|
|
2017
2015
|
/**
|
|
2018
2016
|
* ListViewLayout view_type = 5;
|
|
2017
|
+
* optional repeated string service_tags = 6; // 匹配到具体服务的标签(多个)
|
|
2019
2018
|
*
|
|
2020
|
-
* 匹配到具体服务的标签(多个)
|
|
2021
|
-
*
|
|
2022
|
-
* @generated from field: repeated string service_tags = 6;
|
|
2023
|
-
*/
|
|
2024
|
-
__publicField(this, "serviceTags", []);
|
|
2025
|
-
/**
|
|
2026
2019
|
* 单个服务最大结果数
|
|
2027
2020
|
*
|
|
2028
|
-
* @generated from field: uint32 pre_tag_limit = 7;
|
|
2021
|
+
* @generated from field: optional uint32 pre_tag_limit = 7;
|
|
2029
2022
|
*/
|
|
2030
|
-
__publicField(this, "preTagLimit"
|
|
2023
|
+
__publicField(this, "preTagLimit");
|
|
2031
2024
|
/**
|
|
2032
2025
|
* 游标(功能未实现)
|
|
2033
2026
|
*
|
|
2034
|
-
* @generated from field: string cursor = 8;
|
|
2027
|
+
* @generated from field: optional string cursor = 8;
|
|
2035
2028
|
*/
|
|
2036
|
-
__publicField(this, "cursor"
|
|
2029
|
+
__publicField(this, "cursor");
|
|
2037
2030
|
/**
|
|
2038
2031
|
* 引用页网址(用于识别从哪个页面提交的查询,从而可以返回相关的数据)
|
|
2039
2032
|
*
|
|
2040
|
-
* @generated from field: string rerefer = 9;
|
|
2033
|
+
* @generated from field: optional string rerefer = 9;
|
|
2041
2034
|
*/
|
|
2042
|
-
__publicField(this, "rerefer"
|
|
2035
|
+
__publicField(this, "rerefer");
|
|
2043
2036
|
/**
|
|
2044
|
-
* @generated from field: string site_host = 10;
|
|
2037
|
+
* @generated from field: optional string site_host = 10;
|
|
2045
2038
|
*/
|
|
2046
|
-
__publicField(this, "siteHost"
|
|
2039
|
+
__publicField(this, "siteHost");
|
|
2047
2040
|
proto3.util.initPartial(data, this);
|
|
2048
2041
|
}
|
|
2049
2042
|
static fromBinary(bytes, options) {
|
|
@@ -2062,53 +2055,17 @@ const _ListParams = class _ListParams extends Message {
|
|
|
2062
2055
|
__publicField(_ListParams, "runtime", proto3);
|
|
2063
2056
|
__publicField(_ListParams, "typeName", "sppb.ListParams");
|
|
2064
2057
|
__publicField(_ListParams, "fields", proto3.util.newFieldList(() => [
|
|
2065
|
-
{
|
|
2066
|
-
no: 1,
|
|
2067
|
-
name: "slugs",
|
|
2068
|
-
kind: "scalar",
|
|
2069
|
-
T: 9
|
|
2070
|
-
/* ScalarType.STRING */
|
|
2071
|
-
},
|
|
2058
|
+
{ no: 1, name: "slugs", kind: "scalar", T: 9, opt: true },
|
|
2072
2059
|
{ no: 2, name: "params", kind: "map", K: 9, V: {
|
|
2073
2060
|
kind: "scalar",
|
|
2074
2061
|
T: 9
|
|
2075
2062
|
/* ScalarType.STRING */
|
|
2076
2063
|
} },
|
|
2077
|
-
{ no:
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
{ no: 4, name: "pagination", kind: "message", T: Paging },
|
|
2083
|
-
{ no: 6, name: "service_tags", kind: "scalar", T: 9, repeated: true },
|
|
2084
|
-
{
|
|
2085
|
-
no: 7,
|
|
2086
|
-
name: "pre_tag_limit",
|
|
2087
|
-
kind: "scalar",
|
|
2088
|
-
T: 13
|
|
2089
|
-
/* ScalarType.UINT32 */
|
|
2090
|
-
},
|
|
2091
|
-
{
|
|
2092
|
-
no: 8,
|
|
2093
|
-
name: "cursor",
|
|
2094
|
-
kind: "scalar",
|
|
2095
|
-
T: 9
|
|
2096
|
-
/* ScalarType.STRING */
|
|
2097
|
-
},
|
|
2098
|
-
{
|
|
2099
|
-
no: 9,
|
|
2100
|
-
name: "rerefer",
|
|
2101
|
-
kind: "scalar",
|
|
2102
|
-
T: 9
|
|
2103
|
-
/* ScalarType.STRING */
|
|
2104
|
-
},
|
|
2105
|
-
{
|
|
2106
|
-
no: 10,
|
|
2107
|
-
name: "site_host",
|
|
2108
|
-
kind: "scalar",
|
|
2109
|
-
T: 9
|
|
2110
|
-
/* ScalarType.STRING */
|
|
2111
|
-
}
|
|
2064
|
+
{ no: 4, name: "pagination", kind: "message", T: Paging, opt: true },
|
|
2065
|
+
{ no: 7, name: "pre_tag_limit", kind: "scalar", T: 13, opt: true },
|
|
2066
|
+
{ no: 8, name: "cursor", kind: "scalar", T: 9, opt: true },
|
|
2067
|
+
{ no: 9, name: "rerefer", kind: "scalar", T: 9, opt: true },
|
|
2068
|
+
{ no: 10, name: "site_host", kind: "scalar", T: 9, opt: true }
|
|
2112
2069
|
]));
|
|
2113
2070
|
let ListParams = _ListParams;
|
|
2114
2071
|
const _CommontListReq = class _CommontListReq extends Message {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import React, { useEffect, useMemo } from "react";
|
|
22
|
+
import Cookies from "universal-cookie";
|
|
23
|
+
import { verifyJwtToken } from "../lib/auth/jwt";
|
|
24
|
+
function useAuth() {
|
|
25
|
+
const [auth, setAuth] = React.useState(null);
|
|
26
|
+
const getVerifiedtoken = () => __async(this, null, function* () {
|
|
27
|
+
var _a;
|
|
28
|
+
const cookies = new Cookies();
|
|
29
|
+
const token = (_a = cookies.get("token")) != null ? _a : null;
|
|
30
|
+
const verifiedToken = yield verifyJwtToken(token);
|
|
31
|
+
setAuth(verifiedToken);
|
|
32
|
+
});
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
getVerifiedtoken();
|
|
35
|
+
}, []);
|
|
36
|
+
const isAdmin = useMemo(() => {
|
|
37
|
+
return (auth == null ? void 0 : auth.role) == "admin";
|
|
38
|
+
}, [auth]);
|
|
39
|
+
return { auth, isAdmin };
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
useAuth
|
|
43
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JWTPayload } from 'jose';
|
|
2
|
+
export declare function getJwtSecretKey(): Uint8Array;
|
|
3
|
+
export interface MyJWTPayload extends JWTPayload {
|
|
4
|
+
username: string;
|
|
5
|
+
role: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function verifyJwtToken(token: string): Promise<MyJWTPayload | null>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { jwtVerify } from "jose";
|
|
22
|
+
function getJwtSecretKey() {
|
|
23
|
+
const secret = process.env.NEXT_PUBLIC_JWT_SECRET_KEY || "%SKNDJKLJDjndofbahsdfy7FT*^DASYB(Du(BSDY(FSYGDUFGLLL^#@LHKDF";
|
|
24
|
+
if (!secret) {
|
|
25
|
+
throw new Error("JWT Secret key is not matched");
|
|
26
|
+
}
|
|
27
|
+
return new TextEncoder().encode(secret);
|
|
28
|
+
}
|
|
29
|
+
function verifyJwtToken(token) {
|
|
30
|
+
return __async(this, null, function* () {
|
|
31
|
+
try {
|
|
32
|
+
const { payload } = yield jwtVerify(token, getJwtSecretKey());
|
|
33
|
+
return payload;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
console.log("verifyJwtToken error", err);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
getJwtSecretKey,
|
|
42
|
+
verifyJwtToken
|
|
43
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
4
|
+
import { atom, useAtom } from "jotai";
|
|
5
|
+
import { TailwindIndicator } from "mtxuilib/common/tailwind-indicator";
|
|
6
|
+
import { AppMetaRender } from "mtxuilib/store/AppMetaRender";
|
|
7
|
+
import { TooltipProvider } from "mtxuilib/ui/tooltip";
|
|
8
|
+
import { AppProgressBar as ProgressBar } from "next-nprogress-bar";
|
|
9
|
+
import { Toaster } from "sonner";
|
|
10
|
+
import Dash5 from "./dash5";
|
|
11
|
+
const dashLayoutNameAtom = atom("default");
|
|
12
|
+
const DashLayout = (props) => {
|
|
13
|
+
const { children } = props;
|
|
14
|
+
const [dashLayoutName, setDashLayoutName] = useAtom(dashLayoutNameAtom);
|
|
15
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16
|
+
/* @__PURE__ */ jsxs(TooltipProvider, { delayDuration: 0, children: [
|
|
17
|
+
dashLayoutName == "default" ? /* @__PURE__ */ jsx(Dash5, { children }) : /* @__PURE__ */ jsxs("div", { className: "bg-slate-300 p-2", children: [
|
|
18
|
+
/* @__PURE__ */ jsx("h1", { children: "unknow layout name" }),
|
|
19
|
+
children
|
|
20
|
+
] }),
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
ProgressBar,
|
|
23
|
+
{
|
|
24
|
+
height: "4px",
|
|
25
|
+
color: "#4934eb",
|
|
26
|
+
options: { showSpinner: false },
|
|
27
|
+
shallowRouting: true
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ jsx(ReactQueryDevtools, {}),
|
|
31
|
+
/* @__PURE__ */ jsx(Toaster, {}),
|
|
32
|
+
/* @__PURE__ */ jsx(TailwindIndicator, {})
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ jsx(AppMetaRender, {})
|
|
35
|
+
] });
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
DashLayout
|
|
39
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { MoonIcon, SunIcon } from "lucide-react";
|
|
4
|
+
import { MtLink } from "mtxuilib/common/mtlink";
|
|
5
|
+
import { Avatar, AvatarFallback, AvatarImage } from "mtxuilib/ui/avatar";
|
|
6
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
7
|
+
import { usePathname } from "next/navigation";
|
|
8
|
+
import { useAuth } from "../hooks/useAuth";
|
|
9
|
+
function UserAvatorMenus() {
|
|
10
|
+
const pathName = usePathname();
|
|
11
|
+
const auth = useAuth();
|
|
12
|
+
return /* @__PURE__ */ jsx(Fragment, { children: !auth.isAdmin ? /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `/login?next=${pathName}`, children: " login" }) : /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
13
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Avatar, { children: [
|
|
14
|
+
/* @__PURE__ */ jsx(AvatarImage, { src: "/mtm_images/placeholder-user.jpg", alt: "@siteCook" }),
|
|
15
|
+
/* @__PURE__ */ jsx(AvatarFallback, { children: "You" })
|
|
16
|
+
] }) }),
|
|
17
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56", children: [
|
|
18
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "My Account" }),
|
|
19
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
20
|
+
/* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
21
|
+
/* @__PURE__ */ jsx(MtLink, { href: "/profile", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
|
|
22
|
+
"Profile",
|
|
23
|
+
/* @__PURE__ */ jsx(DropdownMenuShortcut, { children: "\u21E7\u2318P" })
|
|
24
|
+
] }) }),
|
|
25
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
|
|
26
|
+
"Settings",
|
|
27
|
+
/* @__PURE__ */ jsx(DropdownMenuShortcut, { children: "\u2318S" })
|
|
28
|
+
] }),
|
|
29
|
+
/* @__PURE__ */ jsx(MtLink, { href: "/admin/site", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
|
|
30
|
+
"Site",
|
|
31
|
+
/* @__PURE__ */ jsx(DropdownMenuShortcut, { children: "\u2318S" })
|
|
32
|
+
] }) })
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
35
|
+
/* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
|
|
36
|
+
/* @__PURE__ */ jsx(DropdownMenuSubTrigger, { children: "Cx" }),
|
|
37
|
+
/* @__PURE__ */ jsx(DropdownMenuPortal, { children: /* @__PURE__ */ jsxs(DropdownMenuSubContent, { children: [
|
|
38
|
+
/* @__PURE__ */ jsx(MtLink, { href: "/admin/cx/config", children: /* @__PURE__ */ jsx(DropdownMenuItem, { children: "config" }) }),
|
|
39
|
+
/* @__PURE__ */ jsx(MtLink, { href: "/admin/cx/result", children: /* @__PURE__ */ jsx(DropdownMenuItem, { children: "result" }) }),
|
|
40
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {})
|
|
41
|
+
] }) })
|
|
42
|
+
] }) }),
|
|
43
|
+
/* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
|
|
44
|
+
/* @__PURE__ */ jsx(DropdownMenuSubTrigger, { children: "Blog" }),
|
|
45
|
+
/* @__PURE__ */ jsx(DropdownMenuPortal, { children: /* @__PURE__ */ jsx(DropdownMenuSubContent, { children: /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) }) })
|
|
46
|
+
] }) }),
|
|
47
|
+
/* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(DropdownMenuSub, { children: /* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(SunIcon, { className: "size-[1.2rem] rotate-0 scale-100 pr-1 transition-all dark:-rotate-90 dark:scale-0" }),
|
|
49
|
+
/* @__PURE__ */ jsx(MoonIcon, { className: "absolute size-[1.2rem] rotate-90 scale-0 pr-1 transition-all dark:rotate-0 dark:scale-100" }),
|
|
50
|
+
"theme",
|
|
51
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Toggle theme" })
|
|
52
|
+
] }) }) }),
|
|
53
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
54
|
+
/* @__PURE__ */ jsx(MtLink, { href: "/logout", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
|
|
55
|
+
"Log out",
|
|
56
|
+
/* @__PURE__ */ jsx(DropdownMenuShortcut, { children: "\u21E7\u2318Q" })
|
|
57
|
+
] }) })
|
|
58
|
+
] })
|
|
59
|
+
] }) });
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
UserAvatorMenus as default
|
|
63
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
Package2,
|
|
5
|
+
Settings
|
|
6
|
+
} from "lucide-react";
|
|
7
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "mtxuilib/ui/tooltip";
|
|
8
|
+
import Link from "next/link";
|
|
9
|
+
const Dash5Aside = () => {
|
|
10
|
+
return /* @__PURE__ */ jsxs("aside", { className: "bg-background fixed inset-y-0 left-0 z-10 hidden w-14 flex-col border-r sm:flex", children: [
|
|
11
|
+
/* @__PURE__ */ jsx("nav", { className: "flex flex-col items-center gap-4 px-2 sm:py-5", children: /* @__PURE__ */ jsxs(
|
|
12
|
+
Link,
|
|
13
|
+
{
|
|
14
|
+
href: "/dash",
|
|
15
|
+
className: "bg-primary text-primary-foreground group flex h-9 w-9 shrink-0 items-center justify-center gap-2 rounded-full text-lg font-semibold md:h-8 md:w-8 md:text-base",
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx(Package2, { className: "h-4 w-4 transition-all group-hover:scale-110" }),
|
|
18
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Acme Inc" })
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
) }),
|
|
22
|
+
/* @__PURE__ */ jsx("nav", { className: "mt-auto flex flex-col items-center gap-4 px-2 sm:py-5", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
23
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
24
|
+
Link,
|
|
25
|
+
{
|
|
26
|
+
href: "#",
|
|
27
|
+
className: "text-muted-foreground hover:text-foreground flex h-9 w-9 items-center justify-center rounded-lg transition-colors md:h-8 md:w-8",
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ jsx(Settings, { className: "h-5 w-5" }),
|
|
30
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Settings" })
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
) }),
|
|
34
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: "Settings" })
|
|
35
|
+
] }) })
|
|
36
|
+
] });
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
Dash5Aside
|
|
40
|
+
};
|