@blocklet/pages-kit 0.2.357 → 0.2.358

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.
@@ -21,23 +21,14 @@ const material_1 = require("@mui/material");
21
21
  const react_1 = require("react");
22
22
  const react_helmet_1 = require("react-helmet");
23
23
  const runtime_1 = require("../state/runtime");
24
+ const fonts_1 = require("../utils/fonts");
24
25
  const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
25
- const getFontUrl = (fontList) => {
26
- var _a;
27
- if (!fontList.length)
28
- return;
29
- const BASE_URL = 'https://fonts.googleapis.com/css?family=';
30
- const newFontList = (_a = fontList
31
- .filter((font) => typeof font === 'string')) === null || _a === void 0 ? void 0 : _a.map((font) => font.replace(/ /g, '+')).join('|');
32
- // eslint-disable-next-line consistent-return
33
- return `${BASE_URL}${newFontList}`;
34
- };
35
26
  function ThemeProvider({ children }) {
36
27
  var _a, _b, _c;
37
28
  const { appearance } = (0, runtime_1.useRuntimeState)().agent.project;
38
29
  const theme = (0, material_1.useTheme)();
39
- const titleFont = (_a = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _a === void 0 ? void 0 : _a.fontFamily;
40
- const headFont = (_c = (_b = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _b === void 0 ? void 0 : _b.heading) === null || _c === void 0 ? void 0 : _c.fontFamily;
30
+ const bodyFontFamily = (_a = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _a === void 0 ? void 0 : _a.fontFamily;
31
+ const headingFontFamily = (_c = (_b = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _b === void 0 ? void 0 : _b.heading) === null || _c === void 0 ? void 0 : _c.fontFamily;
41
32
  const newTheme = (0, react_1.useMemo)(() => {
42
33
  var _a, _b, _c, _d, _e, _f;
43
34
  let { primary } = theme.palette;
@@ -164,7 +155,17 @@ function ThemeProvider({ children }) {
164
155
  ],
165
156
  });
166
157
  }, [theme]);
167
- return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: newTheme, children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, { children: (0, jsx_runtime_1.jsx)("link", { rel: "stylesheet", href: getFontUrl([titleFont, headFont]) }) }), (0, jsx_runtime_1.jsxs)(material_1.CssBaseline, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: (theme) => theme.unstable_sx({
158
+ const fontUrls = (0, react_1.useMemo)(() => {
159
+ const urls = [bodyFontFamily, headingFontFamily]
160
+ .filter((i) => !!i)
161
+ .map((font) => {
162
+ var _a;
163
+ return ((_a = fonts_1.chineseFonts.find((i) => i.value === font)) === null || _a === void 0 ? void 0 : _a.link) ||
164
+ `https://fonts.googleapis.com/css?family=${font.replace(/ /g, '+')}`;
165
+ });
166
+ return [...new Set(urls)];
167
+ }, [bodyFontFamily, headingFontFamily]);
168
+ return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: newTheme, children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, { children: fontUrls.map((url) => ((0, jsx_runtime_1.jsx)("link", { rel: "stylesheet", href: url }, url))) }), (0, jsx_runtime_1.jsxs)(material_1.CssBaseline, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: (theme) => theme.unstable_sx({
168
169
  'h1,h2,h3,h4,h5': {
169
170
  fontFamily: `${theme.typography.h1.fontFamily} !important`,
170
171
  },
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chineseFonts = void 0;
4
+ exports.chineseFonts = [
5
+ {
6
+ key: '东方大楷',
7
+ value: 'Alimama DongFangDaKai',
8
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-alimama-dong-fang-da-kai-regular/font.css',
9
+ },
10
+ {
11
+ key: '鸿雷行书',
12
+ value: 'hongleixingshu',
13
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-hongleixingshu-regular/font.css',
14
+ },
15
+ {
16
+ key: '方正楷体',
17
+ value: 'FZKai-Z03',
18
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-kai-z-03-regular/font.css',
19
+ },
20
+ {
21
+ key: '方正宋体',
22
+ value: 'FZShuSong-Z01',
23
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-shu-song-z-01-regular/font.css',
24
+ },
25
+ {
26
+ key: '方正黑体',
27
+ value: 'FZHei-B01',
28
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-hei-b-01-regular/font.css',
29
+ },
30
+ {
31
+ key: '方正仿宋',
32
+ value: 'FZFangSong-Z02S',
33
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-fang-song-z-02-s-regular/font.css',
34
+ },
35
+ ];