@lark-apaas/client-toolkit-lite 1.1.3 → 1.1.5

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/index.cjs CHANGED
@@ -34,6 +34,7 @@ __export(index_exports, {
34
34
  ActiveLink: () => ActiveLink,
35
35
  AppContainer: () => AppContainer_default,
36
36
  NavLink: () => NavLink2,
37
+ PagePlaceholder: () => PagePlaceholder_default,
37
38
  QueryProvider: () => QueryProvider_default,
38
39
  TrackKey: () => TrackKey,
39
40
  UniversalLink: () => UniversalLink,
@@ -570,9 +571,52 @@ var messages = {
570
571
  var messages_default = messages;
571
572
 
572
573
  // src/utils/locale.ts
574
+ var STORAGE_KEY = "miaoda:preview-locale";
575
+ function toLocale(value) {
576
+ const lang = value ?? "zh";
577
+ return lang.toLowerCase().startsWith("zh") ? "zh" : "en";
578
+ }
579
+ __name(toLocale, "toLocale");
580
+ function readLocaleFromQuery() {
581
+ if (typeof window === "undefined") return null;
582
+ try {
583
+ const value = new URLSearchParams(window.location.search).get("locale");
584
+ return value && value.length > 0 ? value : null;
585
+ } catch {
586
+ return null;
587
+ }
588
+ }
589
+ __name(readLocaleFromQuery, "readLocaleFromQuery");
590
+ function readLocaleFromStorage() {
591
+ if (typeof window === "undefined") return null;
592
+ try {
593
+ const value = window.localStorage?.getItem(STORAGE_KEY);
594
+ return value && value.length > 0 ? value : null;
595
+ } catch {
596
+ return null;
597
+ }
598
+ }
599
+ __name(readLocaleFromStorage, "readLocaleFromStorage");
600
+ function writeLocaleToStorage(value) {
601
+ if (typeof window === "undefined") return;
602
+ try {
603
+ window.localStorage?.setItem(STORAGE_KEY, value);
604
+ } catch {
605
+ }
606
+ }
607
+ __name(writeLocaleToStorage, "writeLocaleToStorage");
573
608
  function getLocale() {
574
- const lang = navigator.language || "zh";
575
- return lang.startsWith("zh") ? "zh" : "en";
609
+ if (process.env.NODE_ENV === "production") {
610
+ return toLocale(navigator.language);
611
+ }
612
+ const fromQuery = readLocaleFromQuery();
613
+ if (fromQuery) {
614
+ writeLocaleToStorage(fromQuery);
615
+ return toLocale(fromQuery);
616
+ }
617
+ const fromStorage = readLocaleFromStorage();
618
+ if (fromStorage) return toLocale(fromStorage);
619
+ return toLocale(navigator.language);
576
620
  }
577
621
  __name(getLocale, "getLocale");
578
622
 
@@ -1278,13 +1322,58 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
1278
1322
  }, "Welcome");
1279
1323
  var Welcome_default = Welcome;
1280
1324
 
1281
- // src/route-components/ActiveLink.tsx
1325
+ // src/components/PagePlaceholder/index.tsx
1282
1326
  var import_react9 = __toESM(require("react"), 1);
1327
+ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
1328
+ return /* @__PURE__ */ import_react9.default.createElement("div", {
1329
+ style: {
1330
+ display: "flex",
1331
+ flexDirection: "column",
1332
+ alignItems: "center",
1333
+ justifyContent: "center",
1334
+ padding: "0 24px",
1335
+ width: "100%",
1336
+ height: "calc(100vh - 64px)",
1337
+ textAlign: "center"
1338
+ }
1339
+ }, /* @__PURE__ */ import_react9.default.createElement("img", {
1340
+ style: {
1341
+ borderRadius: "6px",
1342
+ marginBottom: "24px"
1343
+ },
1344
+ width: "320",
1345
+ height: "200",
1346
+ src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
1347
+ alt: "Welcome"
1348
+ }), /* @__PURE__ */ import_react9.default.createElement("div", {
1349
+ style: {
1350
+ fontSize: "16px",
1351
+ fontWeight: 500,
1352
+ marginBottom: "4px",
1353
+ lineHeight: "24px"
1354
+ }
1355
+ }, title), /* @__PURE__ */ import_react9.default.createElement("div", {
1356
+ style: {
1357
+ color: "#6b7280",
1358
+ fontSize: "16px",
1359
+ lineHeight: "24px",
1360
+ maxWidth: "480px",
1361
+ overflow: "hidden",
1362
+ display: "-webkit-box",
1363
+ WebkitLineClamp: 2,
1364
+ WebkitBoxOrient: "vertical"
1365
+ }
1366
+ }, description));
1367
+ }, "PagePlaceholder");
1368
+ var PagePlaceholder_default = PagePlaceholder;
1369
+
1370
+ // src/route-components/ActiveLink.tsx
1371
+ var import_react10 = __toESM(require("react"), 1);
1283
1372
  var import_react_router_dom = require("react-router-dom");
