@lark-apaas/client-toolkit-lite 1.1.1-beta.1 → 1.1.1-beta.3
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 +50 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +50 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -374,26 +374,18 @@ function splitWorkspaceUrl(fullUrl) {
|
|
|
374
374
|
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
375
375
|
|
|
376
376
|
// src/integrations/dataloom.ts
|
|
377
|
-
var
|
|
377
|
+
var import_dataloom = require("@lark-apaas/dataloom");
|
|
378
378
|
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
379
|
-
const { baseUrl
|
|
380
|
-
baseUrl: ""
|
|
381
|
-
workspace: ""
|
|
379
|
+
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
380
|
+
baseUrl: ""
|
|
382
381
|
};
|
|
383
382
|
const appId = getAppId() ?? "";
|
|
384
|
-
return (0,
|
|
383
|
+
return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
|
|
385
384
|
global: {
|
|
386
385
|
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
387
386
|
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
388
387
|
brandName: "miaoda",
|
|
389
|
-
appId
|
|
390
|
-
onError: /* @__PURE__ */ __name((error, dataloomInstance) => {
|
|
391
|
-
if (error?.status === 401) {
|
|
392
|
-
if (error?.code === "k_ident_013001") {
|
|
393
|
-
dataloomInstance.service.session.redirectToLogin();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}, "onError")
|
|
388
|
+
appId
|
|
397
389
|
}
|
|
398
390
|
});
|
|
399
391
|
}, "createDataLoomClient");
|
|
@@ -571,9 +563,52 @@ var messages = {
|
|
|
571
563
|
var messages_default = messages;
|
|
572
564
|
|
|
573
565
|
// src/utils/locale.ts
|
|
566
|
+
var STORAGE_KEY = "miaoda:preview-locale";
|
|
567
|
+
function toLocale(value) {
|
|
568
|
+
const lang = value ?? "zh";
|
|
569
|
+
return lang.toLowerCase().startsWith("zh") ? "zh" : "en";
|
|
570
|
+
}
|
|
571
|
+
__name(toLocale, "toLocale");
|
|
572
|
+
function readLocaleFromQuery() {
|
|
573
|
+
if (typeof window === "undefined") return null;
|
|
574
|
+
try {
|
|
575
|
+
const value = new URLSearchParams(window.location.search).get("locale");
|
|
576
|
+
return value && value.length > 0 ? value : null;
|
|
577
|
+
} catch {
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
__name(readLocaleFromQuery, "readLocaleFromQuery");
|
|
582
|
+
function readLocaleFromStorage() {
|
|
583
|
+
if (typeof window === "undefined") return null;
|
|
584
|
+
try {
|
|
585
|
+
const value = window.localStorage?.getItem(STORAGE_KEY);
|
|
586
|
+
return value && value.length > 0 ? value : null;
|
|
587
|
+
} catch {
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
__name(readLocaleFromStorage, "readLocaleFromStorage");
|
|
592
|
+
function writeLocaleToStorage(value) {
|
|
593
|
+
if (typeof window === "undefined") return;
|
|
594
|
+
try {
|
|
595
|
+
window.localStorage?.setItem(STORAGE_KEY, value);
|
|
596
|
+
} catch {
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
__name(writeLocaleToStorage, "writeLocaleToStorage");
|
|
574
600
|
function getLocale() {
|
|
575
|
-
|
|
576
|
-
|
|
601
|
+
if (process.env.NODE_ENV === "production") {
|
|
602
|
+
return toLocale(navigator.language);
|
|
603
|
+
}
|
|
604
|
+
const fromQuery = readLocaleFromQuery();
|
|
605
|
+
if (fromQuery) {
|
|
606
|
+
writeLocaleToStorage(fromQuery);
|
|
607
|
+
return toLocale(fromQuery);
|
|
608
|
+
}
|
|
609
|
+
const fromStorage = readLocaleFromStorage();
|
|
610
|
+
if (fromStorage) return toLocale(fromStorage);
|
|
611
|
+
return toLocale(navigator.language);
|
|
577
612
|
}
|
|
578
613
|
__name(getLocale, "getLocale");
|
|
579
614
|
|