@fe-free/core 6.0.9 → 6.0.11
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/CHANGELOG.md +16 -0
- package/README.md +1 -5
- package/package.json +3 -3
- package/src/button/button.stories.tsx +1 -0
- package/src/core_app/config.ts +1 -6
- package/src/core_app/index.tsx +3 -2
- package/src/editor_json/index.tsx +1 -1
- package/src/i18n.tsx +45 -25
- package/src/index.ts +0 -1
- package/src/theme.ts +0 -46
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @fe-free/core
|
|
2
2
|
|
|
3
|
+
## 6.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- theme
|
|
8
|
+
- @fe-free/icons@6.0.11
|
|
9
|
+
- @fe-free/tool@6.0.11
|
|
10
|
+
|
|
11
|
+
## 6.0.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- feat: i18n
|
|
16
|
+
- @fe-free/icons@6.0.10
|
|
17
|
+
- @fe-free/tool@6.0.10
|
|
18
|
+
|
|
3
19
|
## 6.0.9
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -117,10 +117,6 @@ import '@fe-free/core/src/tailwind.css';
|
|
|
117
117
|
|
|
118
118
|
### 主题
|
|
119
119
|
|
|
120
|
-
| 导出 | 说明 |
|
|
121
|
-
| ---------------- | -------- |
|
|
122
|
-
| `themeVariables` | 主题变量 |
|
|
123
|
-
|
|
124
120
|
### Tailwind Token 参考(tailwind.css)
|
|
125
121
|
|
|
126
122
|
`tailwind.css` 通过 `@theme` 定义了以下 CSS 变量,引入后可在项目中使用对应 Tailwind 类名(如 `text-primary`、`bg-theme03`、`text-text-color-03` 等)。完整定义见 `packages/core/src/tailwind.css`。
|
|
@@ -157,7 +153,7 @@ import '@fe-free/core/src/tailwind.css';
|
|
|
157
153
|
| | `--background-color-03` | 背景中 |
|
|
158
154
|
| | `--background-color-04` | 背景深 |
|
|
159
155
|
|
|
160
|
-
使用示例:`className="text-primary"`、`className="bg-theme03"`、`className="text-text-color-03"
|
|
156
|
+
使用示例:`className="text-primary"`、`className="bg-theme03"`、`className="text-text-color-03"`。
|
|
161
157
|
|
|
162
158
|
当你在本仓库或引用 `@fe-free/core` 的项目中编写代码时,可参考以下约定:
|
|
163
159
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.11",
|
|
4
4
|
"description": "React 业务核心组件库:CRUD、ProForm 扩展、布局、路由、树、上传等(Antd + ProComponents)",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"i18next-icu": "^2.4.1",
|
|
44
44
|
"react": "^19.2.0",
|
|
45
45
|
"react-i18next": "^16.4.0",
|
|
46
|
-
"@fe-free/icons": "6.0.
|
|
47
|
-
"@fe-free/tool": "6.0.
|
|
46
|
+
"@fe-free/icons": "6.0.11",
|
|
47
|
+
"@fe-free/tool": "6.0.11"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"i18n-extract": "rm -rf ./src/locales/zh-CN && npx i18next-cli extract"
|
package/src/core_app/config.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { themeVariables } from '../theme';
|
|
2
|
-
|
|
3
1
|
const themeConfig = {
|
|
4
2
|
cssVar: true,
|
|
5
|
-
token: {
|
|
6
|
-
colorPrimary: themeVariables.color.theme08,
|
|
7
|
-
},
|
|
8
3
|
components: {
|
|
9
4
|
Table: {
|
|
10
|
-
headerBg:
|
|
5
|
+
headerBg: '#f0f7fe',
|
|
11
6
|
headerBorderRadius: 0,
|
|
12
7
|
},
|
|
13
8
|
},
|
package/src/core_app/index.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import { merge } from 'lodash-es';
|
|
|
8
8
|
import { useEffect, useMemo } from 'react';
|
|
9
9
|
import { useTranslation } from 'react-i18next';
|
|
10
10
|
import { BrowserRouter as Router, useNavigate } from 'react-router-dom';
|
|
11
|
+
|
|
11
12
|
import { EnumLanguage, I18nProvider } from '../i18n';
|
|
12
13
|
import { routeTool } from '../route';
|
|
13
14
|
import { customValueTypeMap } from '../value_type_map';
|
|
@@ -86,7 +87,7 @@ function CheckUpdate({ basename }: { basename: string }) {
|
|
|
86
87
|
return () => {
|
|
87
88
|
clearInterval(timer);
|
|
88
89
|
};
|
|
89
|
-
}, [t]);
|
|
90
|
+
}, [t, basename, modal]);
|
|
90
91
|
|
|
91
92
|
return null;
|
|
92
93
|
}
|
|
@@ -139,7 +140,7 @@ function CoreAppBase(props: CoreAppProps) {
|
|
|
139
140
|
if (window.location.pathname === '/' && basename !== '/' && basename !== '') {
|
|
140
141
|
window.location.href = basename;
|
|
141
142
|
}
|
|
142
|
-
}, []);
|
|
143
|
+
}, [basename]);
|
|
143
144
|
|
|
144
145
|
const theme = useMemo(() => {
|
|
145
146
|
return merge(themeConfig, configProviderProps?.theme);
|
package/src/i18n.tsx
CHANGED
|
@@ -29,40 +29,60 @@ const listLanguage = Object.keys(valueEnumLanguage).map((key) => {
|
|
|
29
29
|
};
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
let hasSetupPlugins = false;
|
|
33
|
+
|
|
34
|
+
function getDefaultLng() {
|
|
35
|
+
if (typeof window === 'undefined') {
|
|
36
|
+
return EnumLanguage.ZH_CN;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const cacheLng = window.localStorage.getItem('i18nextLng') || EnumLanguage.ZH_CN;
|
|
34
40
|
const lng = listLanguage.find((item) => item.value === cacheLng) ? cacheLng : EnumLanguage.ZH_CN;
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
return lng;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function initI18n({ enTranslation = {} }: { enTranslation?: Record<string, unknown> } = {}) {
|
|
46
|
+
if (i18n.isInitialized) {
|
|
47
|
+
i18n.addResourceBundle(EnumLanguage.EN_US, 'translation', enTranslation, true, true);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!hasSetupPlugins) {
|
|
52
|
+
i18n.use(LanguageDetector).use(initReactI18next).use(ICU);
|
|
53
|
+
hasSetupPlugins = true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const lng = getDefaultLng();
|
|
57
|
+
console.log('initI18n', lng);
|
|
58
|
+
|
|
59
|
+
void i18n.init({
|
|
60
|
+
resources: {
|
|
61
|
+
[EnumLanguage.ZH_CN]: {
|
|
62
|
+
translation: {},
|
|
52
63
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
interpolation: {
|
|
56
|
-
escapeValue: false,
|
|
64
|
+
[EnumLanguage.EN_US]: {
|
|
65
|
+
translation: enTranslation,
|
|
57
66
|
},
|
|
58
|
-
}
|
|
67
|
+
},
|
|
68
|
+
lng,
|
|
69
|
+
fallbackLng: EnumLanguage.ZH_CN,
|
|
70
|
+
interpolation: {
|
|
71
|
+
escapeValue: false,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
59
74
|
}
|
|
60
75
|
|
|
61
76
|
function I18nProvider({ children }: { children: React.ReactNode }) {
|
|
77
|
+
initI18n();
|
|
62
78
|
return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
|
|
81
|
+
initI18n();
|
|
82
|
+
|
|
83
|
+
if (typeof window !== 'undefined') {
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
window._i18n = i18n;
|
|
86
|
+
}
|
|
67
87
|
|
|
68
88
|
export { EnumLanguage, I18nProvider, initI18n, listLanguage, valueEnumLanguage };
|
package/src/index.ts
CHANGED
|
@@ -65,7 +65,6 @@ export { NumberSlider, PercentageSlider } from './slider';
|
|
|
65
65
|
export type { NumberSliderProps, PercentageSliderProps } from './slider';
|
|
66
66
|
export { Tabs } from './tabs';
|
|
67
67
|
export type { TabsProps } from './tabs';
|
|
68
|
-
export { themeVariables } from './theme';
|
|
69
68
|
export { FileTree, flatToTreeData, Tree } from './tree';
|
|
70
69
|
export type { FileTreeProps, TreeProps } from './tree';
|
|
71
70
|
export {
|
package/src/theme.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const themeVariables = {
|
|
2
|
-
color: {
|
|
3
|
-
primary: '#0374e9', // 主题色
|
|
4
|
-
|
|
5
|
-
// 目前是主题蓝
|
|
6
|
-
theme09: '#0368d2', // 加深 hover
|
|
7
|
-
theme08: '#0374e9', // 主要
|
|
8
|
-
theme05: '#a2cbf7', // 次要
|
|
9
|
-
theme03: '#e6f1fd', // 背景
|
|
10
|
-
theme02: '#f0f7fe',
|
|
11
|
-
|
|
12
|
-
red09: '#e64547', // 加深 hover
|
|
13
|
-
red08: '#ff4d4f', // 主要
|
|
14
|
-
red05: '#ffb8b9', // 次要
|
|
15
|
-
red03: '#ffeded', // 背景
|
|
16
|
-
|
|
17
|
-
green09: '#01a468', // 加深 hover
|
|
18
|
-
green08: '#01b673', // 主要
|
|
19
|
-
green05: '#9be5c8', // 次要
|
|
20
|
-
green03: '#ddf9ec', // 背景
|
|
21
|
-
|
|
22
|
-
yellow09: '#bf7a05', // 加深 hover
|
|
23
|
-
yellow08: '#faad14', // 主要
|
|
24
|
-
yellow05: '#eecf9b', // 次要
|
|
25
|
-
yellow03: '#f6e7cd', // 背景
|
|
26
|
-
},
|
|
27
|
-
textColor: {
|
|
28
|
-
'01': '#15191e', // 主要
|
|
29
|
-
'02': '#444444', // 次要
|
|
30
|
-
'03': '#777777', // 描述
|
|
31
|
-
'04': '#bfbfbf', // placeholder
|
|
32
|
-
},
|
|
33
|
-
borderColor: {
|
|
34
|
-
'01': '#e2e7f0', // 主要
|
|
35
|
-
'02': '#d5dde9', // 表单
|
|
36
|
-
'03': '#c0c7d2',
|
|
37
|
-
},
|
|
38
|
-
backgroundColor: {
|
|
39
|
-
'01': '#f1f3f5', // 主要
|
|
40
|
-
'02': '#ececec', // 加深 hover
|
|
41
|
-
'03': '#d9d9d9', // disabled
|
|
42
|
-
'04': '#c0c0c0',
|
|
43
|
-
},
|
|
44
|
-
} as const;
|
|
45
|
-
|
|
46
|
-
export { themeVariables };
|