@lark-apaas/client-toolkit 1.2.22-alpha.2 → 1.2.22-alpha.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.
|
@@ -19,29 +19,37 @@ function getCompatibilityUserProfile() {
|
|
|
19
19
|
const useCurrentUserProfile = ()=>{
|
|
20
20
|
const [userInfo, setUserInfo] = useState(()=>getCompatibilityUserProfile());
|
|
21
21
|
useEffect(()=>{
|
|
22
|
-
let cancelled = false;
|
|
23
|
-
const fetchAndSetUserInfo = async ()=>{
|
|
24
|
-
const dataloom = await getDataloom();
|
|
25
|
-
const result = await dataloom?.service?.session?.getUserInfo();
|
|
26
|
-
if (cancelled) return;
|
|
27
|
-
const info = result?.data?.user_info;
|
|
28
|
-
const userName = getNameFromArray(info?.name);
|
|
29
|
-
const newUserInfo = {
|
|
30
|
-
user_id: info?.user_id?.toString(),
|
|
31
|
-
email: info?.email,
|
|
32
|
-
name: userName,
|
|
33
|
-
avatar: info?.avatar?.image?.large,
|
|
34
|
-
userName: userName,
|
|
35
|
-
userAvatar: info?.avatar?.image?.large
|
|
36
|
-
};
|
|
37
|
-
if ('development' === process.env.NODE_ENV) logger.info('MiaoDaMetaInfoChanged', newUserInfo);
|
|
38
|
-
setUserInfo(newUserInfo);
|
|
39
|
-
};
|
|
40
22
|
let handleMetaInfoChanged;
|
|
41
23
|
if (isSparkRuntime()) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
24
|
+
(async ()=>{
|
|
25
|
+
const dataloom = await getDataloom();
|
|
26
|
+
const result = await dataloom?.service?.session?.getUserInfo();
|
|
27
|
+
const userInfo = result?.data?.user_info;
|
|
28
|
+
const userName = getNameFromArray(userInfo?.name);
|
|
29
|
+
setUserInfo({
|
|
30
|
+
user_id: userInfo?.user_id?.toString(),
|
|
31
|
+
email: userInfo?.email,
|
|
32
|
+
name: userName,
|
|
33
|
+
avatar: userInfo?.avatar?.image?.large,
|
|
34
|
+
userName: userName,
|
|
35
|
+
userAvatar: userInfo?.avatar?.image?.large
|
|
36
|
+
});
|
|
37
|
+
})();
|
|
38
|
+
handleMetaInfoChanged = async ()=>{
|
|
39
|
+
const dataloom = await getDataloom();
|
|
40
|
+
const result = await dataloom?.service?.session?.getUserInfo();
|
|
41
|
+
const userInfo = result?.data?.user_info;
|
|
42
|
+
const userName = getNameFromArray(userInfo?.name);
|
|
43
|
+
const newUserInfo = {
|
|
44
|
+
user_id: userInfo?.user_id?.toString(),
|
|
45
|
+
email: userInfo?.email,
|
|
46
|
+
name: userName,
|
|
47
|
+
avatar: userInfo?.avatar?.image?.large,
|
|
48
|
+
userName: userName,
|
|
49
|
+
userAvatar: userInfo?.avatar?.image?.large
|
|
50
|
+
};
|
|
51
|
+
if ('development' === process.env.NODE_ENV) logger.info('MiaoDaMetaInfoChanged', newUserInfo);
|
|
52
|
+
setUserInfo(newUserInfo);
|
|
45
53
|
};
|
|
46
54
|
} else handleMetaInfoChanged = ()=>{
|
|
47
55
|
if ('development' === process.env.NODE_ENV) logger.info('MiaoDaMetaInfoChanged', getCompatibilityUserProfile());
|
|
@@ -49,7 +57,6 @@ const useCurrentUserProfile = ()=>{
|
|
|
49
57
|
};
|
|
50
58
|
window.addEventListener('MiaoDaMetaInfoChanged', handleMetaInfoChanged);
|
|
51
59
|
return ()=>{
|
|
52
|
-
cancelled = true;
|
|
53
60
|
window.removeEventListener('MiaoDaMetaInfoChanged', handleMetaInfoChanged);
|
|
54
61
|
};
|
|
55
62
|
}, []);
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
declare const createDataLoomClient: (url?: string, pat?: string) => import("@data-loom/js").DataloomClient<any, "public", any>;
|
|
2
1
|
/** 获取dataloom实例 */
|
|
3
|
-
export declare function getDataloom(): Promise<
|
|
4
|
-
export {};
|
|
2
|
+
export declare function getDataloom(): Promise<import("@data-loom/js").DataloomClient<any, "public", any>>;
|
|
@@ -23,18 +23,12 @@ const createDataLoomClient = (url, pat)=>{
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
let dataloom = null;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
34
|
-
return dataloom;
|
|
35
|
-
}).finally(()=>{
|
|
36
|
-
pendingPromise = null;
|
|
37
|
-
});
|
|
38
|
-
return pendingPromise;
|
|
26
|
+
async function getDataloom() {
|
|
27
|
+
if (dataloom) return dataloom;
|
|
28
|
+
const info = await getInitialInfo();
|
|
29
|
+
const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
|
|
30
|
+
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
31
|
+
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
32
|
+
return dataloom;
|
|
39
33
|
}
|
|
40
34
|
export { getDataloom };
|
|
@@ -13,10 +13,9 @@ interface AppRuntimePublished {
|
|
|
13
13
|
interface BucketConfig {
|
|
14
14
|
default_bucket_id?: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/** 获取应用初始化信息(仅全栈沙箱模式下使用) */
|
|
17
|
+
export declare function getInitialInfo(refresh?: boolean): Promise<{
|
|
17
18
|
app_info?: AppRuntimePublished;
|
|
18
19
|
app_runtime_extra?: AppRuntimeExtra;
|
|
19
|
-
}
|
|
20
|
-
/** 获取应用初始化信息(仅全栈沙箱模式下使用) */
|
|
21
|
-
export declare function getInitialInfo(refresh?: boolean): Promise<typeof initialInfo>;
|
|
20
|
+
}>;
|
|
22
21
|
export {};
|
|
@@ -23,17 +23,10 @@ async function getAppPublished() {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
let initialInfo;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
initialInfo = info;
|
|
32
|
-
if (initialInfo) window._bucket_id = initialInfo.app_runtime_extra?.bucket?.default_bucket_id;
|
|
33
|
-
return initialInfo;
|
|
34
|
-
}).finally(()=>{
|
|
35
|
-
pendingPromise = null;
|
|
36
|
-
});
|
|
37
|
-
return pendingPromise;
|
|
26
|
+
async function getInitialInfo(refresh = false) {
|
|
27
|
+
if (initialInfo && !refresh) return initialInfo;
|
|
28
|
+
initialInfo = await getAppPublished();
|
|
29
|
+
if (initialInfo) window._bucket_id = initialInfo.app_runtime_extra?.bucket?.default_bucket_id;
|
|
30
|
+
return initialInfo;
|
|
38
31
|
}
|
|
39
32
|
export { getInitialInfo };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.2.22-alpha.
|
|
3
|
+
"version": "1.2.22-alpha.3",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@ant-design/colors": "^7.2.1",
|
|
100
100
|
"@ant-design/cssinjs": "^1.24.0",
|
|
101
101
|
"@data-loom/js": "0.4.7",
|
|
102
|
-
"@lark-apaas/aily-web-sdk": "
|
|
102
|
+
"@lark-apaas/aily-web-sdk": "0.0.2-alpha.11",
|
|
103
103
|
"@lark-apaas/auth-sdk": "^0.1.0",
|
|
104
104
|
"@lark-apaas/client-capability": "^0.1.4",
|
|
105
105
|
"@lark-apaas/miaoda-inspector": "^1.0.16",
|