@umijs/plugins 4.0.71 → 4.0.73

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/layout.js CHANGED
@@ -64,6 +64,8 @@ var layout_default = (api) => {
64
64
  antdVersion = require(`${pkgPath2}/package.json`).version;
65
65
  } catch (e) {
66
66
  }
67
+ const isAntd5 = antdVersion.startsWith("5");
68
+ const layoutFile = isAntd5 ? "Layout.css" : "Layout.less";
67
69
  api.describe({
68
70
  key: "layout",
69
71
  config: {
@@ -130,7 +132,7 @@ import React, { useMemo } from 'react';
130
132
  import {
131
133
  ProLayout,
132
134
  } from "${resolvedPkgPath}";
133
- import './Layout.less';
135
+ import './${layoutFile}';
134
136
  import Logo from './Logo';
135
137
  import Exception from './Exception';
136
138
  import { getRightRenderContent } from './rightRender';
@@ -517,12 +519,12 @@ export function getRightRenderContent (opts: {
517
519
  })
518
520
  });
519
521
  api.writeTmpFile({
520
- path: "Layout.less",
522
+ path: layoutFile,
521
523
  content: `
522
524
  ${// antd@5里面没有这个样式了
523
- antdVersion.startsWith("5") ? "" : "@import '~antd/es/style/themes/default.less';"}
525
+ isAntd5 ? "" : "@import '~antd/es/style/themes/default.less';"}
524
526
  @media screen and (max-width: 480px) {
525
- // 在小屏幕的时候可以有更好的体验
527
+ /* 在小屏幕的时候可以有更好的体验 */
526
528
  .umi-plugin-layout-container {
527
529
  width: 100% !important;
528
530
  }
@@ -530,13 +532,11 @@ ${// antd@5里面没有这个样式了
530
532
  border-radius: 0 !important;
531
533
  }
532
534
  }
533
- .umi-plugin-layout-menu {
534
- .anticon {
535
- margin-right: 8px;
536
- }
537
- .ant-dropdown-menu-item {
538
- min-width: 160px;
539
- }
535
+ .umi-plugin-layout-menu .anticon {
536
+ margin-right: 8px;
537
+ }
538
+ .umi-plugin-layout-menu .ant-dropdown-menu-item {
539
+ min-width: 160px;
540
540
  }
541
541
  .umi-plugin-layout-right {
542
542
  display: flex !important;
@@ -544,30 +544,30 @@ ${// antd@5里面没有这个样式了
544
544
  height: 100%;
545
545
  margin-left: auto;
546
546
  overflow: hidden;
547
- .umi-plugin-layout-action {
548
- display: flex;
549
- align-items: center;
550
- height: 100%;
551
- padding: 0 12px;
552
- cursor: pointer;
553
- transition: all 0.3s;
554
- > i {
555
- color: rgba(255, 255, 255, 0.85);
556
- vertical-align: middle;
557
- }
558
- &:hover {
559
- background: rgba(0, 0, 0, 0.025);
560
- }
561
- &:global(.opened) {
562
- background: rgba(0, 0, 0, 0.025);
563
- }
564
- }
565
- .umi-plugin-layout-search {
566
- padding: 0 12px;
567
- &:hover {
568
- background: transparent;
569
- }
570
- }
547
+ }
548
+ .umi-plugin-layout-right .umi-plugin-layout-action {
549
+ display: flex;
550
+ align-items: center;
551
+ height: 100%;
552
+ padding: 0 12px;
553
+ cursor: pointer;
554
+ transition: all 0.3s;
555
+ }
556
+ .umi-plugin-layout-right .umi-plugin-layout-action > i {
557
+ color: rgba(255, 255, 255, 0.85);
558
+ vertical-align: middle;
559
+ }
560
+ .umi-plugin-layout-right .umi-plugin-layout-action:hover {
561
+ background: rgba(0, 0, 0, 0.025);
562
+ }
563
+ .umi-plugin-layout-right .umi-plugin-layout-action.opened {
564
+ background: rgba(0, 0, 0, 0.025);
565
+ }
566
+ .umi-plugin-layout-right .umi-plugin-layout-search {
567
+ padding: 0 12px;
568
+ }
569
+ .umi-plugin-layout-right .umi-plugin-layout-search:hover {
570
+ background: transparent;
571
571
  }
572
572
  .umi-plugin-layout-name {
573
573
  margin-left: 8px;
@@ -22,8 +22,11 @@ __export(tailwindcss_exports, {
22
22
  default: () => tailwindcss_default
23
23
  });
24
24
  module.exports = __toCommonJS(tailwindcss_exports);
25
+ var import_fs = require("fs");
25
26
  var import_path = require("path");
26
27
  var import_plugin_utils = require("umi/plugin-utils");
28
+ var CHECK_INTERVAL = 300;
29
+ var CHECK_TIMEOUT_UNIT_SECOND = 5;
27
30
  var tailwindcss_default = (api) => {
28
31
  api.describe({
29
32
  key: "tailwindcss",
@@ -71,7 +74,21 @@ var tailwindcss_default = (api) => {
71
74
  });
72
75
  } else {
73
76
  api.logger.info("tailwindcss service started");
74
- resolve();
77
+ const interval = setInterval(() => {
78
+ if ((0, import_fs.existsSync)(generatedPath)) {
79
+ clearInterval(interval);
80
+ resolve();
81
+ }
82
+ }, CHECK_INTERVAL);
83
+ const timer = setTimeout(() => {
84
+ if (!(0, import_fs.existsSync)(generatedPath)) {
85
+ clearInterval(timer);
86
+ api.logger.error(
87
+ `tailwindcss generate failed after ${CHECK_TIMEOUT_UNIT_SECOND} seconds, please check your tailwind.css and tailwind.config.js`
88
+ );
89
+ process.exit(1);
90
+ }
91
+ }, CHECK_TIMEOUT_UNIT_SECOND * 1e3);
75
92
  }
76
93
  });
77
94
  });
@@ -5,8 +5,11 @@
5
5
  * @since 2019-06-20
6
6
  */
7
7
 
8
- import React, { ReactComponentElement } from 'react';
8
+ import React from 'react';
9
9
  import { Navigate, type IRouteProps } from 'umi';
10
+ import { defaultMicroAppRouteMode, MicroAppRouteMode } from './constants';
11
+ import { getMicroAppRouteComponent } from './getMicroAppRouteComponent';
12
+ import type { MicroAppRoute } from './types';
10
13
 
11
14
  export const defaultMountContainerId = 'root-subapp';
12
15
 
@@ -44,14 +47,7 @@ function testPathWithStaticPrefix(pathPrefix: string, realPath: string) {
44
47
  // }
45
48
 
46
49
  export function patchMicroAppRoute(
47
- route: any,
48
- getMicroAppRouteComponent: (opts: {
49
- appName: string;
50
- base: string;
51
- routePath: string;
52
- masterHistoryType: string;
53
- routeProps?: any;
54
- }) => string | ReactComponentElement<any>,
50
+ route: MicroAppRoute,
55
51
  masterOptions: {
56
52
  base: string;
57
53
  masterHistoryType: string;
@@ -75,8 +71,9 @@ export function patchMicroAppRoute(
75
71
  }
76
72
  }
77
73
 
78
- // 自动追加通配符,匹配子应用的路由
79
- if (!route.path.endsWith('/*')) {
74
+ const { mode = defaultMicroAppRouteMode } = route;
75
+ // 在前缀模式下,自动追加通配符,匹配子应用的路由
76
+ if (mode === MicroAppRouteMode.PREPEND && !route.path.endsWith('/*')) {
80
77
  route.path = route.path.replace(/\/?$/, '/*');
81
78
  }
82
79
 
@@ -90,6 +87,7 @@ export function patchMicroAppRoute(
90
87
  appName: microAppName,
91
88
  base,
92
89
  routePath: route.path,
90
+ routeMode: route.mode,
93
91
  masterHistoryType,
94
92
  routeProps,
95
93
  };
@@ -5,3 +5,15 @@ export const defaultMasterRootId = 'root-master';
5
5
  export const defaultHistoryType = 'browser';
6
6
  export const qiankunStateForSlaveModelNamespace = '@@qiankunStateForSlave';
7
7
  export const qiankunStateFromMasterModelNamespace = '@@qiankunStateFromMaster';
8
+ export enum MicroAppRouteMode {
9
+ /**
10
+ * 既作为匹配规则,也作为子应用 router.basename
11
+ */
12
+ PREPEND = 'prepend',
13
+ /**
14
+ * 仅作为匹配规则
15
+ */
16
+ MATCH = 'match',
17
+ }
18
+
19
+ export const defaultMicroAppRouteMode = MicroAppRouteMode.PREPEND;
@@ -1,23 +1,27 @@
1
1
  import React from 'react';
2
2
  import { useMatch } from 'umi';
3
3
  import { MicroApp } from './MicroApp';
4
+ import { defaultMicroAppRouteMode, MicroAppRouteMode } from './constants';
4
5
 
5
6
  export function getMicroAppRouteComponent(opts: {
6
7
  appName: string;
7
8
  base: string;
8
9
  routePath: string;
10
+ routeMode: MicroAppRouteMode;
9
11
  masterHistoryType: string;
10
12
  routeProps?: any;
11
13
  }) {
12
- const { base, masterHistoryType, appName, routeProps, routePath } = opts;
14
+ const { base, masterHistoryType, appName, routeProps, routePath, routeMode = defaultMicroAppRouteMode } = opts;
13
15
  const RouteComponent = () => {
14
16
  const match = useMatch(routePath);
15
17
  const url = match ? match.pathnameBase : '';
16
18
  // 默认取静态配置的 base
17
- let umiConfigBase = base === '/' ? '' : base;
19
+ let umiConfigBase = base === '/' ? '' : trimEndSlash(base);
20
+ // 匹配模式下,routePath 不会作为 prefix
21
+ const prefix = routeMode === MicroAppRouteMode.MATCH ? '' : trimEndSlash(url);
18
22
 
19
23
  // 拼接子应用挂载路由
20
- let runtimeMatchedBase = umiConfigBase + (url.endsWith('/') ? url.substr(0, url.length - 1) : url);
24
+ let runtimeMatchedBase = umiConfigBase + prefix;
21
25
 
22
26
  {{#dynamicRoot}}
23
27
  // @see https://github.com/umijs/umi/blob/master/packages/preset-built-in/src/plugins/commands/htmlUtils.ts#L102
@@ -35,3 +39,7 @@ export function getMicroAppRouteComponent(opts: {
35
39
 
36
40
  return RouteComponent;
37
41
  }
42
+
43
+ function trimEndSlash(p: string) {
44
+ return p.endsWith('/') ? p.slice(0, -1) : p;
45
+ }
@@ -5,10 +5,9 @@ import { getPluginManager } from '@@/core/plugin';
5
5
  import { prefetchApps } from 'qiankun';
6
6
  import { ApplyPluginsType } from 'umi';
7
7
  import { insertRoute, noop, patchMicroAppRoute } from './common';
8
- import { getMicroAppRouteComponent } from './getMicroAppRouteComponent';
9
8
  import { getMasterOptions, setMasterOptions } from './masterOptions';
10
- import { MasterOptions, MicroAppRoute } from './types';
11
9
  import { deepFilterLeafRoutes } from './routeUtils';
10
+ import { MasterOptions, MicroAppRoute } from './types';
12
11
 
13
12
  let microAppRuntimeRoutes: MicroAppRoute[];
14
13
 
@@ -55,9 +54,8 @@ function patchMicroAppRouteComponent(routes: any[]) {
55
54
  getMasterOptions() as MasterOptions;
56
55
  microAppRuntimeRoutes.reverse().forEach((microAppRoute) => {
57
56
  const patchRoute = (route: any) => {
58
- patchMicroAppRoute(route, getMicroAppRouteComponent, {
57
+ patchMicroAppRoute(route, {
59
58
  base,
60
- routePath: route.path,
61
59
  masterHistoryType,
62
60
  routeBindingAlias,
63
61
  });
@@ -1,6 +1,7 @@
1
1
  // @ts-nocheck
2
2
  /* eslint-disable */
3
3
  import { FrameworkConfiguration, FrameworkLifeCycles } from 'qiankun';
4
+ import type { MicroAppRouteMode } from './constants';
4
5
 
5
6
  type BaseIConfig = any;
6
7
 
@@ -18,6 +19,7 @@ export type App = {
18
19
  export type MicroAppRoute = {
19
20
  path: string;
20
21
  microApp: string;
22
+ mode: `${MicroAppRouteMode}`;
21
23
  } & Record<string, any>;
22
24
 
23
25
  export type MasterOptions = {
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
- import qiankunRender, { contextOptsStack } from './lifecycles';
3
2
  import { createHistory } from '@@/core/history';
3
+ import qiankunRender, { contextOptsStack } from './lifecycles';
4
4
 
5
5
  export function render(oldRender: any) {
6
6
  return qiankunRender().then(oldRender);
@@ -11,7 +11,9 @@ export function modifyClientRenderOpts(memo: any) {
11
11
  const clientRenderOpts = contextOptsStack.shift();
12
12
  const { basename, historyType } = memo;
13
13
 
14
- const newBasename = clientRenderOpts?.basename || basename;
14
+ // use ?? instead of ||, incase clientRenderOpts.basename is ''
15
+ // only break when microApp has a config.base and mount path is /*
16
+ const newBasename = clientRenderOpts?.basename ?? basename;
15
17
  const newHistoryType = clientRenderOpts?.historyType || historyType;
16
18
 
17
19
  if (newHistoryType !== historyType || newBasename !== basename) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.71",
3
+ "version": "4.0.73",
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",
@@ -44,12 +44,12 @@
44
44
  "styled-components": "6.0.0-rc.0",
45
45
  "tslib": "^2",
46
46
  "warning": "^4.0.3",
47
- "@umijs/valtio": "1.0.3",
48
- "@umijs/bundler-utils": "4.0.71"
47
+ "@umijs/bundler-utils": "4.0.73",
48
+ "@umijs/valtio": "1.0.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "antd": "^4.24.1",
52
- "umi": "4.0.71"
52
+ "umi": "4.0.73"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"