@skyfox2000/webui 1.4.3 → 1.4.4

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.
@@ -6,7 +6,6 @@ import {
6
6
  AppSource,
7
7
  isBaseMicroApp,
8
8
  isMicroApp,
9
- mainAppApis,
10
9
  RouteRecord,
11
10
  EnvConfig,
12
11
  } from '@skyfox2000/microbase';
@@ -18,6 +17,7 @@ import { Component, h, nextTick } from 'vue';
18
17
  import { LoginExpiredError, useUserInfo } from './userInfo';
19
18
  import { ApiResponse, httpPost, IUrlInfo, ResStatus } from '@skyfox2000/fapi';
20
19
  import message from 'vue-m-message';
20
+ import { MicroOpenApis } from '@/utils/micro-openapis';
21
21
 
22
22
  // const APPINFO_STORE_KEY = 'appInfoStore';
23
23
 
@@ -353,9 +353,9 @@ export const useAppInfo = defineStore('appInfo', {
353
353
  this.appInfo.defaultPage = findFirstPage(filteredRoutes) || '';
354
354
  if (this.appInfo.defaultPage) {
355
355
  this.menuLoaded = true;
356
- if (mainAppApis.value && mainAppApis.value.mainAppPush) {
356
+ if (isMicroApp()) {
357
357
  const fullPath = this.formatRoute(this.appInfo.defaultPage);
358
- mainAppApis.value.mainAppPush(fullPath);
358
+ MicroOpenApis.mainAppPush(fullPath);
359
359
  }
360
360
  continueNavigation(this.appInfo.defaultPage);
361
361
  }
@@ -393,9 +393,9 @@ export const useAppInfo = defineStore('appInfo', {
393
393
  nextTick(() => {
394
394
  // 直接使用当前应用路由AppRouter
395
395
  AppRouter.push({ path });
396
- if (mainAppApis.value && mainAppApis.value.mainAppPush) {
396
+ if (isMicroApp()) {
397
397
  const fullPath = this.formatRoute(path);
398
- mainAppApis.value.mainAppPush(fullPath);
398
+ MicroOpenApis.mainAppPush(fullPath);
399
399
  }
400
400
  });
401
401
  },
@@ -1,6 +1,7 @@
1
+ import { MicroOpenApis } from '@/utils/micro-openapis';
1
2
  import { API_HOST, ApiResponse, httpPost, IUrlInfo, ResStatus, SERVER_HOST } from '@skyfox2000/fapi';
2
3
 
3
- import { HostInfo, MainOpenApis } from '@skyfox2000/microbase';
4
+ import { HostInfo, isMicroApp } from '@skyfox2000/microbase';
4
5
 
5
6
  import { defineStore } from 'pinia';
6
7
 
@@ -57,11 +58,11 @@ export const useHostInfo = defineStore('hostInfo', {
57
58
  * 加载站点信息
58
59
  * @param hostApi 启动配置主机地址
59
60
  * @param hostKey 站点信息,默认为当前主域名
60
- * @param mainOpenApis 宿主机开放接口
61
61
  */
62
- async loadHostInfo(hostApi: string, hostKey?: string, mainOpenApis?: MainOpenApis): Promise<void> {
63
- if (mainOpenApis) {
64
- this._setHostInfo(mainOpenApis.getHostInfo());
62
+ async loadHostInfo(hostApi: string, hostKey?: string): Promise<void> {
63
+ if (isMicroApp()) {
64
+ const hostInfo = await MicroOpenApis.getHostInfo();
65
+ this._setHostInfo(hostInfo);
65
66
  return;
66
67
  }
67
68
 
@@ -1,10 +1,12 @@
1
1
  import { hostUrl, IUrlInfo } from '@skyfox2000/fapi';
2
2
 
3
- import { getToken } from '@/utils/main-openapis';
4
3
  import { UploadFile, UploadStatus } from '@/typings/upload.d';
5
4
  import dayjs from 'dayjs';
6
5
  import message from 'vue-m-message';
7
6
  import { Ref } from 'vue';
7
+ import { MicroOpenApis } from './micro-openapis';
8
+ import { isMicroApp } from '@skyfox2000/microbase';
9
+ import { useUserInfo } from '@/stores/userInfo';
8
10
 
9
11
  export class path {
10
12
  /**
@@ -233,7 +235,7 @@ export class AsyncUploader {
233
235
 
234
236
  // 添加授权 Token(如果需要)
235
237
  if (this.urlInfo.authorize) {
236
- const token = getToken(); // 假设 getToken 是获取 Token 的方法
238
+ const token = isMicroApp() ? MicroOpenApis.getToken() : useUserInfo().getToken(); // 假设 getToken 是获取 Token 的方法
237
239
  if (!token) {
238
240
  reject(new Error('未授权或授权过期'));
239
241
  return;
@@ -360,4 +362,3 @@ export class AsyncUploader {
360
362
  // console.error('上传错误:', error);
361
363
  // }
362
364
  // })();
363
-
@@ -3,6 +3,8 @@
3
3
  * 提供与主应用的通信接口,基于micro-app框架
4
4
  */
5
5
 
6
+ import { AppInfo, HostInfo, UserInfo } from '@skyfox2000/microbase';
7
+
6
8
  // 定义请求数据格式
7
9
  interface ApiRequestData {
8
10
  type: 'API_REQUEST';
@@ -112,43 +114,43 @@ class MicroAppSDK {
112
114
  /**
113
115
  * 获取应用信息
114
116
  */
115
- static async getAppInfo(): Promise<any> {
117
+ static async getAppInfo(): Promise<AppInfo> {
116
118
  return this.callMainAppMethod('getAppInfo');
117
119
  }
118
120
 
119
121
  /**
120
122
  * 获取主机信息
121
123
  */
122
- static async getHostInfo(): Promise<any> {
124
+ static async getHostInfo(): Promise<HostInfo> {
123
125
  return this.callMainAppMethod('getHostInfo');
124
126
  }
125
127
 
126
128
  /**
127
129
  * 获取用户信息
128
130
  */
129
- static async getUserInfo(): Promise<any> {
131
+ static async getUserInfo(): Promise<UserInfo> {
130
132
  return this.callMainAppMethod('getUserInfo');
131
133
  }
132
134
 
133
135
  /**
134
136
  * 获取授权令牌
135
137
  */
136
- static async getToken(): Promise<any> {
138
+ static async getToken(): Promise<string> {
137
139
  return this.callMainAppMethod('getToken');
138
140
  }
139
141
 
140
142
  /**
141
143
  * 用户登出
142
144
  */
143
- static async userLogout(): Promise<any> {
145
+ static async userLogout(): Promise<void> {
144
146
  return this.callMainAppMethod('userLogout');
145
147
  }
146
148
 
147
149
  /**
148
150
  * 主应用推送
149
151
  */
150
- static async mainAppPush(params: any): Promise<any> {
151
- return this.callMainAppMethod('mainAppPush', params);
152
+ static async mainAppPush(path: string): Promise<void> {
153
+ return this.callMainAppMethod('mainAppPush', path);
152
154
  }
153
155
  }
154
156