@vef-framework/starter 1.0.121 → 1.0.123
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/cjs/api.cjs +17 -0
- package/cjs/app.cjs +27 -0
- package/cjs/components/index.cjs +20 -0
- package/cjs/components/vef-access-denied-page/index.cjs +27 -0
- package/cjs/components/vef-access-denied-page/props.cjs +4 -0
- package/cjs/components/vef-app/index.cjs +19 -0
- package/cjs/components/vef-app/props.cjs +4 -0
- package/cjs/components/vef-dev-assistant/index.cjs +159 -0
- package/cjs/components/vef-dev-assistant/props.cjs +4 -0
- package/cjs/components/vef-error-page/index.cjs +24 -0
- package/cjs/components/vef-error-page/props.cjs +4 -0
- package/cjs/components/vef-login-page/index.cjs +41 -0
- package/cjs/components/vef-login-page/props.cjs +4 -0
- package/cjs/components/vef-not-found-page/index.cjs +26 -0
- package/cjs/components/vef-not-found-page/props.cjs +4 -0
- package/cjs/components/vef-router-provider/index.cjs +22 -0
- package/cjs/components/vef-router-provider/props.cjs +4 -0
- package/cjs/constants.cjs +17 -0
- package/cjs/helper.cjs +22 -0
- package/cjs/index.cjs +47 -0
- package/cjs/router.cjs +72 -0
- package/cjs/routes/access-denied.cjs +14 -0
- package/cjs/routes/index.cjs +14 -0
- package/cjs/routes/layout.cjs +136 -0
- package/cjs/routes/login.cjs +31 -0
- package/cjs/routes/root.cjs +24 -0
- package/cjs/store.cjs +21 -0
- package/esm/api.js +15 -0
- package/esm/app.js +25 -0
- package/esm/components/index.js +10 -0
- package/esm/components/vef-access-denied-page/index.js +23 -0
- package/esm/components/vef-access-denied-page/props.js +2 -0
- package/esm/components/vef-app/index.js +15 -0
- package/esm/components/vef-app/props.js +2 -0
- package/esm/components/vef-dev-assistant/index.js +155 -0
- package/esm/components/vef-dev-assistant/props.js +2 -0
- package/esm/components/vef-error-page/index.js +20 -0
- package/esm/components/vef-error-page/props.js +2 -0
- package/esm/components/vef-login-page/index.js +37 -0
- package/esm/components/vef-login-page/props.js +2 -0
- package/esm/components/vef-not-found-page/index.js +22 -0
- package/esm/components/vef-not-found-page/props.js +2 -0
- package/esm/components/vef-router-provider/index.js +18 -0
- package/esm/components/vef-router-provider/props.js +2 -0
- package/esm/constants.js +10 -0
- package/esm/helper.js +20 -0
- package/esm/index.js +22 -0
- package/esm/router.js +70 -0
- package/esm/routes/access-denied.js +12 -0
- package/esm/routes/index.js +7 -0
- package/esm/routes/layout.js +134 -0
- package/esm/routes/login.js +29 -0
- package/esm/routes/root.js +22 -0
- package/esm/store.js +19 -0
- package/package.json +17 -16
- package/es/api.js +0 -1
- package/es/app.js +0 -1
- package/es/components/index.js +0 -1
- package/es/components/vef-access-denied-page/index.js +0 -1
- package/es/components/vef-app/index.js +0 -1
- package/es/components/vef-dev-assistant/index.js +0 -30
- package/es/components/vef-error-page/index.js +0 -1
- package/es/components/vef-login-page/index.js +0 -1
- package/es/components/vef-not-found-page/index.js +0 -1
- package/es/components/vef-router-provider/index.js +0 -1
- package/es/constants.js +0 -1
- package/es/helper.js +0 -1
- package/es/index.js +0 -1
- package/es/router.js +0 -1
- package/es/routes/access-denied.js +0 -1
- package/es/routes/index.js +0 -1
- package/es/routes/layout.js +0 -1
- package/es/routes/login.js +0 -1
- package/es/routes/root.js +0 -1
- package/es/store.js +0 -1
- package/lib/api.cjs +0 -1
- package/lib/app.cjs +0 -1
- package/lib/components/index.cjs +0 -1
- package/lib/components/vef-access-denied-page/index.cjs +0 -1
- package/lib/components/vef-access-denied-page/props.cjs +0 -1
- package/lib/components/vef-app/index.cjs +0 -1
- package/lib/components/vef-app/props.cjs +0 -1
- package/lib/components/vef-dev-assistant/index.cjs +0 -30
- package/lib/components/vef-dev-assistant/props.cjs +0 -1
- package/lib/components/vef-error-page/index.cjs +0 -1
- package/lib/components/vef-error-page/props.cjs +0 -1
- package/lib/components/vef-login-page/index.cjs +0 -1
- package/lib/components/vef-login-page/props.cjs +0 -1
- package/lib/components/vef-not-found-page/index.cjs +0 -1
- package/lib/components/vef-not-found-page/props.cjs +0 -1
- package/lib/components/vef-router-provider/index.cjs +0 -1
- package/lib/components/vef-router-provider/props.cjs +0 -1
- package/lib/constants.cjs +0 -1
- package/lib/helper.cjs +0 -1
- package/lib/index.cjs +0 -1
- package/lib/router.cjs +0 -1
- package/lib/routes/access-denied.cjs +0 -1
- package/lib/routes/index.cjs +0 -1
- package/lib/routes/layout.cjs +0 -1
- package/lib/routes/login.cjs +0 -1
- package/lib/routes/root.cjs +0 -1
- package/lib/store.cjs +0 -1
package/cjs/api.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var core = require('@vef-framework/core');
|
|
5
|
+
var store = require('./store.cjs');
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
function createApiClient(options) {
|
|
9
|
+
return core.createApiClient({
|
|
10
|
+
...options,
|
|
11
|
+
getAccessToken() {
|
|
12
|
+
return store.useAppStore.getState().token?.accessToken;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.createApiClient = createApiClient;
|
package/cjs/app.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var client = require('react-dom/client');
|
|
6
|
+
require('./components/index.cjs');
|
|
7
|
+
var index = require('./components/vef-app/index.cjs');
|
|
8
|
+
|
|
9
|
+
"use strict";
|
|
10
|
+
function createApp() {
|
|
11
|
+
const root = client.createRoot(
|
|
12
|
+
document.getElementById("root"),
|
|
13
|
+
{
|
|
14
|
+
identifierPrefix: "vef-"
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
return {
|
|
18
|
+
render: (props) => {
|
|
19
|
+
root.render(
|
|
20
|
+
react.createElement(index.default, props)
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
unmount: () => root.unmount()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.createApp = createApp;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var index = require('./vef-access-denied-page/index.cjs');
|
|
5
|
+
var index$1 = require('./vef-app/index.cjs');
|
|
6
|
+
var index$2 = require('./vef-dev-assistant/index.cjs');
|
|
7
|
+
var index$3 = require('./vef-error-page/index.cjs');
|
|
8
|
+
var index$4 = require('./vef-login-page/index.cjs');
|
|
9
|
+
var index$5 = require('./vef-not-found-page/index.cjs');
|
|
10
|
+
var index$6 = require('./vef-router-provider/index.cjs');
|
|
11
|
+
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
exports.VefAccessDeniedPage = index.default;
|
|
15
|
+
exports.VefApp = index$1.default;
|
|
16
|
+
exports.VefDevAssistant = index$2.default;
|
|
17
|
+
exports.VefErrorPage = index$3.default;
|
|
18
|
+
exports.VefLoginPage = index$4.default;
|
|
19
|
+
exports.VefNotFoundPage = index$5.default;
|
|
20
|
+
exports.VefRouterProvider = index$6.default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
7
|
+
var reactRouter = require('@tanstack/react-router');
|
|
8
|
+
var components = require('@vef-framework/components');
|
|
9
|
+
var react = require('react');
|
|
10
|
+
var constants = require('../../constants.cjs');
|
|
11
|
+
|
|
12
|
+
"use strict";
|
|
13
|
+
function VefAccessDeniedPage(props) {
|
|
14
|
+
const { pathname } = reactRouter.useLocation();
|
|
15
|
+
const { redirect } = reactRouter.useRouterState();
|
|
16
|
+
const navigate = reactRouter.useNavigate();
|
|
17
|
+
const handleNavigateHome = react.useCallback(
|
|
18
|
+
() => navigate({
|
|
19
|
+
to: constants.INDEX_PAGE_PATH,
|
|
20
|
+
replace: true
|
|
21
|
+
}),
|
|
22
|
+
[navigate]
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsx(components.VefAccessDenied, { uri: redirect?._fromLocation?.pathname ?? pathname, onNavigateHome: handleNavigateHome, ...props });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.default = VefAccessDeniedPage;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
7
|
+
var components = require('@vef-framework/components');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
var index = require('../vef-router-provider/index.cjs');
|
|
10
|
+
|
|
11
|
+
"use strict";
|
|
12
|
+
function VefApp({
|
|
13
|
+
router,
|
|
14
|
+
...configProviderProps
|
|
15
|
+
}) {
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.StrictMode, { children: /* @__PURE__ */ jsxRuntime.jsx(components.VefConfigProvider, { ...configProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { router }) }) });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.default = VefApp;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
7
|
+
var react = require('@emotion/react');
|
|
8
|
+
var components = require('@vef-framework/components');
|
|
9
|
+
var hooks = require('@vef-framework/hooks');
|
|
10
|
+
var shared = require('@vef-framework/shared');
|
|
11
|
+
var lucideReact = require('lucide-react');
|
|
12
|
+
var react$2 = require('motion/react');
|
|
13
|
+
var react$1 = require('react');
|
|
14
|
+
|
|
15
|
+
"use strict";
|
|
16
|
+
const devtoolsContainerStyle = react.css`
|
|
17
|
+
position: fixed;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 600px;
|
|
21
|
+
z-index: 2;
|
|
22
|
+
|
|
23
|
+
.tsqd-text-logo-container {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.TanStackRouterDevtoolsPanel {
|
|
28
|
+
> button {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
> div:first-of-type {
|
|
33
|
+
> div:first-of-type {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
> div {
|
|
39
|
+
padding: ${shared.themeVariables.paddingSm};
|
|
40
|
+
scrollbar-width: thin;
|
|
41
|
+
scrollbar-color: #334155 transparent;
|
|
42
|
+
box-shadow: ${shared.themeVariables.boxShadowDrawerDown};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
function IconCoffee(props) {
|
|
47
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { height: 24, viewBox: "0 0 24 24", width: 24, xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
48
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M17 14v4c0 1.66 -1.34 3 -3 3h-6c-1.66 0 -3 -1.34 -3 -3v-4Z", fill: "currentColor", fillOpacity: 0, children: /* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "fill-opacity", begin: "0.8s", dur: "0.5s", fill: "freeze", values: "0;1" }) }),
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsxs("g", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, children: [
|
|
50
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M17 9v9c0 1.66 -1.34 3 -3 3h-6c-1.66 0 -3 -1.34 -3 -3v-9Z", strokeDasharray: 48, strokeDashoffset: 48, children: /* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "stroke-dashoffset", dur: "0.6s", fill: "freeze", values: "48;0" }) }),
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M17 9h3c0.55 0 1 0.45 1 1v3c0 0.55 -0.45 1 -1 1h-3", strokeDasharray: 14, strokeDashoffset: 14, children: /* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "stroke-dashoffset", begin: "0.6s", dur: "0.2s", fill: "freeze", values: "14;0" }) }),
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx("mask", { id: "lineMdCoffeeHalfEmptyFilledLoop0", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 0c0 2-2 2-2 4s2 2 2 4-2 2-2 4 2 2 2 4M12 0c0 2-2 2-2 4s2 2 2 4-2 2-2 4 2 2 2 4M16 0c0 2-2 2-2 4s2 2 2 4-2 2-2 4 2 2 2 4", stroke: "#fff", children: /* @__PURE__ */ jsxRuntime.jsx("animateMotion", { calcMode: "linear", dur: "3s", path: "M0 0v-8", repeatCount: "indefinite" }) }) }),
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsxs("rect", { fill: "currentColor", height: 0, mask: "url(#lineMdCoffeeHalfEmptyFilledLoop0)", width: 24, y: 7, children: [
|
|
54
|
+
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "y", begin: "0.8s", dur: "0.6s", fill: "freeze", values: "7;2" }),
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "height", begin: "0.8s", dur: "0.6s", fill: "freeze", values: "0;5" })
|
|
56
|
+
] })
|
|
57
|
+
] })
|
|
58
|
+
] });
|
|
59
|
+
}
|
|
60
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
61
|
+
const RouterDevtools = isDev ? react$1.lazy(() => import('@tanstack/router-devtools').then((mod) => ({
|
|
62
|
+
default: mod.TanStackRouterDevtoolsPanel
|
|
63
|
+
}))) : () => null;
|
|
64
|
+
const QueryDevtools = isDev ? react$1.lazy(() => import('@tanstack/react-query-devtools').then((mod) => ({
|
|
65
|
+
default: mod.ReactQueryDevtoolsPanel
|
|
66
|
+
}))) : () => null;
|
|
67
|
+
const variants = {
|
|
68
|
+
opened: {
|
|
69
|
+
opacity: 1,
|
|
70
|
+
y: 0,
|
|
71
|
+
transition: {
|
|
72
|
+
type: "spring",
|
|
73
|
+
bounce: 0,
|
|
74
|
+
duration: 0.2
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
closed: {
|
|
78
|
+
opacity: 0,
|
|
79
|
+
y: "50%"
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
function VefDevAssistant() {
|
|
83
|
+
const [visibleDevtools, setVisibleDevtools] = react$1.useState(null);
|
|
84
|
+
const handleShowQueryDevtools = react$1.useCallback((event) => {
|
|
85
|
+
event.stopPropagation();
|
|
86
|
+
setVisibleDevtools((visible) => visible === "query" ? null : "query");
|
|
87
|
+
}, []);
|
|
88
|
+
const handleShowRouterDevtools = react$1.useCallback((event) => {
|
|
89
|
+
event.stopPropagation();
|
|
90
|
+
setVisibleDevtools((visible) => visible === "router" ? null : "router");
|
|
91
|
+
}, []);
|
|
92
|
+
hooks.useKeyPress("esc", () => {
|
|
93
|
+
if (visibleDevtools) {
|
|
94
|
+
setVisibleDevtools(null);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
98
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
99
|
+
components.VefFloatButtonGroup,
|
|
100
|
+
{
|
|
101
|
+
collapsable: true,
|
|
102
|
+
shape: "square",
|
|
103
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(components.VefIcon, { size: "huge", children: /* @__PURE__ */ jsxRuntime.jsx(IconCoffee, {}) }),
|
|
104
|
+
onClick: (event) => event.stopPropagation(),
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
+
components.VefFloatButton,
|
|
108
|
+
{
|
|
109
|
+
tip: "API调试控制台",
|
|
110
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(components.VefIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CompassIcon, {}) }),
|
|
111
|
+
onClick: handleShowQueryDevtools
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
115
|
+
components.VefFloatButton,
|
|
116
|
+
{
|
|
117
|
+
tip: "路由调试控制台",
|
|
118
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(components.VefIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SendIcon, {}) }),
|
|
119
|
+
onClick: handleShowRouterDevtools
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react$2.AnimatePresence, { mode: "wait", children: [
|
|
126
|
+
visibleDevtools === "query" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
127
|
+
react$2.motion.div,
|
|
128
|
+
{
|
|
129
|
+
animate: "opened",
|
|
130
|
+
css: devtoolsContainerStyle,
|
|
131
|
+
exit: "closed",
|
|
132
|
+
initial: "closed",
|
|
133
|
+
variants,
|
|
134
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(components.VefLoadingPlaceholder, {}), children: /* @__PURE__ */ jsxRuntime.jsx(QueryDevtools, { style: { height: "100%" } }) })
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
visibleDevtools === "router" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
138
|
+
react$2.motion.div,
|
|
139
|
+
{
|
|
140
|
+
animate: "opened",
|
|
141
|
+
css: devtoolsContainerStyle,
|
|
142
|
+
exit: "closed",
|
|
143
|
+
initial: "closed",
|
|
144
|
+
variants,
|
|
145
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(components.VefLoadingPlaceholder, {}), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
146
|
+
RouterDevtools,
|
|
147
|
+
{
|
|
148
|
+
isOpen: visibleDevtools === "router",
|
|
149
|
+
setIsOpen: shared.noop,
|
|
150
|
+
style: { height: "100%" }
|
|
151
|
+
}
|
|
152
|
+
) })
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] })
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
exports.default = VefDevAssistant;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
7
|
+
var components = require('@vef-framework/components');
|
|
8
|
+
var core = require('@vef-framework/core');
|
|
9
|
+
var react = require('react');
|
|
10
|
+
|
|
11
|
+
"use strict";
|
|
12
|
+
function VefErrorPage({
|
|
13
|
+
error,
|
|
14
|
+
info,
|
|
15
|
+
reset
|
|
16
|
+
}) {
|
|
17
|
+
const { reset: resetQueryError } = core.useQueryErrorResetBoundary();
|
|
18
|
+
react.useEffect(() => {
|
|
19
|
+
resetQueryError();
|
|
20
|
+
}, [resetQueryError]);
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx(components.VefError, { componentStack: info?.componentStack, error, reset });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.default = VefErrorPage;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
7
|
+
var reactRouter = require('@tanstack/react-router');
|
|
8
|
+
var components = require('@vef-framework/components');
|
|
9
|
+
var constants = require('../../constants.cjs');
|
|
10
|
+
var store = require('../../store.cjs');
|
|
11
|
+
|
|
12
|
+
"use strict";
|
|
13
|
+
function VefLoginPage(props) {
|
|
14
|
+
const router = reactRouter.useRouter();
|
|
15
|
+
const navigate = reactRouter.useNavigate();
|
|
16
|
+
const { redirect } = reactRouter.useSearch({
|
|
17
|
+
from: constants.LOGIN_PAGE_ROUTE
|
|
18
|
+
});
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
20
|
+
components.VefLogin,
|
|
21
|
+
{
|
|
22
|
+
onLoginSuccess: async ({ accessToken, refreshToken }) => {
|
|
23
|
+
store.useAppStore.setState({
|
|
24
|
+
isAuthenticated: true,
|
|
25
|
+
token: Object.freeze({
|
|
26
|
+
accessToken,
|
|
27
|
+
refreshToken
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
await router.invalidate();
|
|
31
|
+
await navigate({
|
|
32
|
+
to: redirect,
|
|
33
|
+
replace: true
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
...props
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.default = VefLoginPage;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
7
|
+
var reactRouter = require('@tanstack/react-router');
|
|
8
|
+
var components = require('@vef-framework/components');
|
|
9
|
+
var react = require('react');
|
|
10
|
+
var constants = require('../../constants.cjs');
|
|
11
|
+
|
|
12
|
+
"use strict";
|
|
13
|
+
function VefNotFoundPage() {
|
|
14
|
+
const navigate = reactRouter.useNavigate();
|
|
15
|
+
const handleNavigateHome = react.useCallback(
|
|
16
|
+
() => navigate({
|
|
17
|
+
to: constants.INDEX_PAGE_PATH,
|
|
18
|
+
replace: true
|
|
19
|
+
}),
|
|
20
|
+
[navigate]
|
|
21
|
+
);
|
|
22
|
+
const { pathname } = reactRouter.useLocation();
|
|
23
|
+
return /* @__PURE__ */ jsxRuntime.jsx(components.VefNotFound, { uri: pathname, onNavigateHome: handleNavigateHome });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.default = VefNotFoundPage;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
7
|
+
var reactRouter = require('@tanstack/react-router');
|
|
8
|
+
var core = require('@vef-framework/core');
|
|
9
|
+
var react = require('react');
|
|
10
|
+
|
|
11
|
+
"use strict";
|
|
12
|
+
function VefRouterProvider({
|
|
13
|
+
router
|
|
14
|
+
}) {
|
|
15
|
+
const { fetchAuthenticatedUserApi } = core.useApiContext();
|
|
16
|
+
const context = react.useMemo(() => ({
|
|
17
|
+
fetchAuthenticatedUserApi
|
|
18
|
+
}), [fetchAuthenticatedUserApi]);
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouter.RouterProvider, { context, router });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.default = VefRouterProvider;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
"use strict";
|
|
5
|
+
const LOGIN_PAGE_PATH = "/login";
|
|
6
|
+
const LOGIN_PAGE_ROUTE = "/_common/login";
|
|
7
|
+
const INDEX_PAGE_PATH = "/";
|
|
8
|
+
const INDEX_PAGE_ROUTE = "/_layout";
|
|
9
|
+
const ACCESS_DENIED_PAGE_PATH = "/access-denied";
|
|
10
|
+
const ACCESS_DENIED_PAGE_ROUTE = "/_common/access-denied";
|
|
11
|
+
|
|
12
|
+
exports.ACCESS_DENIED_PAGE_PATH = ACCESS_DENIED_PAGE_PATH;
|
|
13
|
+
exports.ACCESS_DENIED_PAGE_ROUTE = ACCESS_DENIED_PAGE_ROUTE;
|
|
14
|
+
exports.INDEX_PAGE_PATH = INDEX_PAGE_PATH;
|
|
15
|
+
exports.INDEX_PAGE_ROUTE = INDEX_PAGE_ROUTE;
|
|
16
|
+
exports.LOGIN_PAGE_PATH = LOGIN_PAGE_PATH;
|
|
17
|
+
exports.LOGIN_PAGE_ROUTE = LOGIN_PAGE_ROUTE;
|
package/cjs/helper.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var constants = require('./constants.cjs');
|
|
5
|
+
var store = require('./store.cjs');
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
async function handleClientLogout(router, fetchAuthenticatedUserApi) {
|
|
9
|
+
await fetchAuthenticatedUserApi.invalidateQueries();
|
|
10
|
+
store.useAppStore.setState(
|
|
11
|
+
{
|
|
12
|
+
isAuthenticated: false
|
|
13
|
+
},
|
|
14
|
+
true
|
|
15
|
+
);
|
|
16
|
+
await router.invalidate();
|
|
17
|
+
await router.navigate({
|
|
18
|
+
to: constants.LOGIN_PAGE_PATH
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.handleClientLogout = handleClientLogout;
|
package/cjs/index.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var api = require('./api.cjs');
|
|
5
|
+
var app = require('./app.cjs');
|
|
6
|
+
require('./components/index.cjs');
|
|
7
|
+
var constants = require('./constants.cjs');
|
|
8
|
+
var helper = require('./helper.cjs');
|
|
9
|
+
var router = require('./router.cjs');
|
|
10
|
+
require('./routes/index.cjs');
|
|
11
|
+
var store = require('./store.cjs');
|
|
12
|
+
var index = require('./components/vef-access-denied-page/index.cjs');
|
|
13
|
+
var index$1 = require('./components/vef-app/index.cjs');
|
|
14
|
+
var index$2 = require('./components/vef-dev-assistant/index.cjs');
|
|
15
|
+
var index$3 = require('./components/vef-error-page/index.cjs');
|
|
16
|
+
var index$4 = require('./components/vef-login-page/index.cjs');
|
|
17
|
+
var index$5 = require('./components/vef-not-found-page/index.cjs');
|
|
18
|
+
var index$6 = require('./components/vef-router-provider/index.cjs');
|
|
19
|
+
var accessDenied = require('./routes/access-denied.cjs');
|
|
20
|
+
var layout = require('./routes/layout.cjs');
|
|
21
|
+
var login = require('./routes/login.cjs');
|
|
22
|
+
var root = require('./routes/root.cjs');
|
|
23
|
+
|
|
24
|
+
"use strict";
|
|
25
|
+
|
|
26
|
+
exports.createApiClient = api.createApiClient;
|
|
27
|
+
exports.createApp = app.createApp;
|
|
28
|
+
exports.ACCESS_DENIED_PAGE_PATH = constants.ACCESS_DENIED_PAGE_PATH;
|
|
29
|
+
exports.ACCESS_DENIED_PAGE_ROUTE = constants.ACCESS_DENIED_PAGE_ROUTE;
|
|
30
|
+
exports.INDEX_PAGE_PATH = constants.INDEX_PAGE_PATH;
|
|
31
|
+
exports.INDEX_PAGE_ROUTE = constants.INDEX_PAGE_ROUTE;
|
|
32
|
+
exports.LOGIN_PAGE_PATH = constants.LOGIN_PAGE_PATH;
|
|
33
|
+
exports.LOGIN_PAGE_ROUTE = constants.LOGIN_PAGE_ROUTE;
|
|
34
|
+
exports.handleClientLogout = helper.handleClientLogout;
|
|
35
|
+
exports.createRouter = router.createRouter;
|
|
36
|
+
exports.useAppStore = store.useAppStore;
|
|
37
|
+
exports.VefAccessDeniedPage = index.default;
|
|
38
|
+
exports.VefApp = index$1.default;
|
|
39
|
+
exports.VefDevAssistant = index$2.default;
|
|
40
|
+
exports.VefErrorPage = index$3.default;
|
|
41
|
+
exports.VefLoginPage = index$4.default;
|
|
42
|
+
exports.VefNotFoundPage = index$5.default;
|
|
43
|
+
exports.VefRouterProvider = index$6.default;
|
|
44
|
+
exports.createAccessDeniedRouteOptions = accessDenied.createAccessDeniedRouteOptions;
|
|
45
|
+
exports.createLayoutRouteOptions = layout.createLayoutRouteOptions;
|
|
46
|
+
exports.createLoginRouteOptions = login.createLoginRouteOptions;
|
|
47
|
+
exports.createRootRoute = root.createRootRoute;
|
package/cjs/router.cjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var reactRouter = require('@tanstack/react-router');
|
|
5
|
+
var components = require('@vef-framework/components');
|
|
6
|
+
var shared = require('@vef-framework/shared');
|
|
7
|
+
var NProgress = require('nprogress');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
|
|
10
|
+
"use strict";
|
|
11
|
+
const defaultGcTime = 10 * 60 * 1e3;
|
|
12
|
+
function createRouter({
|
|
13
|
+
routeTree,
|
|
14
|
+
history
|
|
15
|
+
}) {
|
|
16
|
+
const router = reactRouter.createRouter({
|
|
17
|
+
routeTree,
|
|
18
|
+
trailingSlash: "never",
|
|
19
|
+
caseSensitive: true,
|
|
20
|
+
history: history === "hash" ? reactRouter.createHashHistory() : reactRouter.createBrowserHistory(),
|
|
21
|
+
search: {
|
|
22
|
+
strict: true
|
|
23
|
+
},
|
|
24
|
+
notFoundMode: "root",
|
|
25
|
+
defaultPendingComponent: () => react.createElement(
|
|
26
|
+
components.VefLoadingPlaceholder,
|
|
27
|
+
{
|
|
28
|
+
size: "large"
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
defaultPendingMs: 500,
|
|
32
|
+
defaultPendingMinMs: 300,
|
|
33
|
+
defaultSsr: false,
|
|
34
|
+
defaultStructuralSharing: true,
|
|
35
|
+
defaultHashScrollIntoView: {
|
|
36
|
+
behavior: "smooth",
|
|
37
|
+
block: "start",
|
|
38
|
+
inline: "center"
|
|
39
|
+
},
|
|
40
|
+
defaultPreload: "intent",
|
|
41
|
+
defaultPreloadDelay: 50,
|
|
42
|
+
defaultPreloadGcTime: defaultGcTime,
|
|
43
|
+
defaultGcTime,
|
|
44
|
+
defaultOnCatch(error, errorInfo) {
|
|
45
|
+
shared.showErrorNotification(
|
|
46
|
+
error.message || error.name,
|
|
47
|
+
react.createElement(
|
|
48
|
+
components.VefText,
|
|
49
|
+
{
|
|
50
|
+
color: "error",
|
|
51
|
+
children: react.createElement("pre", {
|
|
52
|
+
style: {
|
|
53
|
+
maxHeight: "480px",
|
|
54
|
+
overflowY: "auto",
|
|
55
|
+
scrollbarWidth: "thin",
|
|
56
|
+
scrollbarColor: "rgba(0, 0, 0, 0.2) transparent"
|
|
57
|
+
},
|
|
58
|
+
children: error.stack || errorInfo.componentStack || "No stack trace available"
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
router.subscribe("onBeforeLoad", ({ pathChanged }) => pathChanged && NProgress.start());
|
|
66
|
+
router.subscribe("onLoad", () => {
|
|
67
|
+
NProgress.done();
|
|
68
|
+
});
|
|
69
|
+
return router;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
exports.createRouter = createRouter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
require('../components/index.cjs');
|
|
5
|
+
var index = require('../components/vef-access-denied-page/index.cjs');
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
function createAccessDeniedRouteOptions() {
|
|
9
|
+
return {
|
|
10
|
+
component: index.default
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.createAccessDeniedRouteOptions = createAccessDeniedRouteOptions;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var accessDenied = require('./access-denied.cjs');
|
|
5
|
+
var layout = require('./layout.cjs');
|
|
6
|
+
var login = require('./login.cjs');
|
|
7
|
+
var root = require('./root.cjs');
|
|
8
|
+
|
|
9
|
+
"use strict";
|
|
10
|
+
|
|
11
|
+
exports.createAccessDeniedRouteOptions = accessDenied.createAccessDeniedRouteOptions;
|
|
12
|
+
exports.createLayoutRouteOptions = layout.createLayoutRouteOptions;
|
|
13
|
+
exports.createLoginRouteOptions = login.createLoginRouteOptions;
|
|
14
|
+
exports.createRootRoute = root.createRootRoute;
|