1284
- var ActiveLink = /* @__PURE__ */ (0, import_react9.forwardRef)(({ to, onClick, className, style, children, ...rest }, ref) => {
1285
- const [currentHash, setCurrentHash] = (0, import_react9.useState)(() => typeof window !== "undefined" ? window.location.hash : "");
1373
+ var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick, className, style, children, ...rest }, ref) => {
1374
+ const [currentHash, setCurrentHash] = (0, import_react10.useState)(() => typeof window !== "undefined" ? window.location.hash : "");
1286
1375
  const isHashRoute = typeof to === "string" && to.startsWith("#");
1287
- (0, import_react9.useEffect)(() => {
1376
+ (0, import_react10.useEffect)(() => {
1288
1377
  if (!isHashRoute) return;
1289
1378
  const handleHashChange = /* @__PURE__ */ __name(() => {
1290
1379
  setCurrentHash(window.location.hash);
@@ -1296,7 +1385,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react9.forwardRef)(({ to, onClick, c
1296
1385
  ]);
1297
1386
  const isActive = isHashRoute && currentHash === to;
1298
1387
  if (!isHashRoute) {
1299
- return /* @__PURE__ */ import_react9.default.createElement(import_react_router_dom.NavLink, {
1388
+ return /* @__PURE__ */ import_react10.default.createElement(import_react_router_dom.NavLink, {
1300
1389
  ref,
1301
1390
  to,
1302
1391
  onClick,
@@ -1337,7 +1426,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react9.forwardRef)(({ to, onClick, c
1337
1426
  isPending: false,
1338
1427
  isTransitioning: false
1339
1428
  }) : children;
1340
- return /* @__PURE__ */ import_react9.default.createElement("a", {
1429
+ return /* @__PURE__ */ import_react10.default.createElement("a", {
1341
1430
  ref,
1342
1431
  href: to,
1343
1432
  onClick: handleHashClick,
@@ -1349,9 +1438,9 @@ var ActiveLink = /* @__PURE__ */ (0, import_react9.forwardRef)(({ to, onClick, c
1349
1438
  ActiveLink.displayName = "ActiveLink";
1350
1439
 
1351
1440
  // src/route-components/NavLink.tsx
1352
- var React7 = __toESM(require("react"), 1);
1441
+ var React8 = __toESM(require("react"), 1);
1353
1442
  var import_react_router_dom2 = require("react-router-dom");
1354
- var NavLink2 = /* @__PURE__ */ React7.forwardRef(({ to, children, className, style, ...props }, ref) => {
1443
+ var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, style, ...props }, ref) => {
1355
1444
  const isHashLink = typeof to === "string" && to.startsWith("#");
1356
1445
  const location = (0, import_react_router_dom2.useLocation)();
1357
1446
  const navigate = (0, import_react_router_dom2.useNavigate)();
@@ -1375,7 +1464,7 @@ var NavLink2 = /* @__PURE__ */ React7.forwardRef(({ to, children, className, sty
1375
1464
  const resolvedClassName = typeof className === "function" ? className(renderProps) : className;
1376
1465
  const resolvedStyle = typeof style === "function" ? style(renderProps) : style;
1377
1466
  const { caseSensitive, end, replace, state, preventScrollReset, relative, viewTransition, ...restProps } = props;
1378
- return /* @__PURE__ */ React7.createElement("a", {
1467
+ return /* @__PURE__ */ React8.createElement("a", {
1379
1468
  href: to,
1380
1469
  onClick: handleClick,
1381
1470
  ref,
@@ -1384,7 +1473,7 @@ var NavLink2 = /* @__PURE__ */ React7.forwardRef(({ to, children, className, sty
1384
1473
  ...restProps
1385
1474
  }, typeof children === "function" ? children(renderProps) : children);
1386
1475
  }
1387
- return /* @__PURE__ */ React7.createElement(import_react_router_dom2.NavLink, {
1476
+ return /* @__PURE__ */ React8.createElement(import_react_router_dom2.NavLink, {
1388
1477
  to,
1389
1478
  ref,
1390
1479
  className,
@@ -1399,7 +1488,7 @@ var NavLink2 = /* @__PURE__ */ React7.forwardRef(({ to, children, className, sty
1399
1488
  NavLink2.displayName = "NavLink";
1400
1489
 
1401
1490
  // src/route-components/UniversalLink.tsx
1402
- var import_react10 = __toESM(require("react"), 1);
1491
+ var import_react11 = __toESM(require("react"), 1);
1403
1492
  var import_react_router_dom3 = require("react-router-dom");
1404
1493
  function isInternalRoute(to) {
1405
1494
  return !to.startsWith("#") && !to.startsWith("http://") && !to.startsWith("https://") && !to.startsWith("//");
@@ -1409,15 +1498,15 @@ function isExternalLink(to) {
1409
1498
  return to.startsWith("http://") || to.startsWith("https://") || to.startsWith("//");
1410
1499
  }
1411
1500
  __name(isExternalLink, "isExternalLink");
1412
- var UniversalLink = /* @__PURE__ */ import_react10.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, ...props }, ref) {
1501
+ var UniversalLink = /* @__PURE__ */ import_react11.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, ...props }, ref) {
1413
1502
  if (isInternalRoute(to)) {
1414
- return /* @__PURE__ */ import_react10.default.createElement(import_react_router_dom3.Link, {
1503
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_router_dom3.Link, {
1415
1504
  to,
1416
1505
  ref,
1417
1506
  ...props
1418
1507
  });
1419
1508
  }
1420
- return /* @__PURE__ */ import_react10.default.createElement("a", {
1509
+ return /* @__PURE__ */ import_react11.default.createElement("a", {
1421
1510
  href: to,
1422
1511
  ref,
1423
1512
  ...props,
@@ -1842,6 +1931,7 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
1842
1931
  ActiveLink,
1843
1932
  AppContainer,
1844
1933
  NavLink,
1934
+ PagePlaceholder,
1845
1935
  QueryProvider,
1846
1936
  TrackKey,
1847
1937
  UniversalLink,