@gct-paas/core 6.0.0-dev.19 → 6.0.0-dev.20

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.
@@ -1,2 +1,2 @@
1
- /*! @gct-paas/core v6.0.0-dev.18 */
1
+ /*! @gct-paas/core v6.0.0-dev.19 */
2
2
  import{createElementBlock as e,defineComponent as r,openBlock as t,unref as a}from"vue";import{useRouter as p}from"vue-router";var o=/* @__PURE__ */r({__name:"redirect-index",setup(r){const{currentRoute:o,replace:i}=p(),{params:s,query:u}=a(o),{path:m,_redirect_type:n="path"}=s;Reflect.deleteProperty(s,"_redirect_type"),Reflect.deleteProperty(s,"path");const c=Array.isArray(m)?m.join("/"):m;return i("name"===n?{name:c,query:u,params:JSON.parse(s._origin_params??"{}")}:{path:c.startsWith("/")?c:"/"+c,query:u}),(r,a)=>(t(),e("div"))}});export{o as default};
@@ -7,7 +7,8 @@ import { App } from 'vue';
7
7
  */
8
8
  export interface IPluginKitModule {
9
9
  /**
10
- * 只在插件加载时调用一次,进行全局资源注册等操作
10
+ * 仅可在 Window 生命周期内调用一次,进行全局资源注册等操作。
11
+ * 重复调用必须直接返回并记录错误。
11
12
  *
12
13
  * @param {App} app
13
14
  * @return {*} {Promise<void>}
package/es/setup-app.mjs CHANGED
@@ -5,6 +5,7 @@ import "./modules/platform-config/index.mjs";
5
5
  import { registerCoreLocale } from "./locale/auto-register.mjs";
6
6
  import { HttpUtil } from "@gct-paas/api";
7
7
  //#region src/setup-app.ts
8
+ var setupAppKey = Symbol.for("@gct-paas/core/setupApp");
8
9
  /**
9
10
  *
10
11
  *
@@ -12,6 +13,11 @@ import { HttpUtil } from "@gct-paas/api";
12
13
  * @param {App} app
13
14
  */
14
15
  async function setupApp(_app) {
16
+ if (Reflect.get(window, setupAppKey)) {
17
+ console.error("@gct-paas/core setupApp 已执行,请勿重复调用。");
18
+ return;
19
+ }
20
+ Reflect.set(window, setupAppKey, true);
15
21
  HttpUtil.use(interceptors);
16
22
  await _gct.init();
17
23
  registerCoreLocale();
@@ -6,6 +6,33 @@ import { globalRefStorage } from "../../store/storage-store.mjs";
6
6
  import "../../store/index.mjs";
7
7
  import { AxiosHeaders } from "axios";
8
8
  //#region src/utils/axios/interceptors.ts
9
+ function logApiError(error) {
10
+ const { config, response, code, message, stack } = error || {};
11
+ console.error("[API 请求失败]", {
12
+ url: config?.url,
13
+ method: config?.method,
14
+ status: response?.status,
15
+ statusText: response?.statusText,
16
+ code,
17
+ message,
18
+ responseData: response?.data,
19
+ stack
20
+ });
21
+ }
22
+ function logBusinessError(response) {
23
+ const { config, data, status, statusText } = response;
24
+ const message = data?.subMessage || data?.message || "接口业务处理失败";
25
+ console.error("[API 业务错误]", {
26
+ url: config?.url,
27
+ method: config?.method,
28
+ status,
29
+ statusText,
30
+ code: data?.code,
31
+ subCode: data?.subCode,
32
+ message,
33
+ responseData: data
34
+ }, new Error(message));
35
+ }
9
36
  /**
10
37
  * 安装拦截器
11
38
  *
@@ -26,6 +53,7 @@ function interceptors(axios) {
26
53
  axios.interceptors.response.use((response) => {
27
54
  if (response.data.code === 200) return response;
28
55
  else {
56
+ logBusinessError(response);
29
57
  const { errorMessageMode } = response.config || {};
30
58
  const { subMessage, message, subCode } = response.data;
31
59
  if (subCode === "sys.global.tenantId.required") {
@@ -37,6 +65,7 @@ function interceptors(axios) {
37
65
  }
38
66
  return response;
39
67
  }, (error) => {
68
+ logApiError(error);
40
69
  const { response, code, message, status } = error || {};
41
70
  const errorMessageMode = response?.config?.errorMessageMode || "none";
42
71
  let errMessage = "";
@@ -37,9 +37,9 @@ var KitPkgUtil = class {
37
37
  loaderUrl
38
38
  );
39
39
  if (module) return module;
40
- else console.warn(`Kit ${kit} does not export a default function`);
40
+ else console.error(`Kit ${kit} does not export a default function`);
41
41
  } catch (error) {
42
- console.warn(`Error loading kit ${kit} from ${loaderUrl}:`, error);
42
+ console.error(`Error loading kit ${kit} from ${loaderUrl}:`, error);
43
43
  }
44
44
  return null;
45
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/core",
3
- "version": "6.0.0-dev.19",
3
+ "version": "6.0.0-dev.20",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "loader": "dist/index.esm.min.js",