@umijs/plugins 4.0.22 → 4.0.24
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/access.js +10 -4
- package/dist/dva.js +62 -0
- package/dist/layout.js +1 -0
- package/dist/valtio.d.ts +3 -0
- package/dist/valtio.js +64 -0
- package/package.json +4 -3
package/dist/access.js
CHANGED
|
@@ -92,8 +92,14 @@ export const Access: React.FC<PropsWithChildren<AccessProps>> = (props) => {
|
|
|
92
92
|
export const useAccessMarkedRoutes = (routes: IRoute[]) => {
|
|
93
93
|
const access = useAccess();
|
|
94
94
|
const markdedRoutes: IRoute[] = React.useMemo(() => {
|
|
95
|
-
const process = (route, parentAccessCode) => {
|
|
96
|
-
|
|
95
|
+
const process = (route, parentAccessCode, parentRoute) => {
|
|
96
|
+
let accessCode = route.access;
|
|
97
|
+
// \u7528\u7236\u7EA7\u7684\u8DEF\u7531\u68C0\u6D4B\u7236\u7EA7\u7684 accessCode
|
|
98
|
+
let detectorRoute = route;
|
|
99
|
+
if (!accessCode && parentAccessCode) {
|
|
100
|
+
accessCode = parentAccessCode;
|
|
101
|
+
detectorRoute = parentRoute;
|
|
102
|
+
}
|
|
97
103
|
|
|
98
104
|
// set default status
|
|
99
105
|
route.unaccessible = ${api.config.access.strictMode ? "true" : "false"};
|
|
@@ -103,7 +109,7 @@ export const useAccessMarkedRoutes = (routes: IRoute[]) => {
|
|
|
103
109
|
const detector = access[accessCode];
|
|
104
110
|
|
|
105
111
|
if (typeof detector === 'function') {
|
|
106
|
-
route.unaccessible = !detector(
|
|
112
|
+
route.unaccessible = !detector(detectorRoute);
|
|
107
113
|
} else if (typeof detector === 'boolean') {
|
|
108
114
|
route.unaccessible = !detector;
|
|
109
115
|
} else if (typeof detector === 'undefined') {
|
|
@@ -114,7 +120,7 @@ export const useAccessMarkedRoutes = (routes: IRoute[]) => {
|
|
|
114
120
|
// check children access code
|
|
115
121
|
if (route.children?.length) {
|
|
116
122
|
const isNoAccessibleChild = !route.children.reduce((hasAccessibleChild, child) => {
|
|
117
|
-
process(child, accessCode);
|
|
123
|
+
process(child, accessCode, route);
|
|
118
124
|
|
|
119
125
|
return hasAccessibleChild || !child.unaccessible;
|
|
120
126
|
}, false);
|
package/dist/dva.js
CHANGED
|
@@ -172,6 +172,68 @@ export { connect, useDispatch, useStore, useSelector } from 'dva';
|
|
|
172
172
|
export { getDvaApp } from './dva';
|
|
173
173
|
`
|
|
174
174
|
});
|
|
175
|
+
api.writeTmpFile({
|
|
176
|
+
path: "types.d.ts",
|
|
177
|
+
tpl: `
|
|
178
|
+
import type { History } from 'umi';
|
|
179
|
+
|
|
180
|
+
export interface ConnectProps {
|
|
181
|
+
dispatch?: Dispatch;
|
|
182
|
+
}
|
|
183
|
+
type RequiredConnectProps = Required<ConnectProps>
|
|
184
|
+
export type ConnectRC<
|
|
185
|
+
T = {},
|
|
186
|
+
> = React.ForwardRefRenderFunction<any, T & RequiredConnectProps>;
|
|
187
|
+
interface Action<T = any> {
|
|
188
|
+
type: T
|
|
189
|
+
}
|
|
190
|
+
interface AnyAction extends Action {
|
|
191
|
+
// Allows any extra properties to be defined in an action.
|
|
192
|
+
[extraProps: string]: any
|
|
193
|
+
}
|
|
194
|
+
interface Dispatch<A extends Action = AnyAction> {
|
|
195
|
+
<T extends A>(action: T): T
|
|
196
|
+
}
|
|
197
|
+
interface EffectsCommandMap {
|
|
198
|
+
put: <A extends AnyAction>(action: A) => any,
|
|
199
|
+
call: Function,
|
|
200
|
+
select: Function,
|
|
201
|
+
take: Function,
|
|
202
|
+
cancel: Function,
|
|
203
|
+
[key: string]: any,
|
|
204
|
+
}
|
|
205
|
+
interface Action<T = any> {
|
|
206
|
+
type: T
|
|
207
|
+
}
|
|
208
|
+
export type Reducer<S = any, A extends Action = AnyAction> = (prevState: S, action: A) => S;
|
|
209
|
+
export type Effect = (action: AnyAction, effects: EffectsCommandMap) => void;
|
|
210
|
+
type EffectType = 'takeEvery' | 'takeLatest' | 'watcher' | 'throttle';
|
|
211
|
+
type EffectWithType = [Effect, { type: EffectType }];
|
|
212
|
+
export type Subscription = (api: SubscriptionAPI, done: Function) => void;
|
|
213
|
+
|
|
214
|
+
export interface ReducersMapObject<T> {
|
|
215
|
+
[key: string]: Reducer<T>,
|
|
216
|
+
}
|
|
217
|
+
export interface EffectsMapObject {
|
|
218
|
+
[key: string]: Effect | EffectWithType,
|
|
219
|
+
}
|
|
220
|
+
export interface SubscriptionAPI {
|
|
221
|
+
dispatch: Dispatch<any>,
|
|
222
|
+
history: History,
|
|
223
|
+
}
|
|
224
|
+
export interface SubscriptionsMapObject {
|
|
225
|
+
[key: string]: Subscription,
|
|
226
|
+
}
|
|
227
|
+
export interface DvaModel<T, E = EffectsMapObject, R = ReducersMapObject<T>> {
|
|
228
|
+
namespace: string,
|
|
229
|
+
state?: T,
|
|
230
|
+
reducers?: R,
|
|
231
|
+
effects?: E,
|
|
232
|
+
subscriptions?: SubscriptionsMapObject,
|
|
233
|
+
}
|
|
234
|
+
`,
|
|
235
|
+
context: {}
|
|
236
|
+
});
|
|
175
237
|
});
|
|
176
238
|
api.addTmpGenerateWatcherPaths(() => {
|
|
177
239
|
return [(0, import_path.join)(api.paths.absSrcPath, "models")];
|
package/dist/layout.js
CHANGED
|
@@ -181,6 +181,7 @@ const { formatMessage } = useIntl();
|
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
const matchedRoute = useMemo(() => matchRoutes(clientRoutes, location.pathname).pop()?.route, [location.pathname]);
|
|
184
|
+
// \u73B0\u5728\u7684 layout \u53CA wrapper \u5B9E\u73B0\u662F\u901A\u8FC7\u7236\u8DEF\u7531\u7684\u5F62\u5F0F\u5B9E\u73B0\u7684, \u4F1A\u5BFC\u81F4\u8DEF\u7531\u6570\u636E\u591A\u4E86\u5197\u4F59\u5C42\u7EA7, proLayout \u6D88\u8D39\u65F6, \u65E0\u6CD5\u6B63\u786E\u5C55\u793A\u83DC\u5355, \u8FD9\u91CC\u5BF9\u5197\u4F59\u6570\u636E\u8FDB\u884C\u8FC7\u6EE4\u64CD\u4F5C
|
|
184
185
|
const newRoutes = filterRoutes(clientRoutes.filter(route => route.id === 'ant-design-pro-layout'), (route) => {
|
|
185
186
|
return (!!route.isLayout && route.id !== 'ant-design-pro-layout') || !!route.isWrapper;
|
|
186
187
|
})
|
package/dist/valtio.d.ts
ADDED
package/dist/valtio.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/valtio.ts
|
|
23
|
+
var valtio_exports = {};
|
|
24
|
+
__export(valtio_exports, {
|
|
25
|
+
default: () => valtio_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(valtio_exports);
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
var import_utils = require("@umijs/utils");
|
|
30
|
+
var valtio_default = (api) => {
|
|
31
|
+
api.describe({
|
|
32
|
+
key: "valtio",
|
|
33
|
+
config: {
|
|
34
|
+
schema(joi) {
|
|
35
|
+
return joi.object();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const libPath = (0, import_utils.winPath)((0, import_path.dirname)(require.resolve("@umijs/valtio/package.json")));
|
|
40
|
+
api.onGenerateFiles(() => {
|
|
41
|
+
api.writeTmpFile({
|
|
42
|
+
path: "index.ts",
|
|
43
|
+
content: `
|
|
44
|
+
export {
|
|
45
|
+
proxy, useSnapshot, snapshot, subscribe,
|
|
46
|
+
proxyWithComputed,
|
|
47
|
+
proxyWithHistory,
|
|
48
|
+
proxyWithDevtools,
|
|
49
|
+
proxyMap,
|
|
50
|
+
proxySet,
|
|
51
|
+
} from '${libPath}';
|
|
52
|
+
`
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
api.modifyConfig((memo) => {
|
|
56
|
+
memo.alias = {
|
|
57
|
+
...memo.alias,
|
|
58
|
+
"@umijs/valtio": libPath
|
|
59
|
+
};
|
|
60
|
+
return memo;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.24",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"@ant-design/antd-theme-variable": "^1.0.0",
|
|
28
28
|
"@ant-design/icons": "^4.7.0",
|
|
29
29
|
"@ant-design/pro-components": "^2.0.1",
|
|
30
|
-
"@umijs/bundler-utils": "4.0.
|
|
30
|
+
"@umijs/bundler-utils": "4.0.24",
|
|
31
|
+
"@umijs/valtio": "^1.0.0",
|
|
31
32
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
32
33
|
"axios": "^0.27.2",
|
|
33
34
|
"babel-plugin-import": "^1.13.5",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"warning": "^4.0.3"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"umi": "4.0.
|
|
50
|
+
"umi": "4.0.24"
|
|
50
51
|
},
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|