@lark-apaas/client-toolkit 1.1.21-alpha.auth.dev.12 → 1.1.21-alpha.auth.dev.14
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/lib/apis/components/QueryProvider.d.ts +1 -0
- package/lib/apis/components/QueryProvider.js +2 -0
- package/lib/components/AppContainer/index.js +15 -12
- package/lib/components/AppContainer/utils/childApi.js +5 -0
- package/lib/components/QueryProvider/index.d.ts +10 -0
- package/lib/components/QueryProvider/index.js +27 -0
- package/lib/hooks/useAppInfo.d.ts +1 -0
- package/lib/hooks/useAppInfo.js +26 -6
- package/lib/integrations/getAppInfo.d.ts +1 -1
- package/lib/integrations/getAppInfo.js +5 -4
- package/lib/types/common.d.ts +1 -0
- package/lib/types/iframe-events.d.ts +3 -0
- package/lib/utils/getInitialInfo.d.ts +2 -1
- package/lib/utils/getInitialInfo.js +2 -2
- package/lib/utils/getParentOrigin.d.ts +1 -1
- package/lib/utils/getParentOrigin.js +2 -0
- package/package.json +5 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as QueryProvider, getDefaultQueryClient } from '../../components/QueryProvider';
|
|
@@ -16,6 +16,7 @@ import { TrackKey } from "../../types/tea.js";
|
|
|
16
16
|
import safety from "./safety.js";
|
|
17
17
|
import { getAppId } from "../../utils/getAppId.js";
|
|
18
18
|
import { ServerLogPoller } from "../../server-log/index.js";
|
|
19
|
+
import QueryProvider from "../QueryProvider/index.js";
|
|
19
20
|
import { AuthProvider } from "@lark-apaas/auth-sdk";
|
|
20
21
|
registerDayjsPlugins();
|
|
21
22
|
initAxiosConfig();
|
|
@@ -225,18 +226,20 @@ const AppContainer_AppContainer = (props)=>{
|
|
|
225
226
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
226
227
|
children: [
|
|
227
228
|
/*#__PURE__*/ jsx(safety, {}),
|
|
228
|
-
/*#__PURE__*/ jsx(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
229
|
+
/*#__PURE__*/ jsx(QueryProvider, {
|
|
230
|
+
children: /*#__PURE__*/ jsx(ConfigProvider, {
|
|
231
|
+
theme: {
|
|
232
|
+
token: antdThemeToken,
|
|
233
|
+
components: {
|
|
234
|
+
Table: antdTableToken,
|
|
235
|
+
Pagination: antdPaginationToken
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
children: /*#__PURE__*/ jsx(App, {
|
|
239
|
+
themeMeta: props.themeMeta,
|
|
240
|
+
enableAuth: props.enableAuth,
|
|
241
|
+
children: children
|
|
242
|
+
})
|
|
240
243
|
})
|
|
241
244
|
})
|
|
242
245
|
]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
declare const getDefaultQueryClient: () => QueryClient;
|
|
4
|
+
export type QueryProviderProps = {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
client?: QueryClient;
|
|
7
|
+
};
|
|
8
|
+
declare const QueryProvider: React.FC<QueryProviderProps>;
|
|
9
|
+
export default QueryProvider;
|
|
10
|
+
export { getDefaultQueryClient };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
let defaultQueryClient = null;
|
|
5
|
+
const getDefaultQueryClient = ()=>{
|
|
6
|
+
if (!defaultQueryClient) defaultQueryClient = new QueryClient({
|
|
7
|
+
defaultOptions: {
|
|
8
|
+
queries: {
|
|
9
|
+
retry: 1,
|
|
10
|
+
refetchOnWindowFocus: false
|
|
11
|
+
},
|
|
12
|
+
mutations: {
|
|
13
|
+
retry: 1
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return defaultQueryClient;
|
|
18
|
+
};
|
|
19
|
+
const QueryProvider = ({ children, client })=>{
|
|
20
|
+
const qc = client ?? getDefaultQueryClient();
|
|
21
|
+
return /*#__PURE__*/ jsx(QueryClientProvider, {
|
|
22
|
+
client: qc,
|
|
23
|
+
children: children
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const components_QueryProvider = QueryProvider;
|
|
27
|
+
export { components_QueryProvider as default, getDefaultQueryClient };
|
package/lib/hooks/useAppInfo.js
CHANGED
|
@@ -3,9 +3,12 @@ import { getAppInfo } from "../integrations/getAppInfo.js";
|
|
|
3
3
|
const useAppInfo = ()=>{
|
|
4
4
|
const [appInfo, setAppInfo] = useState({});
|
|
5
5
|
useEffect(()=>{
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const updateDomInfo = (info)=>{
|
|
7
|
+
if (info.name) {
|
|
8
|
+
document.title = info.name;
|
|
9
|
+
const meta = document.querySelector("meta[property='og:title']");
|
|
10
|
+
if (meta) meta.content = info.name;
|
|
11
|
+
}
|
|
9
12
|
if (info.avatar) {
|
|
10
13
|
let link = document.querySelector("link[rel~='icon']");
|
|
11
14
|
if (!link) {
|
|
@@ -14,13 +17,30 @@ const useAppInfo = ()=>{
|
|
|
14
17
|
document.head.appendChild(link);
|
|
15
18
|
}
|
|
16
19
|
link.href = info.avatar;
|
|
20
|
+
const meta = document.querySelector("meta[property='og:image']");
|
|
21
|
+
if (meta) meta.content = info.avatar;
|
|
22
|
+
}
|
|
23
|
+
if (info.description) {
|
|
24
|
+
const meta = document.querySelector("meta[property='og:description']");
|
|
25
|
+
if (meta) meta.content = info.description;
|
|
17
26
|
}
|
|
18
|
-
|
|
27
|
+
};
|
|
28
|
+
const handleMetaInfoChanged = async (info)=>{
|
|
29
|
+
if (!info) info = await getAppInfo(true);
|
|
30
|
+
updateDomInfo(info);
|
|
31
|
+
setAppInfo((prev)=>({
|
|
32
|
+
...prev,
|
|
33
|
+
...info
|
|
34
|
+
}));
|
|
19
35
|
};
|
|
20
36
|
handleMetaInfoChanged();
|
|
21
|
-
|
|
37
|
+
const onUpdate = (e)=>{
|
|
38
|
+
const info = e.detail;
|
|
39
|
+
handleMetaInfoChanged(info);
|
|
40
|
+
};
|
|
41
|
+
window.addEventListener('MiaoDaMetaInfoChanged', onUpdate);
|
|
22
42
|
return ()=>{
|
|
23
|
-
window.removeEventListener('MiaoDaMetaInfoChanged',
|
|
43
|
+
window.removeEventListener('MiaoDaMetaInfoChanged', onUpdate);
|
|
24
44
|
};
|
|
25
45
|
}, []);
|
|
26
46
|
return {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AppInfoPayload } from '../types/common';
|
|
2
|
-
export declare function getAppInfo(): Promise<AppInfoPayload>;
|
|
2
|
+
export declare function getAppInfo(refresh?: boolean): Promise<AppInfoPayload>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { getInitialInfo } from "../utils/getInitialInfo.js";
|
|
2
2
|
import { isSparkRuntime } from "../utils/utils.js";
|
|
3
|
-
async function getAppInfo() {
|
|
3
|
+
async function getAppInfo(refresh = false) {
|
|
4
4
|
let appInfo = 'undefined' != typeof window ? window._appInfo : void 0;
|
|
5
|
-
if (!appInfo && isSparkRuntime()) {
|
|
6
|
-
const info = (await getInitialInfo())?.app_info;
|
|
5
|
+
if ((!appInfo || refresh) && isSparkRuntime()) {
|
|
6
|
+
const info = (await getInitialInfo(refresh))?.app_info;
|
|
7
7
|
appInfo = {
|
|
8
8
|
name: info?.app_name || '',
|
|
9
|
-
avatar: info?.app_avatar || ''
|
|
9
|
+
avatar: info?.app_avatar || '',
|
|
10
|
+
description: info?.app_description || ''
|
|
10
11
|
};
|
|
11
12
|
if (appInfo.name) appInfo.name = appInfo.name.trim();
|
|
12
13
|
if ('undefined' != typeof window) window._appInfo = appInfo;
|
package/lib/types/common.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AppInfoPayload } from "./common";
|
|
1
2
|
export interface IframeMessage<T = unknown> {
|
|
2
3
|
type: string;
|
|
3
4
|
data: T;
|
|
@@ -55,6 +56,8 @@ export interface ParentApi {
|
|
|
55
56
|
export interface ChildApi {
|
|
56
57
|
getRoutes: () => Promise<any[]>;
|
|
57
58
|
getSourceMap: () => Promise<string>;
|
|
59
|
+
/** 更新应用信息 */
|
|
60
|
+
updateAppInfo: (appInfo: AppInfoPayload) => void;
|
|
58
61
|
apiProxy: {
|
|
59
62
|
api_get: (url: string, config?: any) => Promise<any>;
|
|
60
63
|
api_post: (url: string, data?: any, config?: any) => Promise<any>;
|
|
@@ -8,12 +8,13 @@ interface AppRuntimePublished {
|
|
|
8
8
|
css_urls?: string[];
|
|
9
9
|
js_urls?: string[];
|
|
10
10
|
app_avatar?: string;
|
|
11
|
+
app_description?: string;
|
|
11
12
|
}
|
|
12
13
|
interface BucketConfig {
|
|
13
14
|
default_bucket_id?: string;
|
|
14
15
|
}
|
|
15
16
|
/** 获取应用初始化信息(仅全栈沙箱模式下使用) */
|
|
16
|
-
export declare function getInitialInfo(): Promise<{
|
|
17
|
+
export declare function getInitialInfo(refresh?: boolean): Promise<{
|
|
17
18
|
app_info?: AppRuntimePublished;
|
|
18
19
|
app_runtime_extra?: AppRuntimeExtra;
|
|
19
20
|
}>;
|
|
@@ -23,8 +23,8 @@ async function getAppPublished() {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
let initialInfo;
|
|
26
|
-
async function getInitialInfo() {
|
|
27
|
-
if (initialInfo) return initialInfo;
|
|
26
|
+
async function getInitialInfo(refresh = false) {
|
|
27
|
+
if (initialInfo && !refresh) return initialInfo;
|
|
28
28
|
initialInfo = await getAppPublished();
|
|
29
29
|
if (initialInfo) window._bucket_id = initialInfo.app_runtime_extra?.bucket?.default_bucket_id;
|
|
30
30
|
return initialInfo;
|
|
@@ -3,4 +3,4 @@ export declare function getEnv(): 'BOE' | 'PRE' | 'ONLINE';
|
|
|
3
3
|
* @internal
|
|
4
4
|
* 获取预览环境父级域名
|
|
5
5
|
*/
|
|
6
|
-
export declare function getPreviewParentOrigin(): "https://force.feishu-boe.cn" | "https://miaoda.feishu.cn" | "https://miaoda.feishu-pre.cn" | "https://miaoda.feishu-boe.cn";
|
|
6
|
+
export declare function getPreviewParentOrigin(): "https://force.feishu.cn" | "https://force.feishu-pre.cn" | "https://force.feishu-boe.cn" | "https://miaoda.feishu.cn" | "https://miaoda.feishu-pre.cn" | "https://miaoda.feishu-boe.cn";
|
|
@@ -6,6 +6,8 @@ function getEnv() {
|
|
|
6
6
|
}
|
|
7
7
|
function getPreviewParentOrigin() {
|
|
8
8
|
const { origin } = window.location;
|
|
9
|
+
if (origin.includes('force.feishuapp.net')) return 'https://force.feishu.cn';
|
|
10
|
+
if (origin.includes('force-pre.feishuapp.net')) return 'https://force.feishu-pre.cn';
|
|
9
11
|
if (origin.includes('force.byted.org')) return 'https://force.feishu-boe.cn';
|
|
10
12
|
if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) return 'https://miaoda.feishu.cn';
|
|
11
13
|
if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) return 'https://miaoda.feishu-pre.cn';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.1.21-alpha.auth.dev.
|
|
3
|
+
"version": "1.1.21-alpha.auth.dev.14",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@ant-design/colors": "^7.2.1",
|
|
87
87
|
"@ant-design/cssinjs": "^1.24.0",
|
|
88
|
-
"@data-loom/js": "0.4.
|
|
89
|
-
"@lark-apaas/auth-sdk": "0.1.0-alpha.
|
|
90
|
-
"@lark-apaas/miaoda-inspector": "^1.0.
|
|
88
|
+
"@data-loom/js": "^0.4.3",
|
|
89
|
+
"@lark-apaas/auth-sdk": "0.1.0-alpha.15",
|
|
90
|
+
"@lark-apaas/miaoda-inspector": "^1.0.7",
|
|
91
91
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
92
92
|
"@radix-ui/react-popover": "^1.1.15",
|
|
93
93
|
"@radix-ui/react-slot": "^1.2.3",
|
|
@@ -154,6 +154,7 @@
|
|
|
154
154
|
"vitest": "^3.2.4"
|
|
155
155
|
},
|
|
156
156
|
"peerDependencies": {
|
|
157
|
+
"@tanstack/react-query": "^5.90.12",
|
|
157
158
|
"antd": ">=5.26.6",
|
|
158
159
|
"react": ">=16.14.0",
|
|
159
160
|
"react-dom": ">=16.14.0",
|