@cfmm/umi-plugins-ui-v2 0.0.30 → 0.0.32

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.
@@ -35,7 +35,7 @@ const ENV_TAG_COLOR: GlobalHeaderProps['ENVTagColor'] = {
35
35
  * 全局头部组件
36
36
  */
37
37
  const GlobalHeader: React.FC<GlobalHeaderProps> = (props) => {
38
- const { replaceItems, insertItems, ENVTagColor = ENV_TAG_COLOR } = props;
38
+ const { replaceItems, insertItems, ENVTagColor = ENV_TAG_COLOR, themeSwitchProps } = props;
39
39
 
40
40
  const { setIsDarkTheme, templateDownloadModalOpenChange } = useModel('global');
41
41
 
@@ -236,7 +236,7 @@ const GlobalHeader: React.FC<GlobalHeaderProps> = (props) => {
236
236
  {
237
237
  key: 'ThemeSwitch',
238
238
  group: groupMap.themeSwitch,
239
- component: <ThemeSwitch style={{ height: 22 }} onThemeChange={setIsDarkTheme} />,
239
+ component: <ThemeSwitch style={{ height: 22 }} onThemeChange={setIsDarkTheme} {...themeSwitchProps}/>,
240
240
  },
241
241
  ];
242
242
 
@@ -13,7 +13,7 @@ import { ThemeSwitchProps } from "../types";
13
13
  * @returns
14
14
  */
15
15
  const ThemeSwitch: React.FC<ThemeSwitchProps> = (props) => {
16
- const { onThemeChange, defaultChecked, ...switchProps } = props;
16
+ const { onThemeChange, defaultChecked, dynamicThemeFix = {}, ...switchProps } = props;
17
17
 
18
18
  let darkMode = typeof defaultChecked === 'boolean' ? defaultChecked : localStorage.getItem('darkMode') === '1';
19
19
 
@@ -30,10 +30,13 @@ const ThemeSwitch: React.FC<ThemeSwitchProps> = (props) => {
30
30
 
31
31
  const defaultFixes = {
32
32
  invert: [],
33
+ // 1. css 字段:DarkReader 注入此 CSS 时不会二次处理,!important 可覆盖其动态改写的样式表
34
+ // 2. ignoreInlineStyle 追加 防止 DarkReader 修改组件通过 style 注入的 CSS 变量
33
35
  css: '',
34
- ignoreInlineStyle: ['.react-switch-handle'],
36
+ ignoreInlineStyle: [],
35
37
  ignoreImageAnalysis: [],
36
38
  disableStyleSheetsProxy: true,
39
+ ...dynamicThemeFix,
37
40
  };
38
41
  if (window.MutationObserver && window.fetch) {
39
42
  setFetch(window.fetch);
@@ -1 +1 @@
1
- export declare const GlobalHeaderTypes = "\n/**\n * \u73AF\u5883\u6807\u7B7E\u989C\u8272\u7C7B\u578B\n */\ntype EnvTagColorType = Record<string, string>;\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport type RightItemKey =\n | 'AuthDropdown'\n | 'HeaderSearch'\n | 'Website'\n | 'helpDocs'\n | 'Full'\n | 'more'\n | 'AvatarDropdown'\n | 'REACT_APP_ENV'\n | 'MySelectLang'\n | 'ThemeSwitch';\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport interface GlobalRightItem {\n key: RightItemKey | string;\n group?: string;\n component: React.ReactNode;\n}\n\n/**\n * \u63D2\u5165\u9879\u76EE\u7C7B\u578B\n */\ninterface InsertItem extends Omit<GlobalRightItem, 'key'> {\n key: string;\n index: number;\n}\n\n/**\n * \u5168\u5C40\u5934\u90E8\u7EC4\u4EF6\u7C7B\u578B\n */\nexport interface GlobalHeaderProps {\n /** \u73AF\u5883\u6807\u7B7E\u989C\u8272 */\n ENVTagColor?: EnvTagColorType;\n /** \u66FF\u6362item */\n replaceItems?: GlobalRightItem[];\n /** \u63D2\u5165item */\n insertItems?: InsertItem[];\n}\n";
1
+ export declare const GlobalHeaderTypes = "\n/**\n * \u73AF\u5883\u6807\u7B7E\u989C\u8272\u7C7B\u578B\n */\ntype EnvTagColorType = Record<string, string>;\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport type RightItemKey =\n | 'AuthDropdown'\n | 'HeaderSearch'\n | 'Website'\n | 'helpDocs'\n | 'Full'\n | 'more'\n | 'AvatarDropdown'\n | 'REACT_APP_ENV'\n | 'MySelectLang'\n | 'ThemeSwitch';\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport interface GlobalRightItem {\n key: RightItemKey | string;\n group?: string;\n component: React.ReactNode;\n}\n\n/**\n * \u63D2\u5165\u9879\u76EE\u7C7B\u578B\n */\ninterface InsertItem extends Omit<GlobalRightItem, 'key'> {\n key: string;\n index: number;\n}\n\n/**\n * \u5168\u5C40\u5934\u90E8\u7EC4\u4EF6\u7C7B\u578B\n */\nexport interface GlobalHeaderProps {\n /** \u73AF\u5883\u6807\u7B7E\u989C\u8272 */\n ENVTagColor?: EnvTagColorType;\n /** \u66FF\u6362item */\n replaceItems?: GlobalRightItem[];\n /** \u63D2\u5165item */\n insertItems?: InsertItem[];\n /** \u4E3B\u9898\u5207\u6362\u7EC4\u4EF6\u5C5E\u6027 */\n themeSwitchProps?: ThemeSwitchProps;\n}\n";
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.GlobalHeaderTypes = void 0;
7
- var GlobalHeaderTypes = exports.GlobalHeaderTypes = "\n/**\n * \u73AF\u5883\u6807\u7B7E\u989C\u8272\u7C7B\u578B\n */\ntype EnvTagColorType = Record<string, string>;\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport type RightItemKey =\n | 'AuthDropdown'\n | 'HeaderSearch'\n | 'Website'\n | 'helpDocs'\n | 'Full'\n | 'more'\n | 'AvatarDropdown'\n | 'REACT_APP_ENV'\n | 'MySelectLang'\n | 'ThemeSwitch';\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport interface GlobalRightItem {\n key: RightItemKey | string;\n group?: string;\n component: React.ReactNode;\n}\n\n/**\n * \u63D2\u5165\u9879\u76EE\u7C7B\u578B\n */\ninterface InsertItem extends Omit<GlobalRightItem, 'key'> {\n key: string;\n index: number;\n}\n\n/**\n * \u5168\u5C40\u5934\u90E8\u7EC4\u4EF6\u7C7B\u578B\n */\nexport interface GlobalHeaderProps {\n /** \u73AF\u5883\u6807\u7B7E\u989C\u8272 */\n ENVTagColor?: EnvTagColorType;\n /** \u66FF\u6362item */\n replaceItems?: GlobalRightItem[];\n /** \u63D2\u5165item */\n insertItems?: InsertItem[];\n}\n";
7
+ var GlobalHeaderTypes = exports.GlobalHeaderTypes = "\n/**\n * \u73AF\u5883\u6807\u7B7E\u989C\u8272\u7C7B\u578B\n */\ntype EnvTagColorType = Record<string, string>;\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport type RightItemKey =\n | 'AuthDropdown'\n | 'HeaderSearch'\n | 'Website'\n | 'helpDocs'\n | 'Full'\n | 'more'\n | 'AvatarDropdown'\n | 'REACT_APP_ENV'\n | 'MySelectLang'\n | 'ThemeSwitch';\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport interface GlobalRightItem {\n key: RightItemKey | string;\n group?: string;\n component: React.ReactNode;\n}\n\n/**\n * \u63D2\u5165\u9879\u76EE\u7C7B\u578B\n */\ninterface InsertItem extends Omit<GlobalRightItem, 'key'> {\n key: string;\n index: number;\n}\n\n/**\n * \u5168\u5C40\u5934\u90E8\u7EC4\u4EF6\u7C7B\u578B\n */\nexport interface GlobalHeaderProps {\n /** \u73AF\u5883\u6807\u7B7E\u989C\u8272 */\n ENVTagColor?: EnvTagColorType;\n /** \u66FF\u6362item */\n replaceItems?: GlobalRightItem[];\n /** \u63D2\u5165item */\n insertItems?: InsertItem[];\n /** \u4E3B\u9898\u5207\u6362\u7EC4\u4EF6\u5C5E\u6027 */\n themeSwitchProps?: ThemeSwitchProps;\n}\n";
@@ -1 +1 @@
1
- export declare const ThemeSwitchTypes = "\nexport interface ThemeSwitchProps extends SwitchProps {\n /**\n * \u5207\u6362\u4E3B\u9898\u89E6\u53D1\n * @param darkMode \u662F\u5426\u9ED1\u6697\u4E3B\u9898\n * @returns\n */\n onThemeChange?: (darkMode: boolean) => void;\n}\n";
1
+ export declare const ThemeSwitchTypes = "\nimport {\n type DynamicThemeFix,\n} from '@umijs/ssr-darkreader';\n \nexport interface ThemeSwitchProps extends SwitchProps {\n /** \u52A8\u6001\u4E3B\u9898\u4FEE\u590D */\n dynamicThemeFix?: Partial<DynamicThemeFix>;\n /**\n * \u5207\u6362\u4E3B\u9898\u89E6\u53D1\n * @param darkMode \u662F\u5426\u9ED1\u6697\u4E3B\u9898\n * @returns\n */\n onThemeChange?: (darkMode: boolean) => void;\n}\n";
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ThemeSwitchTypes = void 0;
7
- var ThemeSwitchTypes = exports.ThemeSwitchTypes = "\nexport interface ThemeSwitchProps extends SwitchProps {\n /**\n * \u5207\u6362\u4E3B\u9898\u89E6\u53D1\n * @param darkMode \u662F\u5426\u9ED1\u6697\u4E3B\u9898\n * @returns\n */\n onThemeChange?: (darkMode: boolean) => void;\n}\n";
7
+ var ThemeSwitchTypes = exports.ThemeSwitchTypes = "\nimport {\n type DynamicThemeFix,\n} from '@umijs/ssr-darkreader';\n \nexport interface ThemeSwitchProps extends SwitchProps {\n /** \u52A8\u6001\u4E3B\u9898\u4FEE\u590D */\n dynamicThemeFix?: Partial<DynamicThemeFix>;\n /**\n * \u5207\u6362\u4E3B\u9898\u89E6\u53D1\n * @param darkMode \u662F\u5426\u9ED1\u6697\u4E3B\u9898\n * @returns\n */\n onThemeChange?: (darkMode: boolean) => void;\n}\n";
@@ -35,7 +35,7 @@ const ENV_TAG_COLOR: GlobalHeaderProps['ENVTagColor'] = {
35
35
  * 全局头部组件
36
36
  */
37
37
  const GlobalHeader: React.FC<GlobalHeaderProps> = (props) => {
38
- const { replaceItems, insertItems, ENVTagColor = ENV_TAG_COLOR } = props;
38
+ const { replaceItems, insertItems, ENVTagColor = ENV_TAG_COLOR, themeSwitchProps } = props;
39
39
 
40
40
  const { setIsDarkTheme, templateDownloadModalOpenChange } = useModel('global');
41
41
 
@@ -236,7 +236,7 @@ const GlobalHeader: React.FC<GlobalHeaderProps> = (props) => {
236
236
  {
237
237
  key: 'ThemeSwitch',
238
238
  group: groupMap.themeSwitch,
239
- component: <ThemeSwitch style={{ height: 22 }} onThemeChange={setIsDarkTheme} />,
239
+ component: <ThemeSwitch style={{ height: 22 }} onThemeChange={setIsDarkTheme} {...themeSwitchProps}/>,
240
240
  },
241
241
  ];
242
242
 
@@ -13,7 +13,7 @@ import { ThemeSwitchProps } from "../types";
13
13
  * @returns
14
14
  */
15
15
  const ThemeSwitch: React.FC<ThemeSwitchProps> = (props) => {
16
- const { onThemeChange, defaultChecked, ...switchProps } = props;
16
+ const { onThemeChange, defaultChecked, dynamicThemeFix = {}, ...switchProps } = props;
17
17
 
18
18
  let darkMode = typeof defaultChecked === 'boolean' ? defaultChecked : localStorage.getItem('darkMode') === '1';
19
19
 
@@ -30,10 +30,13 @@ const ThemeSwitch: React.FC<ThemeSwitchProps> = (props) => {
30
30
 
31
31
  const defaultFixes = {
32
32
  invert: [],
33
+ // 1. css 字段:DarkReader 注入此 CSS 时不会二次处理,!important 可覆盖其动态改写的样式表
34
+ // 2. ignoreInlineStyle 追加 防止 DarkReader 修改组件通过 style 注入的 CSS 变量
33
35
  css: '',
34
- ignoreInlineStyle: ['.react-switch-handle'],
36
+ ignoreInlineStyle: [],
35
37
  ignoreImageAnalysis: [],
36
38
  disableStyleSheetsProxy: true,
39
+ ...dynamicThemeFix,
37
40
  };
38
41
  if (window.MutationObserver && window.fetch) {
39
42
  setFetch(window.fetch);
@@ -1 +1 @@
1
- export declare const GlobalHeaderTypes = "\n/**\n * \u73AF\u5883\u6807\u7B7E\u989C\u8272\u7C7B\u578B\n */\ntype EnvTagColorType = Record<string, string>;\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport type RightItemKey =\n | 'AuthDropdown'\n | 'HeaderSearch'\n | 'Website'\n | 'helpDocs'\n | 'Full'\n | 'more'\n | 'AvatarDropdown'\n | 'REACT_APP_ENV'\n | 'MySelectLang'\n | 'ThemeSwitch';\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport interface GlobalRightItem {\n key: RightItemKey | string;\n group?: string;\n component: React.ReactNode;\n}\n\n/**\n * \u63D2\u5165\u9879\u76EE\u7C7B\u578B\n */\ninterface InsertItem extends Omit<GlobalRightItem, 'key'> {\n key: string;\n index: number;\n}\n\n/**\n * \u5168\u5C40\u5934\u90E8\u7EC4\u4EF6\u7C7B\u578B\n */\nexport interface GlobalHeaderProps {\n /** \u73AF\u5883\u6807\u7B7E\u989C\u8272 */\n ENVTagColor?: EnvTagColorType;\n /** \u66FF\u6362item */\n replaceItems?: GlobalRightItem[];\n /** \u63D2\u5165item */\n insertItems?: InsertItem[];\n}\n";
1
+ export declare const GlobalHeaderTypes = "\n/**\n * \u73AF\u5883\u6807\u7B7E\u989C\u8272\u7C7B\u578B\n */\ntype EnvTagColorType = Record<string, string>;\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport type RightItemKey =\n | 'AuthDropdown'\n | 'HeaderSearch'\n | 'Website'\n | 'helpDocs'\n | 'Full'\n | 'more'\n | 'AvatarDropdown'\n | 'REACT_APP_ENV'\n | 'MySelectLang'\n | 'ThemeSwitch';\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport interface GlobalRightItem {\n key: RightItemKey | string;\n group?: string;\n component: React.ReactNode;\n}\n\n/**\n * \u63D2\u5165\u9879\u76EE\u7C7B\u578B\n */\ninterface InsertItem extends Omit<GlobalRightItem, 'key'> {\n key: string;\n index: number;\n}\n\n/**\n * \u5168\u5C40\u5934\u90E8\u7EC4\u4EF6\u7C7B\u578B\n */\nexport interface GlobalHeaderProps {\n /** \u73AF\u5883\u6807\u7B7E\u989C\u8272 */\n ENVTagColor?: EnvTagColorType;\n /** \u66FF\u6362item */\n replaceItems?: GlobalRightItem[];\n /** \u63D2\u5165item */\n insertItems?: InsertItem[];\n /** \u4E3B\u9898\u5207\u6362\u7EC4\u4EF6\u5C5E\u6027 */\n themeSwitchProps?: ThemeSwitchProps;\n}\n";
@@ -1 +1 @@
1
- export var GlobalHeaderTypes = "\n/**\n * \u73AF\u5883\u6807\u7B7E\u989C\u8272\u7C7B\u578B\n */\ntype EnvTagColorType = Record<string, string>;\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport type RightItemKey =\n | 'AuthDropdown'\n | 'HeaderSearch'\n | 'Website'\n | 'helpDocs'\n | 'Full'\n | 'more'\n | 'AvatarDropdown'\n | 'REACT_APP_ENV'\n | 'MySelectLang'\n | 'ThemeSwitch';\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport interface GlobalRightItem {\n key: RightItemKey | string;\n group?: string;\n component: React.ReactNode;\n}\n\n/**\n * \u63D2\u5165\u9879\u76EE\u7C7B\u578B\n */\ninterface InsertItem extends Omit<GlobalRightItem, 'key'> {\n key: string;\n index: number;\n}\n\n/**\n * \u5168\u5C40\u5934\u90E8\u7EC4\u4EF6\u7C7B\u578B\n */\nexport interface GlobalHeaderProps {\n /** \u73AF\u5883\u6807\u7B7E\u989C\u8272 */\n ENVTagColor?: EnvTagColorType;\n /** \u66FF\u6362item */\n replaceItems?: GlobalRightItem[];\n /** \u63D2\u5165item */\n insertItems?: InsertItem[];\n}\n";
1
+ export var GlobalHeaderTypes = "\n/**\n * \u73AF\u5883\u6807\u7B7E\u989C\u8272\u7C7B\u578B\n */\ntype EnvTagColorType = Record<string, string>;\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport type RightItemKey =\n | 'AuthDropdown'\n | 'HeaderSearch'\n | 'Website'\n | 'helpDocs'\n | 'Full'\n | 'more'\n | 'AvatarDropdown'\n | 'REACT_APP_ENV'\n | 'MySelectLang'\n | 'ThemeSwitch';\n\n/**\n * \u53F3\u4FA7\u9879\u76EE\u7C7B\u578B\n */\nexport interface GlobalRightItem {\n key: RightItemKey | string;\n group?: string;\n component: React.ReactNode;\n}\n\n/**\n * \u63D2\u5165\u9879\u76EE\u7C7B\u578B\n */\ninterface InsertItem extends Omit<GlobalRightItem, 'key'> {\n key: string;\n index: number;\n}\n\n/**\n * \u5168\u5C40\u5934\u90E8\u7EC4\u4EF6\u7C7B\u578B\n */\nexport interface GlobalHeaderProps {\n /** \u73AF\u5883\u6807\u7B7E\u989C\u8272 */\n ENVTagColor?: EnvTagColorType;\n /** \u66FF\u6362item */\n replaceItems?: GlobalRightItem[];\n /** \u63D2\u5165item */\n insertItems?: InsertItem[];\n /** \u4E3B\u9898\u5207\u6362\u7EC4\u4EF6\u5C5E\u6027 */\n themeSwitchProps?: ThemeSwitchProps;\n}\n";
@@ -1 +1 @@
1
- export declare const ThemeSwitchTypes = "\nexport interface ThemeSwitchProps extends SwitchProps {\n /**\n * \u5207\u6362\u4E3B\u9898\u89E6\u53D1\n * @param darkMode \u662F\u5426\u9ED1\u6697\u4E3B\u9898\n * @returns\n */\n onThemeChange?: (darkMode: boolean) => void;\n}\n";
1
+ export declare const ThemeSwitchTypes = "\nimport {\n type DynamicThemeFix,\n} from '@umijs/ssr-darkreader';\n \nexport interface ThemeSwitchProps extends SwitchProps {\n /** \u52A8\u6001\u4E3B\u9898\u4FEE\u590D */\n dynamicThemeFix?: Partial<DynamicThemeFix>;\n /**\n * \u5207\u6362\u4E3B\u9898\u89E6\u53D1\n * @param darkMode \u662F\u5426\u9ED1\u6697\u4E3B\u9898\n * @returns\n */\n onThemeChange?: (darkMode: boolean) => void;\n}\n";
@@ -1 +1 @@
1
- export var ThemeSwitchTypes = "\nexport interface ThemeSwitchProps extends SwitchProps {\n /**\n * \u5207\u6362\u4E3B\u9898\u89E6\u53D1\n * @param darkMode \u662F\u5426\u9ED1\u6697\u4E3B\u9898\n * @returns\n */\n onThemeChange?: (darkMode: boolean) => void;\n}\n";
1
+ export var ThemeSwitchTypes = "\nimport {\n type DynamicThemeFix,\n} from '@umijs/ssr-darkreader';\n \nexport interface ThemeSwitchProps extends SwitchProps {\n /** \u52A8\u6001\u4E3B\u9898\u4FEE\u590D */\n dynamicThemeFix?: Partial<DynamicThemeFix>;\n /**\n * \u5207\u6362\u4E3B\u9898\u89E6\u53D1\n * @param darkMode \u662F\u5426\u9ED1\u6697\u4E3B\u9898\n * @returns\n */\n onThemeChange?: (darkMode: boolean) => void;\n}\n";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfmm/umi-plugins-ui-v2",
3
3
  "author": "ysj <411367308@qq.com>",
4
- "version": "0.0.30",
4
+ "version": "0.0.32",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
7
7
  "publishConfig": {