@skyfox2000/microbase 1.0.14 → 1.0.15
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/index.d.ts +0 -4
- package/package.json +1 -1
- package/src/utils/micro-app.ts +72 -76
package/lib/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/utils/micro-app.ts
CHANGED
|
@@ -3,17 +3,17 @@ import { HostInfo } from "@/stores/hostInfo";
|
|
|
3
3
|
import { SettingInfo } from "@/stores/settingInfo";
|
|
4
4
|
import { LoginInfo, UserInfo } from "@/stores/userInfo";
|
|
5
5
|
import { ApiResponse } from "@skyfox2000/fapi";
|
|
6
|
-
import {
|
|
6
|
+
import { ref } from "vue";
|
|
7
7
|
/**
|
|
8
8
|
* 是否微服务运行环境
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
11
|
export const isMicroApp = (): boolean => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
if (window.__MICRO_APP_ENVIRONMENT__) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -21,85 +21,81 @@ export const isMicroApp = (): boolean => {
|
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
23
|
export const isBaseMicroApp = (): boolean => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
if (window.__MICRO_APP_BASE_APPLICATION__) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* 主应用初始化数据格式
|
|
33
33
|
*/
|
|
34
34
|
export interface MainAppData {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 主应用开放接口
|
|
37
|
+
*/
|
|
38
|
+
MainApis: MainOpenApis;
|
|
39
|
+
/**
|
|
40
|
+
* 主应用开放事件
|
|
41
|
+
*/
|
|
42
|
+
MainEvents: MainOpenEvents;
|
|
43
|
+
/**
|
|
44
|
+
* 加载的页面地址
|
|
45
|
+
*/
|
|
46
|
+
pageUrl: string;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* 主应用开放接口
|
|
51
51
|
*/
|
|
52
52
|
export interface MainOpenApis {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 子应用推送路由变更
|
|
92
|
-
*/
|
|
93
|
-
mainAppPush?: (subPath: string) => void;
|
|
53
|
+
/**
|
|
54
|
+
* 获取HostInfo
|
|
55
|
+
*/
|
|
56
|
+
getHostInfo: () => HostInfo;
|
|
57
|
+
/**
|
|
58
|
+
* 获取当前应用AppInfo
|
|
59
|
+
*/
|
|
60
|
+
getAppInfo: () => AppInfo;
|
|
61
|
+
/**
|
|
62
|
+
* 用户注册接口
|
|
63
|
+
*/
|
|
64
|
+
userRegister?: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* 用户登录接口
|
|
67
|
+
*/
|
|
68
|
+
userLogin?: (loginInfo: LoginInfo) => Promise<ApiResponse<LoginInfo> | void>;
|
|
69
|
+
/**
|
|
70
|
+
* 用户注销接口
|
|
71
|
+
*/
|
|
72
|
+
userLogout?: () => Promise<ApiResponse<any> | void>;
|
|
73
|
+
/**
|
|
74
|
+
* 获取授权码
|
|
75
|
+
* @returns 授权码
|
|
76
|
+
*/
|
|
77
|
+
getToken: () => string;
|
|
78
|
+
/**
|
|
79
|
+
* 获取当前用户信息
|
|
80
|
+
*/
|
|
81
|
+
getUserInfo: () => UserInfo;
|
|
82
|
+
/**
|
|
83
|
+
* 获取前端设置信息
|
|
84
|
+
*/
|
|
85
|
+
getSettingInfo?: () => SettingInfo;
|
|
86
|
+
/**
|
|
87
|
+
* 子应用推送路由变更
|
|
88
|
+
*/
|
|
89
|
+
mainAppPush?: (subPath: string) => void;
|
|
94
90
|
}
|
|
95
91
|
/**
|
|
96
92
|
* 主应用开放事件注册
|
|
97
93
|
*/
|
|
98
94
|
export interface MainOpenEvents {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
/**
|
|
96
|
+
* 前端设置信息变更
|
|
97
|
+
*/
|
|
98
|
+
onSettingChanged?: () => void;
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
export const mainAppApis = ref<MainOpenApis | undefined>();
|
|
@@ -110,12 +106,12 @@ export const mainPageUrl = ref<string | undefined>();
|
|
|
110
106
|
* 从页面加载处获取接口
|
|
111
107
|
*/
|
|
112
108
|
export const initMainAppData = () => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
109
|
+
const mainAppData: MainAppData = window.microApp.getData(
|
|
110
|
+
true
|
|
111
|
+
) as unknown as MainAppData;
|
|
112
|
+
if (mainAppData) {
|
|
113
|
+
mainAppApis.value = mainAppData.MainApis;
|
|
114
|
+
mainAppEvents.value = mainAppData.MainEvents;
|
|
115
|
+
mainPageUrl.value = mainAppData.pageUrl;
|
|
116
|
+
}
|
|
121
117
|
};
|