@umijs/plugins 4.0.0-canary.20230629.2 → 4.0.0-canary.20230724.1

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;
@@ -7,6 +7,7 @@
7
7
 
8
8
  import React from 'react';
9
9
  import { Navigate, type IRouteProps } from 'umi';
10
+ import { defaultMicroAppRouteMode, MicroAppRouteMode } from './constants';
10
11
  import { getMicroAppRouteComponent } from './getMicroAppRouteComponent';
11
12
  import type { MicroAppRoute } from './types';
12
13
 
@@ -70,8 +71,9 @@ export function patchMicroAppRoute(
70
71
  }
71
72
  }
72
73
 
74
+ const { mode = defaultMicroAppRouteMode } = route;
73
75
  // 在前缀模式下,自动追加通配符,匹配子应用的路由
74
- if (route.mode === 'prepend' && !route.path.endsWith('/*')) {
76
+ if (mode === MicroAppRouteMode.PREPEND && !route.path.endsWith('/*')) {
75
77
  route.path = route.path.replace(/\/?$/, '/*');
76
78
  }
77
79
 
@@ -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,24 @@
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;
9
- routeMode: 'match' | 'prepend';
10
+ routeMode: MicroAppRouteMode;
10
11
  masterHistoryType: string;
11
12
  routeProps?: any;
12
13
  }) {
13
- const { base, masterHistoryType, appName, routeProps, routePath, routeMode = 'prepend' } = opts;
14
+ const { base, masterHistoryType, appName, routeProps, routePath, routeMode = defaultMicroAppRouteMode } = opts;
14
15
  const RouteComponent = () => {
15
16
  const match = useMatch(routePath);
16
17
  const url = match ? match.pathnameBase : '';
17
18
  // 默认取静态配置的 base
18
19
  let umiConfigBase = base === '/' ? '' : base;
19
20
  // 匹配模式下,routePath 不会作为 prefix
20
- const prefix = routeMode === 'match' ? '' : (url.endsWith('/') ? url.substr(0, url.length - 1) : url);
21
+ const prefix = routeMode === MicroAppRouteMode.MATCH ? '' : (url.endsWith('/') ? url.substr(0, url.length - 1) : url);
21
22
 
22
23
  // 拼接子应用挂载路由
23
24
  let runtimeMatchedBase = umiConfigBase + prefix;
@@ -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,11 +19,7 @@ export type App = {
18
19
  export type MicroAppRoute = {
19
20
  path: string;
20
21
  microApp: string;
21
- /**
22
- * prepend 既作为匹配规则,也作为子应用 router.basename
23
- * match 仅作为匹配规则
24
- */
25
- mode: 'match' | 'prepend';
22
+ mode: `${MicroAppRouteMode}`;
26
23
  } & Record<string, any>;
27
24
 
28
25
  export type MasterOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.0-canary.20230629.2",
3
+ "version": "4.0.0-canary.20230724.1",
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.0-canary.20230629.2"
47
+ "@umijs/bundler-utils": "4.0.0-canary.20230724.1",
48
+ "@umijs/valtio": "1.0.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "antd": "^4.24.1",
52
- "umi": "4.0.0-canary.20230629.2"
52
+ "umi": "4.0.0-canary.20230724.1"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"